Skip to content

Commit e7a5708

Browse files
committed
Fix compiler warnings
- Rename test methods - Sort methods
1 parent bf987d5 commit e7a5708

File tree

1 file changed

+24
-40
lines changed

1 file changed

+24
-40
lines changed

src/test/java/org/apache/commons/csv/JiraCsv196Test.java

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* under the License.
1818
*/
1919
package org.apache.commons.csv;
20-
import static org.junit.jupiter.api.Assertions.assertEquals;
2120

21+
import static org.junit.jupiter.api.Assertions.assertEquals;
2222

2323
import java.io.IOException;
2424
import java.io.InputStreamReader;
@@ -27,51 +27,35 @@
2727

2828
import org.junit.jupiter.api.Test;
2929

30-
3130
public class JiraCsv196Test {
32-
@Test
33-
public void parseThreeBytes() throws IOException {
34-
final CSVFormat format = CSVFormat.Builder.create()
35-
.setDelimiter(',')
36-
.setQuote('\'')
37-
.get();
38-
final CSVParser parser = new CSVParser.Builder()
39-
.setFormat(format)
40-
.setReader(getTestInput("org/apache/commons/csv/CSV-196/japanese.csv"))
41-
.setCharset(StandardCharsets.UTF_8)
42-
.setEnableByteTracking(true)
43-
.get();
44-
final long[] charByteKey = {0, 89, 242, 395};
45-
int idx = 0;
46-
for (CSVRecord record : parser) {
47-
assertEquals(charByteKey[idx++], record.getBytePosition());
48-
}
49-
parser.close();
50-
}
5131

32+
private Reader getTestInput(String path) {
33+
return new InputStreamReader(ClassLoader.getSystemClassLoader().getResourceAsStream(path));
34+
}
5235

5336
@Test
54-
public void parseFourBytes() throws IOException {
55-
final CSVFormat format = CSVFormat.Builder.create()
56-
.setDelimiter(',')
57-
.setQuote('\'')
58-
.get();
59-
final CSVParser parser = new CSVParser.Builder()
60-
.setFormat(format)
61-
.setReader(getTestInput("org/apache/commons/csv/CSV-196/emoji.csv"))
62-
.setCharset(StandardCharsets.UTF_8)
63-
.setEnableByteTracking(true)
64-
.get();
65-
final long[] charByteKey = {0, 84, 701, 1318, 1935};
66-
int idx = 0;
67-
for (CSVRecord record : parser) {
68-
assertEquals(charByteKey[idx++], record.getBytePosition());
37+
public void testParseFourBytes() throws IOException {
38+
final CSVFormat format = CSVFormat.Builder.create().setDelimiter(',').setQuote('\'').get();
39+
try (CSVParser parser = new CSVParser.Builder().setFormat(format).setReader(getTestInput("org/apache/commons/csv/CSV-196/emoji.csv"))
40+
.setCharset(StandardCharsets.UTF_8).setEnableByteTracking(true).get()) {
41+
final long[] charByteKey = { 0, 84, 701, 1318, 1935 };
42+
int idx = 0;
43+
for (CSVRecord record : parser) {
44+
assertEquals(charByteKey[idx++], record.getBytePosition());
45+
}
6946
}
70-
parser.close();
7147
}
7248

73-
private Reader getTestInput(String path) {
74-
return new InputStreamReader(
75-
ClassLoader.getSystemClassLoader().getResourceAsStream(path));
49+
@Test
50+
public void testParseThreeBytes() throws IOException {
51+
final CSVFormat format = CSVFormat.Builder.create().setDelimiter(',').setQuote('\'').get();
52+
try (CSVParser parser = new CSVParser.Builder().setFormat(format).setReader(getTestInput("org/apache/commons/csv/CSV-196/japanese.csv"))
53+
.setCharset(StandardCharsets.UTF_8).setEnableByteTracking(true).get()) {
54+
final long[] charByteKey = { 0, 89, 242, 395 };
55+
int idx = 0;
56+
for (CSVRecord record : parser) {
57+
assertEquals(charByteKey[idx++], record.getBytePosition());
58+
}
59+
}
7660
}
7761
}

0 commit comments

Comments
 (0)