Return-Path: Delivered-To: apmail-commons-commits-archive@locus.apache.org Received: (qmail 57367 invoked from network); 21 May 2008 19:58:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 May 2008 19:58:28 -0000 Received: (qmail 58920 invoked by uid 500); 21 May 2008 19:58:27 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 58846 invoked by uid 500); 21 May 2008 19:58:27 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 58837 invoked by uid 99); 21 May 2008 19:58:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 May 2008 12:58:27 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 May 2008 19:57:36 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AFCA92388A05; Wed, 21 May 2008 12:57:52 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r658834 - in /commons/proper/codec/trunk/src: java/org/apache/commons/codec/binary/ java/org/apache/commons/codec/language/ test/org/apache/commons/codec/ test/org/apache/commons/codec/binary/ test/org/apache/commons/codec/digest/ test/org/... Date: Wed, 21 May 2008 19:57:52 -0000 To: commits@commons.apache.org From: niallp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080521195752.AFCA92388A05@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: niallp Date: Wed May 21 12:57:51 2008 New Revision: 658834 URL: http://svn.apache.org/viewvc?rev=658834&view=rev Log: Remove tabs Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/DoubleMetaphone.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/RefinedSoundex.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/SoundexUtils.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/BinaryEncoderAbstractTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/digest/DigestUtilsTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/MetaphoneTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/RefinedSoundexTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/SoundexTest.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java?rev=658834&r1=658833&r2=658834&view=diff ============================================================================== --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java Wed May 21 12:57:51 2008 @@ -113,7 +113,7 @@ return out; } - + /** * Converts an array of character bytes representing hexidecimal values into an * array of bytes of those same values. The returned array will be half the @@ -128,10 +128,10 @@ * to this function * @see #decodeHex(char[]) */ - public byte[] decode(byte[] array) throws DecoderException { - return decodeHex(new String(array).toCharArray()); - } - + public byte[] decode(byte[] array) throws DecoderException { + return decodeHex(new String(array).toCharArray()); + } + /** * Converts a String or an array of character bytes representing hexidecimal values into an * array of bytes of those same values. The returned array will be half the @@ -146,15 +146,15 @@ * to this function or the object is not a String or char[] * @see #decodeHex(char[]) */ - public Object decode(Object object) throws DecoderException { - try { + public Object decode(Object object) throws DecoderException { + try { char[] charArray = object instanceof String ? ((String) object).toCharArray() : (char[]) object; - return decodeHex(charArray); - } catch (ClassCastException e) { - throw new DecoderException(e.getMessage()); - } - } - + return decodeHex(charArray); + } catch (ClassCastException e) { + throw new DecoderException(e.getMessage()); + } + } + /** * Converts an array of bytes into an array of bytes for the characters representing the * hexidecimal values of each byte in order. The returned array will be @@ -165,9 +165,9 @@ * @return A byte[] containing the bytes of the hexidecimal characters * @see #encodeHex(byte[]) */ - public byte[] encode(byte[] array) { - return new String(encodeHex(array)).getBytes(); - } + public byte[] encode(byte[] array) { + return new String(encodeHex(array)).getBytes(); + } /** * Converts a String or an array of bytes into an array of characters representing the @@ -180,14 +180,14 @@ * @throws EncoderException Thrown if the given object is not a String or byte[] * @see #encodeHex(byte[]) */ - public Object encode(Object object) throws EncoderException { - try { + public Object encode(Object object) throws EncoderException { + try { byte[] byteArray = object instanceof String ? ((String) object).getBytes() : (byte[]) object; - return encodeHex(byteArray); - } catch (ClassCastException e) { - throw new EncoderException(e.getMessage()); - } - } + return encodeHex(byteArray); + } catch (ClassCastException e) { + throw new EncoderException(e.getMessage()); + } + } } Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/DoubleMetaphone.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/DoubleMetaphone.java?rev=658834&r1=658833&r2=658834&view=diff ============================================================================== --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/DoubleMetaphone.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/DoubleMetaphone.java Wed May 21 12:57:51 2008 @@ -807,24 +807,24 @@ * Complex condition 0 for 'C' */ private boolean conditionC0(String value, int index) { - if (contains(value, index, 4, "CHIA")) { - return true; - } else if (index <= 1) { - return false; - } else if (isVowel(charAt(value, index - 2))) { - return false; - } else if (!contains(value, index - 1, 3, "ACH")) { - return false; - } else { - char c = charAt(value, index + 2); - return (c != 'I' && c != 'E') || - contains(value, index - 2, 6, "BACHER", "MACHER"); - } - } + if (contains(value, index, 4, "CHIA")) { + return true; + } else if (index <= 1) { + return false; + } else if (isVowel(charAt(value, index - 2))) { + return false; + } else if (!contains(value, index - 1, 3, "ACH")) { + return false; + } else { + char c = charAt(value, index + 2); + return (c != 'I' && c != 'E') || + contains(value, index - 2, 6, "BACHER", "MACHER"); + } + } /** - * Complex condition 0 for 'CH' - */ + * Complex condition 0 for 'CH' + */ private boolean conditionCH0(String value, int index) { if (index != 0) { return false; @@ -870,20 +870,20 @@ * Complex condition 0 for 'M' */ private boolean conditionM0(String value, int index) { - if (charAt(value, index + 1) == 'M') { - return true; - } - return contains(value, index - 1, 3, "UMB") && - ((index + 1) == value.length() - 1 || contains(value, - index + 2, 2, "ER")); - } + if (charAt(value, index + 1) == 'M') { + return true; + } + return contains(value, index - 1, 3, "UMB") && + ((index + 1) == value.length() - 1 || contains(value, + index + 2, 2, "ER")); + } //-- BEGIN HELPER FUNCTIONS --// /** - * Determines whether or not a value is of slavo-germanic orgin. A value is - * of slavo-germanic origin if it contians any of 'W', 'K', 'CZ', or 'WITZ'. - */ + * Determines whether or not a value is of slavo-germanic orgin. A value is + * of slavo-germanic origin if it contians any of 'W', 'K', 'CZ', or 'WITZ'. + */ private boolean isSlavoGermanic(String value) { return value.indexOf('W') > -1 || value.indexOf('K') > -1 || value.indexOf("CZ") > -1 || value.indexOf("WITZ") > -1; @@ -916,21 +916,21 @@ * Cleans the input */ private String cleanInput(String input) { - if (input == null) { - return null; - } - input = input.trim(); - if (input.length() == 0) { - return null; - } - return input.toUpperCase(java.util.Locale.ENGLISH); - } + if (input == null) { + return null; + } + input = input.trim(); + if (input.length() == 0) { + return null; + } + return input.toUpperCase(java.util.Locale.ENGLISH); + } /** - * Gets the character at index index if available, otherwise - * it returns Character.MIN_VALUE so that there is some sort - * of a default - */ + * Gets the character at index index if available, otherwise + * it returns Character.MIN_VALUE so that there is some sort + * of a default + */ protected char charAt(String value, int index) { if (index < 0 || index >= value.length()) { return Character.MIN_VALUE; Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java?rev=658834&r1=658833&r2=658834&view=diff ============================================================================== --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java Wed May 21 12:57:51 2008 @@ -135,7 +135,7 @@ int n = 0 ; while ((code.length() < this.getMaxCodeLen()) && - (n < wdsz) ) { // max code size of 4 works well + (n < wdsz) ) { // max code size of 4 works well char symb = local.charAt(n) ; // remove duplicate letters except C if ((symb != 'C') && (isPreviousChar( local, n, symb )) ) { @@ -150,7 +150,7 @@ case 'B' : if ( isPreviousChar(local, n, 'M') && isLastChar(wdsz, n) ) { // B is silent if word ends in MB - break; + break; } code.append(symb); break; @@ -171,13 +171,13 @@ break; // CI,CE,CY -> S } if (isPreviousChar(local, n, 'S') && - isNextChar(local, n, 'H') ) { // SCH->sk + isNextChar(local, n, 'H') ) { // SCH->sk code.append('K') ; break ; } if (isNextChar(local, n, 'H')) { // detect CH if ((n == 0) && - (wdsz >= 3) && + (wdsz >= 3) && isVowel(local,2) ) { // CH consonant -> K consonant code.append('K'); } else { @@ -207,8 +207,8 @@ break; } if ((n > 0) && - ( regionMatch(local, n, "GN") || - regionMatch(local, n, "GNED") ) ) { + ( regionMatch(local, n, "GN") || + regionMatch(local, n, "GNED") ) ) { break; // silent G } if (isPreviousChar(local, n, 'G')) { @@ -266,8 +266,8 @@ break; case 'S' : if (regionMatch(local,n,"SH") || - regionMatch(local,n,"SIO") || - regionMatch(local,n,"SIA")) { + regionMatch(local,n,"SIO") || + regionMatch(local,n,"SIA")) { code.append('X'); } else { code.append('S'); @@ -275,12 +275,12 @@ break; case 'T' : if (regionMatch(local,n,"TIA") || - regionMatch(local,n,"TIO")) { + regionMatch(local,n,"TIO")) { code.append('X'); break; } if (regionMatch(local,n,"TCH")) { - // Silent if in "TCH" + // Silent if in "TCH" break; } // substitute numeral 0 for TH (resembles theta after all) @@ -294,7 +294,7 @@ code.append('F'); break ; case 'W' : case 'Y' : // silent if not followed by vowel if (!isLastChar(wdsz,n) && - isVowel(local,n+1)) { + isVowel(local,n+1)) { code.append(symb); } break ; @@ -307,47 +307,47 @@ n++ ; } // end else from symb != 'C' if (code.length() > this.getMaxCodeLen()) { - code.setLength(this.getMaxCodeLen()); + code.setLength(this.getMaxCodeLen()); } } return code.toString(); } - private boolean isVowel(StringBuffer string, int index) { - return VOWELS.indexOf(string.charAt(index)) >= 0; - } - - private boolean isPreviousChar(StringBuffer string, int index, char c) { - boolean matches = false; - if( index > 0 && - index < string.length() ) { - matches = string.charAt(index - 1) == c; - } - return matches; - } - - private boolean isNextChar(StringBuffer string, int index, char c) { - boolean matches = false; - if( index >= 0 && - index < string.length() - 1 ) { - matches = string.charAt(index + 1) == c; - } - return matches; - } - - private boolean regionMatch(StringBuffer string, int index, String test) { - boolean matches = false; - if( index >= 0 && - (index + test.length() - 1) < string.length() ) { - String substring = string.substring( index, index + test.length()); - matches = substring.equals( test ); - } - return matches; - } - - private boolean isLastChar(int wdsz, int n) { - return n + 1 == wdsz; - } + private boolean isVowel(StringBuffer string, int index) { + return VOWELS.indexOf(string.charAt(index)) >= 0; + } + + private boolean isPreviousChar(StringBuffer string, int index, char c) { + boolean matches = false; + if( index > 0 && + index < string.length() ) { + matches = string.charAt(index - 1) == c; + } + return matches; + } + + private boolean isNextChar(StringBuffer string, int index, char c) { + boolean matches = false; + if( index >= 0 && + index < string.length() - 1 ) { + matches = string.charAt(index + 1) == c; + } + return matches; + } + + private boolean regionMatch(StringBuffer string, int index, String test) { + boolean matches = false; + if( index >= 0 && + (index + test.length() - 1) < string.length() ) { + String substring = string.substring( index, index + test.length()); + matches = substring.equals( test ); + } + return matches; + } + + private boolean isLastChar(int wdsz, int n) { + return n + 1 == wdsz; + } /** Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/RefinedSoundex.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/RefinedSoundex.java?rev=658834&r1=658833&r2=658834&view=diff ============================================================================== --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/RefinedSoundex.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/RefinedSoundex.java Wed May 21 12:57:51 2008 @@ -31,85 +31,85 @@ public class RefinedSoundex implements StringEncoder { /** - * RefinedSoundex is *refined* for a number of reasons one being that the - * mappings have been altered. This implementation contains default - * mappings for US English. - */ + * RefinedSoundex is *refined* for a number of reasons one being that the + * mappings have been altered. This implementation contains default + * mappings for US English. + */ public static final char[] US_ENGLISH_MAPPING = "01360240043788015936020505".toCharArray(); /** - * Every letter of the alphabet is "mapped" to a numerical value. This char - * array holds the values to which each letter is mapped. This - * implementation contains a default map for US_ENGLISH - */ + * Every letter of the alphabet is "mapped" to a numerical value. This char + * array holds the values to which each letter is mapped. This + * implementation contains a default map for US_ENGLISH + */ private final char[] soundexMapping; /** - * This static variable contains an instance of the RefinedSoundex using - * the US_ENGLISH mapping. - */ + * This static variable contains an instance of the RefinedSoundex using + * the US_ENGLISH mapping. + */ public static final RefinedSoundex US_ENGLISH = new RefinedSoundex(); /** - * Creates an instance of the RefinedSoundex object using the default US - * English mapping. - */ + * Creates an instance of the RefinedSoundex object using the default US + * English mapping. + */ public RefinedSoundex() { this(US_ENGLISH_MAPPING); } /** - * Creates a refined soundex instance using a custom mapping. This - * constructor can be used to customize the mapping, and/or possibly - * provide an internationalized mapping for a non-Western character set. - * - * @param mapping - * Mapping array to use when finding the corresponding code for - * a given character - */ + * Creates a refined soundex instance using a custom mapping. This + * constructor can be used to customize the mapping, and/or possibly + * provide an internationalized mapping for a non-Western character set. + * + * @param mapping + * Mapping array to use when finding the corresponding code for + * a given character + */ public RefinedSoundex(char[] mapping) { this.soundexMapping = mapping; } /** - * Returns the number of characters in the two encoded Strings that are the - * same. This return value ranges from 0 to the length of the shortest - * encoded String: 0 indicates little or no similarity, and 4 out of 4 (for - * example) indicates strong similarity or identical values. For refined - * Soundex, the return value can be greater than 4. - * - * @param s1 - * A String that will be encoded and compared. - * @param s2 - * A String that will be encoded and compared. - * @return The number of characters in the two encoded Strings that are the - * same from 0 to to the length of the shortest encoded String. - * - * @see SoundexUtils#difference(StringEncoder,String,String) - * @see - * MS T-SQL DIFFERENCE - * - * @throws EncoderException - * if an error occurs encoding one of the strings + * Returns the number of characters in the two encoded Strings that are the + * same. This return value ranges from 0 to the length of the shortest + * encoded String: 0 indicates little or no similarity, and 4 out of 4 (for + * example) indicates strong similarity or identical values. For refined + * Soundex, the return value can be greater than 4. + * + * @param s1 + * A String that will be encoded and compared. + * @param s2 + * A String that will be encoded and compared. + * @return The number of characters in the two encoded Strings that are the + * same from 0 to to the length of the shortest encoded String. + * + * @see SoundexUtils#difference(StringEncoder,String,String) + * @see + * MS T-SQL DIFFERENCE + * + * @throws EncoderException + * if an error occurs encoding one of the strings * @since 1.3 - */ + */ public int difference(String s1, String s2) throws EncoderException { return SoundexUtils.difference(this, s1, s2); } /** - * Encodes an Object using the refined soundex algorithm. This method is - * provided in order to satisfy the requirements of the Encoder interface, - * and will throw an EncoderException if the supplied object is not of type - * java.lang.String. - * - * @param pObject - * Object to encode - * @return An object (or type java.lang.String) containing the refined - * soundex code which corresponds to the String supplied. - * @throws EncoderException - * if the parameter supplied is not of type java.lang.String - */ + * Encodes an Object using the refined soundex algorithm. This method is + * provided in order to satisfy the requirements of the Encoder interface, + * and will throw an EncoderException if the supplied object is not of type + * java.lang.String. + * + * @param pObject + * Object to encode + * @return An object (or type java.lang.String) containing the refined + * soundex code which corresponds to the String supplied. + * @throws EncoderException + * if the parameter supplied is not of type java.lang.String + */ public Object encode(Object pObject) throws EncoderException { if (!(pObject instanceof java.lang.String)) { throw new EncoderException("Parameter supplied to RefinedSoundex encode is not of type java.lang.String"); @@ -118,25 +118,25 @@ } /** - * Encodes a String using the refined soundex algorithm. - * - * @param pString - * A String object to encode - * @return A Soundex code corresponding to the String supplied - */ + * Encodes a String using the refined soundex algorithm. + * + * @param pString + * A String object to encode + * @return A Soundex code corresponding to the String supplied + */ public String encode(String pString) { return soundex(pString); } /** - * Returns the mapping code for a given character. The mapping codes are - * maintained in an internal char array named soundexMapping, and the - * default values of these mappings are US English. - * - * @param c - * char to get mapping for - * @return A character (really a numeral) to return for the given char - */ + * Returns the mapping code for a given character. The mapping codes are + * maintained in an internal char array named soundexMapping, and the + * default values of these mappings are US English. + * + * @param c + * char to get mapping for + * @return A character (really a numeral) to return for the given char + */ char getMappingCode(char c) { if (!Character.isLetter(c)) { return 0; @@ -145,12 +145,12 @@ } /** - * Retreives the Refined Soundex code for a given String object. - * - * @param str - * String to encode using the Refined Soundex algorithm - * @return A soundex code for the String supplied - */ + * Retreives the Refined Soundex code for a given String object. + * + * @param str + * String to encode using the Refined Soundex algorithm + * @return A soundex code for the String supplied + */ public String soundex(String str) { if (str == null) { return null; Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/SoundexUtils.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/SoundexUtils.java?rev=658834&r1=658833&r2=658834&view=diff ============================================================================== --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/SoundexUtils.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/SoundexUtils.java Wed May 21 12:57:51 2008 @@ -30,13 +30,13 @@ final class SoundexUtils { /** - * Cleans up the input string before Soundex processing by only returning - * upper case letters. - * - * @param str - * The String to clean. - * @return A clean String. - */ + * Cleans up the input string before Soundex processing by only returning + * upper case letters. + * + * @param str + * The String to clean. + * @return A clean String. + */ static String clean(String str) { if (str == null || str.length() == 0) { return str; @@ -56,55 +56,55 @@ } /** - * Encodes the Strings and returns the number of characters in the two - * encoded Strings that are the same. - *
    - *
  • For Soundex, this return value ranges from 0 through 4: 0 indicates - * little or no similarity, and 4 indicates strong similarity or identical - * values.
  • - *
  • For refined Soundex, the return value can be greater than 4.
  • - *
