Use final.
This commit is contained in:
parent
de4508c6c9
commit
6bfd380cb1
|
@ -91,10 +91,10 @@ public class CSVParserTest {
|
|||
|
||||
@Test
|
||||
public void testParseWithDelimiterWithQuote() throws IOException {
|
||||
String source = "'a,b,c',xyz";
|
||||
CSVFormat csvFormat = CSVFormat.DEFAULT.withQuote('\'');
|
||||
final String source = "'a,b,c',xyz";
|
||||
final CSVFormat csvFormat = CSVFormat.DEFAULT.withQuote('\'');
|
||||
try (CSVParser csvParser = csvFormat.parse(new StringReader(source))) {
|
||||
CSVRecord csvRecord = csvParser.nextRecord();
|
||||
final CSVRecord csvRecord = csvParser.nextRecord();
|
||||
assertEquals("a,b,c", csvRecord.get(0));
|
||||
assertEquals("xyz", csvRecord.get(1));
|
||||
}
|
||||
|
@ -102,8 +102,8 @@ public class CSVParserTest {
|
|||
|
||||
@Test
|
||||
public void testParseWithDelimiterStringWithQuote() throws IOException {
|
||||
String source = "'a[|]b[|]c'[|]xyz\r\nabc[abc][|]xyz";
|
||||
CSVFormat csvFormat = CSVFormat.DEFAULT.builder().setDelimiter("[|]").setQuote('\'').build();
|
||||
final String source = "'a[|]b[|]c'[|]xyz\r\nabc[abc][|]xyz";
|
||||
final CSVFormat csvFormat = CSVFormat.DEFAULT.builder().setDelimiter("[|]").setQuote('\'').build();
|
||||
try (CSVParser csvParser = csvFormat.parse(new StringReader(source))) {
|
||||
CSVRecord csvRecord = csvParser.nextRecord();
|
||||
assertEquals("a[|]b[|]c", csvRecord.get(0));
|
||||
|
@ -116,10 +116,10 @@ public class CSVParserTest {
|
|||
|
||||
@Test
|
||||
public void testParseWithDelimiterWithEscape() throws IOException {
|
||||
String source = "a!,b!,c,xyz";
|
||||
CSVFormat csvFormat = CSVFormat.DEFAULT.withEscape('!');
|
||||
final String source = "a!,b!,c,xyz";
|
||||
final CSVFormat csvFormat = CSVFormat.DEFAULT.withEscape('!');
|
||||
try (CSVParser csvParser = csvFormat.parse(new StringReader(source))) {
|
||||
CSVRecord csvRecord = csvParser.nextRecord();
|
||||
final CSVRecord csvRecord = csvParser.nextRecord();
|
||||
assertEquals("a,b,c", csvRecord.get(0));
|
||||
assertEquals("xyz", csvRecord.get(1));
|
||||
}
|
||||
|
@ -127,8 +127,8 @@ public class CSVParserTest {
|
|||
|
||||
@Test
|
||||
public void testParseWithDelimiterStringWithEscape() throws IOException {
|
||||
String source = "a![!|!]b![|]c[|]xyz\r\nabc[abc][|]xyz";
|
||||
CSVFormat csvFormat = CSVFormat.DEFAULT.builder().setDelimiter("[|]").setEscape('!').build();
|
||||
final String source = "a![!|!]b![|]c[|]xyz\r\nabc[abc][|]xyz";
|
||||
final CSVFormat csvFormat = CSVFormat.DEFAULT.builder().setDelimiter("[|]").setEscape('!').build();
|
||||
try (CSVParser csvParser = csvFormat.parse(new StringReader(source))) {
|
||||
CSVRecord csvRecord = csvParser.nextRecord();
|
||||
assertEquals("a[|]b![|]c", csvRecord.get(0));
|
||||
|
@ -141,10 +141,10 @@ public class CSVParserTest {
|
|||
|
||||
@Test
|
||||
public void testParseWithQuoteWithEscape() throws IOException {
|
||||
String source = "'a?,b?,c?d',xyz";
|
||||
CSVFormat csvFormat = CSVFormat.DEFAULT.withQuote('\'').withEscape('?');
|
||||
final String source = "'a?,b?,c?d',xyz";
|
||||
final CSVFormat csvFormat = CSVFormat.DEFAULT.withQuote('\'').withEscape('?');
|
||||
try (CSVParser csvParser = csvFormat.parse(new StringReader(source))) {
|
||||
CSVRecord csvRecord = csvParser.nextRecord();
|
||||
final CSVRecord csvRecord = csvParser.nextRecord();
|
||||
assertEquals("a,b,c?d", csvRecord.get(0));
|
||||
assertEquals("xyz", csvRecord.get(1));
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public class CSVParserTest {
|
|||
|
||||
@Test
|
||||
public void testParseWithQuoteThrowsException() {
|
||||
CSVFormat csvFormat = CSVFormat.DEFAULT.withQuote('\'');
|
||||
final CSVFormat csvFormat = CSVFormat.DEFAULT.withQuote('\'');
|
||||
assertThrows(IOException.class, () -> csvFormat.parse(new StringReader("'a,b,c','")).nextRecord());
|
||||
assertThrows(IOException.class, () -> csvFormat.parse(new StringReader("'a,b,c'abc,xyz")).nextRecord());
|
||||
assertThrows(IOException.class, () -> csvFormat.parse(new StringReader("'abc'a,b,c',xyz")).nextRecord());
|
||||
|
@ -160,13 +160,13 @@ public class CSVParserTest {
|
|||
|
||||
@Test
|
||||
public void testNotValueCSV() throws IOException {
|
||||
String source = "#";
|
||||
CSVFormat csvFormat = CSVFormat.DEFAULT.withCommentMarker('#');
|
||||
CSVParser csvParser = csvFormat.parse(new StringReader(source));
|
||||
CSVRecord csvRecord = csvParser.nextRecord();
|
||||
final String source = "#";
|
||||
final CSVFormat csvFormat = CSVFormat.DEFAULT.withCommentMarker('#');
|
||||
final CSVParser csvParser = csvFormat.parse(new StringReader(source));
|
||||
final CSVRecord csvRecord = csvParser.nextRecord();
|
||||
assertNull(csvRecord);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBackslashEscaping() throws IOException {
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public class ExtendedBufferedReaderTest {
|
|||
|
||||
@Test
|
||||
public void testReadingInDifferentBuffer() throws Exception {
|
||||
char[] tmp1 = new char[2], tmp2 = new char[4];
|
||||
final char[] tmp1 = new char[2], tmp2 = new char[4];
|
||||
try (ExtendedBufferedReader reader = createBufferedReader("1\r\n2\r\n")) {
|
||||
reader.read(tmp1, 0, 2);
|
||||
reader.read(tmp2, 2, 2);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class JiraCsv206Test {
|
|||
final CSVFormat csvFormat = CSVFormat.DEFAULT.builder().setDelimiter("[|]").build();
|
||||
CSVRecord record = null;
|
||||
try (final CSVParser csvParser = new CSVParser(reader, csvFormat)) {
|
||||
Iterator<CSVRecord> iterator = csvParser.iterator();
|
||||
final Iterator<CSVRecord> iterator = csvParser.iterator();
|
||||
record = iterator.next();
|
||||
assertEquals("FirstName", record.get(0));
|
||||
assertEquals("LastName", record.get(1));
|
||||
|
|
Loading…
Reference in New Issue