Source Code Cross Referenced for StringTools_replaceAll_Test.java in  » Code-Analyzer » soot » soot » util » 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 » Code Analyzer » soot » soot.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package soot.util;
002:
003:        import soot.util.StringTools;
004:        import junit.framework.Test;
005:        import junit.framework.TestCase;
006:        import junit.framework.TestSuite;
007:
008:        /**
009:         * JUnit test suite for the StringTools.replaceAll() method.
010:         */
011:        public class StringTools_replaceAll_Test extends TestCase {
012:
013:            public StringTools_replaceAll_Test(String name) {
014:                super (name);
015:            }
016:
017:            private static void runAndCompare(String orig, String toBeReplaced,
018:                    String replacement, String expected) {
019:                String result = StringTools.replaceAll(orig, toBeReplaced,
020:                        replacement);
021:                assertEquals(expected, result);
022:            }
023:
024:            public void testNoOccurrences() {
025:                runAndCompare(
026:                        "This string contains no occurrences of the pattern.",
027:                        "absent", "present",
028:                        "This string contains no occurrences of the pattern.");
029:            }
030:
031:            public void testOccurrenceAtBeginning() {
032:                runAndCompare(
033:                        "The pattern is at the beginning of this string.",
034:                        "The pattern", "A replacement",
035:                        "A replacement is at the beginning of this string.");
036:            }
037:
038:            public void testOccurrenceAtEnd() {
039:                runAndCompare("This string ends with the pattern.",
040:                        "the pattern.", "a replacement.",
041:                        "This string ends with a replacement.");
042:            }
043:
044:            public void testReplaceWholeOriginal() {
045:                runAndCompare("The whole shebang.", "The whole shebang.",
046:                        "Everything in its entirety.",
047:                        "Everything in its entirety.");
048:            }
049:
050:            public void testReplaceEverythingInPieces() {
051:                runAndCompare("old?old?old?old?old?old?old?", "old?", "new!",
052:                        "new!new!new!new!new!new!new!");
053:            }
054:
055:            public void testMultipleOccurrencesSameLength() {
056:                runAndCompare("abcOLDabcOLDabOLDOLDa", "OLD", "NEW",
057:                        "abcNEWabcNEWabNEWNEWa");
058:            }
059:
060:            public void testMultipleOccurrencesShorter() {
061:                runAndCompare("abcOLDabcOLDabOLDOLDa", "OLD", "NE",
062:                        "abcNEabcNEabNENEa");
063:            }
064:
065:            public void testMultipleOccurrencesLonger() {
066:                runAndCompare("abcOLDabcOLDabOLDOLDa", "OLD", "_REFURBISHED_",
067:                        "abc_REFURBISHED_abc_REFURBISHED_ab_REFURBISHED__REFURBISHED_a");
068:            }
069:
070:            public void testBlankReplacement() {
071:                runAndCompare("abcOLDabcOLDabOLDOLDa", "OLD", "", "abcabcaba");
072:            }
073:
074:            public void testBlankPattern() {
075:                runAndCompare("abcOLDabcOLDabOLDOLDa", "", "new",
076:                        "abcOLDabcOLDabOLDOLDa");
077:            }
078:
079:            public void testPatternLongerThanOrig() {
080:                runAndCompare("This is a string", "This is a string pattern",
081:                        "This is a string replacement", "This is a string");
082:            }
083:
084:            public void testSingleLetterPatternSingleLetterReplacement() {
085:                runAndCompare(
086:                        "in this string is a phrase in in which to replace the 'i's, including the last i",
087:                        "i",
088:                        "1",
089:                        "1n th1s str1ng 1s a phrase 1n 1n wh1ch to replace the '1's, 1nclud1ng the last 1");
090:            }
091:
092:            public void testSingleLetterPatternZeroLetterReplacement() {
093:                runAndCompare(
094:                        "in this string is a phrase in in which to replace the 'i's, including the last i",
095:                        "i", "",
096:                        "n ths strng s a phrase n n whch to replace the ''s, ncludng the last ");
097:            }
098:
099:            public void testSingleLetterPatternMultiLetterReplacement() {
100:                runAndCompare(
101:                        "in this string is a phrase in in which to replace the 'i's, including the last i",
102:                        "i",
103:                        "III",
104:                        "IIIn thIIIs strIIIng IIIs a phrase IIIn IIIn whIIIch to replace the 'III's, IIIncludIIIng the last III");
105:            }
106:
107:            public void testPatternIncludedInsideReplacement() {
108:                // This checks that including the pattern to be replaced within
109:                // the replacing text does not cause some sort of infinite loop.
110:                runAndCompare("Some old text to be folded.", "old", "embold",
111:                        "Some embold text to be fembolded.");
112:            }
113:
114:            public void testBlankOriginal() {
115:                runAndCompare("", "old", "new", "");
116:            }
117:
118:            public static Test reflectionSuite() {
119:                TestSuite suite = new TestSuite(
120:                        StringTools_replaceAll_Test.class);
121:                return suite;
122:            }
123:
124:            public static void main(String[] arg) {
125:                junit.textui.TestRunner.run(reflectionSuite());
126:            }
127:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.