Author: tilman
Date: Sat Apr 5 18:32:22 2025
New Revision: 1924820
URL: http://svn.apache.org/viewvc?rev=1924820&view=rev
Log:
PDFBOX-5660: Sonar fix
Modified:
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/ContentStreamWriterTest.java
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorBavaria.java
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/metadata/TestSynchronizedMetadataValidation.java
pdfbox/branches/3.0/tools/src/test/java/org/apache/pdfbox/tools/PDFBoxHeadlessTest.java
pdfbox/branches/3.0/tools/src/test/java/org/apache/pdfbox/tools/TestExtractText.java
Modified:
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/ContentStreamWriterTest.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/ContentStreamWriterTest.java?rev=1924820&r1=1924819&r2=1924820&view=diff
==============================================================================
---
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/ContentStreamWriterTest.java
(original)
+++
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/ContentStreamWriterTest.java
Sat Apr 5 18:32:22 2025
@@ -33,10 +33,7 @@ import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.common.PDStream;
import org.apache.pdfbox.rendering.PDFRenderer;
import org.apache.pdfbox.rendering.TestPDFToImage;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
@@ -48,39 +45,21 @@ import org.junit.jupiter.api.parallel.Ex
@Execution(ExecutionMode.SAME_THREAD)
class ContentStreamWriterTest
{
- private final File testDirIn = new
File("target/test-output/contentstream/in");
- private final File testDirOut = new
File("target/test-output/contentstream/out");
-
- ContentStreamWriterTest()
- {
- testDirIn.mkdirs();
- testDirOut.mkdirs();
- }
-
+ private static final File TESTDIRIN = new
File("target/test-output/contentstream/in");
+ private static final File TESTDIROUT = new
File("target/test-output/contentstream/out");
+
@BeforeAll
- public static void setUpClass()
+ static void setUp()
{
+ TESTDIRIN.mkdirs();
+ TESTDIROUT.mkdirs();
+
// PDFBOX-5425: try to avoid "java.awt.color.CMMException: Unknown
profile ID"
ColorSpace csRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
csRGB.toRGB(new float[] { 0, 0, 0 });
ColorSpace csXYZ = ColorSpace.getInstance(ColorSpace.CS_CIEXYZ);
csXYZ.toRGB(new float[] { 0, 0, 0 });
}
-
- @AfterAll
- public static void tearDownClass()
- {
- }
-
- @BeforeEach
- void setUp()
- {
- }
-
- @AfterEach
- public void tearDown()
- {
- }
/**
* Test parse content stream, write back tokens and compare rendering.
@@ -98,7 +77,7 @@ class ContentStreamWriterTest
for (int i = 0; i < doc.getNumberOfPages(); ++i)
{
BufferedImage bim1 = r.renderImageWithDPI(i, 96);
- ImageIO.write(bim1, "png", new File(testDirIn, filename + "-"
+ (i + 1) + ".png"));
+ ImageIO.write(bim1, "png", new File(TESTDIRIN, filename + "-"
+ (i + 1) + ".png"));
PDPage page = doc.getPage(i);
PDStream newContent = new PDStream(doc);
try (OutputStream os =
newContent.createOutputStream(COSName.FLATE_DECODE))
@@ -109,12 +88,12 @@ class ContentStreamWriterTest
}
page.setContents(newContent);
}
- doc.save(new File(testDirIn, filename));
+ doc.save(new File(TESTDIRIN, filename));
}
- if (!TestPDFToImage.doTestFile(new File(testDirIn, filename),
testDirIn.getAbsolutePath(),
- testDirOut.getAbsolutePath()))
+ if (!TestPDFToImage.doTestFile(new File(TESTDIRIN, filename),
TESTDIRIN.getAbsolutePath(),
+ TESTDIROUT.getAbsolutePath()))
{
- fail("Rendering failed or is not identical, see in " + testDirOut);
+ fail("Rendering failed or is not identical, see in " + TESTDIROUT);
}
}
}
Modified:
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorBavaria.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorBavaria.java?rev=1924820&r1=1924819&r2=1924820&view=diff
==============================================================================
---
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorBavaria.java
(original)
+++
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorBavaria.java
Sat Apr 5 18:32:22 2025
@@ -125,7 +125,7 @@ class TestIsartorBavaria
}
@BeforeAll
- public static void beforeClass() throws Exception
+ static void beforeClass() throws Exception
{
String irp = System.getProperty("isartor.results.path");
if (irp != null)
@@ -148,7 +148,7 @@ class TestIsartorBavaria
}
@AfterAll
- public static void afterClass() throws Exception
+ static void afterClass() throws Exception
{
if (isartorResultFile != null)
{
@@ -157,7 +157,7 @@ class TestIsartorBavaria
}
@ParameterizedTest
- @MethodSource("initializeParameters")
+ @MethodSource("initializeParameters")
void validate(File file, Set<String> expectedErrorSet) throws Exception
{
ValidationResult result = PreflightParser.validate(file);
Modified:
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java?rev=1924820&r1=1924819&r2=1924820&view=diff
==============================================================================
---
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java
(original)
+++
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java
Sat Apr 5 18:32:22 2025
@@ -90,7 +90,7 @@ class TestValidFiles
}
@BeforeAll
- public static void beforeClass() throws Exception
+ static void beforeClass() throws Exception
{
String irp = System.getProperty(RESULTS_FILE);
if (irp == null)
@@ -106,13 +106,13 @@ class TestValidFiles
}
@AfterAll
- public static void afterClass() throws Exception
+ static void afterClass() throws Exception
{
IOUtils.closeQuietly(isartorResultFile);
}
@ParameterizedTest
- @MethodSource("initializeParameters")
+ @MethodSource("initializeParameters")
void validate(File path) throws Exception
{
logger = LogFactory.getLog(path != null ? path.getName() : "dummy");
Modified:
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/metadata/TestSynchronizedMetadataValidation.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/metadata/TestSynchronizedMetadataValidation.java?rev=1924820&r1=1924819&r2=1924820&view=diff
==============================================================================
---
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/metadata/TestSynchronizedMetadataValidation.java
(original)
+++
pdfbox/branches/3.0/preflight/src/test/java/org/apache/pdfbox/preflight/metadata/TestSynchronizedMetadataValidation.java
Sat Apr 5 18:32:22 2025
@@ -64,13 +64,13 @@ class TestSynchronizedMetadataValidation
protected List<ValidationError> ve;
@BeforeAll
- public static void initSynchronizedMetadataValidation()
+ static void initSynchronizedMetadataValidation()
{
sync = new SynchronizedMetaDataValidation();
}
@BeforeEach
- public void initNewDocumentInformation() throws Exception
+ void initNewDocumentInformation() throws Exception
{
doc = new PDDocument();
dico = doc.getDocumentInformation();
Modified:
pdfbox/branches/3.0/tools/src/test/java/org/apache/pdfbox/tools/PDFBoxHeadlessTest.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/3.0/tools/src/test/java/org/apache/pdfbox/tools/PDFBoxHeadlessTest.java?rev=1924820&r1=1924819&r2=1924820&view=diff
==============================================================================
---
pdfbox/branches/3.0/tools/src/test/java/org/apache/pdfbox/tools/PDFBoxHeadlessTest.java
(original)
+++
pdfbox/branches/3.0/tools/src/test/java/org/apache/pdfbox/tools/PDFBoxHeadlessTest.java
Sat Apr 5 18:32:22 2025
@@ -41,13 +41,13 @@ class PDFBoxHeadlessTest
final ByteArrayOutputStream err = new ByteArrayOutputStream();
@BeforeAll
- public static void setHeadless()
+ static void setHeadless()
{
System.setProperty("java.awt.headless", "true");
- }
+ }
@BeforeEach
- public void setUpStreams()
+ void setUpStreams()
{
out.reset();
err.reset();
@@ -56,7 +56,7 @@ class PDFBoxHeadlessTest
}
@AfterEach
- public void restoreStreams()
+ void restoreStreams()
{
System.setOut(originalOut);
System.setErr(originalErr);
Modified:
pdfbox/branches/3.0/tools/src/test/java/org/apache/pdfbox/tools/TestExtractText.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/3.0/tools/src/test/java/org/apache/pdfbox/tools/TestExtractText.java?rev=1924820&r1=1924819&r2=1924820&view=diff
==============================================================================
---
pdfbox/branches/3.0/tools/src/test/java/org/apache/pdfbox/tools/TestExtractText.java
(original)
+++
pdfbox/branches/3.0/tools/src/test/java/org/apache/pdfbox/tools/TestExtractText.java
Sat Apr 5 18:32:22 2025
@@ -54,7 +54,7 @@ class TestExtractText
static String filename2 = null;
@BeforeAll
- public static void setupFilenames()
+ static void setupFilenames()
{
// the filename representation is platform dependent
filename1 = Paths.get(TESTFILE1).toString();
@@ -62,7 +62,7 @@ class TestExtractText
}
@BeforeEach
- public void setUpStreams()
+ void setUpStreams()
{
out.reset();
try
@@ -78,7 +78,7 @@ class TestExtractText
}
@AfterEach
- public void restoreStreams()
+ void restoreStreams()
{
System.setOut(originalOut);
if (printStream != null)