Skip to content

Commit

Permalink
Merge branch 'develop' into devsecops
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-ivanov committed Dec 12, 2024
2 parents cd3a6c1 + 809b554 commit c034625
Show file tree
Hide file tree
Showing 23 changed files with 200 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public virtual void MakeLighterTest() {
}

// Android-Conversion-Skip-Block-Start (java.awt library isn't available on Android)
[iText.Commons.Utils.NoopAnnotation]
// java.awt is not compatible with graalvm
[NUnit.Framework.Test]
public virtual void ColorByAWTColorConstantTest() {
// RED
Expand All @@ -72,6 +74,8 @@ public virtual void ColorByAWTColorConstantTest() {
NUnit.Framework.Assert.AreEqual(1, rgbColorValue[2], 0.0001);
}

[iText.Commons.Utils.NoopAnnotation]
// java.awt is not compatible with graalvm
[NUnit.Framework.Test]
public virtual void ColorByAWTColorTest() {
System.Drawing.Color color = System.Drawing.Color.FromArgb(50, 100, 150);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public class PdfCanvasTest : ExtendedITextTest {

private const String TITLE = "Empty iText Document";

private sealed class _ContentProvider_86 : PdfCanvasTest.ContentProvider {
public _ContentProvider_86() {
private sealed class _ContentProvider_87 : PdfCanvasTest.ContentProvider {
public _ContentProvider_87() {
}

public void DrawOnCanvas(PdfCanvas canvas, int pageNumber) {
Expand All @@ -73,7 +73,7 @@ public void DrawOnCanvas(PdfCanvas canvas, int pageNumber) {
}
}

private static readonly PdfCanvasTest.ContentProvider DEFAULT_CONTENT_PROVIDER = new _ContentProvider_86();
private static readonly PdfCanvasTest.ContentProvider DEFAULT_CONTENT_PROVIDER = new _ContentProvider_87();

[NUnit.Framework.OneTimeSetUp]
public static void BeforeClass() {
Expand Down Expand Up @@ -247,12 +247,12 @@ public virtual void Create1000PagesDocumentWithText() {
int pageCount = 1000;
String filename = DESTINATION_FOLDER + "1000PagesDocumentWithText.pdf";
PdfWriter writer = CompareTool.CreateTestPdfWriter(filename);
CreateStandardDocument(writer, pageCount, new _ContentProvider_387());
CreateStandardDocument(writer, pageCount, new _ContentProvider_388());
AssertStandardDocument(filename, pageCount);
}

private sealed class _ContentProvider_387 : PdfCanvasTest.ContentProvider {
public _ContentProvider_387() {
private sealed class _ContentProvider_388 : PdfCanvasTest.ContentProvider {
public _ContentProvider_388() {
}

public void DrawOnCanvas(PdfCanvas canvas, int pageNumber) {
Expand Down Expand Up @@ -865,16 +865,16 @@ public virtual void CanvasInitializationStampingExistingStream() {
[NUnit.Framework.Test]
public virtual void CanvasStreamFlushedNoException() {
PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()));
PdfStream stream = new _PdfStream_1121();
PdfStream stream = new _PdfStream_1123();
stream.Put(PdfName.Filter, new PdfName("FlateDecode"));
NUnit.Framework.Assert.DoesNotThrow(() => {
new PdfCanvas(stream, new PdfResources(), doc);
}
);
}

private sealed class _PdfStream_1121 : PdfStream {
public _PdfStream_1121() {
private sealed class _PdfStream_1123 : PdfStream {
public _PdfStream_1123() {
this.isFlushed = false;
}

Expand All @@ -894,7 +894,7 @@ public override bool IsFlushed() {
public virtual void CanvasInitializationStampingExistingStreamMemoryLimitAware() {
String srcFile = SOURCE_FOLDER + "pageWithContent.pdf";
ReaderProperties properties = new ReaderProperties();
MemoryLimitsAwareHandler handler = new _MemoryLimitsAwareHandler_1144();
MemoryLimitsAwareHandler handler = new _MemoryLimitsAwareHandler_1146();
handler.SetMaxSizeOfSingleDecompressedPdfStream(1);
properties.SetMemoryLimitsAwareHandler(handler);
PdfDocument document = new PdfDocument(new PdfReader(srcFile, properties));
Expand All @@ -905,8 +905,8 @@ public virtual void CanvasInitializationStampingExistingStreamMemoryLimitAware()
);
}

private sealed class _MemoryLimitsAwareHandler_1144 : MemoryLimitsAwareHandler {
public _MemoryLimitsAwareHandler_1144() {
private sealed class _MemoryLimitsAwareHandler_1146 : MemoryLimitsAwareHandler {
public _MemoryLimitsAwareHandler_1146() {
}

public override bool IsMemoryLimitsAwarenessRequiredOnDecompression(PdfArray filters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public virtual void PdfUA2LinkAnnotNoAltTest() {
paragraph.Add(link);
new Document(pdfDocument).Add(paragraph);
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand Down Expand Up @@ -128,7 +128,7 @@ public virtual void PdfUA2FileAttachmentAnnotNoAFRelTest() {
annot.SetContents("Hello world");
pdfPage.AddAnnotation(annot);
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand Down Expand Up @@ -163,7 +163,7 @@ public virtual void PdfUA2RubberStampNoContentsAnnotationsTest() {
pdfPage.AddAnnotation(stamp);
pdfPage.Flush();
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand Down Expand Up @@ -194,7 +194,7 @@ public virtual void PdfUA2ScreenNoContentsAnnotationsTest() {
pdfPage.AddAnnotation(screen);
pdfPage.Flush();
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand Down Expand Up @@ -225,7 +225,7 @@ public virtual void PdfUA2InkAnnotationsNoContentTest() {
pdfPage.AddAnnotation(ink);
pdfPage.Flush();
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand Down Expand Up @@ -256,7 +256,7 @@ public virtual void PdfUA2RedactionNoContentsAnnotationsTest() {
pdfPage.AddAnnotation(redact);
pdfPage.Flush();
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand Down Expand Up @@ -287,7 +287,7 @@ public virtual void PdfUA23DNoContentsAnnotationsTest() {
pdfPage.AddAnnotation(annot);
pdfPage.Flush();
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand Down Expand Up @@ -318,7 +318,7 @@ public virtual void PdfUA2RichMediaNoContentsAnnotationsTest() {
pdfPage.AddAnnotation(annot);
pdfPage.Flush();
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand Down Expand Up @@ -353,7 +353,7 @@ public virtual void PdfUA2NotAllowedTrapNetAnnotationTest() {
PdfTrapNetworkAnnotation annot = new PdfTrapNetworkAnnotation(PageSize.A4, form);
pdfPage.AddAnnotation(annot);
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand All @@ -367,7 +367,7 @@ public virtual void PdfUA2NotAllowedSoundAnnotationTest() {
PdfAnnotation annot = new PdfSoundAnnotation(new Rectangle(100, 100, 100, 100), new PdfStream());
pdfPage.AddAnnotation(annot);
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand All @@ -386,7 +386,7 @@ public virtual void PdfUA2AltContentDiffAnnotationTest() {
paragraph.Add(link);
new Document(pdfDocument).Add(paragraph);
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand Down Expand Up @@ -424,7 +424,7 @@ public virtual void AnnotationInvisibleButNoArtifactTest() {
pdfPage.AddAnnotation(annot);
pdfPage.Flush();
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand All @@ -440,7 +440,7 @@ public virtual void AnnotationNoViewButNoArtifactTest() {
pdfPage.AddAnnotation(annot);
pdfPage.Flush();
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand Down
8 changes: 4 additions & 4 deletions itext.tests/itext.layout.tests/itext/layout/PdfUA2Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ public virtual void CheckMetadataNoTitleTest() {
pdfDocument.GetCatalog().SetViewerPreferences(new PdfViewerPreferences().SetDisplayDocTitle(true));
pdfDocument.GetCatalog().SetLang(new PdfString("en-US"));
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand All @@ -602,7 +602,7 @@ public virtual void CheckMetadataDisplayDocTitleFalseTest() {
PdfDocumentInfo info = pdfDocument.GetDocumentInfo();
info.SetTitle("PdfUA2 Title");
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand All @@ -619,7 +619,7 @@ public virtual void CheckMetadataNoViewerPrefTest() {
PdfDocumentInfo info = pdfDocument.GetDocumentInfo();
info.SetTitle("PdfUA2 Title");
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand Down Expand Up @@ -652,7 +652,7 @@ public virtual void CheckEmbeddedFileNoDescTest() {
((PdfDictionary)spec.GetPdfObject()).Remove(PdfName.Desc);
pdfDocument.AddFileAttachment("specificname", spec);
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outFile));
new VeraPdfValidator().ValidateFailure(outFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
Expand Down
2 changes: 2 additions & 0 deletions itext.tests/itext.pdfa.tests/itext/pdfa/PdfABarcodeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ You should have received a copy of the GNU Affero General Public License
using iText.Test;

namespace iText.Pdfa {
[iText.Commons.Utils.NoopAnnotation]
// java.awt is not compatible with graalvm
[NUnit.Framework.Category("IntegrationTest")]
public class PdfABarcodeTest : ExtendedITextTest {
public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
Expand Down
2 changes: 1 addition & 1 deletion itext.tests/itext.pdfa.tests/itext/pdfa/PdfAFontTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ private void CreateDocumentWithFont(String outFileName, String fontFileName, Str
}

private void CompareResult(String outPdf, String cmpPdf, String expectedVeraPdfWarning) {
NUnit.Framework.Assert.AreEqual(expectedVeraPdfWarning, new VeraPdfValidator().Validate(outPdf));
new VeraPdfValidator().ValidateWarning(outPdf, expectedVeraPdfWarning);
// 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ public virtual void CheckValidatorLogsWithWarningTest() {
String expectedWarningsForFileWithWarnings = "The following warnings and errors were logged during validation:\n"
+ "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";
NUnit.Framework.Assert.AreEqual(expectedWarningsForFileWithWarnings, new VeraPdfValidator().Validate(DESTINATION_FOLDER
+ target));
IgnoreRunningWhenNative((isNative) => {
NUnit.Framework.Assert.AreEqual(expectedWarningsForFileWithWarnings, new VeraPdfValidator().Validate(DESTINATION_FOLDER
+ target));
}
);
}

[NUnit.Framework.Test]
Expand All @@ -72,11 +75,14 @@ public virtual void CheckValidatorLogsCleanupTest() {
String expectedWarningsForFileWithWarnings = "The following warnings and errors were logged during validation:\n"
+ "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";
NUnit.Framework.Assert.AreEqual(expectedWarningsForFileWithWarnings, new VeraPdfValidator().Validate(DESTINATION_FOLDER
+ fileNameWithWarnings));
//We check that the logs are empty after the first check
NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(DESTINATION_FOLDER + fileNameWithoutWarnings
));
IgnoreRunningWhenNative((isNative) => {
NUnit.Framework.Assert.AreEqual(expectedWarningsForFileWithWarnings, new VeraPdfValidator().Validate(DESTINATION_FOLDER
+ fileNameWithWarnings));
//We check that the logs are empty after the first check
NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(DESTINATION_FOLDER + fileNameWithoutWarnings
));
}
);
}

[NUnit.Framework.Test]
Expand All @@ -85,8 +91,22 @@ public virtual void CheckValidatorLogsForFileContainingErrorsTest() {
String target = "checkValidatorLogsForFileContainingErrorsTest.pdf";
FileUtil.Copy(SOURCE_FOLDER + source, DESTINATION_FOLDER + target);
String expectedResponseForErrors = "VeraPDF verification failed. See verification results: file:";
String result = new VeraPdfValidator().Validate(DESTINATION_FOLDER + target);
NUnit.Framework.Assert.IsTrue(result.StartsWith(expectedResponseForErrors));
IgnoreRunningWhenNative((isNative) => {
String result = new VeraPdfValidator().Validate(DESTINATION_FOLDER + target);
NUnit.Framework.Assert.IsTrue(result.StartsWith(expectedResponseForErrors));
}
);
}

private static readonly bool isNative = Environment.GetEnvironmentVariable("org.graalvm.nativeimage.imagecode"
) != null;

public static void IgnoreRunningWhenNative(Action<Object> test) {
// VeraPdf doesn't work in native mode so skip VeraPdf validation
if (isNative) {
return;
}
test(isNative);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public virtual void Ua1StampAnnotWithAltTest() {
);
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, SOURCE_FOLDER + "cmp_ua1StampAnnotWithAltTest.pdf"
, DESTINATION_FOLDER, "diff_"));
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outPdf));
new VeraPdfValidator().ValidateFailure(outPdf);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android)
Expand All @@ -243,7 +243,7 @@ public virtual void Ua1ScreenAnnotWithAltTest() {
);
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, SOURCE_FOLDER + "cmp_ua1ScreenAnnotWithAltTest.pdf"
, DESTINATION_FOLDER, "diff_"));
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outPdf));
new VeraPdfValidator().ValidateFailure(outPdf);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android)
Expand Down Expand Up @@ -757,7 +757,7 @@ public virtual void Ua1PrinterMAnnotNotInTagStructureTest() {
NUnit.Framework.Assert.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.
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outPdf));
new VeraPdfValidator().ValidateFailure(outPdf);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public virtual void TrueTypeFontWithDifferencesTest() {
canvas.SaveState().OpenTag(tagPointer.GetTagReference()).BeginText().MoveText(36, 786).SetFontAndSize(font
, 36).ShowText("world").EndText().RestoreState().CloseTag();
}
NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outPdf));
new VeraPdfValidator().ValidateFailure(outPdf);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android)
Expand Down
Loading

0 comments on commit c034625

Please sign in to comment.