diff --git a/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java b/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java index 0bc3e68a45..98699f511d 100644 --- a/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java +++ b/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java @@ -31,24 +31,24 @@ public class MetaphoneTest extends AbstractStringEncoderTest { public void assertIsMetaphoneEqual(final String source, final String[] matches) { // match source to all matches for (final String matche : matches) { - assertTrue(this.getStringEncoder().isMetaphoneEqual(source, matche), "Source: " + source + ", should have same Metaphone as: " + matche); + assertTrue(getStringEncoder().isMetaphoneEqual(source, matche), "Source: " + source + ", should have same Metaphone as: " + matche); } // match to each other for (final String matche : matches) { for (final String matche2 : matches) { - assertTrue(this.getStringEncoder().isMetaphoneEqual(matche, matche2)); + assertTrue(getStringEncoder().isMetaphoneEqual(matche, matche2)); } } } public void assertMetaphoneEqual(final String[][] pairs) { - this.validateFixture(pairs); + validateFixture(pairs); for (final String[] pair : pairs) { final String name0 = pair[0]; final String name1 = pair[1]; final String failMsg = "Expected match between " + name0 + " and " + name1; - assertTrue(this.getStringEncoder().isMetaphoneEqual(name0, name1), failMsg); - assertTrue(this.getStringEncoder().isMetaphoneEqual(name1, name0), failMsg); + assertTrue(getStringEncoder().isMetaphoneEqual(name0, name1), failMsg); + assertTrue(getStringEncoder().isMetaphoneEqual(name1, name0), failMsg); } } @@ -59,35 +59,35 @@ protected Metaphone createStringEncoder() { @Test public void testDiscardOfSCEOrSCIOrSCY() { - assertEquals("SNS", this.getStringEncoder().metaphone("SCIENCE")); - assertEquals("SN", this.getStringEncoder().metaphone("SCENE")); - assertEquals("S", this.getStringEncoder().metaphone("SCY")); + assertEquals("SNS", getStringEncoder().metaphone("SCIENCE")); + assertEquals("SN", getStringEncoder().metaphone("SCENE")); + assertEquals("S", getStringEncoder().metaphone("SCY")); } @Test public void testDiscardOfSilentGN() { // NOTE: This does not test for silent GN, but for starting with GN - assertEquals("N", this.getStringEncoder().metaphone("GNU")); + assertEquals("N", getStringEncoder().metaphone("GNU")); // NOTE: Trying to test for GNED, but expected code does not appear to execute - assertEquals("SNT", this.getStringEncoder().metaphone("SIGNED")); + assertEquals("SNT", getStringEncoder().metaphone("SIGNED")); } @Test public void testDiscardOfSilentHAfterG() { - assertEquals("KNT", this.getStringEncoder().metaphone("GHENT")); - assertEquals("B", this.getStringEncoder().metaphone("BAUGH")); + assertEquals("KNT", getStringEncoder().metaphone("GHENT")); + assertEquals("B", getStringEncoder().metaphone("BAUGH")); } @Test public void testExceedLength() { // should be AKSKS, but is truncated by Max Code Length - assertEquals("AKSK", this.getStringEncoder().metaphone("AXEAXE")); + assertEquals("AKSK", getStringEncoder().metaphone("AXEAXE")); } @Test public void testIsMetaphoneEqual1() { - this.assertMetaphoneEqual(new String[][] { { "Case", "case" }, { "CASE", "Case" }, { "caSe", "cAsE" }, { "quick", "cookie" } }); + assertMetaphoneEqual(new String[][] { { "Case", "case" }, { "CASE", "Case" }, { "caSe", "cAsE" }, { "quick", "cookie" } }); } /** @@ -95,7 +95,7 @@ public void testIsMetaphoneEqual1() { */ @Test public void testIsMetaphoneEqual2() { - this.assertMetaphoneEqual(new String[][] { { "Lawrence", "Lorenza" }, { "Gary", "Cahra" }, }); + assertMetaphoneEqual(new String[][] { { "Lawrence", "Lorenza" }, { "Gary", "Cahra" }, }); } /** @@ -105,7 +105,7 @@ public void testIsMetaphoneEqual2() { */ @Test public void testIsMetaphoneEqualAero() { - this.assertIsMetaphoneEqual("Aero", new String[] { "Eure" }); + assertIsMetaphoneEqual("Aero", new String[] { "Eure" }); } /** @@ -115,7 +115,7 @@ public void testIsMetaphoneEqualAero() { */ @Test public void testIsMetaphoneEqualAlbert() { - this.assertIsMetaphoneEqual("Albert", new String[] { "Ailbert", "Alberik", "Albert", "Alberto", "Albrecht" }); + assertIsMetaphoneEqual("Albert", new String[] { "Ailbert", "Alberik", "Albert", "Alberto", "Albrecht" }); } /** @@ -123,7 +123,7 @@ public void testIsMetaphoneEqualAlbert() { */ @Test public void testIsMetaphoneEqualGary() { - this.assertIsMetaphoneEqual("Gary", + assertIsMetaphoneEqual("Gary", new String[] { "Cahra", "Cara", "Carey", "Cari", "Caria", "Carie", "Caro", "Carree", "Carri", "Carrie", "Carry", "Cary", "Cora", "Corey", "Cori", "Corie", "Correy", "Corri", "Corrie", "Corry", "Cory", "Gray", "Kara", "Kare", "Karee", "Kari", "Karia", "Karie", "Karrah", "Karrie", "Karry", "Kary", "Keri", "Kerri", "Kerrie", "Kerry", "Kira", "Kiri", "Kora", "Kore", "Kori", "Korie", "Korrie", "Korry" }); @@ -134,7 +134,7 @@ public void testIsMetaphoneEqualGary() { */ @Test public void testIsMetaphoneEqualJohn() { - this.assertIsMetaphoneEqual("John", + assertIsMetaphoneEqual("John", new String[] { "Gena", "Gene", "Genia", "Genna", "Genni", "Gennie", "Genny", "Giana", "Gianna", "Gina", "Ginni", "Ginnie", "Ginny", "Jaine", "Jan", "Jana", "Jane", "Janey", "Jania", "Janie", "Janna", "Jany", "Jayne", "Jean", "Jeana", "Jeane", "Jeanie", "Jeanna", "Jeanne", "Jeannie", "Jen", "Jena", "Jeni", "Jenn", "Jenna", "Jennee", "Jenni", "Jennie", "Jenny", "Jinny", "Jo Ann", "Jo-Ann", "Jo-Anne", "Joan", @@ -149,7 +149,7 @@ public void testIsMetaphoneEqualJohn() { */ @Test public void testIsMetaphoneEqualKnight() { - this.assertIsMetaphoneEqual("Knight", new String[] { "Hynda", "Nada", "Nadia", "Nady", "Nat", "Nata", "Natty", "Neda", "Nedda", "Nedi", "Netta", + assertIsMetaphoneEqual("Knight", new String[] { "Hynda", "Nada", "Nadia", "Nady", "Nat", "Nata", "Natty", "Neda", "Nedda", "Nedi", "Netta", "Netti", "Nettie", "Netty", "Nita", "Nydia" }); } @@ -158,7 +158,7 @@ public void testIsMetaphoneEqualKnight() { */ @Test public void testIsMetaphoneEqualMary() { - this.assertIsMetaphoneEqual("Mary", new String[] { "Mair", "Maire", "Mara", "Mareah", "Mari", "Maria", "Marie", "Mary", "Maura", "Maure", "Meara", + assertIsMetaphoneEqual("Mary", new String[] { "Mair", "Maire", "Mara", "Mareah", "Mari", "Maria", "Marie", "Mary", "Maura", "Maure", "Meara", "Merrie", "Merry", "Mira", "Moira", "Mora", "Moria", "Moyra", "Muire", "Myra", "Myrah" }); } @@ -167,7 +167,7 @@ public void testIsMetaphoneEqualMary() { */ @Test public void testIsMetaphoneEqualParis() { - this.assertIsMetaphoneEqual("Paris", new String[] { "Pearcy", "Perris", "Piercy", "Pierz", "Pryse" }); + assertIsMetaphoneEqual("Paris", new String[] { "Pearcy", "Perris", "Piercy", "Pierz", "Pryse" }); } /** @@ -175,7 +175,7 @@ public void testIsMetaphoneEqualParis() { */ @Test public void testIsMetaphoneEqualPeter() { - this.assertIsMetaphoneEqual("Peter", new String[] { "Peadar", "Peder", "Pedro", "Peter", "Petr", "Peyter", "Pieter", "Pietro", "Piotr" }); + assertIsMetaphoneEqual("Peter", new String[] { "Peadar", "Peder", "Pedro", "Peter", "Petr", "Peyter", "Pieter", "Pietro", "Piotr" }); } /** @@ -183,7 +183,7 @@ public void testIsMetaphoneEqualPeter() { */ @Test public void testIsMetaphoneEqualRay() { - this.assertIsMetaphoneEqual("Ray", new String[] { "Ray", "Rey", "Roi", "Roy", "Ruy" }); + assertIsMetaphoneEqual("Ray", new String[] { "Ray", "Rey", "Roi", "Roy", "Ruy" }); } /** @@ -191,7 +191,7 @@ public void testIsMetaphoneEqualRay() { */ @Test public void testIsMetaphoneEqualSusan() { - this.assertIsMetaphoneEqual("Susan", + assertIsMetaphoneEqual("Susan", new String[] { "Siusan", "Sosanna", "Susan", "Susana", "Susann", "Susanna", "Susannah", "Susanne", "Suzann", "Suzanna", "Suzanne", "Zuzana" }); } @@ -202,7 +202,7 @@ public void testIsMetaphoneEqualSusan() { */ @Test public void testIsMetaphoneEqualWhite() { - this.assertIsMetaphoneEqual("White", + assertIsMetaphoneEqual("White", new String[] { "Wade", "Wait", "Waite", "Wat", "Whit", "Wiatt", "Wit", "Wittie", "Witty", "Wood", "Woodie", "Woody" }); } @@ -213,7 +213,7 @@ public void testIsMetaphoneEqualWhite() { */ @Test public void testIsMetaphoneEqualWright() { - this.assertIsMetaphoneEqual("Wright", new String[] { "Rota", "Rudd", "Ryde" }); + assertIsMetaphoneEqual("Wright", new String[] { "Rota", "Rudd", "Ryde" }); } /** @@ -221,69 +221,69 @@ public void testIsMetaphoneEqualWright() { */ @Test public void testIsMetaphoneEqualXalan() { - this.assertIsMetaphoneEqual("Xalan", new String[] { "Celene", "Celina", "Celine", "Selena", "Selene", "Selina", "Seline", "Suellen", "Xylina" }); + assertIsMetaphoneEqual("Xalan", new String[] { "Celene", "Celina", "Celine", "Selena", "Selene", "Selina", "Seline", "Suellen", "Xylina" }); } @Test public void testMetaphone() { - assertEquals("HL", this.getStringEncoder().metaphone("howl")); - assertEquals("TSTN", this.getStringEncoder().metaphone("testing")); - assertEquals("0", this.getStringEncoder().metaphone("The")); - assertEquals("KK", this.getStringEncoder().metaphone("quick")); - assertEquals("BRN", this.getStringEncoder().metaphone("brown")); - assertEquals("FKS", this.getStringEncoder().metaphone("fox")); - assertEquals("JMPT", this.getStringEncoder().metaphone("jumped")); - assertEquals("OFR", this.getStringEncoder().metaphone("over")); - assertEquals("0", this.getStringEncoder().metaphone("the")); - assertEquals("LS", this.getStringEncoder().metaphone("lazy")); - assertEquals("TKS", this.getStringEncoder().metaphone("dogs")); + assertEquals("HL", getStringEncoder().metaphone("howl")); + assertEquals("TSTN", getStringEncoder().metaphone("testing")); + assertEquals("0", getStringEncoder().metaphone("The")); + assertEquals("KK", getStringEncoder().metaphone("quick")); + assertEquals("BRN", getStringEncoder().metaphone("brown")); + assertEquals("FKS", getStringEncoder().metaphone("fox")); + assertEquals("JMPT", getStringEncoder().metaphone("jumped")); + assertEquals("OFR", getStringEncoder().metaphone("over")); + assertEquals("0", getStringEncoder().metaphone("the")); + assertEquals("LS", getStringEncoder().metaphone("lazy")); + assertEquals("TKS", getStringEncoder().metaphone("dogs")); } @Test public void testPHTOF() { - assertEquals("FX", this.getStringEncoder().metaphone("PHISH")); + assertEquals("FX", getStringEncoder().metaphone("PHISH")); } @Test public void testSetMaxLengthWithTruncation() { // should be AKSKS, but istruncated by Max Code Length - this.getStringEncoder().setMaxCodeLen(6); - assertEquals("AKSKSK", this.getStringEncoder().metaphone("AXEAXEAXE")); + getStringEncoder().setMaxCodeLen(6); + assertEquals("AKSKSK", getStringEncoder().metaphone("AXEAXEAXE")); } @Test public void testSHAndSIOAndSIAToX() { - assertEquals("XT", this.getStringEncoder().metaphone("SHOT")); - assertEquals("OTXN", this.getStringEncoder().metaphone("ODSIAN")); - assertEquals("PLXN", this.getStringEncoder().metaphone("PULSION")); + assertEquals("XT", getStringEncoder().metaphone("SHOT")); + assertEquals("OTXN", getStringEncoder().metaphone("ODSIAN")); + assertEquals("PLXN", getStringEncoder().metaphone("PULSION")); } @Test public void testTCH() { - assertEquals("RX", this.getStringEncoder().metaphone("RETCH")); - assertEquals("WX", this.getStringEncoder().metaphone("WATCH")); + assertEquals("RX", getStringEncoder().metaphone("RETCH")); + assertEquals("WX", getStringEncoder().metaphone("WATCH")); } @Test public void testTIOAndTIAToX() { - assertEquals("OX", this.getStringEncoder().metaphone("OTIA")); - assertEquals("PRXN", this.getStringEncoder().metaphone("PORTION")); + assertEquals("OX", getStringEncoder().metaphone("OTIA")); + assertEquals("PRXN", getStringEncoder().metaphone("PORTION")); } @Test public void testTranslateOfSCHAndCH() { - assertEquals("SKTL", this.getStringEncoder().metaphone("SCHEDULE")); - assertEquals("SKMT", this.getStringEncoder().metaphone("SCHEMATIC")); + assertEquals("SKTL", getStringEncoder().metaphone("SCHEDULE")); + assertEquals("SKMT", getStringEncoder().metaphone("SCHEMATIC")); - assertEquals("KRKT", this.getStringEncoder().metaphone("CHARACTER")); - assertEquals("TX", this.getStringEncoder().metaphone("TEACH")); + assertEquals("KRKT", getStringEncoder().metaphone("CHARACTER")); + assertEquals("TX", getStringEncoder().metaphone("TEACH")); } @Test public void testTranslateToJOfDGEOrDGIOrDGY() { - assertEquals("TJ", this.getStringEncoder().metaphone("DODGY")); - assertEquals("TJ", this.getStringEncoder().metaphone("DODGE")); - assertEquals("AJMT", this.getStringEncoder().metaphone("ADGIEMTI")); + assertEquals("TJ", getStringEncoder().metaphone("DODGY")); + assertEquals("TJ", getStringEncoder().metaphone("DODGE")); + assertEquals("AJMT", getStringEncoder().metaphone("ADGIEMTI")); } /** @@ -292,19 +292,19 @@ public void testTranslateToJOfDGEOrDGIOrDGY() { @Test public void testWhy() { // PHP returns "H". The original metaphone returns an empty string. - assertEquals("", this.getStringEncoder().metaphone("WHY")); + assertEquals("", getStringEncoder().metaphone("WHY")); } @Test public void testWordEndingInMB() { - assertEquals("KM", this.getStringEncoder().metaphone("COMB")); - assertEquals("TM", this.getStringEncoder().metaphone("TOMB")); - assertEquals("WM", this.getStringEncoder().metaphone("WOMB")); + assertEquals("KM", getStringEncoder().metaphone("COMB")); + assertEquals("TM", getStringEncoder().metaphone("TOMB")); + assertEquals("WM", getStringEncoder().metaphone("WOMB")); } @Test public void testWordsWithCIA() { - assertEquals("XP", this.getStringEncoder().metaphone("CIAPO")); + assertEquals("XP", getStringEncoder().metaphone("CIAPO")); } public void validateFixture(final String[][] pairs) {