Skip to content

Commit 201781b

Browse files
committed
PDFBOX-5660: Sonar fix
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1924821 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1d6d25c commit 201781b

File tree

4 files changed

+18
-39
lines changed

4 files changed

+18
-39
lines changed

pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/ContentStreamWriterTest.java

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@
3333
import org.apache.pdfbox.pdmodel.common.PDStream;
3434
import org.apache.pdfbox.rendering.PDFRenderer;
3535
import org.apache.pdfbox.rendering.TestPDFToImage;
36-
import org.junit.jupiter.api.AfterAll;
37-
import org.junit.jupiter.api.AfterEach;
3836
import org.junit.jupiter.api.BeforeAll;
39-
import org.junit.jupiter.api.BeforeEach;
4037
import org.junit.jupiter.api.Test;
4138
import org.junit.jupiter.api.parallel.Execution;
4239
import org.junit.jupiter.api.parallel.ExecutionMode;
@@ -48,39 +45,21 @@
4845
@Execution(ExecutionMode.SAME_THREAD)
4946
class ContentStreamWriterTest
5047
{
51-
private final File testDirIn = new File("target/test-output/contentstream/in");
52-
private final File testDirOut = new File("target/test-output/contentstream/out");
53-
54-
ContentStreamWriterTest()
55-
{
56-
testDirIn.mkdirs();
57-
testDirOut.mkdirs();
58-
}
48+
private static final File TESTDIRIN = new File("target/test-output/contentstream/in");
49+
private static final File TESTDIROUT = new File("target/test-output/contentstream/out");
5950

6051
@BeforeAll
61-
public static void setUpClass()
52+
static void setUp()
6253
{
54+
TESTDIRIN.mkdirs();
55+
TESTDIROUT.mkdirs();
56+
6357
// PDFBOX-5425: try to avoid "java.awt.color.CMMException: Unknown profile ID"
6458
ColorSpace csRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
6559
csRGB.toRGB(new float[] { 0, 0, 0 });
6660
ColorSpace csXYZ = ColorSpace.getInstance(ColorSpace.CS_CIEXYZ);
6761
csXYZ.toRGB(new float[] { 0, 0, 0 });
6862
}
69-
70-
@AfterAll
71-
public static void tearDownClass()
72-
{
73-
}
74-
75-
@BeforeEach
76-
public void setUp()
77-
{
78-
}
79-
80-
@AfterEach
81-
public void tearDown()
82-
{
83-
}
8463

8564
/**
8665
* Test parse content stream, write back tokens and compare rendering.
@@ -98,7 +77,7 @@ void testPDFBox4750() throws IOException
9877
for (int i = 0; i < doc.getNumberOfPages(); ++i)
9978
{
10079
BufferedImage bim1 = r.renderImageWithDPI(i, 96);
101-
ImageIO.write(bim1, "png", new File(testDirIn, filename + "-" + (i + 1) + ".png"));
80+
ImageIO.write(bim1, "png", new File(TESTDIRIN, filename + "-" + (i + 1) + ".png"));
10281
PDPage page = doc.getPage(i);
10382
PDStream newContent = new PDStream(doc);
10483
try (OutputStream os = newContent.createOutputStream(COSName.FLATE_DECODE))
@@ -109,12 +88,12 @@ void testPDFBox4750() throws IOException
10988
}
11089
page.setContents(newContent);
11190
}
112-
doc.save(new File(testDirIn, filename));
91+
doc.save(new File(TESTDIRIN, filename));
11392
}
114-
if (!TestPDFToImage.doTestFile(new File(testDirIn, filename), testDirIn.getAbsolutePath(),
115-
testDirOut.getAbsolutePath()))
93+
if (!TestPDFToImage.doTestFile(new File(TESTDIRIN, filename), TESTDIRIN.getAbsolutePath(),
94+
TESTDIROUT.getAbsolutePath()))
11695
{
117-
fail("Rendering failed or is not identical, see in " + testDirOut);
96+
fail("Rendering failed or is not identical, see in " + TESTDIROUT);
11897
}
11998
}
12099
}

pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class TestPDDocument
4646
private static final File TESTRESULTSDIR = new File("target/test-output");
4747

4848
@BeforeAll
49-
public static void setUp() throws Exception
49+
static void setUp() throws Exception
5050
{
5151
TESTRESULTSDIR.mkdirs();
5252
}

tools/src/test/java/org/apache/pdfbox/tools/PDFBoxHeadlessTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ class PDFBoxHeadlessTest
4141
final ByteArrayOutputStream err = new ByteArrayOutputStream();
4242

4343
@BeforeAll
44-
public static void setHeadless()
44+
static void setUp()
4545
{
4646
System.setProperty("java.awt.headless", "true");
47-
}
47+
}
4848

4949
@BeforeEach
50-
public void setUpStreams()
50+
void setUpStreams()
5151
{
5252
out.reset();
5353
err.reset();
@@ -56,7 +56,7 @@ public void setUpStreams()
5656
}
5757

5858
@AfterEach
59-
public void restoreStreams()
59+
void restoreStreams()
6060
{
6161
System.setOut(originalOut);
6262
System.setErr(originalErr);

tools/src/test/java/org/apache/pdfbox/tools/TestExtractText.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ class TestExtractText
5454
static String filename2 = null;
5555

5656
@BeforeAll
57-
public static void setupFilenames()
57+
static void setupFilenames()
5858
{
5959
// the filename representation is platform dependent
6060
filename1 = Paths.get(TESTFILE1).toString();
6161
filename2 = Paths.get(TESTFILE2).toString();
6262
}
6363

6464
@BeforeEach
65-
public void setUpStreams()
65+
void setUpStreams()
6666
{
6767
out.reset();
6868
try

0 commit comments

Comments
 (0)