Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/Caverphone2Test.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/Caverphone2Test.java?rev=1087894&r1=1087893&r2=1087894&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/Caverphone2Test.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/Caverphone2Test.java Fri Apr 1 20:59:03 2011 @@ -28,10 +28,6 @@ import org.apache.commons.codec.StringEn */ public class Caverphone2Test extends CaverphoneTest { - public Caverphone2Test(String name) { - super(name); - } - protected StringEncoder createStringEncoder() { return new Caverphone2(); }
Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/CaverphoneTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/CaverphoneTest.java?rev=1087894&r1=1087893&r2=1087894&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/CaverphoneTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/CaverphoneTest.java Fri Apr 1 20:59:03 2011 @@ -22,6 +22,7 @@ import junit.framework.Assert; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; import org.apache.commons.codec.StringEncoderAbstractTest; +import org.junit.Test; /** * @author Apache Software Foundation @@ -29,10 +30,6 @@ import org.apache.commons.codec.StringEn */ public class CaverphoneTest extends StringEncoderAbstractTest { - public CaverphoneTest(String name) { - super(name); - } - protected StringEncoder createStringEncoder() { return new Caverphone(); } @@ -44,6 +41,7 @@ public class CaverphoneTest extends Stri * * @throws EncoderException */ + @Test public void testCaverphoneRevisitedCommonCodeAT11111111() throws EncoderException { this.checkEncodingVariations("AT11111111", new String[]{ "add", @@ -68,6 +66,7 @@ public class CaverphoneTest extends Stri * * @throws EncoderException */ + @Test public void testCaverphoneRevisitedExamples() throws EncoderException { String[][] data = {{"Stevenson", "STFNSN1111"}, {"Peter", "PTA1111111"}}; this.checkEncodings(data); @@ -78,6 +77,7 @@ public class CaverphoneTest extends Stri * * @throws EncoderException */ + @Test public void testCaverphoneRevisitedRandomNameKLN1111111() throws EncoderException { this.checkEncodingVariations("KLN1111111", new String[]{ "Cailean", @@ -169,6 +169,7 @@ public class CaverphoneTest extends Stri * * @throws EncoderException */ + @Test public void testCaverphoneRevisitedRandomNameTN11111111() throws EncoderException { this.checkEncodingVariations("TN11111111", new String[]{ "Dan", @@ -247,6 +248,7 @@ public class CaverphoneTest extends Stri * * @throws EncoderException */ + @Test public void testCaverphoneRevisitedRandomNameTTA1111111() throws EncoderException { this.checkEncodingVariations("TTA1111111", new String[]{ "Darda", @@ -324,24 +326,28 @@ public class CaverphoneTest extends Stri * * @throws EncoderException */ + @Test public void testCaverphoneRevisitedRandomWords() throws EncoderException { this.checkEncodingVariations("RTA1111111", new String[]{"rather", "ready", "writer"}); this.checkEncoding("SSA1111111", "social"); this.checkEncodingVariations("APA1111111", new String[]{"able", "appear"}); } + @Test public void testEndMb() throws EncoderException { String[][] data = {{"mb", "M111111111"}, {"mbmb", "MPM1111111"}}; this.checkEncodings(data); } // Caverphone Revisited + @Test public void testIsCaverphoneEquals() { Caverphone caverphone = new Caverphone(); Assert.assertFalse("Caverphone encodings should not be equal", caverphone.isCaverphoneEqual("Peter", "Stevenson")); Assert.assertTrue("Caverphone encodings should be equal", caverphone.isCaverphoneEqual("Peter", "Peady")); } + @Test public void testSpecificationExamples() throws EncoderException { String[][] data = { {"Peter", "PTA1111111"}, Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/ColognePhoneticTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/ColognePhoneticTest.java?rev=1087894&r1=1087893&r2=1087894&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/ColognePhoneticTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/ColognePhoneticTest.java Fri Apr 1 20:59:03 2011 @@ -17,10 +17,10 @@ package org.apache.commons.codec.language; - import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; import org.apache.commons.codec.StringEncoderAbstractTest; +import org.junit.Test; /** * Tests the deprecated class {@link ColognePhonetic}. @@ -31,22 +31,21 @@ import org.apache.commons.codec.StringEn */ public class ColognePhoneticTest extends StringEncoderAbstractTest { - public ColognePhoneticTest(String name) { - super(name); - } - protected StringEncoder createStringEncoder() { return new ColognePhonetic(); } + @Test public void testAabjoe() throws EncoderException { this.checkEncoding("01", "Aabjoe"); } + @Test public void testAaclan() throws EncoderException { this.checkEncoding("0856", "Aaclan"); } + @Test public void testEdgeCases() throws EncoderException { String[][] data = { {"a", "0"}, @@ -81,6 +80,7 @@ public class ColognePhoneticTest extends this.checkEncodings(data); } + @Test public void testExamples() throws EncoderException { String[][] data = { {"m\u00DCller", "657"}, @@ -114,6 +114,7 @@ public class ColognePhoneticTest extends this.checkEncodings(data); } + @Test public void testHyphen() throws EncoderException { String[][] data = {{"bergisch-gladbach", "174845214"}, {"Müller-Lüdenscheidt", "65752682"}, // From the Javadoc example: @@ -121,6 +122,7 @@ public class ColognePhoneticTest extends this.checkEncodings(data); } + @Test public void testIsEncodeEquals() { String[][] data = { {"Meyer", "Müller"}, @@ -136,11 +138,13 @@ public class ColognePhoneticTest extends } } + @Test public void testVariationsMella() throws EncoderException { String data[] = {"mella", "milah", "moulla", "mellah", "muehle", "mule"}; this.checkEncodingVariations("65", data); } + @Test public void testVariationsMeyer() throws EncoderException { String data[] = {"Meier", "Maier", "Mair", "Meyer", "Meyr", "Mejer", "Major"}; this.checkEncodingVariations("67", data); Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/DoubleMetaphone2Test.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/DoubleMetaphone2Test.java?rev=1087894&r1=1087893&r2=1087894&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/DoubleMetaphone2Test.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/language/DoubleMetaphone2Test.java Fri Apr 1 20:59:03 2011 @@ -17,8 +17,11 @@ package org.apache.commons.codec.language; +import static org.junit.Assert.assertEquals; + import org.apache.commons.codec.StringEncoder; import org.apache.commons.codec.StringEncoderAbstractTest; +import org.junit.Test; /** * Tests {@link DoubleMetaphone}. @@ -1259,16 +1262,6 @@ public class DoubleMetaphone2Test extend {"weikersheim", "AKRS", "FKRS"}, {"zhao", "J", "J"}}; - /** - * Construct a new test case. - * - * @param name - * The name of the test - */ - public DoubleMetaphone2Test(String name) { - super(name); - } - private void checkDoubleMetaphone(int typeIndex, boolean alternate) { for (int i = 0; i < TEST_DATA.length; i++) { String value = TEST_DATA[i][0]; @@ -1290,6 +1283,7 @@ public class DoubleMetaphone2Test extend /** * Test alternative encoding. */ + @Test public void testDoubleMetaphoneAlternate() { this.checkDoubleMetaphone(ALTERNATE_INDEX, true); } @@ -1297,6 +1291,7 @@ public class DoubleMetaphone2Test extend /** * Test primary encoding. */ + @Test public void testDoubleMetaphonePrimary() { this.checkDoubleMetaphone(PRIMARY_INDEX, false); } 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=1087894&r1=1087893&r2=1087894&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 Fri Apr 1 20:59:03 2011 @@ -17,9 +17,15 @@ package org.apache.commons.codec.language; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; import org.apache.commons.codec.StringEncoderAbstractTest; +import org.junit.Test; /** * Tests {@link DoubleMetaphone}. @@ -1000,10 +1006,6 @@ public class DoubleMetaphoneTest extends "wundeews", "windows" }, { "yeild", "yield" }, }; - public DoubleMetaphoneTest(String name) { - super(name); - } - /** * Tests encoding APIs in one place. */ @@ -1058,6 +1060,7 @@ public class DoubleMetaphoneTest extends return new DoubleMetaphone(); } + @Test public void testDoubleMetaphone() { assertDoubleMetaphone("TSTN", "testing"); assertDoubleMetaphone("0", "The"); @@ -1098,6 +1101,7 @@ public class DoubleMetaphoneTest extends assertDoubleMetaphoneAlt("XRN", "Czerny"); } + @Test public void testEmpty() { assertEquals(null, this.getDoubleMetaphone().doubleMetaphone(null)); assertEquals(null, this.getDoubleMetaphone().doubleMetaphone("")); @@ -1108,6 +1112,7 @@ public class DoubleMetaphoneTest extends /** * Test setting maximum length */ + @Test public void testSetMaxCodeLength() { String value = "jumped"; @@ -1125,6 +1130,7 @@ public class DoubleMetaphoneTest extends assertEquals("Max=3 Alternate", "AMP", doubleMetaphone.doubleMetaphone(value, true)); } + @Test public void testIsDoubleMetaphoneEqualBasic() { String[][] testFixture = new String[][] { { "Case", "case" }, { "CASE", "Case" }, { @@ -1143,6 +1149,7 @@ public class DoubleMetaphoneTest extends /** * Example in the original article but failures in this Java impl: */ + @Test public void testIsDoubleMetaphoneEqualExtended1() { // String[][] testFixture = new String[][] { { "Smith", "Schmidt" } // }; @@ -1150,6 +1157,7 @@ public class DoubleMetaphoneTest extends // doubleMetaphoneEqualTest(testFixture, true); } + @Test public void testIsDoubleMetaphoneEqualExtended2() { String[][] testFixture = new String[][] { { "Jablonski", "Yablonsky" } }; @@ -1161,6 +1169,7 @@ public class DoubleMetaphoneTest extends * Used to generate the MATCHES array and test possible matches from the * FIXTURE array. */ + @Test public void testIsDoubleMetaphoneEqualExtended3() { this.validateFixture(FIXTURE); StringBuffer failures = new StringBuffer(); @@ -1192,6 +1201,7 @@ public class DoubleMetaphoneTest extends } } + @Test public void testIsDoubleMetaphoneEqualWithMATCHES() { this.validateFixture(MATCHES); for (int i = 0; i < MATCHES.length; i++) { @@ -1205,15 +1215,18 @@ public class DoubleMetaphoneTest extends } } + @Test public void testIsDoubleMetaphoneNotEqual() { doubleMetaphoneNotEqualTest(false); doubleMetaphoneNotEqualTest(true); } + @Test public void testCCedilla() { this.getDoubleMetaphone().isDoubleMetaphoneEqual("�", "S"); } + @Test public void testNTilde() { this.getDoubleMetaphone().isDoubleMetaphoneEqual("�", "N"); } 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=1087894&r1=1087893&r2=1087894&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 Fri Apr 1 20:59:03 2011 @@ -17,8 +17,13 @@ package org.apache.commons.codec.language; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import org.apache.commons.codec.StringEncoder; import org.apache.commons.codec.StringEncoderAbstractTest; +import org.junit.Test; /** * @author Apache Software Foundation @@ -26,10 +31,6 @@ import org.apache.commons.codec.StringEn */ public class MetaphoneTest extends StringEncoderAbstractTest { - public MetaphoneTest(String name) { - super(name); - } - public void assertIsMetaphoneEqual(String source, String[] matches) { // match source to all matches for (int i = 0; i < matches.length; i++) { @@ -66,6 +67,7 @@ public class MetaphoneTest extends Strin return new Metaphone(); } + @Test public void testIsMetaphoneEqual1() { this.assertMetaphoneEqual(new String[][] { { "Case", "case" }, { "CASE", "Case" }, { @@ -77,6 +79,7 @@ public class MetaphoneTest extends Strin /** * Matches computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqual2() { this.assertMetaphoneEqual(new String[][] { { "Lawrence", "Lorenza" }, { "Gary", "Cahra" }, }); @@ -87,6 +90,7 @@ public class MetaphoneTest extends Strin * * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualAero() { this.assertIsMetaphoneEqual("Aero", new String[] { "Eure" }); } @@ -96,6 +100,7 @@ public class MetaphoneTest extends Strin * * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualWhite() { this.assertIsMetaphoneEqual( "White", @@ -107,6 +112,7 @@ public class MetaphoneTest extends Strin * * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualAlbert() { this.assertIsMetaphoneEqual("Albert", new String[] { "Ailbert", "Alberik", "Albert", "Alberto", "Albrecht" }); } @@ -114,6 +120,7 @@ public class MetaphoneTest extends Strin /** * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualGary() { this.assertIsMetaphoneEqual( "Gary", @@ -167,6 +174,7 @@ public class MetaphoneTest extends Strin /** * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualJohn() { this.assertIsMetaphoneEqual( "John", @@ -237,6 +245,7 @@ public class MetaphoneTest extends Strin * * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualKnight() { this.assertIsMetaphoneEqual( "Knight", @@ -261,6 +270,7 @@ public class MetaphoneTest extends Strin /** * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualMary() { this.assertIsMetaphoneEqual( "Mary", @@ -291,6 +301,7 @@ public class MetaphoneTest extends Strin /** * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualParis() { this.assertIsMetaphoneEqual("Paris", new String[] { "Pearcy", "Perris", "Piercy", "Pierz", "Pryse" }); } @@ -298,6 +309,7 @@ public class MetaphoneTest extends Strin /** * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualPeter() { this.assertIsMetaphoneEqual( "Peter", @@ -307,6 +319,7 @@ public class MetaphoneTest extends Strin /** * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualRay() { this.assertIsMetaphoneEqual("Ray", new String[] { "Ray", "Rey", "Roi", "Roy", "Ruy" }); } @@ -314,6 +327,7 @@ public class MetaphoneTest extends Strin /** * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualSusan() { this.assertIsMetaphoneEqual( "Susan", @@ -337,6 +351,7 @@ public class MetaphoneTest extends Strin * * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualWright() { this.assertIsMetaphoneEqual("Wright", new String[] { "Rota", "Rudd", "Ryde" }); } @@ -344,12 +359,14 @@ public class MetaphoneTest extends Strin /** * Match data computed from http://www.lanw.com/java/phonetic/default.htm */ + @Test public void testIsMetaphoneEqualXalan() { this.assertIsMetaphoneEqual( "Xalan", new String[] { "Celene", "Celina", "Celine", "Selena", "Selene", "Selina", "Seline", "Suellen", "Xylina" }); } + @Test public void testMetaphone() { assertEquals("HL", this.getMetaphone().metaphone("howl")); assertEquals("TSTN", this.getMetaphone().metaphone("testing")); @@ -364,12 +381,14 @@ public class MetaphoneTest extends Strin assertEquals("TKS", this.getMetaphone().metaphone("dogs")); } + @Test public void testWordEndingInMB() { assertEquals( "KM", this.getMetaphone().metaphone("COMB") ); assertEquals( "TM", this.getMetaphone().metaphone("TOMB") ); assertEquals( "WM", this.getMetaphone().metaphone("WOMB") ); } + @Test public void testDiscardOfSCEOrSCIOrSCY() { assertEquals( "SNS", this.getMetaphone().metaphone("SCIENCE") ); assertEquals( "SN", this.getMetaphone().metaphone("SCENE") ); @@ -379,15 +398,18 @@ public class MetaphoneTest extends Strin /** * Tests (CODEC-57) Metaphone.metaphone(String) returns an empty string when passed the word "why" */ + @Test public void testWhy() { // PHP returns "H". The original metaphone returns an empty string. assertEquals("", this.getMetaphone().metaphone("WHY")); } + @Test public void testWordsWithCIA() { assertEquals( "XP", this.getMetaphone().metaphone("CIAPO") ); } + @Test public void testTranslateOfSCHAndCH() { assertEquals( "SKTL", this.getMetaphone().metaphone("SCHEDULE") ); assertEquals( "SKMT", this.getMetaphone().metaphone("SCHEMATIC") ); @@ -396,17 +418,20 @@ public class MetaphoneTest extends Strin assertEquals( "TX", this.getMetaphone().metaphone("TEACH") ); } + @Test public void testTranslateToJOfDGEOrDGIOrDGY() { assertEquals( "TJ", this.getMetaphone().metaphone("DODGY") ); assertEquals( "TJ", this.getMetaphone().metaphone("DODGE") ); assertEquals( "AJMT", this.getMetaphone().metaphone("ADGIEMTI") ); } + @Test public void testDiscardOfSilentHAfterG() { assertEquals( "KNT", this.getMetaphone().metaphone("GHENT") ); assertEquals( "B", this.getMetaphone().metaphone("BAUGH") ); } + @Test public void testDiscardOfSilentGN() { // NOTE: This does not test for silent GN, but for starting with GN assertEquals( "N", this.getMetaphone().metaphone("GNU") ); @@ -415,31 +440,37 @@ public class MetaphoneTest extends Strin assertEquals( "SNT", this.getMetaphone().metaphone("SIGNED") ); } + @Test public void testPHTOF() { assertEquals( "FX", this.getMetaphone().metaphone("PHISH") ); } + @Test public void testSHAndSIOAndSIAToX() { assertEquals( "XT", this.getMetaphone().metaphone("SHOT") ); assertEquals( "OTXN", this.getMetaphone().metaphone("ODSIAN") ); assertEquals( "PLXN", this.getMetaphone().metaphone("PULSION") ); } + @Test public void testTIOAndTIAToX() { assertEquals( "OX", this.getMetaphone().metaphone("OTIA") ); assertEquals( "PRXN", this.getMetaphone().metaphone("PORTION") ); } + @Test public void testTCH() { assertEquals( "RX", this.getMetaphone().metaphone("RETCH") ); assertEquals( "WX", this.getMetaphone().metaphone("WATCH") ); } + @Test public void testExceedLength() { // should be AKSKS, but istruncated by Max Code Length assertEquals( "AKSK", this.getMetaphone().metaphone("AXEAXE") ); } + @Test public void testSetMaxLengthWithTruncation() { // should be AKSKS, but istruncated by Max Code Length this.getMetaphone().setMaxCodeLen( 6 ); 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=1087894&r1=1087893&r2=1087894&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 Fri Apr 1 20:59:03 2011 @@ -17,9 +17,12 @@ package org.apache.commons.codec.language; +import static org.junit.Assert.assertEquals; + import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; import org.apache.commons.codec.StringEncoderAbstractTest; +import org.junit.Test; /** * Tests RefinedSoundex. @@ -29,10 +32,6 @@ import org.apache.commons.codec.StringEn */ public class RefinedSoundexTest extends StringEncoderAbstractTest { - public RefinedSoundexTest(String name) { - super(name); - } - protected StringEncoder createStringEncoder() { return new RefinedSoundex(); } @@ -44,6 +43,7 @@ public class RefinedSoundexTest extends return (RefinedSoundex)this.getStringEncoder(); } + @Test public void testDifference() throws EncoderException { // Edge cases assertEquals(0, this.getRefinedSoundex().difference(null, null)); @@ -65,6 +65,7 @@ public class RefinedSoundexTest extends assertEquals(5, this.getRefinedSoundex().difference("Anothers", "Brothers")); } + @Test public void testEncode() { assertEquals("T6036084", this.getRefinedSoundex().encode("testing")); assertEquals("T6036084", this.getRefinedSoundex().encode("TESTING")); @@ -82,19 +83,23 @@ public class RefinedSoundexTest extends assertEquals("D6043", RefinedSoundex.US_ENGLISH.encode("dogs")); } + @Test public void testGetMappingCodeNonLetter() { char code = this.getRefinedSoundex().getMappingCode('#'); assertEquals("Code does not equals zero", 0, code); } + @Test public void testNewInstance() { assertEquals("D6043", new RefinedSoundex().soundex("dogs")); } + @Test public void testNewInstance2() { assertEquals("D6043", new RefinedSoundex(RefinedSoundex.US_ENGLISH_MAPPING_STRING.toCharArray()).soundex("dogs")); } + @Test public void testNewInstance3() { assertEquals("D6043", new RefinedSoundex(RefinedSoundex.US_ENGLISH_MAPPING_STRING).soundex("dogs")); } 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=1087894&r1=1087893&r2=1087894&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 Fri Apr 1 20:59:03 2011 @@ -24,6 +24,7 @@ import junit.framework.Assert; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; import org.apache.commons.codec.StringEncoderAbstractTest; +import org.junit.Test; /** * Tests {@link Soundex}. @@ -35,10 +36,6 @@ import org.apache.commons.codec.StringEn */ public class SoundexTest extends StringEncoderAbstractTest { - public SoundexTest(String name) { - super(name); - } - protected StringEncoder createStringEncoder() { return new Soundex(); } @@ -50,6 +47,7 @@ public class SoundexTest extends StringE return (Soundex)this.getStringEncoder(); } + @Test public void testB650() throws EncoderException { this.checkEncodingVariations("B650", (new String[]{ "BARHAM", @@ -94,11 +92,13 @@ public class SoundexTest extends StringE "BYRUM"})); } + @Test public void testBadCharacters() { Assert.assertEquals("H452", this.getSoundexEncoder().encode("HOL>MES")); } + @Test public void testDifference() throws EncoderException { // Edge cases Assert.assertEquals(0, this.getSoundexEncoder().difference(null, null)); @@ -118,6 +118,7 @@ public class SoundexTest extends StringE Assert.assertEquals(2, this.getSoundexEncoder().difference("Anothers", "Brothers")); } + @Test public void testEncodeBasic() { Assert.assertEquals("T235", this.getSoundexEncoder().encode("testing")); Assert.assertEquals("T000", this.getSoundexEncoder().encode("The")); @@ -134,6 +135,7 @@ public class SoundexTest extends StringE /** * Examples from http://www.bradandkathy.com/genealogy/overviewofsoundex.html */ + @Test public void testEncodeBatch2() { Assert.assertEquals("A462", this.getSoundexEncoder().encode("Allricht")); Assert.assertEquals("E166", this.getSoundexEncoder().encode("Eberhard")); @@ -156,6 +158,7 @@ public class SoundexTest extends StringE /** * Examples from http://www.archives.gov/research_room/genealogy/census/soundex.html */ + @Test public void testEncodeBatch3() { Assert.assertEquals("W252", this.getSoundexEncoder().encode("Washington")); Assert.assertEquals("L000", this.getSoundexEncoder().encode("Lee")); @@ -171,6 +174,7 @@ public class SoundexTest extends StringE /** * Examples from: http://www.myatt.demon.co.uk/sxalg.htm */ + @Test public void testEncodeBatch4() { Assert.assertEquals("H452", this.getSoundexEncoder().encode("HOLMES")); Assert.assertEquals("A355", this.getSoundexEncoder().encode("ADOMOMI")); @@ -183,6 +187,7 @@ public class SoundexTest extends StringE } + @Test public void testEncodeIgnoreApostrophes() throws EncoderException { this.checkEncodingVariations("O165", (new String[]{ "OBrien", @@ -200,6 +205,7 @@ public class SoundexTest extends StringE * * @throws EncoderException */ + @Test public void testEncodeIgnoreHyphens() throws EncoderException { this.checkEncodingVariations("K525", (new String[]{ "KINGSMITH", @@ -215,6 +221,7 @@ public class SoundexTest extends StringE "KINGSMITH-"})); } + @Test public void testEncodeIgnoreTrimmable() { Assert.assertEquals("W252", this.getSoundexEncoder().encode(" \t\n\r Washington \t\n\r ")); } @@ -222,6 +229,7 @@ public class SoundexTest extends StringE /** * Consonants from the same code group separated by W or H are treated as one. */ + @Test public void testHWRuleEx1() { // From // http://www.archives.gov/research_room/genealogy/census/soundex.html: @@ -235,6 +243,7 @@ public class SoundexTest extends StringE * * Test data from http://www.myatt.demon.co.uk/sxalg.htm */ + @Test public void testHWRuleEx2() { Assert.assertEquals("B312", this.getSoundexEncoder().encode("BOOTHDAVIS")); Assert.assertEquals("B312", this.getSoundexEncoder().encode("BOOTH-DAVIS")); @@ -245,6 +254,7 @@ public class SoundexTest extends StringE * * @throws EncoderException */ + @Test public void testHWRuleEx3() throws EncoderException { Assert.assertEquals("S460", this.getSoundexEncoder().encode("Sgler")); Assert.assertEquals("S460", this.getSoundexEncoder().encode("Swhgler")); @@ -268,12 +278,14 @@ public class SoundexTest extends StringE "SILLER"})); } + @Test public void testMaxLength() throws Exception { Soundex soundex = new Soundex(); soundex.setMaxLength(soundex.getMaxLength()); Assert.assertEquals("S460", this.getSoundexEncoder().encode("Sgler")); } + @Test public void testMaxLengthLessThan3Fix() throws Exception { Soundex soundex = new Soundex(); soundex.setMaxLength(2); @@ -284,6 +296,7 @@ public class SoundexTest extends StringE * Examples for MS SQLServer from * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_setu-sus_3o6w.asp */ + @Test public void testMsSqlServer1() { Assert.assertEquals("S530", this.getSoundexEncoder().encode("Smith")); Assert.assertEquals("S530", this.getSoundexEncoder().encode("Smythe")); @@ -296,6 +309,7 @@ public class SoundexTest extends StringE * * @throws EncoderException */ + @Test public void testMsSqlServer2() throws EncoderException { this.checkEncodingVariations("E625", (new String[]{"Erickson", "Erickson", "Erikson", "Ericson", "Ericksen", "Ericsen"})); } @@ -303,6 +317,7 @@ public class SoundexTest extends StringE /** * Examples for MS SQLServer from http://databases.about.com/library/weekly/aa042901a.htm */ + @Test public void testMsSqlServer3() { Assert.assertEquals("A500", this.getSoundexEncoder().encode("Ann")); Assert.assertEquals("A536", this.getSoundexEncoder().encode("Andrew")); @@ -318,22 +333,27 @@ public class SoundexTest extends StringE /** * https://issues.apache.org/jira/browse/CODEC-54 https://issues.apache.org/jira/browse/CODEC-56 */ + @Test public void testNewInstance() { Assert.assertEquals("W452", new Soundex().soundex("Williams")); } + @Test public void testNewInstance2() { Assert.assertEquals("W452", new Soundex(Soundex.US_ENGLISH_MAPPING_STRING.toCharArray()).soundex("Williams")); } + @Test public void testNewInstance3() { Assert.assertEquals("W452", new Soundex(Soundex.US_ENGLISH_MAPPING_STRING).soundex("Williams")); } + @Test public void testSoundexUtilsConstructable() { new SoundexUtils(); } + @Test public void testSoundexUtilsNullBehaviour() { Assert.assertEquals(null, SoundexUtils.clean(null)); Assert.assertEquals("", SoundexUtils.clean("")); @@ -344,6 +364,7 @@ public class SoundexTest extends StringE /** * https://issues.apache.org/jira/browse/CODEC-54 https://issues.apache.org/jira/browse/CODEC-56 */ + @Test public void testUsEnglishStatic() { Assert.assertEquals("W452", Soundex.US_ENGLISH.soundex("Williams")); } @@ -353,6 +374,7 @@ public class SoundexTest extends StringE * * http://issues.apache.org/bugzilla/show_bug.cgi?id=29080 */ + @Test public void testUsMappingEWithAcute() { Assert.assertEquals("E000", this.getSoundexEncoder().encode("e")); if (Character.isLetter('�')) { @@ -372,6 +394,7 @@ public class SoundexTest extends StringE * * http://issues.apache.org/bugzilla/show_bug.cgi?id=29080 */ + @Test public void testUsMappingOWithDiaeresis() { Assert.assertEquals("O000", this.getSoundexEncoder().encode("o")); if (Character.isLetter('�')) { Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/BCodecTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/BCodecTest.java?rev=1087894&r1=1087893&r2=1087894&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/BCodecTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/BCodecTest.java Fri Apr 1 20:59:03 2011 @@ -17,11 +17,14 @@ package org.apache.commons.codec.net; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; +import org.apache.commons.codec.CharEncoding; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; -import org.apache.commons.codec.CharEncoding; +import org.junit.Test; /** * Quoted-printable codec test cases @@ -29,7 +32,7 @@ import org.apache.commons.codec.CharEnco * @author <a href="mailto:[email protected]">Oleg Kalnichevski</a> * @version $Id$ */ -public class BCodecTest extends TestCase { +public class BCodecTest { static final int SWISS_GERMAN_STUFF_UNICODE[] = { 0x47, 0x72, 0xFC, 0x65, 0x7A, 0x69, 0x5F, 0x7A, 0xE4, 0x6D, 0xE4 }; @@ -37,10 +40,6 @@ public class BCodecTest extends TestCase static final int RUSSIAN_STUFF_UNICODE[] = { 0x412, 0x441, 0x435, 0x43C, 0x5F, 0x43F, 0x440, 0x438, 0x432, 0x435, 0x442 }; - public BCodecTest(String name) { - super(name); - } - private String constructString(int[] unicodeChars) { StringBuffer buffer = new StringBuffer(); if (unicodeChars != null) { @@ -51,12 +50,14 @@ public class BCodecTest extends TestCase return buffer.toString(); } + @Test public void testNullInput() throws Exception { BCodec bcodec = new BCodec(); assertNull(bcodec.doDecoding(null)); assertNull(bcodec.doEncoding(null)); } + @Test public void testUTF8RoundTrip() throws Exception { String ru_msg = constructString(RUSSIAN_STUFF_UNICODE); @@ -71,6 +72,7 @@ public class BCodecTest extends TestCase assertEquals(ch_msg, bcodec.decode(bcodec.encode(ch_msg))); } + @Test public void testBasicEncodeDecode() throws Exception { BCodec bcodec = new BCodec(); String plain = "Hello there"; @@ -79,12 +81,14 @@ public class BCodecTest extends TestCase assertEquals("Basic B decoding test", plain, bcodec.decode(encoded)); } + @Test public void testEncodeDecodeNull() throws Exception { BCodec bcodec = new BCodec(); assertNull("Null string B encoding test", bcodec.encode((String) null)); assertNull("Null string B decoding test", bcodec.decode((String) null)); } + @Test public void testEncodeStringWithNull() throws Exception { BCodec bcodec = new BCodec(); String test = null; @@ -92,6 +96,7 @@ public class BCodecTest extends TestCase assertEquals("Result should be null", null, result); } + @Test public void testDecodeStringWithNull() throws Exception { BCodec bcodec = new BCodec(); String test = null; @@ -99,6 +104,7 @@ public class BCodecTest extends TestCase assertEquals("Result should be null", null, result); } + @Test public void testEncodeObjects() throws Exception { BCodec bcodec = new BCodec(); String plain = "what not"; @@ -118,6 +124,7 @@ public class BCodecTest extends TestCase } } + @Test public void testInvalidEncoding() { BCodec bcodec = new BCodec("NONSENSE"); try { @@ -134,6 +141,7 @@ public class BCodecTest extends TestCase } } + @Test public void testDecodeObjects() throws Exception { BCodec bcodec = new BCodec(); String decoded = "=?UTF-8?B?d2hhdCBub3Q=?="; Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QCodecTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QCodecTest.java?rev=1087894&r1=1087893&r2=1087894&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QCodecTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QCodecTest.java Fri Apr 1 20:59:03 2011 @@ -18,11 +18,16 @@ package org.apache.commons.codec.net; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import org.apache.commons.codec.CharEncoding; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; -import org.apache.commons.codec.CharEncoding; +import org.junit.Test; /** * Quoted-printable codec test cases @@ -30,7 +35,7 @@ import org.apache.commons.codec.CharEnco * @author <a href="mailto:[email protected]">Oleg Kalnichevski</a> * @version $Id$ */ -public class QCodecTest extends TestCase { +public class QCodecTest { static final int SWISS_GERMAN_STUFF_UNICODE [] = { 0x47, 0x72, 0xFC, 0x65, 0x7A, 0x69, 0x5F, 0x7A, 0xE4, 0x6D, 0xE4 @@ -41,10 +46,6 @@ public class QCodecTest extends TestCase 0x432, 0x435, 0x442 }; - public QCodecTest(String name) { - super(name); - } - private String constructString(int [] unicodeChars) { StringBuffer buffer = new StringBuffer(); if (unicodeChars != null) { @@ -55,12 +56,14 @@ public class QCodecTest extends TestCase return buffer.toString(); } + @Test public void testNullInput() throws Exception { QCodec qcodec = new QCodec(); assertNull(qcodec.doDecoding(null)); assertNull(qcodec.doEncoding(null)); } + @Test public void testUTF8RoundTrip() throws Exception { String ru_msg = constructString(RUSSIAN_STUFF_UNICODE); @@ -79,6 +82,7 @@ public class QCodecTest extends TestCase } + @Test public void testBasicEncodeDecode() throws Exception { QCodec qcodec = new QCodec(); String plain = "= Hello there =\r\n"; @@ -89,6 +93,7 @@ public class QCodecTest extends TestCase plain, qcodec.decode(encoded)); } + @Test public void testUnsafeEncodeDecode() throws Exception { QCodec qcodec = new QCodec(); String plain = "?_=\r\n"; @@ -99,6 +104,7 @@ public class QCodecTest extends TestCase plain, qcodec.decode(encoded)); } + @Test public void testEncodeDecodeNull() throws Exception { QCodec qcodec = new QCodec(); assertNull("Null string Q encoding test", @@ -107,6 +113,7 @@ public class QCodecTest extends TestCase qcodec.decode((String)null)); } + @Test public void testEncodeStringWithNull() throws Exception { QCodec qcodec = new QCodec(); String test = null; @@ -114,6 +121,7 @@ public class QCodecTest extends TestCase assertEquals("Result should be null", null, result); } + @Test public void testDecodeStringWithNull() throws Exception { QCodec qcodec = new QCodec(); String test = null; @@ -122,6 +130,7 @@ public class QCodecTest extends TestCase } + @Test public void testEncodeObjects() throws Exception { QCodec qcodec = new QCodec(); String plain = "1+1 = 2"; @@ -142,6 +151,7 @@ public class QCodecTest extends TestCase } + @Test public void testInvalidEncoding() { QCodec qcodec = new QCodec("NONSENSE"); try { @@ -158,6 +168,7 @@ public class QCodecTest extends TestCase } } + @Test public void testDecodeObjects() throws Exception { QCodec qcodec = new QCodec(); String decoded = "=?UTF-8?Q?1+1 =3D 2?="; @@ -178,6 +189,7 @@ public class QCodecTest extends TestCase } + @Test public void testEncodeDecodeBlanks() throws Exception { String plain = "Mind those pesky blanks"; String encoded1 = "=?UTF-8?Q?Mind those pesky blanks?="; @@ -196,6 +208,7 @@ public class QCodecTest extends TestCase } + @Test public void testLetUsMakeCloverHappy() throws Exception { QCodec qcodec = new QCodec(); qcodec.setEncodeBlanks(true); Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QuotedPrintableCodecTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QuotedPrintableCodecTest.java?rev=1087894&r1=1087893&r2=1087894&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QuotedPrintableCodecTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QuotedPrintableCodecTest.java Fri Apr 1 20:59:03 2011 @@ -17,11 +17,14 @@ package org.apache.commons.codec.net; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; +import org.apache.commons.codec.CharEncoding; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; -import org.apache.commons.codec.CharEncoding; +import org.junit.Test; /** * Quoted-printable codec test cases @@ -29,7 +32,7 @@ import org.apache.commons.codec.CharEnco * @author <a href="mailto:[email protected]">Oleg Kalnichevski</a> * @version $Id$ */ -public class QuotedPrintableCodecTest extends TestCase { +public class QuotedPrintableCodecTest { static final int SWISS_GERMAN_STUFF_UNICODE [] = { 0x47, 0x72, 0xFC, 0x65, 0x7A, 0x69, 0x5F, 0x7A, 0xE4, 0x6D, 0xE4 @@ -40,10 +43,6 @@ public class QuotedPrintableCodecTest ex 0x432, 0x435, 0x442 }; - public QuotedPrintableCodecTest(String name) { - super(name); - } - private String constructString(int [] unicodeChars) { StringBuffer buffer = new StringBuffer(); if (unicodeChars != null) { @@ -54,6 +53,7 @@ public class QuotedPrintableCodecTest ex return buffer.toString(); } + @Test public void testUTF8RoundTrip() throws Exception { String ru_msg = constructString(RUSSIAN_STUFF_UNICODE); @@ -71,6 +71,7 @@ public class QuotedPrintableCodecTest ex assertEquals(ch_msg, qpcodec.decode(qpcodec.encode(ch_msg, CharEncoding.UTF_8), CharEncoding.UTF_8)); } + @Test public void testBasicEncodeDecode() throws Exception { QuotedPrintableCodec qpcodec = new QuotedPrintableCodec(); String plain = "= Hello there =\r\n"; @@ -81,6 +82,7 @@ public class QuotedPrintableCodecTest ex plain, qpcodec.decode(encoded)); } + @Test public void testSafeCharEncodeDecode() throws Exception { QuotedPrintableCodec qpcodec = new QuotedPrintableCodec(); String plain = "abc123_-.*~!@#$%^&()+{}\"\\;:`,/[]"; @@ -92,6 +94,7 @@ public class QuotedPrintableCodecTest ex } + @Test public void testUnsafeEncodeDecode() throws Exception { QuotedPrintableCodec qpcodec = new QuotedPrintableCodec(); String plain = "=\r\n"; @@ -102,6 +105,7 @@ public class QuotedPrintableCodecTest ex plain, qpcodec.decode(encoded)); } + @Test public void testEncodeDecodeNull() throws Exception { QuotedPrintableCodec qpcodec = new QuotedPrintableCodec(); assertNull("Null string quoted-printable encoding test", @@ -111,6 +115,7 @@ public class QuotedPrintableCodecTest ex } + @Test public void testDecodeInvalid() throws Exception { QuotedPrintableCodec qpcodec = new QuotedPrintableCodec(); try { @@ -133,6 +138,7 @@ public class QuotedPrintableCodecTest ex } } + @Test public void testEncodeNull() throws Exception { QuotedPrintableCodec qpcodec = new QuotedPrintableCodec(); byte[] plain = null; @@ -141,6 +147,7 @@ public class QuotedPrintableCodecTest ex null, encoded); } + @Test public void testEncodeUrlWithNullBitSet() throws Exception { QuotedPrintableCodec qpcodec = new QuotedPrintableCodec(); String plain = "1+1 = 2"; @@ -153,12 +160,14 @@ public class QuotedPrintableCodecTest ex } + @Test public void testDecodeWithNullArray() throws Exception { byte[] plain = null; byte[] result = QuotedPrintableCodec.decodeQuotedPrintable( plain ); assertEquals("Result should be null", null, result); } + @Test public void testEncodeStringWithNull() throws Exception { QuotedPrintableCodec qpcodec = new QuotedPrintableCodec(); String test = null; @@ -166,6 +175,7 @@ public class QuotedPrintableCodecTest ex assertEquals("Result should be null", null, result); } + @Test public void testDecodeStringWithNull() throws Exception { QuotedPrintableCodec qpcodec = new QuotedPrintableCodec(); String test = null; @@ -173,6 +183,7 @@ public class QuotedPrintableCodecTest ex assertEquals("Result should be null", null, result); } + @Test public void testEncodeObjects() throws Exception { QuotedPrintableCodec qpcodec = new QuotedPrintableCodec(); String plain = "1+1 = 2"; @@ -198,6 +209,7 @@ public class QuotedPrintableCodecTest ex } } + @Test public void testInvalidEncoding() { QuotedPrintableCodec qpcodec = new QuotedPrintableCodec("NONSENSE"); String plain = "Hello there!"; @@ -215,6 +227,7 @@ public class QuotedPrintableCodecTest ex } } + @Test public void testDecodeObjects() throws Exception { QuotedPrintableCodec qpcodec = new QuotedPrintableCodec(); String plain = "1+1 =3D 2"; @@ -240,6 +253,7 @@ public class QuotedPrintableCodecTest ex } } + @Test public void testDefaultEncoding() throws Exception { String plain = "Hello there!"; QuotedPrintableCodec qpcodec = new QuotedPrintableCodec("UnicodeBig"); Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/RFC1522CodecTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/RFC1522CodecTest.java?rev=1087894&r1=1087893&r2=1087894&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/RFC1522CodecTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/RFC1522CodecTest.java Fri Apr 1 20:59:03 2011 @@ -17,10 +17,12 @@ package org.apache.commons.codec.net; -import junit.framework.TestCase; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; -import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.CharEncoding; +import org.apache.commons.codec.DecoderException; +import org.junit.Test; /** * RFC 1522 compliant codec test cases @@ -28,11 +30,7 @@ import org.apache.commons.codec.CharEnco * @author <a href="mailto:[email protected]">Oleg Kalnichevski</a> * @version $Id$ */ -public class RFC1522CodecTest extends TestCase { - - public RFC1522CodecTest(String name) { - super(name); - } +public class RFC1522CodecTest { static class RFC1522TestCodec extends RFC1522Codec { @@ -50,6 +48,7 @@ public class RFC1522CodecTest extends Te } + @Test public void testNullInput() throws Exception { RFC1522TestCodec testcodec = new RFC1522TestCodec(); assertNull(testcodec.decodeText(null)); @@ -66,6 +65,7 @@ public class RFC1522CodecTest extends Te } } + @Test public void testDecodeInvalid() throws Exception { assertExpectedDecoderException("whatever"); assertExpectedDecoderException("=?"); Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/URLCodecTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/URLCodecTest.java?rev=1087894&r1=1087893&r2=1087894&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/URLCodecTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/URLCodecTest.java Fri Apr 1 20:59:03 2011 @@ -17,13 +17,16 @@ package org.apache.commons.codec.net; -import java.io.UnsupportedEncodingException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; -import junit.framework.TestCase; +import java.io.UnsupportedEncodingException; +import org.apache.commons.codec.CharEncoding; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; -import org.apache.commons.codec.CharEncoding; +import org.junit.Test; /** * URL codec test cases @@ -31,7 +34,7 @@ import org.apache.commons.codec.CharEnco * @author Apache Software Foundation * @version $Id$ */ -public class URLCodecTest extends TestCase { +public class URLCodecTest { static final int SWISS_GERMAN_STUFF_UNICODE [] = { 0x47, 0x72, 0xFC, 0x65, 0x7A, 0x69, 0x5F, 0x7A, 0xE4, 0x6D, 0xE4 @@ -42,10 +45,6 @@ public class URLCodecTest extends TestCa 0x432, 0x435, 0x442 }; - public URLCodecTest(String name) { - super(name); - } - private void validateState(URLCodec urlCodec) { assertEquals(urlCodec.getEncoding(), urlCodec.getDefaultCharset()); } @@ -60,6 +59,7 @@ public class URLCodecTest extends TestCa return buffer.toString(); } + @Test public void testUTF8RoundTrip() throws Exception { String ru_msg = constructString(RUSSIAN_STUFF_UNICODE); @@ -79,6 +79,7 @@ public class URLCodecTest extends TestCa this.validateState(urlCodec); } + @Test public void testBasicEncodeDecode() throws Exception { URLCodec urlCodec = new URLCodec(); String plain = "Hello there!"; @@ -91,6 +92,7 @@ public class URLCodecTest extends TestCa } + @Test public void testSafeCharEncodeDecode() throws Exception { URLCodec urlCodec = new URLCodec(); String plain = "abc123_-.*"; @@ -103,6 +105,7 @@ public class URLCodecTest extends TestCa } + @Test public void testUnsafeEncodeDecode() throws Exception { URLCodec urlCodec = new URLCodec(); String plain = "~!@#$%^&()+{}\"\\;:`,/[]"; @@ -115,6 +118,7 @@ public class URLCodecTest extends TestCa } + @Test public void testEncodeDecodeNull() throws Exception { URLCodec urlCodec = new URLCodec(); assertNull("Null string URL encoding test", @@ -125,6 +129,7 @@ public class URLCodecTest extends TestCa } + @Test public void testDecodeInvalid() throws Exception { URLCodec urlCodec = new URLCodec(); try { @@ -156,6 +161,7 @@ public class URLCodecTest extends TestCa this.validateState(urlCodec); } + @Test public void testDecodeInvalidContent() throws UnsupportedEncodingException, DecoderException { String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE); URLCodec urlCodec = new URLCodec(); @@ -168,6 +174,7 @@ public class URLCodecTest extends TestCa this.validateState(urlCodec); } + @Test public void testEncodeNull() throws Exception { URLCodec urlCodec = new URLCodec(); byte[] plain = null; @@ -177,6 +184,7 @@ public class URLCodecTest extends TestCa this.validateState(urlCodec); } + @Test public void testEncodeUrlWithNullBitSet() throws Exception { URLCodec urlCodec = new URLCodec(); String plain = "Hello there!"; @@ -188,12 +196,14 @@ public class URLCodecTest extends TestCa this.validateState(urlCodec); } + @Test public void testDecodeWithNullArray() throws Exception { byte[] plain = null; byte[] result = URLCodec.decodeUrl( plain ); assertEquals("Result should be null", null, result); } + @Test public void testEncodeStringWithNull() throws Exception { URLCodec urlCodec = new URLCodec(); String test = null; @@ -201,6 +211,7 @@ public class URLCodecTest extends TestCa assertEquals("Result should be null", null, result); } + @Test public void testDecodeStringWithNull() throws Exception { URLCodec urlCodec = new URLCodec(); String test = null; @@ -208,6 +219,7 @@ public class URLCodecTest extends TestCa assertEquals("Result should be null", null, result); } + @Test public void testEncodeObjects() throws Exception { URLCodec urlCodec = new URLCodec(); String plain = "Hello there!"; @@ -234,6 +246,7 @@ public class URLCodecTest extends TestCa this.validateState(urlCodec); } + @Test public void testInvalidEncoding() { URLCodec urlCodec = new URLCodec("NONSENSE"); String plain = "Hello there!"; @@ -252,6 +265,7 @@ public class URLCodecTest extends TestCa this.validateState(urlCodec); } + @Test public void testDecodeObjects() throws Exception { URLCodec urlCodec = new URLCodec(); String plain = "Hello+there%21"; @@ -278,6 +292,7 @@ public class URLCodecTest extends TestCa this.validateState(urlCodec); } + @Test public void testDefaultEncoding() throws Exception { String plain = "Hello there!"; URLCodec urlCodec = new URLCodec("UnicodeBig"); Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/UtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/UtilsTest.java?rev=1087894&r1=1087893&r2=1087894&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/UtilsTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/UtilsTest.java Fri Apr 1 20:59:03 2011 @@ -17,7 +17,7 @@ package org.apache.commons.codec.net; -import junit.framework.TestCase; +import org.junit.Test; /** * Tests Utils. @@ -29,12 +29,13 @@ import junit.framework.TestCase; * @version $Id$ * @since 1.4 */ -public class UtilsTest extends TestCase { +public class UtilsTest { /** * We could make the constructor private but there does not seem to be a point to jumping through extra code hoops * to restrict instantiation right now. */ + @Test public void testConstructor() { new Utils(); }
