commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ki...@apache.org
Subject [06/13] [text] Use a shared parser instance for tests
Date Mon, 20 Apr 2015 02:59:03 GMT
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/master
Commit: bbba0a327b7ad8873d176254ec2a550757911bda
Parents: 1f6c5da
Author: Benedikt Ritter <britter@apache.org>
Authored: Sun Apr 19 16:30:00 2015 +0200
Committer: Benedikt Ritter <britter@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,


Mime
View raw message