You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2023/03/26 07:46:39 UTC
svn commit: r1908726 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/BidiTest.java
Author: tilman
Date: Sun Mar 26 07:46:39 2023
New Revision: 1908726
URL: http://svn.apache.org/viewvc?rev=1908726&view=rev
Log:
PDFBOX-4892: simplify code; follow code conventions
Modified:
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/BidiTest.java
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/BidiTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/BidiTest.java?rev=1908726&r1=1908725&r2=1908726&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/BidiTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/text/BidiTest.java Sun Mar 26 07:46:39 2023
@@ -28,6 +28,7 @@ import java.io.LineNumberReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
+import java.nio.file.Files;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -46,10 +47,10 @@ class BidiTest
/**
* Logger instance.
*/
- private static final Log log = LogFactory.getLog(BidiTest.class);
+ private static final Log LOG = LogFactory.getLog(BidiTest.class);
private static final File IN_DIR = new File("src/test/resources/org/apache/pdfbox/text/");
- private static final File outDir = new File("target/test-output");
+ private static final File OUT_DIR = new File("target/test-output");
private static final String NAME_OF_PDF = "BidiSample.pdf";
private static final String ENCODING = "UTF-8";
@@ -60,11 +61,7 @@ class BidiTest
@BeforeEach
public void setUp() throws IOException
{
- if (!outDir.exists() && !outDir.mkdirs())
- {
- throw (new IOException("Error creating " + outDir.getAbsolutePath() + " directory"));
- }
-
+ Files.createDirectories(OUT_DIR.toPath());
document = Loader.loadPDF(new File(IN_DIR, NAME_OF_PDF));
stripper = new PDFTextStripper();
stripper.setLineSeparator("\n");
@@ -74,14 +71,14 @@ class BidiTest
void testSorted() throws IOException
{
File testFile = new File(IN_DIR, NAME_OF_PDF);
- doTestFile(testFile, outDir, false, true);
+ doTestFile(testFile, OUT_DIR, false, true);
}
@Test
void testNotSorted() throws IOException
{
File testFile = new File(IN_DIR, NAME_OF_PDF);
- doTestFile(testFile, outDir, false, false);
+ doTestFile(testFile, OUT_DIR, false, false);
}
@AfterEach
@@ -104,11 +101,11 @@ class BidiTest
{
if(bSort)
{
- log.info("Preparing to parse " + inFile.getName() + " for sorted test");
+ LOG.info("Preparing to parse " + inFile.getName() + " for sorted test");
}
else
{
- log.info("Preparing to parse " + inFile.getName() + " for standard test");
+ LOG.info("Preparing to parse " + inFile.getName() + " for standard test");
}
File outFile;
@@ -137,8 +134,8 @@ class BidiTest
if (bLogResult)
{
- log.info("Text for " + inFile.getName() + ":");
- log.info(stripper.getText(document));
+ LOG.info("Text for " + inFile.getName() + ":");
+ LOG.info(stripper.getText(document));
}
if (!expectedFile.exists())
@@ -215,7 +212,7 @@ class BidiTest
if( expectedArray[expectedIndex] != actualArray[actualIndex] )
{
equals = false;
- log.warn("Lines differ at index"
+ LOG.warn("Lines differ at index"
+ " expected:" + expectedIndex + "-" + (int)expectedArray[expectedIndex]
+ " actual:" + actualIndex + "-" + (int)actualArray[actualIndex] );
break;
@@ -230,12 +227,12 @@ class BidiTest
if( expectedIndex != expectedArray.length )
{
equals = false;
- log.warn("Expected line is longer at:" + expectedIndex );
+ LOG.warn("Expected line is longer at:" + expectedIndex );
}
if( actualIndex != actualArray.length )
{
equals = false;
- log.warn("Actual line is longer at:" + actualIndex );
+ LOG.warn("Actual line is longer at:" + actualIndex );
}
}
}