Skip to content

Commit 3362f9c

Browse files
committed
Static imports in the unit tests
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1301084 13f79535-47bb-0310-9956-ffa450edef68
1 parent 186e9f9 commit 3362f9c

5 files changed

Lines changed: 217 additions & 217 deletions

File tree

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

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
import java.io.ObjectInputStream;
2323
import java.io.ObjectOutputStream;
2424

25-
import org.junit.Assert;
2625
import org.junit.Test;
2726

27+
import static org.junit.Assert.*;
28+
2829
public class CSVFormatTest {
2930

3031
@Test
@@ -41,43 +42,43 @@ public void testImmutalibity() {
4142
format.withEmptyLinesIgnored(false);
4243
format.withUnicodeEscapesInterpreted(false);
4344

44-
Assert.assertEquals('!', format.getDelimiter());
45-
Assert.assertEquals('!', format.getEncapsulator());
46-
Assert.assertEquals('!', format.getCommentStart());
47-
Assert.assertEquals('!', format.getEscape());
48-
Assert.assertEquals("\r\n", format.getLineSeparator());
45+
assertEquals('!', format.getDelimiter());
46+
assertEquals('!', format.getEncapsulator());
47+
assertEquals('!', format.getCommentStart());
48+
assertEquals('!', format.getEscape());
49+
assertEquals("\r\n", format.getLineSeparator());
4950

50-
Assert.assertEquals(true, format.isLeadingSpacesIgnored());
51-
Assert.assertEquals(true, format.isTrailingSpacesIgnored());
52-
Assert.assertEquals(true, format.isEmptyLinesIgnored());
53-
Assert.assertEquals(true, format.isUnicodeEscapesInterpreted());
51+
assertEquals(true, format.isLeadingSpacesIgnored());
52+
assertEquals(true, format.isTrailingSpacesIgnored());
53+
assertEquals(true, format.isEmptyLinesIgnored());
54+
assertEquals(true, format.isUnicodeEscapesInterpreted());
5455
}
5556

5657
@Test
5758
public void testMutators() {
5859
CSVFormat format = new CSVFormat('!', '!', '!', '!', true, true, true, true, "\r\n");
5960

60-
Assert.assertEquals('?', format.withDelimiter('?').getDelimiter());
61-
Assert.assertEquals('?', format.withEncapsulator('?').getEncapsulator());
62-
Assert.assertEquals('?', format.withCommentStart('?').getCommentStart());
63-
Assert.assertEquals("?", format.withLineSeparator("?").getLineSeparator());
64-
Assert.assertEquals('?', format.withEscape('?').getEscape());
65-
66-
Assert.assertEquals(false, format.withLeadingSpacesIgnored(false).isLeadingSpacesIgnored());
67-
Assert.assertEquals(false, format.withTrailingSpacesIgnored(false).isTrailingSpacesIgnored());
68-
Assert.assertEquals(false, format.withSurroundingSpacesIgnored(false).isLeadingSpacesIgnored());
69-
Assert.assertEquals(false, format.withSurroundingSpacesIgnored(false).isTrailingSpacesIgnored());
70-
Assert.assertEquals(false, format.withEmptyLinesIgnored(false).isEmptyLinesIgnored());
71-
Assert.assertEquals(false, format.withUnicodeEscapesInterpreted(false).isUnicodeEscapesInterpreted());
61+
assertEquals('?', format.withDelimiter('?').getDelimiter());
62+
assertEquals('?', format.withEncapsulator('?').getEncapsulator());
63+
assertEquals('?', format.withCommentStart('?').getCommentStart());
64+
assertEquals("?", format.withLineSeparator("?").getLineSeparator());
65+
assertEquals('?', format.withEscape('?').getEscape());
66+
67+
assertEquals(false, format.withLeadingSpacesIgnored(false).isLeadingSpacesIgnored());
68+
assertEquals(false, format.withTrailingSpacesIgnored(false).isTrailingSpacesIgnored());
69+
assertEquals(false, format.withSurroundingSpacesIgnored(false).isLeadingSpacesIgnored());
70+
assertEquals(false, format.withSurroundingSpacesIgnored(false).isTrailingSpacesIgnored());
71+
assertEquals(false, format.withEmptyLinesIgnored(false).isEmptyLinesIgnored());
72+
assertEquals(false, format.withUnicodeEscapesInterpreted(false).isUnicodeEscapesInterpreted());
7273
}
7374

7475
@Test
7576
public void testFormat() {
7677
CSVFormat format = CSVFormat.DEFAULT;
7778

78-
Assert.assertEquals("", format.format());
79-
Assert.assertEquals("a,b,c", format.format("a", "b", "c"));
80-
Assert.assertEquals("\"x,y\",z", format.format("x,y", "z"));
79+
assertEquals("", format.format());
80+
assertEquals("a,b,c", format.format("a", "b", "c"));
81+
assertEquals("\"x,y\",z", format.format("x,y", "z"));
8182
}
8283

8384
@Test
@@ -86,49 +87,49 @@ public void testValidation() {
8687

8788
try {
8889
format.withDelimiter('\n');
89-
Assert.fail();
90+
fail();
9091
} catch (IllegalArgumentException e) {
9192
// expected
9293
}
9394

9495
try {
9596
format.withEscape('\r');
96-
Assert.fail();
97+
fail();
9798
} catch (IllegalArgumentException e) {
9899
// expected
99100
}
100101

101102
try {
102103
format.withEncapsulator('\n');
103-
Assert.fail();
104+
fail();
104105
} catch (IllegalArgumentException e) {
105106
// expected
106107
}
107108

108109
try {
109110
format.withCommentStart('\r');
110-
Assert.fail();
111+
fail();
111112
} catch (IllegalArgumentException e) {
112113
// expected
113114
}
114115

115116
try {
116117
format.withDelimiter('!').withEscape('!').validate();
117-
Assert.fail();
118+
fail();
118119
} catch (IllegalArgumentException e) {
119120
// expected
120121
}
121122

122123
try {
123124
format.withDelimiter('!').withCommentStart('!').validate();
124-
Assert.fail();
125+
fail();
125126
} catch (IllegalArgumentException e) {
126127
// expected
127128
}
128129

129130
try {
130131
format.withEncapsulator('!').withCommentStart('!').validate();
131-
Assert.fail();
132+
fail();
132133
} catch (IllegalArgumentException e) {
133134
// expected
134135
}
@@ -137,7 +138,7 @@ public void testValidation() {
137138

138139
try {
139140
format.withEscape('!').withCommentStart('!').validate();
140-
Assert.fail();
141+
fail();
141142
} catch (IllegalArgumentException e) {
142143
// expected
143144
}
@@ -147,7 +148,7 @@ public void testValidation() {
147148

148149
try {
149150
format.withEncapsulator('!').withDelimiter('!').validate();
150-
Assert.fail();
151+
fail();
151152
} catch (IllegalArgumentException e) {
152153
// expected
153154
}
@@ -165,15 +166,15 @@ public void testSerialization() throws Exception {
165166
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(out.toByteArray()));
166167
CSVFormat format = (CSVFormat) in.readObject();
167168

168-
Assert.assertNotNull(format);
169-
Assert.assertEquals("delimiter", CSVFormat.DEFAULT.getDelimiter(), format.getDelimiter());
170-
Assert.assertEquals("encapsulator", CSVFormat.DEFAULT.getEncapsulator(), format.getEncapsulator());
171-
Assert.assertEquals("comment start", CSVFormat.DEFAULT.getCommentStart(), format.getCommentStart());
172-
Assert.assertEquals("line separator", CSVFormat.DEFAULT.getLineSeparator(), format.getLineSeparator());
173-
Assert.assertEquals("escape", CSVFormat.DEFAULT.getEscape(), format.getEscape());
174-
Assert.assertEquals("unicode escape", CSVFormat.DEFAULT.isUnicodeEscapesInterpreted(), format.isUnicodeEscapesInterpreted());
175-
Assert.assertEquals("trim left", CSVFormat.DEFAULT.isLeadingSpacesIgnored(), format.isLeadingSpacesIgnored());
176-
Assert.assertEquals("trim right", CSVFormat.DEFAULT.isTrailingSpacesIgnored(), format.isTrailingSpacesIgnored());
177-
Assert.assertEquals("empty lines", CSVFormat.DEFAULT.isEmptyLinesIgnored(), format.isEmptyLinesIgnored());
169+
assertNotNull(format);
170+
assertEquals("delimiter", CSVFormat.DEFAULT.getDelimiter(), format.getDelimiter());
171+
assertEquals("encapsulator", CSVFormat.DEFAULT.getEncapsulator(), format.getEncapsulator());
172+
assertEquals("comment start", CSVFormat.DEFAULT.getCommentStart(), format.getCommentStart());
173+
assertEquals("line separator", CSVFormat.DEFAULT.getLineSeparator(), format.getLineSeparator());
174+
assertEquals("escape", CSVFormat.DEFAULT.getEscape(), format.getEscape());
175+
assertEquals("unicode escape", CSVFormat.DEFAULT.isUnicodeEscapesInterpreted(), format.isUnicodeEscapesInterpreted());
176+
assertEquals("trim left", CSVFormat.DEFAULT.isLeadingSpacesIgnored(), format.isLeadingSpacesIgnored());
177+
assertEquals("trim right", CSVFormat.DEFAULT.isTrailingSpacesIgnored(), format.isTrailingSpacesIgnored());
178+
assertEquals("empty lines", CSVFormat.DEFAULT.isEmptyLinesIgnored(), format.isEmptyLinesIgnored());
178179
}
179180
}

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,24 @@
1717

1818
package org.apache.commons.csv;
1919

20-
import static org.apache.commons.csv.CSVLexer.Token.Type.EOF;
21-
import static org.apache.commons.csv.CSVLexer.Token.Type.EORECORD;
22-
import static org.apache.commons.csv.CSVLexer.Token.Type.TOKEN;
23-
2420
import java.io.IOException;
2521
import java.io.StringReader;
2622

2723
import org.apache.commons.csv.CSVLexer.Token;
28-
import org.junit.Assert;
2924
import org.junit.Test;
3025

26+
import static org.apache.commons.csv.CSVLexer.Token.Type.*;
27+
import static org.junit.Assert.*;
28+
3129
public class CSVLexerTest {
3230

3331
private CSVLexer getLexer(String input, CSVFormat format) {
3432
return new CSVLexer(format, new ExtendedBufferedReader(new StringReader(input)));
3533
}
3634

3735
private void assertTokenEquals(Token.Type expectedType, String expectedContent, Token token) {
38-
Assert.assertEquals("Token type", expectedType, token.type);
39-
Assert.assertEquals("Token content", expectedContent, token.content.toString());
36+
assertEquals("Token type", expectedType, token.type);
37+
assertEquals("Token content", expectedContent, token.content.toString());
4038
}
4139

4240
// Single line (without comment)

0 commit comments

Comments
 (0)