Skip to content

Commit 126f872

Browse files
committed
Review ignored tests
-Update links to tickets. -Remove ignore where possible. QA-140
1 parent 96d9e95 commit 126f872

File tree

16 files changed

+74
-65
lines changed

16 files changed

+74
-65
lines changed

io/src/test/java/com/itextpdf/io/font/woff2/w3c/decoder/ValidationOff012Test.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ This file is part of the iText (R) project.
4545
import com.itextpdf.io.font.woff2.w3c.W3CWoff2DecodeTest;
4646
import org.junit.Ignore;
4747

48-
@Ignore("Different from c++ version. See html font-face test for more details")
48+
@Ignore("DEVSIX-1612: different result in java and C#")
49+
//NOTE: Should be invalid by w3c test suite spec. See w3cProblemTest07 in html font-face test for more details.
4950
public class ValidationOff012Test extends W3CWoff2DecodeTest {
5051
@Override
5152
protected String getFontName() {

io/src/test/java/com/itextpdf/io/font/woff2/w3c/format/BlocksMetadataPadding001Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ This file is part of the iText (R) project.
4545
import com.itextpdf.io.font.woff2.w3c.W3CWoff2DecodeTest;
4646
import org.junit.Ignore;
4747

48-
@Ignore("Different in result form expected in w3c suite. See html font-face test for more details")
4948
public class BlocksMetadataPadding001Test extends W3CWoff2DecodeTest {
5049
@Override
5150
protected String getFontName() {
@@ -57,6 +56,7 @@ protected String getTestInfo() {
5756
}
5857
@Override
5958
protected boolean isFontValid() {
60-
return false;
59+
//NOTE: Should be invalid by w3c test suite spec. See w3cProblemTest01 in html font-face test for more details.
60+
return true;
6161
}
6262
}

io/src/test/java/com/itextpdf/io/font/woff2/w3c/format/DirectoryTableOrder002Test.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ This file is part of the iText (R) project.
4545
import com.itextpdf.io.font.woff2.w3c.W3CWoff2DecodeTest;
4646
import org.junit.Ignore;
4747

48-
@Ignore("Different from c++ version. See html font-face test for more details")
48+
@Ignore("DEVSIX-1612: different result in java and C#")
49+
//NOTE: Should be invalid by w3c test suite spec. See w3cProblemTest02 in html font-face test for more details.
4950
public class DirectoryTableOrder002Test extends W3CWoff2DecodeTest {
5051
@Override
5152
protected String getFontName() {

io/src/test/java/com/itextpdf/io/font/woff2/w3c/format/HeaderFlavor001Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ This file is part of the iText (R) project.
4545
import com.itextpdf.io.font.woff2.w3c.W3CWoff2DecodeTest;
4646
import org.junit.Ignore;
4747

48-
@Ignore("Different in result form expected in w3c suite. See html font-face test for more details")
4948
public class HeaderFlavor001Test extends W3CWoff2DecodeTest {
5049
@Override
5150
protected String getFontName() {
@@ -57,6 +56,7 @@ protected String getTestInfo() {
5756
}
5857
@Override
5958
protected boolean isFontValid() {
60-
return false;
59+
//NOTE: Should be invalid by w3c test suite spec. See w3cProblemTest03 in html font-face test for more details.
60+
return true;
6161
}
6262
}

io/src/test/java/com/itextpdf/io/font/woff2/w3c/format/HeaderFlavor002Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ This file is part of the iText (R) project.
4545
import com.itextpdf.io.font.woff2.w3c.W3CWoff2DecodeTest;
4646
import org.junit.Ignore;
4747

48-
@Ignore("Different in result form expected in w3c suite. See html font-face test for more details")
4948
public class HeaderFlavor002Test extends W3CWoff2DecodeTest {
5049
@Override
5150
protected String getFontName() {
@@ -57,6 +56,7 @@ protected String getTestInfo() {
5756
}
5857
@Override
5958
protected boolean isFontValid() {
60-
return false;
59+
//NOTE: Should be invalid by w3c test suite spec. See w3cProblemTest04 in html font-face test for more details.
60+
return true;
6161
}
6262
}

io/src/test/java/com/itextpdf/io/font/woff2/w3c/format/HeaderReserved001Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ This file is part of the iText (R) project.
4545
import com.itextpdf.io.font.woff2.w3c.W3CWoff2DecodeTest;
4646
import org.junit.Ignore;
4747

48-
@Ignore("Different in result form expected in w3c suite. See html font-face test for more details")
4948
public class HeaderReserved001Test extends W3CWoff2DecodeTest {
5049
@Override
5150
protected String getFontName() {
@@ -57,6 +56,7 @@ protected String getTestInfo() {
5756
}
5857
@Override
5958
protected boolean isFontValid() {
60-
return false;
59+
//NOTE: Should be invalid by w3c test suite spec. See w3cProblemTest05 in html font-face test for more details.
60+
return true;
6161
}
6262
}

io/src/test/java/com/itextpdf/io/font/woff2/w3c/format/TabledataHmtxTransform003Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ This file is part of the iText (R) project.
4545
import com.itextpdf.io.font.woff2.w3c.W3CWoff2DecodeTest;
4646
import org.junit.Ignore;
4747

48-
@Ignore("Different in result form expected in w3c suite. See html font-face test for more details")
4948
public class TabledataHmtxTransform003Test extends W3CWoff2DecodeTest {
5049
@Override
5150
protected String getFontName() {
@@ -57,6 +56,7 @@ protected String getTestInfo() {
5756
}
5857
@Override
5958
protected boolean isFontValid() {
60-
return false;
59+
//NOTE: Should be invalid by w3c test suite spec. See w3cProblemTest06 in html font-face test for more details.
60+
return true;
6161
}
6262
}

kernel/src/test/java/com/itextpdf/kernel/pdf/EncodingTest.java

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -225,50 +225,56 @@ public void notdefInType0Test() throws IOException, InterruptedException {
225225
}
226226

227227
@Test
228-
@Ignore("Should we update built-in font's descriptor in case not standard font encoding?")
229228
public void symbolDefaultFontTest() throws IOException, InterruptedException {
230229
String fileName = "symbolDefaultFontTest.pdf";
231230
PdfWriter writer = new PdfWriter(outputFolder + fileName);
232231
PdfDocument doc = new PdfDocument(writer);
233232

234-
PdfFont font = PdfFontFactory.createFont(FontConstants.SYMBOL, PdfEncodings.WINANSI);
235-
PdfCanvas canvas = new PdfCanvas(doc.addNewPage());
236-
String str = "";
233+
PdfFont font = PdfFontFactory.createFont(FontConstants.SYMBOL);
234+
fillSymbolDefaultPage(font, doc.addNewPage());
235+
//WinAnsi encoding doesn't support special symbols
236+
font = PdfFontFactory.createFont(FontConstants.SYMBOL, PdfEncodings.WINANSI);
237+
fillSymbolDefaultPage(font, doc.addNewPage());
238+
doc.close();
239+
240+
Assert.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_"));
241+
}
242+
243+
private void fillSymbolDefaultPage(PdfFont font, PdfPage page) {
244+
PdfCanvas canvas = new PdfCanvas(page);
245+
StringBuilder builder = new StringBuilder();
237246
for (int i = 32; i <= 100; i++) {
238-
str += (char) i;
247+
builder.append((char) i);
239248
}
240249
canvas.
241250
saveState().
242251
beginText().
243-
moveText(36, 806).
244252
setFontAndSize(font, 12).
245-
showText(str).
246-
endText();
247-
248-
str = "";
253+
moveText(36, 806).
254+
showText(builder.toString()).
255+
endText().
256+
restoreState();
257+
builder = new StringBuilder();
249258
for (int i = 101; i <= 190; i++) {
250-
str += (char) i;
259+
builder.append((char) i);
251260
}
252261
canvas.
253262
saveState().
254263
beginText().
255-
moveText(36, 786).
256264
setFontAndSize(font, 12).
257-
showText(str).
265+
moveText(36, 786).
266+
showText(builder.toString()).
258267
endText();
259-
str = "";
268+
builder = new StringBuilder();
260269
for (int i = 191; i <= 254; i++) {
261-
str += (char) i;
270+
builder.append((char) i);
262271
}
263272
canvas.
264273
beginText().
265274
moveText(36, 766).
266-
showText(str).
275+
showText(builder.toString()).
267276
endText().
268277
restoreState();
269-
doc.close();
270-
271-
Assert.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_"));
272278
}
273279

274280
@Test

kernel/src/test/java/com/itextpdf/kernel/pdf/PdfEncryptionTest.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ public void stampDocNoUserPassword() throws InterruptedException, IOException, X
378378
}
379379

380380
@Test
381-
@Ignore("Specific crypto filters for EFF StmF and StrF are not supported at the moment.")
382381
public void encryptWithPasswordAes128EmbeddedFilesOnly() throws IOException, GeneralSecurityException, XMPException, InterruptedException {
383382
String filename = "encryptWithPasswordAes128EmbeddedFilesOnly.pdf";
384383
int encryptionType = EncryptionConstants.ENCRYPTION_AES_128 | EncryptionConstants.EMBEDDED_FILES_ONLY;
@@ -403,16 +402,10 @@ public void encryptWithPasswordAes128EmbeddedFilesOnly() throws IOException, Gen
403402
document.close();
404403

405404

406-
checkDecryptedWithPasswordContent(destinationFolder + filename, OWNER, textContent);
407-
checkDecryptedWithPasswordContent(destinationFolder + filename, USER, textContent);
408-
409-
CompareTool compareTool = new CompareTool().enableEncryptionCompare();
410-
String compareResult = compareTool.compareByContent(outFileName, sourceFolder + "cmp_" + filename, destinationFolder, "diff_", USER, USER);
411-
if (compareResult != null) {
412-
fail(compareResult);
413-
}
414-
checkEncryptedWithPasswordDocumentStamping(filename, OWNER);
415-
checkEncryptedWithPasswordDocumentAppending(filename, OWNER);
405+
//NOTE: Specific crypto filters for EFF StmF and StrF are not supported at the moment. iText don't distinguish objects based on their semantic role
406+
// because of this we can't read streams correctly and corrupt such documents on stamping.
407+
checkDecryptedWithPasswordContent(destinationFolder + filename, OWNER, textContent, true);
408+
checkDecryptedWithPasswordContent(destinationFolder + filename, USER, textContent, true);
416409
}
417410

418411
@Test
@@ -510,13 +503,23 @@ public PrivateKey getPrivateKey() throws GeneralSecurityException, IOException {
510503
}
511504

512505
public void checkDecryptedWithPasswordContent(String src, byte[] password, String pageContent) throws IOException {
506+
checkDecryptedWithPasswordContent(src, password, pageContent, false);
507+
}
508+
509+
private void checkDecryptedWithPasswordContent(String src, byte[] password, String pageContent, boolean expectError) throws IOException {
513510
PdfReader reader = new com.itextpdf.kernel.pdf.PdfReader(src, new ReaderProperties().setPassword(password));
514511
PdfDocument document = new com.itextpdf.kernel.pdf.PdfDocument(reader);
515512
PdfPage page = document.getPage(1);
516513

517-
Assert.assertTrue("Expected content: \n" + pageContent, new String(page.getStreamBytes(0)).contains(pageContent));
518-
Assert.assertEquals("Encrypted author", author, document.getDocumentInfo().getAuthor());
519-
Assert.assertEquals("Encrypted creator", creator, document.getDocumentInfo().getCreator());
514+
if (expectError) {
515+
Assert.assertFalse("Expected content: \n" + pageContent, new String(page.getStreamBytes(0)).contains(pageContent));
516+
Assert.assertNotEquals("Encrypted author", author, document.getDocumentInfo().getAuthor());
517+
Assert.assertNotEquals("Encrypted creator", creator, document.getDocumentInfo().getCreator());
518+
} else {
519+
Assert.assertTrue("Expected content: \n" + pageContent, new String(page.getStreamBytes(0)).contains(pageContent));
520+
Assert.assertEquals("Encrypted author", author, document.getDocumentInfo().getAuthor());
521+
Assert.assertEquals("Encrypted creator", creator, document.getDocumentInfo().getCreator());
522+
}
520523

521524
document.close();
522525
}

kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderTest.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -747,21 +747,20 @@ public void correctSimpleDoc3() throws IOException {
747747
}
748748

749749
@Test
750-
@Ignore("ignore") //test with abnormal object declaration
750+
@LogMessages(messages = @LogMessage(messageTemplate = LogMessageConstant.XREF_ERROR))
751751
public void correctSimpleDoc4() throws IOException {
752752
String filename = sourceFolder + "correctSimpleDoc4.pdf";
753753

754754
PdfReader reader = new PdfReader(filename);
755-
PdfDocument document = new PdfDocument(reader);
756-
Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref());
757-
758-
int pageCount = document.getNumberOfPages();
759-
Assert.assertEquals(1, pageCount);
760-
761-
PdfPage page = document.getPage(1);
762-
Assert.assertNotNull(page.getContentStream(0).getBytes());
763-
764-
document.close();
755+
try {
756+
//NOTE test with abnormal object declaration that iText can't resolve.
757+
PdfDocument document = new PdfDocument(reader);
758+
Assert.fail("Expect exception");
759+
} catch (PdfException e) {
760+
Assert.assertEquals( PdfException.InvalidPageStructurePagesPagesMustBePdfDictionary, e.getMessage());
761+
} finally {
762+
reader.close();
763+
}
765764
}
766765

767766
@Test

0 commit comments

Comments
 (0)