Repository: commons-text
Updated Branches:
  refs/heads/master e3bb7f75a -> 6d69377a2


TEXT-31: remove package main/test o.a.c.t.names


Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/53279c12
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/53279c12
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/53279c12

Branch: refs/heads/master
Commit: 53279c1237a8b503fbd39ea279e2ae216779d2ed
Parents: e3bb7f7
Author: Rob Tompkins <chtom...@gmail.com>
Authored: Wed Nov 30 15:19:39 2016 -0800
Committer: Rob Tompkins <chtom...@gmail.com>
Committed: Wed Nov 30 15:19:39 2016 -0800

----------------------------------------------------------------------
 .../commons/text/names/HumanNameParser.java     | 192 -------------------
 .../org/apache/commons/text/names/Name.java     | 158 ---------------
 .../commons/text/names/NameParseException.java  |  77 --------
 .../apache/commons/text/names/NameString.java   | 122 ------------
 .../apache/commons/text/names/package-info.java |  25 ---
 .../commons/text/names/HumanNameParserTest.java | 103 ----------
 .../commons/text/names/NameStringTest.java      |  71 -------
 7 files changed, 748 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/53279c12/src/main/java/org/apache/commons/text/names/HumanNameParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/names/HumanNameParser.java 
b/src/main/java/org/apache/commons/text/names/HumanNameParser.java
deleted file mode 100644
index 5f4fa20..0000000
--- a/src/main/java/org/apache/commons/text/names/HumanNameParser.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.text.names;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
-
-import org.apache.commons.lang3.StringUtils;
-
-/**
- * A parser capable of parsing name parts out of a single string.
- *
- * <h3>Parsing examples</h3>
- *
- * <p>The code works by basically applying several Regexes in a certain order
- * and removing (chopping) tokens off the original string. The parser creates
- * a {@link Name} object representing the parse result. Note that passing null
- * to the {@link #parse(String)} method will result in an exception.</p>
- *
- * <table summary="Examples">
- *  <tr>
- *   <th>input</th>
- *   <th>Leading initial</th>
- *   <th>First name</th>
- *   <th>Nick name</th>
- *   <th>Middle name</th>
- *   <th>Last Name</th>
- *   <th>Suffix</th>
- *  </tr>
- *  <tr>
- *   <td>J. Walter Weatherman</td>
- *   <td>J.</td>
- *   <td>Walter</td>
- *   <td></td>
- *   <td></td>
- *   <td>Weatherman</td>
- *   <td></td>
- *  </tr>
- *  <tr>
- *   <td>de la Cruz, Ana M.</td>
- *   <td></td>
- *   <td>Ana</td>
- *   <td></td>
- *   <td>M.</td>
- *   <td>de la Cruz</td>
- *   <td></td>
- *  </tr>
- *  <tr>
- *   <td>James C. ('Jimmy') O'Dell, Jr.</td>
- *   <td></td>
- *   <td>James</td>
- *   <td>Jimmy</td>
- *   <td>C.</td>
- *   <td>O'Dell</td>
- *   <td>Jr.</td>
- *  </tr>
- * </table>
- *
- * <h3>Sample usage</h3>
- *
- * <p>HumanNameParser instances are immutable and can be reused for parsing 
multiple names:</p>
- *
- * <pre>
- * HumanNameParser parser = new HumanNameParser();
- * Name parsedName = parser.parse("S�rgio Vieira de Mello")
- * String firstName = parsedName.getFirstName();
- * String nickname = parsedName.getNickName();
- * // ...
- *
- * Name nextName = parser.parse("James C. ('Jimmy') O'Dell, Jr.")
- * String firstName = nextName.getFirstName();
- * String nickname = nextName.getNickName();
- * </pre>
- *
- * <h3>Further notes</h3>
- *
- * <p>The original code was written in <a 
href="http://jasonpriem.com/human-name-parse";>PHP</a>
- * and ported to <a 
href="http://tupilabs.github.io/HumanNameParser.java/";>Java</a>. This
- * implementation is based on the Java implementation, with additions
- * suggested in <a 
href="https://issues.apache.org/jira/browse/TEXT-15";>TEXT-15</a>
- * and <a href="https://issues.apache.org/jira/browse/TEXT-16";>TEXT-16</a>.</p>
- *
- * <p>This class is immutable.</p>
- */
-public final class HumanNameParser {
-
-    /**
-     * List of suffixes. Not exposed to users or children classes.
-     */
-    private final List<String> suffixes;
-    /**
-     * List of salutations. Not exposed to users or children classes.
-     */
-    private final List<String> salutations;
-    /**
-     * List of prefixes. Not exposed to users or children classes.
-     */
-    private final List<String> prefixes;
-
-    /**
-     * Creates a new parser.
-     */
-    public HumanNameParser() {
-        // TODO make this configurable
-        this.salutations = Arrays.asList(
-                "mr",  "mrs", "ms", "miss", "dr"
-        );
-        this.suffixes = Arrays.asList(
-                "esq", "esquire", "jr",
-                "sr", "2", "ii", "iii", "iv");
-        this.prefixes = Arrays.asList(
-                    "bar", "ben", "bin", "da", "dal",
-                    "de la", "de", "del", "der", "di", "ibn", "la", "le",
-                    "san", "st", "ste", "van", "van der", "van den", "vel",
-                    "von");
-    }
-
-    /**
-     * Parses a name from the given string.
-     *
-     * @param name the name to parse. Must not be null.
-     * @throws NameParseException if the parser fails to retrieve the name 
parts.
-     * @throws NullPointerException if name is null.
-     * @return The name object
-     */
-    public Name parse(final String name) {
-        Objects.requireNonNull(name, "Parameter 'name' must not be null.");
-
-        final NameString nameString = new NameString(name);
-        // TODO compile regexes only once when the parser is created
-        final String suffixes = StringUtils.join(this.suffixes, "\\.*|") + 
"\\.*";
-        final String prefixes = StringUtils.join(this.prefixes, " |") + " ";
-        final String salutations = StringUtils.join(this.salutations, " |");
-
-        // The regex use is a bit tricky.  *Everything* matched by the regex 
will be replaced,
-        // but you can select a particular parenthesized submatch to be 
returned.
-        // Also, note that each regex requres that the preceding ones have 
been run, and matches chopped out.
-        // names that starts or end w/ an apostrophe break this
-        final String nicknamesRegex = "(?i) 
('|\\\"|\\(\\\"*'*)(.+?)('|\\\"|\\\"*'*\\)) ";
-        final String suffixRegex = "(?i),* *((" + suffixes + ")$)";
-        final String lastRegex = "(?i)(?!^)\\b([^ ]+ y |" + prefixes + ")*[^ 
]+$";
-        final String salutationRegex = "^(?i)(("+salutations+")(\\.|\\s))";
-        // note the lookahead, which isn't returned or replaced
-        final String leadingInitRegex = "(?i)(^(.\\.*)(?= \\p{L}{2}))";
-        final String firstRegex = "(?i)^([^ ]+)";
-
-        String salutation = nameString.chopWithRegex(salutationRegex, 1);
-
-        // get nickname, if there is one
-        final String nickname = nameString.chopWithRegex(nicknamesRegex, 2);
-
-        // get suffix, if there is one
-        final String suffix = nameString.chopWithRegex(suffixRegex, 1);
-
-        // flip the before-comma and after-comma parts of the name
-        nameString.flip(",");
-
-        // get the last name
-        final String last = nameString.chopWithRegex(lastRegex, 0);
-
-        // get the first initial, if there is one
-        final String leadingInit = nameString.chopWithRegex(leadingInitRegex, 
1);
-
-        // get the first name
-        final String first = nameString.chopWithRegex(firstRegex, 0);
-        if (StringUtils.isBlank(first)) {
-            throw new NameParseException("Couldn't find a first name in '{" + 
nameString.getWrappedString() + "}'");
-        }
-
-        // if anything's left, that's the middle name
-        String middle = nameString.getWrappedString();
-        
-        return new Name(leadingInit, salutation, first, nickname, middle, 
last, suffix);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/53279c12/src/main/java/org/apache/commons/text/names/Name.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/names/Name.java 
b/src/main/java/org/apache/commons/text/names/Name.java
deleted file mode 100644
index 8b6f267..0000000
--- a/src/main/java/org/apache/commons/text/names/Name.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.text.names;
-
-import java.util.Objects;
-
-/**
- * An object representing the result of parsing a Name.
- *
- * <p>This class is immutable.</p>
- */
-public final class Name {
-
-    /**
-     * Leading initial. e.g. <em>F.</em>, as in <em>Francisco ('Chico') Silva 
Zhao II</em>.
-     */
-    private final String leadingInitial;
-    /**
-     * Salutation. e.g. <em>Dr.</em>, as in <em>Dr. Jekyll</em>, or 
<em>Mr.</em>, as in <em>Mr. Hyde</em/>.
-     */
-    private final String salutation;
-    /**
-     * The first name, e.g. <em>Francisco</em>, as in <em>Francisco ('Chico') 
Silva Zhao II</em>.
-     */
-    private final String firstName;
-    /**
-     * The nickname, e.g. <em>Chico</em>, as in <em>Francisco ('Chico') Silva 
Zhao II</em>.
-     */
-    private final String nickName;
-    /**
-     * The middle name, e.g. <em>Silva</em>, as in <em>Francisco ('Chico') 
Silva Zhao II</em>.
-     */
-    private final String middleName;
-    /**
-     * The last name, e.g. <em>Zhao</em>, as in <em>Francisco ('Chico') Silva 
Zhao II</em>.
-     */
-    private final String lastName;
-    /**
-     * The suffix, e.g. <em>II</em>, as in <em>Francisco ('Chico') Silva Zhao 
II</em>.
-     */
-    private final String suffix;
-
-    /**
-     * Create a Name.
-     *
-     * @param leadingInitial the leading initial
-     * @param salutation the salutation
-     * @param firstName the first name
-     * @param nickName the nickname
-     * @param middleName the middle name
-     * @param lastName the last name
-     * @param suffix a suffix
-     */
-    Name(final String leadingInitial, final String salutation, final String 
firstName, final String nickName, final String middleName, final String 
lastName, final String suffix) {
-        this.leadingInitial = leadingInitial;
-        this.salutation = salutation;
-        this.firstName = firstName;
-        this.nickName = nickName;
-        this.middleName = middleName;
-        this.lastName = lastName;
-        this.suffix = suffix;
-    }
-
-    /**
-     * Gets the leading init part of the name.
-     *
-     * @return the leading init part of the name
-     */
-    public String getLeadingInitial() {
-        return leadingInitial;
-    }
-
-
-    public String getSalutation() {
-        return salutation;
-    }
-
-    /**
-     * Gets the first name.
-     *
-     * @return first name
-     */
-    public String getFirstName() {
-        return firstName;
-    }
-
-    /**
-     * Gets the nickname.
-     *
-     * @return the nickname
-     */
-    public String getNickName() {
-        return nickName;
-    }
-
-    /**
-     * Gets the middle name.
-     *
-     * @return the middle name
-     */
-    public String getMiddleName() {
-        return middleName;
-    }
-
-    /**
-     * Gets the last name.
-     *
-     * @return the last name
-     */
-    public String getLastName() {
-        return lastName;
-    }
-
-    /**
-     * Gets the suffix part of the name.
-     *
-     * @return the name suffix
-     */
-    public String getSuffix() {
-        return suffix;
-    }
-
-    @Override
-    public boolean equals(final Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        final Name name = (Name) o;
-        return Objects.equals(leadingInitial, name.leadingInitial)
-                && Objects.equals(firstName, name.firstName)
-                && Objects.equals(nickName, name.nickName)
-                && Objects.equals(middleName, name.middleName)
-                && Objects.equals(lastName, name.lastName)
-                && Objects.equals(suffix, name.suffix);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(leadingInitial, firstName, nickName, middleName, 
lastName, suffix);
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/53279c12/src/main/java/org/apache/commons/text/names/NameParseException.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/text/names/NameParseException.java 
b/src/main/java/org/apache/commons/text/names/NameParseException.java
deleted file mode 100644
index 90f9fd7..0000000
--- a/src/main/java/org/apache/commons/text/names/NameParseException.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.text.names;
-
-/**
- * Name parse exception.
- */
-public final class NameParseException extends RuntimeException {
-
-    /**
-     * Serial UID.
-     */
-    private static final long serialVersionUID = -2375904385006224156L;
-
-    /**
-     * Constructor.
-     */
-    public NameParseException() {
-        super();
-    }
-
-    /**
-     * Contructor with message.
-     *
-     * @param message message
-     */
-    public NameParseException(final String message) {
-        super(message);
-    }
-
-    /**
-     * Constructor with case.
-     *
-     * @param cause cause
-     */
-    public NameParseException(final Throwable cause) {
-        super(cause);
-    }
-
-    /**
-     * Constructor with message and cause.
-     *
-     * @param message message
-     * @param cause cause
-     */
-    public NameParseException(final String message, final Throwable cause) {
-        super(message, cause);
-    }
-
-    /**
-     * Complete constructor.
-     *
-     * @param message message
-     * @param cause cause
-     * @param enableSuppression flag to enable suppression
-     * @param writableStackTrace a writable stack trace
-     */
-    public NameParseException(final String message, final Throwable cause,
-            final boolean enableSuppression, final boolean writableStackTrace) 
{
-        super(message, cause, enableSuppression, writableStackTrace);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/53279c12/src/main/java/org/apache/commons/text/names/NameString.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/names/NameString.java 
b/src/main/java/org/apache/commons/text/names/NameString.java
deleted file mode 100644
index 822497f..0000000
--- a/src/main/java/org/apache/commons/text/names/NameString.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.text.names;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * A wrapper around a String representing a Name to parse. Contains the logic
- * for handling executing Regexes on the wrapped name string.
- *
- * <p>This class is not thread-safe.</p>
- */
-final class NameString {
-
-    /**
-     * Encapsulated string. Not immutable!
-     */
-    private String str;
-
-    /**
-     * Creates a new Name object.
-     *
-     * @param str encapsulated string.
-     */
-    NameString(final String str) {
-        this.str = str;
-    }
-
-    /**
-     * Gets the wrapped string.
-     *
-     * @return wrapped string
-     */
-    String getWrappedString() {
-        return str;
-    }
-
-    /**
-     * Uses a regex to chop off and return part of the namestring.
-     * There are two parts: first, it returns the matched substring,
-     * and then it removes that substring from the encapsulated
-     * string and normalizes it.
-     *
-     * @param regex matches the part of the namestring to chop off
-     * @param submatchIndex which of the parenthesized submatches to use
-     * @return the part of the namestring that got chopped off
-     */
-    String chopWithRegex(final String regex, final int submatchIndex) {
-        final String chopped = "";
-        Pattern pattern = Pattern.compile(regex);
-        Matcher matcher = pattern.matcher(this.str);
-
-        // workdaround for numReplacements in Java
-        int numReplacements = 0;
-        while (matcher.find()) {
-            numReplacements++;
-        }
-
-        // recreate or the groups are gone
-        pattern = Pattern.compile(regex);
-        matcher = pattern.matcher(this.str);
-        if (matcher.find()) {
-            final boolean subset = matcher.groupCount() > submatchIndex;
-            if (subset) {
-                this.str = this.str.replaceAll(regex, " ");
-                if (numReplacements > 1) {
-                    throw new NameParseException("The regex being used to find 
the name has multiple matches.");
-                }
-                this.norm();
-                return matcher.group(submatchIndex).trim();
-            }
-        }
-        return chopped;
-    }
-
-    /**
-     * Flips the front and back parts of a name with one another.
-     * Front and back are determined by a specified character somewhere in the
-     * middle of the string.
-     *
-     * @param flipAroundChar the character(s) demarcating the two halves you 
want to flip.
-     * @throws NameParseException if a regex fails or a condition is not 
expected
-     */
-    void flip(final String flipAroundChar) {
-        final String[] parts = this.str.split(flipAroundChar);
-        if (parts.length == 2) {
-            this.str = String.format("%s %s", parts[1], parts[0]);
-            this.norm();
-        } else if (parts.length > 2) {
-            throw new NameParseException(
-                    "Can't flip around multiple '" + flipAroundChar + "' 
characters in namestring.");
-        }
-    }
-
-    /**
-     * <p>Removes extra whitespace and punctuation from {@code this.str}.</p>
-     *
-     * <p>Strips whitespace chars from ends, strips redundant whitespace, 
converts
-     * whitespace chars to " ".</p>
-     */
-    private void norm() {
-        this.str = this.str.trim();
-        this.str = this.str.replaceAll("\\s+", " ");
-        this.str = this.str.replaceAll(",$", " ");
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/53279c12/src/main/java/org/apache/commons/text/names/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/names/package-info.java 
b/src/main/java/org/apache/commons/text/names/package-info.java
deleted file mode 100644
index 868f6e1..0000000
--- a/src/main/java/org/apache/commons/text/names/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * <p>A human names parser in Java.</p>
- *
- * <p>The parser can parse different name formats, producing parts of names 
such as
- * first and last name, prefix, suffix and nickname.</p>
- *
- * @since 1.0
- */
-package org.apache.commons.text.names;

http://git-wip-us.apache.org/repos/asf/commons-text/blob/53279c12/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
deleted file mode 100644
index 1dd6085..0000000
--- a/src/test/java/org/apache/commons/text/names/HumanNameParserTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.text.names;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertThat;
-
-import java.nio.charset.Charset;
-
-import org.apache.commons.csv.CSVFormat;
-import org.apache.commons.csv.CSVParser;
-import org.apache.commons.csv.CSVRecord;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Tests the {@code HumanNameParser} class.
- */
-public class HumanNameParserTest {
-
-    private CSVParser inputParser;
-    private HumanNameParser nameParser;
-
-    @Before
-    public void setUp() throws Exception {
-        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 (inputParser != null) {
-            inputParser.close();
-        }
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void shouldThrowNullPointerException_WhenNullIsParsed() throws 
Exception {
-        nameParser.parse(null);
-    }
-
-    @Test
-    public void testInputs() {
-        for (final CSVRecord record : inputParser) {
-            validateRecord(record);
-        }
-    }
-
-    
-    /**
-     * Validates a line in the testNames.txt file.
-     *
-     * @param record a CSVRecord representing one record in the input file.
-     */
-    private void validateRecord(final CSVRecord record) {
-        final Name result = nameParser.parse(record.get(Columns.Name));
-
-        final long recordNum = record.getRecordNumber();
-
-        assertThat("Wrong Salutation in record " + recordNum,
-                result.getSalutation(), 
equalTo(record.get(Columns.Salutation)));
-
-        assertThat("Wrong LeadingInit in record " + recordNum,
-                result.getLeadingInitial(), 
equalTo(record.get(Columns.LeadingInit)));
-
-        assertThat("Wrong FirstName in record " + recordNum,
-                result.getFirstName(), equalTo(record.get(Columns.FirstName)));
-
-        assertThat("Wrong NickName in record " + recordNum,
-                result.getNickName(), equalTo(record.get(Columns.NickName)));
-
-        assertThat("Wrong MiddleName in record " + recordNum,
-                result.getMiddleName(), 
equalTo(record.get(Columns.MiddleName)));
-
-        assertThat("Wrong LastName in record " + recordNum,
-                result.getLastName(), equalTo(record.get(Columns.LastName)));
-
-        assertThat("Wrong Suffix in record " + recordNum,
-                result.getSuffix(), equalTo(record.get(Columns.Suffix)));
-    }
-
-    private enum Columns {
-        
Name,Salutation,LeadingInit,FirstName,NickName,MiddleName,LastName,Suffix
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/53279c12/src/test/java/org/apache/commons/text/names/NameStringTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/names/NameStringTest.java 
b/src/test/java/org/apache/commons/text/names/NameStringTest.java
deleted file mode 100644
index 4431d4a..0000000
--- a/src/test/java/org/apache/commons/text/names/NameStringTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.text.names;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Tests for {@code Name} and {@code HumanNameParser}. Utilizes the same
- * input file as the PHP library 0.2 version.
- */
-public class NameStringTest {
-
-    private NameString nameString;
-
-    @Before
-    public void setUp() {
-        nameString = new NameString("Björn O'Malley");
-    }
-
-    @Test
-    public void testChopWithRegexReturnsChoppedSubstring() {
-        assertThat(nameString.chopWithRegex("(^([^ ]+))(.+)", 1), 
equalTo("Björn"));
-    }
-
-    @Test
-    public void testChopWithRegexChopsStartOffNameStr() {
-        nameString.chopWithRegex("(^[^ ]+)", 0);
-
-        assertThat(nameString.getWrappedString(), equalTo("O'Malley"));
-    }
-
-    @Test
-    public void testChopWithRegexChopsEndOffNameStr() {
-        nameString.chopWithRegex("( (.+)$)", 1);
-
-        assertThat(nameString.getWrappedString(), equalTo("Björn"));
-    }
-
-    @Test
-    public void testChopWithRegexChopsMiddleFromNameStr() {
-        nameString.chopWithRegex("( '[^']+' )", 0);
-
-        assertThat(nameString.getWrappedString(), equalTo("Björn O'Malley"));
-    }
-
-    @Test
-    public void testFlip() {
-        nameString.flip(",");
-
-        assertThat(nameString.getWrappedString(), equalTo("Björn O'Malley"));
-    }
-
-}

Reply via email to