Source Code Cross Referenced for TestRewriterPool.java in  » Portal » Open-Portal » com » sun » portal » rewriter » 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.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.test;
006:
007:        import com.sun.portal.rewriter.Rewriter;
008:        import com.sun.portal.rewriter.RewriterModule;
009:        import com.sun.portal.rewriter.RewriterPool;
010:        import com.sun.portal.rewriter.engines.AbstractRewriter;
011:        import com.sun.portal.rewriter.engines.LanguageConstants;
012:        import com.sun.portal.rewriter.rom.RuleSet;
013:        import com.sun.portal.rewriter.rom.RuleSetManager;
014:        import com.sun.portal.rewriter.test.util.BasicTestCase;
015:        import com.sun.portal.rewriter.test.util.CreateRuleSet;
016:        import com.sun.portal.rewriter.util.Resource;
017:        import com.sun.portal.rewriter.util.uri.PageSpec;
018:
019:        public class TestRewriterPool extends BasicTestCase {
020:            public TestRewriterPool(String aName) {
021:                super (aName);
022:            }//constructor
023:
024:            public void testCreateRewriter() throws Exception {
025:                Rewriter lRewriter = RewriterPool
026:                        .create(
027:                                Resource
028:                                        .read(RewriterModule.RESOURCE_GENERIC_RULESET_LOCATION),
029:                                "aad");
030:                assertNull(lRewriter);
031:            }//testCreateRewriter()
032:
033:            public void testRewriterInstance() throws Exception {
034:                //store some known id ruleset
035:                RuleSet testRuleSet = CreateRuleSet.emptyRuleSet();
036:                String xmlString = testRuleSet.toXML();
037:                RuleSetManager.getDefault().store(xmlString);
038:                assertTrue(RuleSetManager.getDefault().matchesWithID(xmlString) != null);
039:
040:                //then call the get instance with that id
041:                PageSpec lSpec = new PageSpec("http://raja/",
042:                        LanguageConstants.MARKUP_MIME);
043:                Rewriter lRewriter = RewriterPool.getDefault().getRewriter(
044:                        testRuleSet.getID(), lSpec);
045:                assertNotNull(lRewriter);
046:                assertEquals(LanguageConstants.MARKUP_MIME,
047:                        ((AbstractRewriter) lRewriter).getMIME());
048:
049:                lSpec = new PageSpec("http://raja/",
050:                        LanguageConstants.HTML_MIME);
051:                lRewriter = RewriterPool.getDefault().getRewriter(
052:                        testRuleSet.getID(), lSpec);
053:                assertNotNull(lRewriter);
054:                assertEquals(LanguageConstants.HTML_MIME,
055:                        ((AbstractRewriter) lRewriter).getMIME());
056:
057:                lSpec = new PageSpec("http://raja/", LanguageConstants.JS_MIME);
058:                lRewriter = RewriterPool.getDefault().getRewriter(
059:                        testRuleSet.getID(), lSpec);
060:                assertNotNull(lRewriter);
061:                assertEquals(LanguageConstants.JS_MIME,
062:                        ((AbstractRewriter) lRewriter).getMIME());
063:
064:                lSpec = new PageSpec("http://raja/", LanguageConstants.XML_MIME);
065:                lRewriter = RewriterPool.getDefault().getRewriter(
066:                        testRuleSet.getID(), lSpec);
067:                assertNotNull(lRewriter);
068:                assertEquals(LanguageConstants.XML_MIME,
069:                        ((AbstractRewriter) lRewriter).getMIME());
070:
071:                lSpec = new PageSpec("http://raja/", LanguageConstants.CSS_MIME);
072:                lRewriter = RewriterPool.getDefault().getRewriter(
073:                        testRuleSet.getID(), lSpec);
074:                assertNotNull(lRewriter);
075:                assertEquals(LanguageConstants.CSS_MIME,
076:                        ((AbstractRewriter) lRewriter).getMIME());
077:
078:                //WML rewriter returns HTML rewriter - internal implemantation
079:                lSpec = new PageSpec("http://raja/", "text/wml");
080:                lRewriter = RewriterPool.getDefault().getRewriter(
081:                        testRuleSet.getID(), lSpec);
082:                assertNull(lRewriter);
083:
084:                //WML rewriter returns HTML rewriter - internal implemantation
085:                lSpec = new PageSpec("http://raja/", "text/vnd.wap.wml");
086:                lRewriter = RewriterPool.getDefault().getRewriter(
087:                        testRuleSet.getID(), lSpec);
088:                assertNull(lRewriter);
089:
090:                //no rewriter exits for this mime type
091:                lSpec = new PageSpec("http://raja/", "zip");
092:                lRewriter = RewriterPool.getDefault().getRewriter(
093:                        testRuleSet.getID(), lSpec);
094:                assertNull(lRewriter);
095:
096:                lSpec = new PageSpec("http://raja/", "xyZ");
097:                lRewriter = RewriterPool.getDefault().getRewriter(
098:                        testRuleSet.getID(), lSpec);
099:                assertNull(lRewriter);
100:
101:                //guess mime from file extenstion
102:                lSpec = new PageSpec("http://raja/ABC.HTML", "");
103:                lRewriter = RewriterPool.getDefault().getRewriter(
104:                        testRuleSet.getID(), lSpec);
105:                assertNotNull("Derived Mime is : " + lSpec.getMIME(), lRewriter);
106:                assertEquals(LanguageConstants.HTML_MIME,
107:                        ((AbstractRewriter) lRewriter).getMIME());
108:
109:                lSpec = new PageSpec("http://raja/ABC.htm", "");
110:                lRewriter = RewriterPool.getDefault().getRewriter(
111:                        testRuleSet.getID(), lSpec);
112:                assertNotNull("Derived Mime is : " + lSpec.getMIME(), lRewriter);
113:                assertEquals(LanguageConstants.HTML_MIME,
114:                        ((AbstractRewriter) lRewriter).getMIME());
115:
116:                lSpec = new PageSpec("http://raja/ABC.jS", "");
117:                lRewriter = RewriterPool.getDefault().getRewriter(
118:                        testRuleSet.getID(), lSpec);
119:                assertNotNull("Derived Mime is : " + lSpec.getMIME(), lRewriter);
120:                assertEquals(LanguageConstants.JS_MIME,
121:                        ((AbstractRewriter) lRewriter).getMIME());
122:
123:                lSpec = new PageSpec("http://raja/ABC.wMl", "");
124:                lRewriter = RewriterPool.getDefault().getRewriter(
125:                        testRuleSet.getID(), lSpec);
126:                assertNull("Derived Mime is : " + lSpec.getMIME(), lRewriter);
127:
128:                lSpec = new PageSpec("http://raja/ABC.CsS", "");
129:                lRewriter = RewriterPool.getDefault().getRewriter(
130:                        testRuleSet.getID(), lSpec);
131:                assertNotNull("Derived Mime is : " + lSpec.getMIME(), lRewriter);
132:                assertEquals(LanguageConstants.CSS_MIME,
133:                        ((AbstractRewriter) lRewriter).getMIME());
134:
135:                lSpec = new PageSpec("http://raja/ABC.xml", "");
136:                lRewriter = RewriterPool.getDefault().getRewriter(
137:                        testRuleSet.getID(), lSpec);
138:                assertNotNull("Derived Mime is : " + lSpec.getMIME(), lRewriter);
139:                assertEquals(LanguageConstants.XML_MIME,
140:                        ((AbstractRewriter) lRewriter).getMIME());
141:
142:                //clean the stored ruleset
143:                RuleSetManager.getDefault().delete(testRuleSet.getID());
144:                assertTrue(RuleSetManager.getDefault().matchesWithID(xmlString) == null);
145:            }//testRewriterInstance()
146:
147:            public static void main(String[] args) {
148:                BasicTestCase.run(TestRewriterPool.class);
149:            }//main()
150:
151:        }//class TestRewriterPool
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.