use of com.itextpdf.test.annotations.LogMessages in project i7j-pdfsweep by itext.
the class PdfCleanUpToolWithInlineImagesTest method cleanUpTest31.
@Test
@LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.IMAGE_SIZE_CANNOT_BE_MORE_4KB) })
public void cleanUpTest31() throws IOException, InterruptedException {
String input = inputPath + "inlineImageCleanup.pdf";
String output = outputPath + "inlineImageCleanup.pdf";
String cmp = inputPath + "cmp_inlineImageCleanup.pdf";
cleanUp(input, output, null);
CleanUpImagesCompareTool cmpTool = new CleanUpImagesCompareTool();
String errorMessage = cmpTool.extractAndCompareImages(output, cmp, outputPath, "1");
String compareByContentResult = cmpTool.compareByContent(output, cmp, outputPath);
if (compareByContentResult != null) {
errorMessage += compareByContentResult;
}
if (!errorMessage.equals("")) {
Assert.fail(errorMessage);
}
}
use of com.itextpdf.test.annotations.LogMessages in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method pathAndIncorrectCMTest.
@Test
@LogMessages(messages = @LogMessage(messageTemplate = CleanUpLogMessageConstant.FAILED_TO_PROCESS_A_TRANSFORMATION_MATRIX, count = 7))
public void pathAndIncorrectCMTest() throws IOException, InterruptedException {
String fileName = "pathAndIncorrectCM";
String input = INPUT_PATH + "pathAndIncorrectCM.pdf";
String output = OUTPUT_PATH + fileName + ".pdf";
String cmp = INPUT_PATH + "cmp_" + fileName + ".pdf";
List<PdfCleanUpLocation> dummyLocationsList = new ArrayList<>();
for (int i = 0; i < 3; i++) {
dummyLocationsList.add(new PdfCleanUpLocation(i + 1, new Rectangle(0, 0, 0, 0), null));
}
cleanUp(input, output, dummyLocationsList);
compareByContent(cmp, output, OUTPUT_PATH, "diff_pathAndIncorrectCMTest");
}
use of com.itextpdf.test.annotations.LogMessages in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method redactPdfWithNoninvertibleMatrix.
@Test
@LogMessages(messages = @LogMessage(messageTemplate = CleanUpLogMessageConstant.FAILED_TO_PROCESS_A_TRANSFORMATION_MATRIX, count = 2))
public void redactPdfWithNoninvertibleMatrix() throws IOException, InterruptedException {
String input = INPUT_PATH + "noninvertibleMatrix.pdf";
String output = OUTPUT_PATH + "redactPdfWithNoninvertibleMatrix.pdf";
String cmp = INPUT_PATH + "cmp_redactPdfWithNoninvertibleMatrix.pdf";
CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
strategy.add(new RegexBasedCleanupStrategy("Hello World!").setRedactionColor(ColorConstants.GREEN));
PdfDocument pdf = new PdfDocument(new PdfReader(input), new PdfWriter(output));
// sweep
PdfCleaner.autoSweepCleanUp(pdf, strategy);
pdf.close();
// compare
compareByContent(cmp, output, OUTPUT_PATH, "diff_redactPdfWithNoninvertibleMatrix_");
}
use of com.itextpdf.test.annotations.LogMessages in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method noninvertibleMatrixRemoveAllTest02.
@Test
@LogMessages(messages = @LogMessage(messageTemplate = CleanUpLogMessageConstant.FAILED_TO_PROCESS_A_TRANSFORMATION_MATRIX))
public void noninvertibleMatrixRemoveAllTest02() throws IOException, InterruptedException {
String fileName = "noninvertibleMatrixRemoveAllTest02";
String input = INPUT_PATH + "noninvertibleMatrix.pdf";
String output = OUTPUT_PATH + fileName + ".pdf";
String cmp = INPUT_PATH + "cmp_" + fileName + ".pdf";
PdfCleanUpLocation wholePageLocation = new PdfCleanUpLocation(1, new Rectangle(-1000, -1000, 2000, 2000), null);
cleanUp(input, output, Arrays.asList(wholePageLocation));
compareByContent(cmp, output, OUTPUT_PATH, "diff_noninvertibleMatrixRemoveAllTest");
}
use of com.itextpdf.test.annotations.LogMessages in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method noPropertiesInResourcesTest.
@Test
@LogMessages(messages = @LogMessage(messageTemplate = IoLogMessageConstant.PDF_REFERS_TO_NOT_EXISTING_PROPERTY_DICTIONARY))
public void noPropertiesInResourcesTest() throws IOException, InterruptedException {
String fileName = "noPropertiesInResourcesTest";
String input = INPUT_PATH + fileName + ".pdf";
String output = OUTPUT_PATH + fileName + ".pdf";
String cmp = INPUT_PATH + "cmp_" + fileName + ".pdf";
List<PdfCleanUpLocation> cleanUpLocations = Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(0, 0, 595, 842), ColorConstants.RED));
cleanUp(input, output, cleanUpLocations);
compareByContent(cmp, output, OUTPUT_PATH, "diff_" + fileName);
}
Aggregations