This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git
The following commit(s) were added to refs/heads/master by this push:
new e7a5708a Fix compiler warnings
e7a5708a is described below
commit e7a5708a1d8ab216ef9e80b151e7a6683885e10d
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Jan 2 15:09:08 2025 -0500
Fix compiler warnings
- Rename test methods
- Sort methods
---
.../org/apache/commons/csv/JiraCsv196Test.java | 64 ++++++++--------------
1 file changed, 24 insertions(+), 40 deletions(-)
diff --git a/src/test/java/org/apache/commons/csv/JiraCsv196Test.java
b/src/test/java/org/apache/commons/csv/JiraCsv196Test.java
index ab7af819..5f429205 100644
--- a/src/test/java/org/apache/commons/csv/JiraCsv196Test.java
+++ b/src/test/java/org/apache/commons/csv/JiraCsv196Test.java
@@ -17,8 +17,8 @@
* under the License.
*/
package org.apache.commons.csv;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -27,51 +27,35 @@ import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.Test;
-
public class JiraCsv196Test {
- @Test
- public void parseThreeBytes() throws IOException {
- final CSVFormat format = CSVFormat.Builder.create()
- .setDelimiter(',')
- .setQuote('\'')
- .get();
- final CSVParser parser = new CSVParser.Builder()
- .setFormat(format)
-
.setReader(getTestInput("org/apache/commons/csv/CSV-196/japanese.csv"))
- .setCharset(StandardCharsets.UTF_8)
- .setEnableByteTracking(true)
- .get();
- final long[] charByteKey = {0, 89, 242, 395};
- int idx = 0;
- for (CSVRecord record : parser) {
- assertEquals(charByteKey[idx++], record.getBytePosition());
- }
- parser.close();
- }
+ private Reader getTestInput(String path) {
+ return new
InputStreamReader(ClassLoader.getSystemClassLoader().getResourceAsStream(path));
+ }
@Test
- public void parseFourBytes() throws IOException {
- final CSVFormat format = CSVFormat.Builder.create()
- .setDelimiter(',')
- .setQuote('\'')
- .get();
- final CSVParser parser = new CSVParser.Builder()
- .setFormat(format)
-
.setReader(getTestInput("org/apache/commons/csv/CSV-196/emoji.csv"))
- .setCharset(StandardCharsets.UTF_8)
- .setEnableByteTracking(true)
- .get();
- final long[] charByteKey = {0, 84, 701, 1318, 1935};
- int idx = 0;
- for (CSVRecord record : parser) {
- assertEquals(charByteKey[idx++], record.getBytePosition());
+ public void testParseFourBytes() throws IOException {
+ final CSVFormat format =
CSVFormat.Builder.create().setDelimiter(',').setQuote('\'').get();
+ try (CSVParser parser = new
CSVParser.Builder().setFormat(format).setReader(getTestInput("org/apache/commons/csv/CSV-196/emoji.csv"))
+
.setCharset(StandardCharsets.UTF_8).setEnableByteTracking(true).get()) {
+ final long[] charByteKey = { 0, 84, 701, 1318, 1935 };
+ int idx = 0;
+ for (CSVRecord record : parser) {
+ assertEquals(charByteKey[idx++], record.getBytePosition());
+ }
}
- parser.close();
}
- private Reader getTestInput(String path) {
- return new InputStreamReader(
- ClassLoader.getSystemClassLoader().getResourceAsStream(path));
+ @Test
+ public void testParseThreeBytes() throws IOException {
+ final CSVFormat format =
CSVFormat.Builder.create().setDelimiter(',').setQuote('\'').get();
+ try (CSVParser parser = new
CSVParser.Builder().setFormat(format).setReader(getTestInput("org/apache/commons/csv/CSV-196/japanese.csv"))
+
.setCharset(StandardCharsets.UTF_8).setEnableByteTracking(true).get()) {
+ final long[] charByteKey = { 0, 89, 242, 395 };
+ int idx = 0;
+ for (CSVRecord record : parser) {
+ assertEquals(charByteKey[idx++], record.getBytePosition());
+ }
+ }
}
}