Source Code Cross Referenced for WildcardMatcherHelperTestCase.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.util;
018:
019:        import java.util.Map;
020:
021:        import junit.framework.TestCase;
022:
023:        /**
024:         * @version $Id: WildcardMatcherHelperTestCase.java 448573 2006-09-21 14:52:23Z anathaniel $
025:         */
026:        public class WildcardMatcherHelperTestCase extends TestCase {
027:
028:            //~ Methods ------------------------------------------------------------------------------------
029:
030:            public void test01WildcardURIMatch() throws Exception {
031:                Map result = WildcardMatcherHelper.match("test", "test");
032:                assertNotNull(result);
033:                assertEquals("test", result.get("0"));
034:                assertNull(result.get("1"));
035:            }
036:
037:            public void test02WildcardURIMatch() throws Exception {
038:                Map result = WildcardMatcherHelper.match("end", "enp");
039:                assertNull(result);
040:            }
041:
042:            public void test03WildcardURIMatch() throws Exception {
043:                Map result = WildcardMatcherHelper.match("/t\\*d", "/t*d");
044:                assertNotNull(result);
045:                assertEquals("/t*d", result.get("0"));
046:            }
047:
048:            public void test04WildcardURIMatch() throws Exception {
049:                Map result = WildcardMatcherHelper.match("\\*d", "*d");
050:                assertNotNull(result);
051:                assertEquals("*d", result.get("0"));
052:            }
053:
054:            public void test05WildcardURIMatch() throws Exception {
055:                Map result = WildcardMatcherHelper.match("**", "*d");
056:                assertNotNull(result);
057:                assertEquals("*d", result.get("0"));
058:                assertEquals("*d", result.get("1"));
059:            }
060:
061:            public void test06WildcardURIMatch() throws Exception {
062:                Map result = WildcardMatcherHelper.match("foo**", "foo*d");
063:                assertNotNull(result);
064:                assertEquals("foo*d", result.get("0"));
065:                assertEquals("*d", result.get("1"));
066:            }
067:
068:            public void test07WildcardURIMatch() throws Exception {
069:                Map result = WildcardMatcherHelper.match("end", "en");
070:                assertNull(result);
071:            }
072:
073:            public void test08WildcardURIMatch() throws Exception {
074:                Map result = WildcardMatcherHelper.match("en", "end");
075:                assertNull(result);
076:            }
077:
078:            public void test09WildcardURIMatch() throws Exception {
079:                Map result = WildcardMatcherHelper.match("end**", "end");
080:                assertNotNull(result);
081:                assertEquals("", result.get("1"));
082:            }
083:
084:            public void test10WildcardURIMatch() throws Exception {
085:                Map result = WildcardMatcherHelper.match("end**end",
086:                        "endendend");
087:                assertNotNull(result);
088:                assertEquals("end", result.get("1"));
089:            }
090:
091:            public void test11WildcardURIMatch() throws Exception {
092:                Map result = WildcardMatcherHelper
093:                        .match("end**end", "endxxend");
094:                assertNotNull(result);
095:                assertEquals("xx", result.get("1"));
096:            }
097:
098:            public void test12WildcardURIMatch() throws Exception {
099:                Map result = WildcardMatcherHelper.match("*/end", "xx/end");
100:                assertNotNull(result);
101:                assertEquals("xx", result.get("1"));
102:            }
103:
104:            public void test13WildcardURIMatch() throws Exception {
105:                Map result = WildcardMatcherHelper.match("ab/cd*/end",
106:                        "ab/cdxx/end");
107:                assertNotNull(result);
108:                assertEquals("xx", result.get("1"));
109:            }
110:
111:            public void test14WildcardURIMatch() throws Exception {
112:                Map result = WildcardMatcherHelper.match("a*/cd*/end",
113:                        "ab/cdxx/end");
114:                assertNotNull(result);
115:                assertEquals("b", result.get("1"));
116:                assertEquals("xx", result.get("2"));
117:            }
118:
119:            public void test15WildcardURIMatch() throws Exception {
120:                Map result = WildcardMatcherHelper.match("a**/cd*/end",
121:                        "ab/yy/cdxx/end");
122:                assertNotNull(result);
123:                assertEquals("b/yy", result.get("1"));
124:                assertEquals("xx", result.get("2"));
125:            }
126:
127:            public void test16WildcardURIMatch() throws Exception {
128:                Map result = WildcardMatcherHelper.match("a**/cd*/end/*",
129:                        "ab/yy/cdxx/end/foobar/ii");
130:                assertNull(result);
131:            }
132:
133:            public void test17WildcardURIMatch() throws Exception {
134:                Map result = WildcardMatcherHelper.match("a**/cd*/end/**",
135:                        "ab/yy/cdxx/end/foobar/ii");
136:                assertNotNull(result);
137:                assertEquals("b/yy", result.get("1"));
138:                assertEquals("xx", result.get("2"));
139:                assertEquals("foobar/ii", result.get("3"));
140:            }
141:
142:            public void test18WildcardURIMatch() throws Exception {
143:                Map result = WildcardMatcherHelper.match("a**cd*/end/**",
144:                        "ab/yy/cdxx/end/foobar/ii");
145:                assertNotNull(result);
146:                assertEquals("b/yy/", result.get("1"));
147:                assertEquals("xx", result.get("2"));
148:                assertEquals("foobar/ii", result.get("3"));
149:            }
150:
151:            public void test19WildcardURIMatch() throws Exception {
152:                Map result = WildcardMatcherHelper.match("*/*.xml",
153:                        "test/something.xmlbla.xml");
154:                assertNotNull(result);
155:                assertEquals("test", result.get("1"));
156:                assertEquals("something.xmlbla", result.get("2"));
157:            }
158:
159:            public void test20WildcardURIMatch() throws Exception {
160:                Map result = WildcardMatcherHelper.match("ab/cd*/end",
161:                        "ab/cd/end");
162:                assertNotNull(result);
163:                assertEquals("", result.get("1"));
164:            }
165:
166:            public void test21WildcardURIMatch() throws Exception {
167:                Map result = WildcardMatcherHelper.match("*/**",
168:                        "samples/blocks/");
169:                assertNotNull(result);
170:                assertEquals("samples", result.get("1"));
171:                assertEquals("blocks/", result.get("2"));
172:            }
173:
174:            public void test22WildcardURIMatch() throws Exception {
175:                Map result = WildcardMatcherHelper.match("*/**", "samples/");
176:                assertNotNull(result);
177:                assertEquals("samples", result.get("1"));
178:                assertEquals("", result.get("2"));
179:            }
180:
181:            public void test23WildcardURIMatch() throws Exception {
182:                Map result = WildcardMatcherHelper.match("**favicon.ico",
183:                        "samples/");
184:                assertNull(result);
185:            }
186:
187:            public void test24WildcardURIMatch() throws Exception {
188:                Map result = WildcardMatcherHelper.match("**favicon.ico",
189:                        "samples1234/");
190:                assertNull(result);
191:            }
192:
193:            public void test25WildcardURIMatch() throws Exception {
194:                Map result = WildcardMatcherHelper.match("**favicon.ico",
195:                        "samples123/");
196:                assertNull(result);
197:            }
198:
199:            public void test26WildcardURIMatch() throws Exception {
200:                Map result = WildcardMatcherHelper.match("**/*/**",
201:                        "foo/bar/baz/bug");
202:                assertNotNull(result);
203:                assertEquals("foo/bar", result.get("1"));
204:                assertEquals("baz", result.get("2"));
205:                assertEquals("bug", result.get("3"));
206:            }
207:
208:            public void test27WildcardURIMatch() throws Exception {
209:                Map result = WildcardMatcherHelper.match("end*end*end*end",
210:                        "endXXendYendend");
211:                assertNotNull(result);
212:                assertEquals("XX", result.get("1"));
213:                assertEquals("Y", result.get("2"));
214:                assertEquals("", result.get("3"));
215:            }
216:
217:            public void test28WildcardURIMatch() throws Exception {
218:                Map result = WildcardMatcherHelper.match("end*end*end*end",
219:                        "endendendend");
220:                assertNotNull(result);
221:                assertEquals("", result.get("1"));
222:                assertEquals("", result.get("2"));
223:                assertEquals("", result.get("3"));
224:            }
225:
226:            public void test29WildcardURIMatch() throws Exception {
227:                Map result = WildcardMatcherHelper.match("end**end**end**end",
228:                        "endXXendYendend");
229:                assertNotNull(result);
230:                assertEquals("XX", result.get("1"));
231:                assertEquals("Y", result.get("2"));
232:                assertEquals("", result.get("3"));
233:            }
234:
235:            public void test30WildcardURIMatch() throws Exception {
236:                Map result = WildcardMatcherHelper.match("end**end**end**end",
237:                        "endendendend");
238:                assertNotNull(result);
239:                assertEquals("", result.get("1"));
240:                assertEquals("", result.get("2"));
241:                assertEquals("", result.get("3"));
242:            }
243:
244:            public void test31WildcardURIMatch() throws Exception {
245:                Map result = WildcardMatcherHelper.match("*/", "test/foo/bar");
246:                assertNull(result);
247:            }
248:
249:            public void test32WildcardURIMatch() throws Exception {
250:                Map result = WildcardMatcherHelper.match("**/*.html",
251:                        "foo/bar/baz.html");
252:                assertNotNull(result);
253:                assertEquals("baz", result.get("2"));
254:                assertEquals("foo/bar", result.get("1"));
255:            }
256:
257:            public void test33WildcardURIMatch() throws Exception {
258:                Map result = WildcardMatcherHelper.match("*.html",
259:                        "menu/baz.html");
260:                assertNull(result);
261:            }
262:
263:            public void test34WildcardURIMatch() throws Exception {
264:                Map result = WildcardMatcherHelper.match("*.html", "baz.html");
265:                assertNotNull(result);
266:                assertEquals("baz", result.get("1"));
267:            }
268:
269:            public void test35WildcardURIMatch() throws Exception {
270:                Map result = WildcardMatcherHelper.match("menu/**/foo_*_bar.*",
271:                        "menu//foo_baz_bar.html");
272:                assertNotNull(result);
273:                assertEquals("", result.get("1"));
274:                assertEquals("baz", result.get("2"));
275:                assertEquals("html", result.get("3"));
276:            }
277:
278:            public void test36WildcardURIMatch() throws Exception {
279:                Map result = WildcardMatcherHelper.match("menu/**/foo/*",
280:                        "menu/bar/baz.xml");
281:                assertNull(result);
282:            }
283:
284:            public void test37WildcardURIMatch() throws Exception {
285:                Map result = WildcardMatcherHelper.match("menu/*.xml",
286:                        "menu/foo/bar.xml");
287:                assertNull(result);
288:            }
289:
290:            public void test38WildcardURIMatch() throws Exception {
291:                Map result = WildcardMatcherHelper.match("\\\\foo\\*\\n\\0\\",
292:                        "\\foo*\\n\\0\\");
293:                assertNotNull(result);
294:            }
295:
296:            public void testEmptyPattern() throws Exception {
297:                assertNotNull(WildcardMatcherHelper.match("", ""));
298:                assertNull(WildcardMatcherHelper.match("", "foo"));
299:                assertNull(WildcardMatcherHelper.match("", "foo/bar"));
300:            }
301:
302:            public void testEndPattern() throws Exception {
303:                assertNotNull(WildcardMatcherHelper.match("*/", "foo/"));
304:                assertNull(WildcardMatcherHelper.match("*/", "foo/bar/"));
305:                assertNull(WildcardMatcherHelper.match("*/", "test/foo/bar/"));
306:            }
307:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.