|
1 | 1 | /*
|
2 | 2 | This file is part of the iText (R) project.
|
3 |
| -Copyright (c) 1998-2021 iText Group NV |
| 3 | +Copyright (c) 1998-2022 iText Group NV |
4 | 4 | Authors: iText Software.
|
5 | 5 |
|
6 | 6 | This program is offered under a commercial and under the AGPL license.
|
@@ -29,70 +29,33 @@ You should have received a copy of the GNU Affero General Public License
|
29 | 29 | using iText.Test.Attributes;
|
30 | 30 |
|
31 | 31 | namespace iText.Pdfocr {
|
| 32 | + [NUnit.Framework.Category("Integration test")] |
32 | 33 | public class PdfInputImageTest : ExtendedITextTest {
|
33 | 34 | [LogMessage(PdfOcrLogMessageConstant.CANNOT_READ_INPUT_IMAGE)]
|
34 | 35 | [NUnit.Framework.Test]
|
35 |
| - public virtual void TestCorruptedImage() { |
36 |
| - NUnit.Framework.Assert.That(() => { |
37 |
| - FileInfo file = new FileInfo(PdfHelper.GetImagesTestDirectory() + "corrupted.jpg"); |
38 |
| - String realOutput = PdfHelper.GetTextFromPdf(file, "testCorruptedImage"); |
39 |
| - NUnit.Framework.Assert.IsNotNull(realOutput); |
40 |
| - NUnit.Framework.Assert.AreEqual("", realOutput); |
41 |
| - } |
42 |
| - , NUnit.Framework.Throws.InstanceOf<PdfOcrInputException>()) |
43 |
| -; |
| 36 | + public virtual void CorruptedImageTest() { |
| 37 | + FileInfo file = new FileInfo(PdfHelper.GetImagesTestDirectory() + "corrupted.jpg"); |
| 38 | + Exception e = NUnit.Framework.Assert.Catch(typeof(PdfOcrInputException), () => PdfHelper.GetTextFromPdf(file |
| 39 | + , "testCorruptedImage")); |
| 40 | + NUnit.Framework.Assert.AreEqual(PdfOcrExceptionMessageConstant.CANNOT_READ_INPUT_IMAGE, e.Message); |
44 | 41 | }
|
45 | 42 |
|
46 | 43 | [LogMessage(PdfOcrLogMessageConstant.CANNOT_READ_INPUT_IMAGE)]
|
47 | 44 | [NUnit.Framework.Test]
|
48 |
| - public virtual void TestCorruptedImageWithoutExtension() { |
49 |
| - NUnit.Framework.Assert.That(() => { |
50 |
| - FileInfo file = new FileInfo(PdfHelper.GetImagesTestDirectory() + "corrupted"); |
51 |
| - String realOutput = PdfHelper.GetTextFromPdf(file, "testCorruptedImageWithoutExtension"); |
52 |
| - NUnit.Framework.Assert.IsNotNull(realOutput); |
53 |
| - NUnit.Framework.Assert.AreEqual("", realOutput); |
54 |
| - } |
55 |
| - , NUnit.Framework.Throws.InstanceOf<PdfOcrInputException>()) |
56 |
| -; |
| 45 | + public virtual void CorruptedImageWithoutExtensionTest() { |
| 46 | + FileInfo file = new FileInfo(PdfHelper.GetImagesTestDirectory() + "corrupted"); |
| 47 | + Exception e = NUnit.Framework.Assert.Catch(typeof(PdfOcrInputException), () => PdfHelper.GetTextFromPdf(file |
| 48 | + , "testCorruptedImageWithoutExtension")); |
| 49 | + NUnit.Framework.Assert.AreEqual(PdfOcrExceptionMessageConstant.CANNOT_READ_INPUT_IMAGE, e.Message); |
57 | 50 | }
|
58 | 51 |
|
59 | 52 | [LogMessage(PdfOcrLogMessageConstant.CANNOT_READ_INPUT_IMAGE)]
|
60 | 53 | [NUnit.Framework.Test]
|
61 |
| - public virtual void TestInvalidImagePathWithoutDot() { |
62 |
| - NUnit.Framework.Assert.That(() => { |
63 |
| - FileInfo file = new FileInfo("testName"); |
64 |
| - String realOutput = PdfHelper.GetTextFromPdf(file, "testInvalidImagePathWithoutDot"); |
65 |
| - NUnit.Framework.Assert.IsNotNull(realOutput); |
66 |
| - NUnit.Framework.Assert.AreEqual("", realOutput); |
67 |
| - } |
68 |
| - , NUnit.Framework.Throws.InstanceOf<PdfOcrInputException>()) |
69 |
| -; |
70 |
| - } |
71 |
| - |
72 |
| - [LogMessage(PdfOcrLogMessageConstant.CANNOT_READ_INPUT_IMAGE)] |
73 |
| - [NUnit.Framework.Test] |
74 |
| - public virtual void TestInvalidImagePathWithDot() { |
75 |
| - NUnit.Framework.Assert.That(() => { |
76 |
| - FileInfo file = new FileInfo("test.Name"); |
77 |
| - String realOutput = PdfHelper.GetTextFromPdf(file, "testInvalidImagePathWithDot"); |
78 |
| - NUnit.Framework.Assert.IsNotNull(realOutput); |
79 |
| - NUnit.Framework.Assert.AreEqual("", realOutput); |
80 |
| - } |
81 |
| - , NUnit.Framework.Throws.InstanceOf<PdfOcrInputException>()) |
82 |
| -; |
83 |
| - } |
84 |
| - |
85 |
| - [LogMessage(PdfOcrLogMessageConstant.CANNOT_READ_INPUT_IMAGE)] |
86 |
| - [NUnit.Framework.Test] |
87 |
| - public virtual void TestValidImageWithoutExtension() { |
88 |
| - NUnit.Framework.Assert.That(() => { |
89 |
| - FileInfo file = new FileInfo(PdfHelper.GetImagesTestDirectory() + "numbers_01"); |
90 |
| - String realOutput = PdfHelper.GetTextFromPdf(file, "testValidImageWithoutExtension"); |
91 |
| - NUnit.Framework.Assert.IsNotNull(realOutput); |
92 |
| - NUnit.Framework.Assert.AreEqual("", realOutput); |
93 |
| - } |
94 |
| - , NUnit.Framework.Throws.InstanceOf<PdfOcrInputException>()) |
95 |
| -; |
| 54 | + public virtual void InvalidPathWithDotTest() { |
| 55 | + FileInfo file = new FileInfo("test.Name"); |
| 56 | + Exception e = NUnit.Framework.Assert.Catch(typeof(PdfOcrInputException), () => PdfHelper.GetTextFromPdf(file |
| 57 | + , "testInvalidPathWithDot")); |
| 58 | + NUnit.Framework.Assert.AreEqual(PdfOcrExceptionMessageConstant.CANNOT_READ_INPUT_IMAGE, e.Message); |
96 | 59 | }
|
97 | 60 | }
|
98 | 61 | }
|
0 commit comments