- * - * @param encoder - * The encoder to use to encode the Strings. - * @param s1 - * A String that will be encoded and compared. - * @param s2 - * A String that will be encoded and compared. - * @return The number of characters in the two Soundex encoded Strings that - * are the same. - * - * @see #differenceEncoded(String,String) - * @see - * MS T-SQL DIFFERENCE - * - * @throws EncoderException - * if an error occurs encoding one of the strings - */ + * Encodes the Strings and returns the number of characters in the two + * encoded Strings that are the same. + *
    + *
  • For Soundex, this return value ranges from 0 through 4: 0 indicates + * little or no similarity, and 4 indicates strong similarity or identical + * values.
  • + *
  • For refined Soundex, the return value can be greater than 4.
  • + *
+ * + * @param encoder + * The encoder to use to encode the Strings. + * @param s1 + * A String that will be encoded and compared. + * @param s2 + * A String that will be encoded and compared. + * @return The number of characters in the two Soundex encoded Strings that + * are the same. + * + * @see #differenceEncoded(String,String) + * @see + * MS T-SQL DIFFERENCE + * + * @throws EncoderException + * if an error occurs encoding one of the strings + */ static int difference(StringEncoder encoder, String s1, String s2) throws EncoderException { return differenceEncoded(encoder.encode(s1), encoder.encode(s2)); } /** - * Returns the number of characters in the two Soundex encoded Strings that - * are the same. - *
    - *
  • For Soundex, this return value ranges from 0 through 4: 0 indicates - * little or no similarity, and 4 indicates strong similarity or identical - * values.
  • - *
  • For refined Soundex, the return value can be greater than 4.
  • - *
