You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2015/04/19 17:14:55 UTC
[06/12] [text] Use a shared parser instance for tests
Use a shared parser instance for tests
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/bbba0a32
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/bbba0a32
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/bbba0a32
Branch: refs/heads/SANDBOX-498
Commit: bbba0a327b7ad8873d176254ec2a550757911bda
Parents: 1f6c5da
Author: Benedikt Ritter <br...@apache.org>
Authored: Sun Apr 19 16:30:00 2015 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Sun Apr 19 16:30:00 2015 +0200
----------------------------------------------------------------------
.../commons/text/names/HumanNameParserTest.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/bbba0a32/src/test/java/org/apache/commons/text/names/HumanNameParserTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/names/HumanNameParserTest.java b/src/test/java/org/apache/commons/text/names/HumanNameParserTest.java
index d059ed4..314a949 100644
--- a/src/test/java/org/apache/commons/text/names/HumanNameParserTest.java
+++ b/src/test/java/org/apache/commons/text/names/HumanNameParserTest.java
@@ -33,32 +33,33 @@ import org.junit.Test;
*/
public class HumanNameParserTest {
- private CSVParser parser;
+ private CSVParser inputParser;
+ private HumanNameParser nameParser;
@Before
public void setUp() throws Exception {
- parser = CSVParser.parse(
+ inputParser = CSVParser.parse(
HumanNameParserTest.class.getResource("testNames.txt"),
Charset.forName("UTF-8"),
CSVFormat.DEFAULT.withDelimiter('|').withHeader());
+ nameParser = new HumanNameParser();
}
@After
public void tearDown() throws Exception {
- if (parser != null) {
- parser.close();
+ if (inputParser != null) {
+ inputParser.close();
}
}
@Test(expected = NullPointerException.class)
public void shouldThrowNullPointerException_WhenNullIsParsed() throws Exception {
- HumanNameParser parser = new HumanNameParser();
- parser.parse(null);
+ nameParser.parse(null);
}
@Test
public void testInputs() {
- for (CSVRecord record : parser) {
+ for (CSVRecord record : inputParser) {
validateRecord(record);
}
}
@@ -70,8 +71,7 @@ public class HumanNameParserTest {
* @param record a CSVRecord representing one record in the input file.
*/
private void validateRecord(CSVRecord record) {
- HumanNameParser parser = new HumanNameParser();
- Name result = parser.parse(record.get(Colums.Name));
+ Name result = nameParser.parse(record.get(Colums.Name));
long recordNum = record.getRecordNumber();
assertThat("Wrong LeadingInit in record " + recordNum,