Skip to content

Commit 91b5ec7

Browse files
committed
PDFBOX-5660: Sonar fix
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1924859 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3e4508d commit 91b5ec7

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.apache.xmpbox.XMPMetadata;
3737
import org.apache.xmpbox.schema.DublinCoreSchema;
3838
import org.apache.xmpbox.xml.DomXmpParser;
39-
import org.junit.jupiter.api.BeforeEach;
39+
import org.junit.jupiter.api.BeforeAll;
4040
import org.junit.jupiter.api.Test;
4141
import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider;
4242
import org.verapdf.pdfa.Foundries;
@@ -51,12 +51,12 @@
5151
*/
5252
class CreatePDFATest
5353
{
54-
private final String outDir = "target/test-output";
54+
private static final String OUTDIR = "target/test-output";
5555

56-
@BeforeEach
57-
void setUp()
56+
@BeforeAll
57+
static void setUp()
5858
{
59-
new File(outDir).mkdirs();
59+
new File(OUTDIR).mkdirs();
6060
}
6161

6262
/**
@@ -65,9 +65,8 @@ void setUp()
6565
@Test
6666
void testCreatePDFA() throws Exception
6767
{
68-
System.out.println("testCreatePDFA");
69-
String pdfaFilename = outDir + "/PDFA.pdf";
70-
String signedPdfaFilename = outDir + "/PDFA_signed.pdf";
68+
String pdfaFilename = OUTDIR + "/PDFA.pdf";
69+
String signedPdfaFilename = OUTDIR + "/PDFA_signed.pdf";
7170
String keystorePath = "src/test/resources/org/apache/pdfbox/examples/signature/keystore.p12";
7271
String message = "The quick brown fox jumps over the lazy dog äöüÄÖÜß @°^²³ {[]}";
7372
String dir = "../pdfbox/src/main/resources/org/apache/pdfbox/resources/ttf/";

pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.nio.charset.StandardCharsets;
3232
import java.nio.file.Files;
3333
import java.nio.file.Paths;
34+
import java.security.NoSuchAlgorithmException;
3435
import java.util.ArrayList;
3536
import java.util.List;
3637
import java.util.Map;
@@ -81,17 +82,17 @@ class TestSymmetricKeyEncryption
8182
*/
8283
private static final Logger LOG = LogManager.getLogger(TestSymmetricKeyEncryption.class);
8384

84-
private static final File testResultsDir = new File("target/test-output/crypto");
85+
private static final File TESTRESULTSDIR = new File("target/test-output/crypto");
8586

8687
private static AccessPermission permission;
8788

8889
static final String USERPASSWORD = "1234567890abcdefghijk1234567890abcdefghijk";
8990
static final String OWNERPASSWORD = "abcdefghijk1234567890abcdefghijk1234567890";
9091

9192
@BeforeAll
92-
static void setUp() throws Exception
93+
static void setUp() throws NoSuchAlgorithmException
9394
{
94-
testResultsDir.mkdirs();
95+
TESTRESULTSDIR.mkdirs();
9596

9697
if (Cipher.getMaxAllowedKeyLength("AES") != Integer.MAX_VALUE)
9798
{
@@ -325,7 +326,7 @@ void testProtectionInnerAttachment() throws Exception
325326
void testPDFBox4453() throws IOException
326327
{
327328
final int TESTCOUNT = 1000;
328-
File file = new File(testResultsDir,"PDFBOX-4453.pdf");
329+
File file = new File(TESTRESULTSDIR,"PDFBOX-4453.pdf");
329330
try (PDDocument doc = new PDDocument())
330331
{
331332
doc.addPage(new PDPage());
@@ -417,7 +418,7 @@ private void testSymmEncrForKeySize(String filename, int keyLength, boolean pref
417418
}
418419
}
419420

420-
File pdfFile = new File(testResultsDir, prefix + keyLength + "-bit-" + (preferAES ? "AES" : "RC4") + "-decrypted.pdf");
421+
File pdfFile = new File(TESTRESULTSDIR, prefix + keyLength + "-bit-" + (preferAES ? "AES" : "RC4") + "-decrypted.pdf");
421422
encryptedDoc.setAllSecurityToBeRemoved(true);
422423
encryptedDoc.save(pdfFile);
423424
}
@@ -439,7 +440,7 @@ private PDDocument encrypt(int keyLength, boolean preferAES, int sizePriorToEncr
439440

440441
doc.protect(spp);
441442

442-
File pdfFile = new File(testResultsDir, prefix + keyLength + "-bit-" + (preferAES ? "AES" : "RC4") + "-encrypted.pdf");
443+
File pdfFile = new File(TESTRESULTSDIR, prefix + keyLength + "-bit-" + (preferAES ? "AES" : "RC4") + "-encrypted.pdf");
443444

444445
doc.save(pdfFile);
445446
doc.close();
@@ -493,7 +494,7 @@ private File extractEmbeddedFile(RandomAccessRead pdfSource, String name) throws
493494
PDComplexFileSpecification complexFileSpec = entry.getValue();
494495
PDEmbeddedFile embeddedFile = complexFileSpec.getEmbeddedFile();
495496

496-
File resultFile = new File(testResultsDir, name);
497+
File resultFile = new File(TESTRESULTSDIR, name);
497498
try (FileOutputStream fos = new FileOutputStream(resultFile);
498499
InputStream is = embeddedFile.createInputStream())
499500
{
@@ -514,7 +515,7 @@ private void testSymmEncrForKeySizeInner(int keyLength, boolean preferAES,
514515
PDDocument document = Loader.loadPDF(inputFileWithEmbeddedFileAsByteArray);
515516
try (PDDocument encryptedDoc = encrypt(keyLength, preferAES, sizePriorToEncr, document, "ContainsEmbedded-", permission, userpassword, ownerpassword))
516517
{
517-
File decryptedFile = new File(testResultsDir, "DecryptedContainsEmbedded-" + keyLength + "-bit-" + (preferAES ? "AES" : "RC4") + ".pdf");
518+
File decryptedFile = new File(TESTRESULTSDIR, "DecryptedContainsEmbedded-" + keyLength + "-bit-" + (preferAES ? "AES" : "RC4") + ".pdf");
518519
encryptedDoc.setAllSecurityToBeRemoved(true);
519520
encryptedDoc.save(decryptedFile);
520521

0 commit comments

Comments
 (0)