- * - * @param es1 - * An encoded String. - * @param es2 - * An encoded String. - * @return The number of characters in the two Soundex encoded Strings that - * are the same. - * - * @see - * MS T-SQL DIFFERENCE - */ + * Returns the number of characters in the two Soundex encoded Strings that + * are the same. + *
    + *
  • For Soundex, this return value ranges from 0 through 4: 0 indicates + * little or no similarity, and 4 indicates strong similarity or identical + * values.
  • + *
  • For refined Soundex, the return value can be greater than 4.
  • + *
+ * + * @param es1 + * An encoded String. + * @param es2 + * An encoded String. + * @return The number of characters in the two Soundex encoded Strings that + * are the same. + * + * @see + * MS T-SQL DIFFERENCE + */ static int differenceEncoded(String es1, String es2) { if (es1 == null || es2 == null) { Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/BinaryEncoderAbstractTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/BinaryEncoderAbstractTest.java?rev=658834&r1=658833&r2=658834&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/BinaryEncoderAbstractTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/BinaryEncoderAbstractTest.java Wed May 21 12:57:51 2008 @@ -40,10 +40,10 @@ public void testEncodeNull() throws Exception { BinaryEncoder encoder = makeEncoder(); - try { - encoder.encode(null); - } catch( EncoderException ee ) { - // An exception should be thrown - } + try { + encoder.encode(null); + } catch( EncoderException ee ) { + // An exception should be thrown + } } } Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java?rev=658834&r1=658833&r2=658834&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java Wed May 21 12:57:51 2008 @@ -464,7 +464,7 @@ public void testKnownEncodings() { assertEquals("VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==",new String(Base64.encodeBase64("The quick brown fox jumped over the lazy dogs.".getBytes()))); - assertEquals("YmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJs\r\nYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFo\r\nIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBi\r\nbGFoIGJsYWg=\r\n",new String(Base64.encodeBase64Chunked("blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah".getBytes()))); + assertEquals("YmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJs\r\nYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFo\r\nIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBi\r\nbGFoIGJsYWg=\r\n",new String(Base64.encodeBase64Chunked("blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah".getBytes()))); assertEquals("SXQgd2FzIHRoZSBiZXN0IG9mIHRpbWVzLCBpdCB3YXMgdGhlIHdvcnN0IG9mIHRpbWVzLg==",new String(Base64.encodeBase64("It was the best of times, it was the worst of times.".getBytes()))); assertEquals("aHR0cDovL2pha2FydGEuYXBhY2hlLm9yZy9jb21tbW9ucw==",new String(Base64.encodeBase64("http://jakarta.apache.org/commmons".getBytes()))); assertEquals("QWFCYkNjRGRFZUZmR2dIaElpSmpLa0xsTW1Obk9vUHBRcVJyU3NUdFV1VnZXd1h4WXlaeg==",new String(Base64.encodeBase64("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz".getBytes()))); @@ -481,38 +481,38 @@ assertEquals("xyzzy!",new String(Base64.decodeBase64("eHl6enkh".getBytes()))); } - public void testNonBase64Test() throws Exception { + public void testNonBase64Test() throws Exception { - byte[] bArray = { '%' }; + byte[] bArray = { '%' }; - assertFalse( "Invalid Base64 array was incorrectly validated as " + - "an array of Base64 encoded data", - Base64.isArrayByteBase64( bArray ) ); + assertFalse( "Invalid Base64 array was incorrectly validated as " + + "an array of Base64 encoded data", + Base64.isArrayByteBase64( bArray ) ); - boolean exceptionThrown = false; + boolean exceptionThrown = false; - try { - Base64 b64 = new Base64(); - byte[] result = b64.decode( bArray ); + try { + Base64 b64 = new Base64(); + byte[] result = b64.decode( bArray ); - assertTrue( "The result should be empty as the test encoded content did " + - "not contain any valid base 64 characters", result.length == 0); - } - catch( Exception e ) { - exceptionThrown = true; - } - - assertFalse( "Exception was thrown when trying to decode " + - "invalid base64 encoded data - RFC 2045 requires that all " + - "non base64 character be discarded, an exception should not" + - " have been thrown", exceptionThrown ); + assertTrue( "The result should be empty as the test encoded content did " + + "not contain any valid base 64 characters", result.length == 0); + } + catch( Exception e ) { + exceptionThrown = true; + } + + assertFalse( "Exception was thrown when trying to decode " + + "invalid base64 encoded data - RFC 2045 requires that all " + + "non base64 character be discarded, an exception should not" + + " have been thrown", exceptionThrown ); - } + } - public void testIgnoringNonBase64InDecode() throws Exception { - assertEquals("The quick brown fox jumped over the lazy dogs.",new String(Base64.decodeBase64("VGhlIH@$#$@%F1aWN@#@#@@rIGJyb3duIGZve\n\r\t%#%#%#%CBqd##$#$W1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==".getBytes()))); - } + public void testIgnoringNonBase64InDecode() throws Exception { + assertEquals("The quick brown fox jumped over the lazy dogs.",new String(Base64.decodeBase64("VGhlIH@$#$@%F1aWN@#@#@@rIGJyb3duIGZve\n\r\t%#%#%#%CBqd##$#$W1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==".getBytes()))); + } public void testIsArrayByteBase64() { assertFalse(Base64.isArrayByteBase64(new byte[] {Byte.MIN_VALUE})); @@ -643,7 +643,7 @@ BigInteger bigInt1 = new BigInteger("85739377120809420210425962799" + "0318636601332086981"); - assertEquals(encodedInt1, new String(Base64.encodeInteger(bigInt1))); + assertEquals(encodedInt1, new String(Base64.encodeInteger(bigInt1))); assertEquals(bigInt1, Base64.decodeInteger(encodedInt1.getBytes())); } Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/digest/DigestUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/digest/DigestUtilsTest.java?rev=658834&r1=658833&r2=658834&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/digest/DigestUtilsTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/digest/DigestUtilsTest.java Wed May 21 12:57:51 2008 @@ -74,8 +74,8 @@ } /** - * An MD5 hash converted to hex should always be 32 characters. - */ + * An MD5 hash converted to hex should always be 32 characters. + */ public void testMD5HexLength() { String hashMe = "this is some string that is longer than 32 characters"; String hash = DigestUtils.md5Hex(hashMe.getBytes()); @@ -87,8 +87,8 @@ } /** - * An MD5 hash should always be a 16 element byte[]. - */ + * An MD5 hash should always be a 16 element byte[]. + */ public void testMD5Length() { String hashMe = "this is some string that is longer than 16 characters"; byte[] hash = DigestUtils.md5(hashMe.getBytes()); @@ -100,46 +100,46 @@ } public void testSha256() throws IOException { - // Examples from FIPS 180-2 - assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", - DigestUtils.sha256Hex("abc")); - assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", - DigestUtils.sha256Hex("abc".getBytes())); - assertEquals("248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1", - DigestUtils.sha256Hex("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")); + // Examples from FIPS 180-2 + assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", + DigestUtils.sha256Hex("abc")); + assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", + DigestUtils.sha256Hex("abc".getBytes())); + assertEquals("248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1", + DigestUtils.sha256Hex("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")); assertEquals(DigestUtils.sha256Hex(testData), DigestUtils.sha256Hex(new ByteArrayInputStream(testData))); } public void testSha384() throws IOException { - // Examples from FIPS 180-2 - assertEquals("cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed" + - "8086072ba1e7cc2358baeca134c825a7", - DigestUtils.sha384Hex("abc")); - assertEquals("cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed" + - "8086072ba1e7cc2358baeca134c825a7", - DigestUtils.sha384Hex("abc".getBytes())); - assertEquals("09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712" + - "fcc7c71a557e2db966c3e9fa91746039", - DigestUtils.sha384Hex("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" + - "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu")); + // Examples from FIPS 180-2 + assertEquals("cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed" + + "8086072ba1e7cc2358baeca134c825a7", + DigestUtils.sha384Hex("abc")); + assertEquals("cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed" + + "8086072ba1e7cc2358baeca134c825a7", + DigestUtils.sha384Hex("abc".getBytes())); + assertEquals("09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712" + + "fcc7c71a557e2db966c3e9fa91746039", + DigestUtils.sha384Hex("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" + + "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu")); assertEquals(DigestUtils.sha384Hex(testData), DigestUtils.sha384Hex(new ByteArrayInputStream(testData))); } public void testSha512() throws IOException { - // Examples from FIPS 180-2 - assertEquals("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" + - "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", - DigestUtils.sha512Hex("abc")); - assertEquals("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" + - "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", - DigestUtils.sha512Hex("abc".getBytes())); - assertEquals("8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018" + - "501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909", - DigestUtils.sha512Hex("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" + - "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu")); + // Examples from FIPS 180-2 + assertEquals("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" + + "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", + DigestUtils.sha512Hex("abc")); + assertEquals("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" + + "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", + DigestUtils.sha512Hex("abc".getBytes())); + assertEquals("8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018" + + "501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909", + DigestUtils.sha512Hex("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" + + "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu")); assertEquals(DigestUtils.sha512Hex(testData), DigestUtils.sha512Hex(new ByteArrayInputStream(testData))); } Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java?rev=658834&r1=658833&r2=658834&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java Wed May 21 12:57:51 2008 @@ -34,14 +34,14 @@ public class DoubleMetaphoneTest extends StringEncoderAbstractTest { /** - * Test data from http://aspell.sourceforge.net/test/batch0.tab. - * - * "Copyright (C) 2002 Kevin Atkinson (kevina@gnu.org). Verbatim copying - * and distribution of this entire article is permitted in any medium, - * provided this notice is preserved." + * Test data from http://aspell.sourceforge.net/test/batch0.tab. + * + * "Copyright (C) 2002 Kevin Atkinson (kevina@gnu.org). Verbatim copying + * and distribution of this entire article is permitted in any medium, + * provided this notice is preserved." * * Massaged the test data in the array below. - */ + */ private static final String[][] FIXTURE = { { "Accosinly", "Occasionally" }, { "Ciculer", "Circler" }, { "Circue", "Circle" }, { @@ -592,8 +592,8 @@ }; /** - * A subset of FIXTURE generated by this test. - */ + * A subset of FIXTURE generated by this test. + */ private static final String[][] MATCHES = { { "Accosinly", "Occasionally" }, { "Maddness", "Madness" }, { "Occusionaly", "Occasionally" }, { @@ -1012,8 +1012,8 @@ } /** - * Tests encoding APIs in one place. - */ + * Tests encoding APIs in one place. + */ private void assertDoubleMetaphone(String expected, String source) { assertEquals(expected, this.getDoubleMetaphone().encode(source)); try { @@ -1026,8 +1026,8 @@ } /** - * Tests encoding APIs in one place. - */ + * Tests encoding APIs in one place. + */ public void assertDoubleMetaphoneAlt(String expected, String source) { assertEquals(expected, this.getDoubleMetaphone().doubleMetaphone(source, true)); } @@ -1132,8 +1132,8 @@ } /** - * Example in the original article but failures in this Java impl: - */ + * Example in the original article but failures in this Java impl: + */ public void testIsDoubleMetaphoneEqualExtended1() { // String[][] testFixture = new String[][] { { "Smith", "Schmidt" } // }; @@ -1149,9 +1149,9 @@ } /** - * Used to generate the MATCHES array and test possible matches from the - * FIXTURE arrary. - */ + * Used to generate the MATCHES array and test possible matches from the + * FIXTURE arrary. + */ public void testIsDoubleMetaphoneEqualExtended3() { this.validateFixture(FIXTURE); StringBuffer failures = new StringBuffer(); Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/MetaphoneTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/MetaphoneTest.java?rev=658834&r1=658833&r2=658834&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/MetaphoneTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/MetaphoneTest.java Wed May 21 12:57:51 2008 @@ -64,8 +64,8 @@ } } /** - * @return Returns the metaphone. - */ + * @return Returns the metaphone. + */ private Metaphone getMetaphone() { return this.metaphone; } @@ -75,9 +75,9 @@ } /** - * @param metaphone - * The metaphone to set. - */ + * @param metaphone + * The metaphone to set. + */ private void setMetaphone(Metaphone metaphone) { this.metaphone = metaphone; } @@ -101,27 +101,27 @@ } /** - * Matches computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Matches computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqual2() { this.assertMetaphoneEqual(new String[][] { { "Lawrence", "Lorenza" }, { "Gary", "Cahra" }, }); } /** - * Initial AE case. - * - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Initial AE case. + * + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualAero() { this.assertIsMetaphoneEqual("Aero", new String[] { "Eure" }); } /** - * Initial WH case. - * - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Initial WH case. + * + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualWhite() { this.assertIsMetaphoneEqual( "White", @@ -129,17 +129,17 @@ } /** - * Initial A, not followed by an E case. - * - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Initial A, not followed by an E case. + * + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualAlbert() { this.assertIsMetaphoneEqual("Albert", new String[] { "Ailbert", "Alberik", "Albert", "Alberto", "Albrecht" }); } /** - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualGary() { this.assertIsMetaphoneEqual( "Gary", @@ -191,8 +191,8 @@ } /** - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualJohn() { this.assertIsMetaphoneEqual( "John", @@ -259,10 +259,10 @@ } /** - * Initial KN case. - * - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Initial KN case. + * + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualKnight() { this.assertIsMetaphoneEqual( "Knight", @@ -285,8 +285,8 @@ "Nydia" }); } /** - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualMary() { this.assertIsMetaphoneEqual( "Mary", @@ -315,15 +315,15 @@ } /** - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualParis() { this.assertIsMetaphoneEqual("Paris", new String[] { "Pearcy", "Perris", "Piercy", "Pierz", "Pryse" }); } /** - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualPeter() { this.assertIsMetaphoneEqual( "Peter", @@ -331,15 +331,15 @@ } /** - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualRay() { this.assertIsMetaphoneEqual("Ray", new String[] { "Ray", "Rey", "Roi", "Roy", "Ruy" }); } /** - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualSusan() { this.assertIsMetaphoneEqual( "Susan", @@ -359,17 +359,17 @@ } /** - * Initial WR case. - * - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Initial WR case. + * + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualWright() { this.assertIsMetaphoneEqual("Wright", new String[] { "Rota", "Rudd", "Ryde" }); } /** - * Match data computed from http://www.lanw.com/java/phonetic/default.htm - */ + * Match data computed from http://www.lanw.com/java/phonetic/default.htm + */ public void testIsMetaphoneEqualXalan() { this.assertIsMetaphoneEqual( "Xalan", @@ -377,7 +377,7 @@ } public void testMetaphone() { - assertEquals("HL", this.getMetaphone().metaphone("howl")); + assertEquals("HL", this.getMetaphone().metaphone("howl")); assertEquals("TSTN", this.getMetaphone().metaphone("testing")); assertEquals("0", this.getMetaphone().metaphone("The")); assertEquals("KK", this.getMetaphone().metaphone("quick")); @@ -389,18 +389,18 @@ assertEquals("LS", this.getMetaphone().metaphone("lazy")); assertEquals("TKS", this.getMetaphone().metaphone("dogs")); } - - public void testWordEndingInMB() { - assertEquals( "KM", this.getMetaphone().metaphone("COMB") ); - assertEquals( "TM", this.getMetaphone().metaphone("TOMB") ); - assertEquals( "WM", this.getMetaphone().metaphone("WOMB") ); - } - - public void testDiscardOfSCEOrSCIOrSCY() { - assertEquals( "SNS", this.getMetaphone().metaphone("SCIENCE") ); - assertEquals( "SN", this.getMetaphone().metaphone("SCENE") ); - assertEquals( "S", this.getMetaphone().metaphone("SCY") ); - } + + public void testWordEndingInMB() { + assertEquals( "KM", this.getMetaphone().metaphone("COMB") ); + assertEquals( "TM", this.getMetaphone().metaphone("TOMB") ); + assertEquals( "WM", this.getMetaphone().metaphone("WOMB") ); + } + + public void testDiscardOfSCEOrSCIOrSCY() { + assertEquals( "SNS", this.getMetaphone().metaphone("SCIENCE") ); + assertEquals( "SN", this.getMetaphone().metaphone("SCENE") ); + assertEquals( "S", this.getMetaphone().metaphone("SCY") ); + } /** * Tests (CODEC-57) Metaphone.metaphone(String) returns an empty string when passed the word "why" @@ -414,60 +414,60 @@ assertEquals( "XP", this.getMetaphone().metaphone("CIAPO") ); } - public void testTranslateOfSCHAndCH() { - assertEquals( "SKTL", this.getMetaphone().metaphone("SCHEDULE") ); - assertEquals( "SKMT", this.getMetaphone().metaphone("SCHEMATIC") ); - - assertEquals( "KRKT", this.getMetaphone().metaphone("CHARACTER") ); - assertEquals( "TX", this.getMetaphone().metaphone("TEACH") ); - } - - public void testTranslateToJOfDGEOrDGIOrDGY() { - assertEquals( "TJ", this.getMetaphone().metaphone("DODGY") ); - assertEquals( "TJ", this.getMetaphone().metaphone("DODGE") ); - assertEquals( "AJMT", this.getMetaphone().metaphone("ADGIEMTI") ); - } - - public void testDiscardOfSilentHAfterG() { - assertEquals( "KNT", this.getMetaphone().metaphone("GHENT") ); - assertEquals( "B", this.getMetaphone().metaphone("BAUGH") ); - } - - public void testDiscardOfSilentGN() { - assertEquals( "N", this.getMetaphone().metaphone("GNU") ); - assertEquals( "SNT", this.getMetaphone().metaphone("SIGNED") ); - } - - public void testPHTOF() { - assertEquals( "FX", this.getMetaphone().metaphone("PHISH") ); - } - - public void testSHAndSIOAndSIAToX() { - assertEquals( "XT", this.getMetaphone().metaphone("SHOT") ); - assertEquals( "OTXN", this.getMetaphone().metaphone("ODSIAN") ); - assertEquals( "PLXN", this.getMetaphone().metaphone("PULSION") ); - } - - public void testTIOAndTIAToX() { - assertEquals( "OX", this.getMetaphone().metaphone("OTIA") ); - assertEquals( "PRXN", this.getMetaphone().metaphone("PORTION") ); - } - - public void testTCH() { - assertEquals( "RX", this.getMetaphone().metaphone("RETCH") ); - assertEquals( "WX", this.getMetaphone().metaphone("WATCH") ); - } - - public void testExceedLength() { - // should be AKSKS, but istruncated by Max Code Length - assertEquals( "AKSK", this.getMetaphone().metaphone("AXEAXE") ); - } - - public void testSetMaxLengthWithTruncation() { - // should be AKSKS, but istruncated by Max Code Length - this.getMetaphone().setMaxCodeLen( 6 ); - assertEquals( "AKSKSK", this.getMetaphone().metaphone("AXEAXEAXE") ); - } + public void testTranslateOfSCHAndCH() { + assertEquals( "SKTL", this.getMetaphone().metaphone("SCHEDULE") ); + assertEquals( "SKMT", this.getMetaphone().metaphone("SCHEMATIC") ); + + assertEquals( "KRKT", this.getMetaphone().metaphone("CHARACTER") ); + assertEquals( "TX", this.getMetaphone().metaphone("TEACH") ); + } + + public void testTranslateToJOfDGEOrDGIOrDGY() { + assertEquals( "TJ", this.getMetaphone().metaphone("DODGY") ); + assertEquals( "TJ", this.getMetaphone().metaphone("DODGE") ); + assertEquals( "AJMT", this.getMetaphone().metaphone("ADGIEMTI") ); + } + + public void testDiscardOfSilentHAfterG() { + assertEquals( "KNT", this.getMetaphone().metaphone("GHENT") ); + assertEquals( "B", this.getMetaphone().metaphone("BAUGH") ); + } + + public void testDiscardOfSilentGN() { + assertEquals( "N", this.getMetaphone().metaphone("GNU") ); + assertEquals( "SNT", this.getMetaphone().metaphone("SIGNED") ); + } + + public void testPHTOF() { + assertEquals( "FX", this.getMetaphone().metaphone("PHISH") ); + } + + public void testSHAndSIOAndSIAToX() { + assertEquals( "XT", this.getMetaphone().metaphone("SHOT") ); + assertEquals( "OTXN", this.getMetaphone().metaphone("ODSIAN") ); + assertEquals( "PLXN", this.getMetaphone().metaphone("PULSION") ); + } + + public void testTIOAndTIAToX() { + assertEquals( "OX", this.getMetaphone().metaphone("OTIA") ); + assertEquals( "PRXN", this.getMetaphone().metaphone("PORTION") ); + } + + public void testTCH() { + assertEquals( "RX", this.getMetaphone().metaphone("RETCH") ); + assertEquals( "WX", this.getMetaphone().metaphone("WATCH") ); + } + + public void testExceedLength() { + // should be AKSKS, but istruncated by Max Code Length + assertEquals( "AKSK", this.getMetaphone().metaphone("AXEAXE") ); + } + + public void testSetMaxLengthWithTruncation() { + // should be AKSKS, but istruncated by Max Code Length + this.getMetaphone().setMaxCodeLen( 6 ); + assertEquals( "AKSKSK", this.getMetaphone().metaphone("AXEAXEAXE") ); + } public void validateFixture(String[][] pairs) { if (pairs.length == 0) { Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/RefinedSoundexTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/RefinedSoundexTest.java?rev=658834&r1=658833&r2=658834&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/RefinedSoundexTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/RefinedSoundexTest.java Wed May 21 12:57:51 2008 @@ -43,8 +43,8 @@ } /** - * @return Returns the encoder. - */ + * @return Returns the encoder. + */ private RefinedSoundex getEncoder() { return this.encoder; } @@ -54,9 +54,9 @@ } /** - * @param encoder - * The encoder to set. - */ + * @param encoder + * The encoder to set. + */ private void setEncoder(RefinedSoundex encoder) { this.encoder = encoder; } @@ -82,11 +82,11 @@ assertEquals(1, this.getEncoder().difference("Margaret", "Andrew")); assertEquals(1, this.getEncoder().difference("Janet", "Margaret")); // Examples from - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_de-dz_8co5.asp + // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_de-dz_8co5.asp assertEquals(5, this.getEncoder().difference("Green", "Greene")); assertEquals(1, this.getEncoder().difference("Blotchet-Halls", "Greene")); // Examples from - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_setu-sus_3o6w.asp + // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_setu-sus_3o6w.asp assertEquals(6, this.getEncoder().difference("Smith", "Smythe")); assertEquals(8, this.getEncoder().difference("Smithers", "Smythers")); assertEquals(5, this.getEncoder().difference("Anothers", "Brothers")); @@ -109,8 +109,8 @@ assertEquals("D6043", RefinedSoundex.US_ENGLISH.encode("dogs")); } - public void testGetMappingCodeNonLetter() { - char code = this.getEncoder().getMappingCode('#'); - assertEquals("Code does not equals zero", 0, code); - } + public void testGetMappingCodeNonLetter() { + char code = this.getEncoder().getMappingCode('#'); + assertEquals("Code does not equals zero", 0, code); + } } Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/SoundexTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/SoundexTest.java?rev=658834&r1=658833&r2=658834&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/SoundexTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/SoundexTest.java Wed May 21 12:57:51 2008 @@ -50,8 +50,8 @@ } /** - * @return Returns the _encoder. - */ + * @return Returns the _encoder. + */ public Soundex getEncoder() { return this.encoder; } @@ -61,9 +61,9 @@ } /** - * @param encoder - * The encoder to set. - */ + * @param encoder + * The encoder to set. + */ public void setEncoder(Soundex encoder) { this.encoder = encoder; } @@ -157,9 +157,9 @@ } /** - * Examples from - * http://www.bradandkathy.com/genealogy/overviewofsoundex.html - */ + * Examples from + * http://www.bradandkathy.com/genealogy/overviewofsoundex.html + */ public void testEncodeBatch2() { assertEquals("A462", this.getEncoder().encode("Allricht")); assertEquals("E166", this.getEncoder().encode("Eberhard")); @@ -180,9 +180,9 @@ } /** - * Examples from - * http://www.archives.gov/research_room/genealogy/census/soundex.html - */ + * Examples from + * http://www.archives.gov/research_room/genealogy/census/soundex.html + */ public void testEncodeBatch3() { assertEquals("W252", this.getEncoder().encode("Washington")); assertEquals("L000", this.getEncoder().encode("Lee")); @@ -196,8 +196,8 @@ } /** - * Examples from: http://www.myatt.demon.co.uk/sxalg.htm - */ + * Examples from: http://www.myatt.demon.co.uk/sxalg.htm + */ public void testEncodeBatch4() { assertEquals("H452", this.getEncoder().encode("HOLMES")); assertEquals("A355", this.getEncoder().encode("ADOMOMI")); @@ -210,18 +210,18 @@ } - public void testBadCharacters() { - assertEquals("H452", this.getEncoder().encode("HOL>MES")); + public void testBadCharacters() { + assertEquals("H452", this.getEncoder().encode("HOL>MES")); - } + } public void testEncodeIgnoreApostrophes() { this.encodeAll(new String[] { "OBrien", "'OBrien", "O'Brien", "OB'rien", "OBr'ien", "OBri'en", "OBrie'n", "OBrien'" }, "O165"); } /** - * Test data from http://www.myatt.demon.co.uk/sxalg.htm - */ + * Test data from http://www.myatt.demon.co.uk/sxalg.htm + */ public void testEncodeIgnoreHyphens() { this.encodeAll( new String[] { @@ -244,9 +244,9 @@ } /** - * Consonants from the same code group separated by W or H are treated as - * one. - */ + * Consonants from the same code group separated by W or H are treated as + * one. + */ public void testHWRuleEx1() { // From // http://www.archives.gov/research_room/genealogy/census/soundex.html: @@ -256,20 +256,20 @@ } /** - * Consonants from the same code group separated by W or H are treated as - * one. - * - * Test data from http://www.myatt.demon.co.uk/sxalg.htm - */ + * Consonants from the same code group separated by W or H are treated as + * one. + * + * Test data from http://www.myatt.demon.co.uk/sxalg.htm + */ public void testHWRuleEx2() { assertEquals("B312", this.getEncoder().encode("BOOTHDAVIS")); assertEquals("B312", this.getEncoder().encode("BOOTH-DAVIS")); } /** - * Consonants from the same code group separated by W or H are treated as - * one. - */ + * Consonants from the same code group separated by W or H are treated as + * one. + */ public void testHWRuleEx3() { assertEquals("S460", this.getEncoder().encode("Sgler")); assertEquals("S460", this.getEncoder().encode("Swhgler"));