Source Code Cross Referenced for TestPattern.java in  » Portal » Open-Portal » com » sun » portal » rewriter » util » re » test » 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 » Portal » Open Portal » com.sun.portal.rewriter.util.re.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:        package com.sun.portal.rewriter.util.re.test;
006:
007:        import com.sun.portal.rewriter.RewriterModule;
008:        import com.sun.portal.rewriter.test.util.BasicTestCase;
009:        import com.sun.portal.rewriter.util.re.Pattern;
010:        import junit.framework.TestSuite;
011:
012:        public class TestPattern extends BasicTestCase {
013:            public TestPattern(String aName) {
014:                super (aName);
015:            }//constuctor
016:
017:            public void testEscapedSemiColonBugNo4929669CapturesNormalBehaviour() {
018:                Object[][] lData = { { "\\\\*abc;", //Escaped Pattern
019:                        new String[] { "\\*abc;" } //tokenized
020:                        },
021:
022:                        { "\\\\*abc\\;", //Escaped Pattern
023:                                new String[] { "\\*abc\\;" } //tokenized
024:                        }, };
025:
026:                for (int i = 0; i < lData.length; i++) {
027:                    String[] lExpectation = (String[]) lData[i][1];
028:
029:                    Pattern p = new Pattern(lData[i][0].toString());
030:                    String[] lResult = p.getSubStrings();
031:                    assertEquals("Expected no of substrings does not match i="
032:                            + i, lExpectation.length, lResult.length);
033:
034:                    for (int j = 0; j < lExpectation.length; j++) {
035:                        assertEquals("Failed at pattern=" + i + ",token=," + j,
036:                                lExpectation[j], lResult[j]);
037:                    }
038:                }
039:            }//testEscapedSemiColonBugNo4929669CapturesNormalBehaviour()
040:
041:            public void testSubStrings() throws Exception {
042:                Object[][] lData = { { "\\\\*abc", //Escaped Pattern
043:                        new String[] { "\\*abc" } //tokenized
044:                        },
045:
046:                        { "\\\\ab*c", //Escaped Pattern
047:                                new String[] { "\\\\ab", "c" } //tokenized
048:                        },
049:
050:                        // Escaped Sequences
051:                        { "\\*abcdef", //source
052:                                new String[] { "*abcdef" } //tokenized
053:                        }, //5
054:
055:                        { "abcdef", //source
056:                                new String[] { "abcdef" } //tokenized
057:                        }, //0
058:
059:                        { "abc*def", //source
060:                                new String[] { "abc", "def" } //tokenized
061:                        }, //1
062:
063:                        { "abc**def", //source
064:                                new String[] { "abc", "def" } //tokenized
065:                        }, //2
066:
067:                        { "ab*cd*ef", //source
068:                                new String[] { "ab", "cd", "ef" } //tokenized
069:                        }, //3
070:
071:                        { "*abcdef", //source
072:                                new String[] { "abcdef" } //tokenized
073:                        }, //4
074:
075:                        { "abc\\*def", //source
076:                                new String[] { "abc*def" } //tokenized
077:                        }, //6
078:
079:                        { "abcd\\*", //source
080:                                new String[] { "abcd*" } //tokenized
081:                        }, //7
082:
083:                        { "ab\\**cd", //source
084:                                new String[] { "ab*", "cd" } //tokenized
085:                        }, //8
086:
087:                        { "ab\\*cd\\*ef", //source
088:                                new String[] { "ab*cd*ef" } //tokenized
089:                        }, //9
090:
091:                        { "ab\\*cd\\ef\\*gh*", //source
092:                                new String[] { "ab*cd\\ef*gh" } //tokenized
093:                        }, //10
094:
095:                        { "ab\\*cdef\\ghij*klmn\\*op", //source
096:                                new String[] { "ab*cdef\\ghij", "klmn*op" } //tokenized
097:                        }, //11
098:
099:                };
100:
101:                for (int i = 0; i < lData.length; i++) {
102:                    Pattern p = new Pattern(lData[i][0].toString());
103:                    String[] lExpectation = (String[]) lData[i][1];
104:
105:                    String[] lResult = p.getSubStrings();
106:
107:                    assertEquals("Expected no of substrings does not match i="
108:                            + i, lExpectation.length, lResult.length);
109:
110:                    for (int j = 0; j < lExpectation.length; j++) {
111:                        assertEquals("Failed at pattern=" + i + ",token=," + j,
112:                                lExpectation[j], lResult[j]);
113:                    }
114:                }
115:            }//testSubStrings()
116:
117:            public void testConver2Patterns() throws Exception {
118:                Object[][] lData = { { new String[] { "ab", "cd" }, "2" },
119:                        { new String[] { "cd" }, "1" }, };
120:
121:                for (int i = 0; i < lData.length; i++) {
122:                    Pattern[] bResult = Pattern.convert2Patterns(
123:                            (String[]) lData[i][0], true);
124:                    assertEquals((new Integer(lData[i][1].toString()))
125:                            .intValue(), bResult.length);
126:                }
127:            }//testConver2Patterns()
128:
129:            public void testConver2PatternsCornerCases() {
130:                Object[][] lData = { { null, Pattern.EMPTY_PATTERN_ARRAY },
131:                        { new String[] {}, Pattern.EMPTY_PATTERN_ARRAY }, };
132:
133:                for (int i = 0; i < lData.length; i++) {
134:                    Pattern[] bResult = Pattern
135:                            .convert2Patterns((String[]) lData[i][0]);
136:                    assertEquals(lData[i][1], bResult);
137:                }
138:            }//testConver2PatternsCornerCases()
139:
140:            public static void main(String[] args) {
141:                RewriterModule.initFile();
142:                BasicTestCase.run(TestPattern.class);
143:                TestSuite testSuite = new TestSuite();
144:                testSuite
145:                        .addTest(new TestPattern(
146:                                "testEscapedSemiColonBugNo4929669CapturesNormalBehaviour"));
147:                //BasicTestCase.run( testSuite );
148:            }//main()
149:
150:        }//class TestPattern
w_w_w___.j_av__a__2___s__.__co_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.