Source Code Cross Referenced for RefinedSoundexTest.java in  » Library » Apache-common-codec » org » apache » commons » codec » language » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache common codec » org.apache.commons.codec.language 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2004 The Apache Software Foundation.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.apache.commons.codec.language;
018:
019:        import junit.framework.Test;
020:        import junit.framework.TestSuite;
021:        import org.apache.commons.codec.EncoderException;
022:        import org.apache.commons.codec.StringEncoder;
023:        import org.apache.commons.codec.StringEncoderAbstractTest;
024:
025:        /**
026:         * Tests RefinedSoundex.
027:         * 
028:         * @version $Id: RefinedSoundexTest.java,v 1.11 2004/05/24 00:17:24 ggregory Exp $
029:         * @author Apache Software Foundation
030:         */
031:        public class RefinedSoundexTest extends StringEncoderAbstractTest {
032:
033:            public static Test suite() {
034:                return (new TestSuite(RefinedSoundexTest.class));
035:            }
036:
037:            private RefinedSoundex encoder = null;
038:
039:            public RefinedSoundexTest(String name) {
040:                super (name);
041:            }
042:
043:            /**
044:             * @return Returns the encoder.
045:             */
046:            private RefinedSoundex getEncoder() {
047:                return this .encoder;
048:            }
049:
050:            protected StringEncoder makeEncoder() {
051:                return new RefinedSoundex();
052:            }
053:
054:            /**
055:             * @param encoder
056:             *                  The encoder to set.
057:             */
058:            private void setEncoder(RefinedSoundex encoder) {
059:                this .encoder = encoder;
060:            }
061:
062:            public void setUp() throws Exception {
063:                super .setUp();
064:                this .setEncoder(new RefinedSoundex());
065:            }
066:
067:            public void tearDown() throws Exception {
068:                super .tearDown();
069:                this .setEncoder(null);
070:            }
071:
072:            public void testDifference() throws EncoderException {
073:                // Edge cases
074:                assertEquals(0, this .getEncoder().difference(null, null));
075:                assertEquals(0, this .getEncoder().difference("", ""));
076:                assertEquals(0, this .getEncoder().difference(" ", " "));
077:                // Normal cases
078:                assertEquals(6, this .getEncoder().difference("Smith", "Smythe"));
079:                assertEquals(3, this .getEncoder().difference("Ann", "Andrew"));
080:                assertEquals(1, this .getEncoder().difference("Margaret",
081:                        "Andrew"));
082:                assertEquals(1, this .getEncoder().difference("Janet",
083:                        "Margaret"));
084:                // Examples from
085:                // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_de-dz_8co5.asp
086:                assertEquals(5, this .getEncoder().difference("Green", "Greene"));
087:                assertEquals(1, this .getEncoder().difference("Blotchet-Halls",
088:                        "Greene"));
089:                // Examples from
090:                // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_setu-sus_3o6w.asp
091:                assertEquals(6, this .getEncoder().difference("Smith", "Smythe"));
092:                assertEquals(8, this .getEncoder().difference("Smithers",
093:                        "Smythers"));
094:                assertEquals(5, this .getEncoder().difference("Anothers",
095:                        "Brothers"));
096:            }
097:
098:            public void testEncode() {
099:                assertEquals("T6036084", this .getEncoder().encode("testing"));
100:                assertEquals("T6036084", this .getEncoder().encode("TESTING"));
101:                assertEquals("T60", this .getEncoder().encode("The"));
102:                assertEquals("Q503", this .getEncoder().encode("quick"));
103:                assertEquals("B1908", this .getEncoder().encode("brown"));
104:                assertEquals("F205", this .getEncoder().encode("fox"));
105:                assertEquals("J408106", this .getEncoder().encode("jumped"));
106:                assertEquals("O0209", this .getEncoder().encode("over"));
107:                assertEquals("T60", this .getEncoder().encode("the"));
108:                assertEquals("L7050", this .getEncoder().encode("lazy"));
109:                assertEquals("D6043", this .getEncoder().encode("dogs"));
110:            }
111:
112:            public void testGetMappingCodeNonLetter() {
113:                char code = this .getEncoder().getMappingCode('#');
114:                assertEquals("Code does not equals zero", 0, code);
115:            }
116:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.