Source Code Cross Referenced for TestResource.java in  » Portal » Open-Portal » com » sun » portal » rewriter » util » 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.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.test;
006:
007:        import com.sun.portal.rewriter.RewriterModule;
008:        import com.sun.portal.rewriter.rom.Rule;
009:        import com.sun.portal.rewriter.test.util.BasicTestCase;
010:        import com.sun.portal.rewriter.util.Resource;
011:        import com.sun.portal.rewriter.util.StringHelper;
012:        import junit.framework.TestSuite;
013:
014:        import java.io.File;
015:        import java.util.Locale;
016:
017:        public class TestResource extends BasicTestCase {
018:            private static final String i18nRuleSetName = Locale.JAPAN
019:                    .getDisplayLanguage(Locale.JAPAN)
020:                    + "_" + Locale.CHINA.getDisplayLanguage(Locale.CHINA);
021:
022:            private static final String sampleXMLData = Rule.XML_HEADER
023:                    + "\n"
024:                    + "<RuleSet id=\"default_ruleset\">\n"
025:                    + "\n"
026:                    + "    <!-- Rules for Rewriting HTML Source -->\n"
027:                    + "    <HTMLRules>\n"
028:                    + "\n"
029:                    + "        <!-- Rules for Rewriting Form Input/Option Values List -->\n"
030:                    + "\n"
031:                    + "        <!-- Rules for Rewriting Applet/Object Parameter Values List -->\n"
032:                    + "\n"
033:                    + "        <!-- Rules for Rewriting HTML Attributes -->\n"
034:                    + "            <Attribute name=\"action\" />\n"
035:                    + "	    <Attribute name=\"background\" />\n"
036:                    + "	    <Attribute name=\"codebase\" />\n"
037:                    + "	    <Attribute name=\"href\" />\n"
038:                    + "	    <Attribute name=\"src\" />\n"
039:                    + "	    <Attribute name=\"value\" />\n"
040:                    + "	    <Attribute name=\"imagePath\" />\n"
041:                    + "	    <Attribute name=\"lowsrc\" />\n"
042:                    + "	    <Attribute name=\"archive\" />\n"
043:                    + "\n"
044:                    + "        <!-- Rules for Rewriting HTML Attributes containing Java Script -->\n"
045:                    + "            <Attribute name=\"onAbort\" type=\"DJS\"/>\n"
046:                    + "            <Attribute name=\"onBlur\" type=\"DJS\"/>\n"
047:                    + "            <Attribute name=\"onChange\" type=\"DJS\"/>\n"
048:                    + "            <Attribute name=\"onClick\" type=\"DJS\"/>\n"
049:                    + "            <Attribute name=\"onDblClick\" type=\"DJS\"/>\n"
050:                    + "            <Attribute name=\"onError\" type=\"DJS\"/>\n"
051:                    + "            <Attribute name=\"onFocus\" type=\"DJS\"/>\n"
052:                    + "            <Attribute name=\"onKeyDown\" type=\"DJS\"/>\n"
053:                    + "            <Attribute name=\"onKeyPress\" type=\"DJS\"/>\n"
054:                    + "            <Attribute name=\"onKeyUp\" type=\"DJS\"/>\n"
055:                    + "            <Attribute name=\"onLoad\" type=\"DJS\"/>\n"
056:                    + "            <Attribute name=\"onMouseDown\" type=\"DJS\"/>\n"
057:                    + "            <Attribute name=\"onMouseMove\" type=\"DJS\"/>\n"
058:                    + "            <Attribute name=\"onMouseOut\" type=\"DJS\"/>\n"
059:                    + "            <Attribute name=\"onMouseOver\" type=\"DJS\"/>\n"
060:                    + "            <Attribute name=\"onMouseUp\" type=\"DJS\"/>\n"
061:                    + "            <Attribute name=\"onReset\" type=\"DJS\"/>\n"
062:                    + "            <Attribute name=\"onSelect\" type=\"DJS\"/>\n"
063:                    + "            <Attribute name=\"onSubmit\" type=\"DJS\"/>\n"
064:                    + "            <Attribute name=\"onUnload\" type=\"DJS\"/>\n"
065:                    + "    </HTMLRules>\n"
066:                    + "\n"
067:                    + "    <!-- Rules for Rewriting JavaScript Source -->\n"
068:                    + "    <JSRules>\n"
069:                    + "\n"
070:                    + "        <!-- Rules for Rewriting JavaScript variables in URLs -->\n"
071:                    + "            <Variable name=\" imgsrc \" type=\"URL\"/>\n"
072:                    + "            <Variable name=\" location.href \" type=\"URL\"/>\n"
073:                    + "            <Variable name=\" _fr.location \" type=\"URL\"/>\n"
074:                    + "            <Variable name=\" mf.location \" type=\"URL\"/>\n"
075:                    + "            <Variable name=\" parent.location \" type=\"URL\"/>\n"
076:                    + "            <Variable name=\" self.location \" type=\"URL\"/>\n"
077:                    + "            <Variable name=\" location \" type=\"EXPRESSION\"/>\n"
078:                    + "            <Variable name=\" window.location.pathname \" type=\"SYSTEM\"/>\n"
079:                    + "\n"
080:                    + "        <!-- Rules for Rewriting JavaScript Function Parameters -->\n"
081:                    + "            <Function type=\"URL\" name=\"openURL\" paramPatterns=\"y\"/>\n"
082:                    + "            <Function type=\"URL\" name=\"openAppURL\" paramPatterns=\"y\"/>\n"
083:                    + "            <Function type=\"URL\" name=\"openNewWindow\" paramPatterns=\"y\"/>\n"
084:                    + "            <Function type=\"URL\" name=\"parent.openNewWindow\" paramPatterns=\"y\"/>\n"
085:                    + "            <Function type=\"URL\" name=\"window.open\" paramPatterns=\"y\"/>\n"
086:                    + "            <Function type=\"DHTML\" name=\"document.write\" paramPatterns=\"y\"/>\n"
087:                    + "            <Function type=\"DHTML\" name=\"document.writeln\" paramPatterns=\"y\"/>\n"
088:                    + "\n"
089:                    + "    </JSRules>\n"
090:                    + "\n"
091:                    + "    <!-- Rules for Rewriting XML Source -->\n"
092:                    + "    <XMLRules>\n"
093:                    + "\n"
094:                    + "        <!-- Rules for Rewriting Attributes -->\n"
095:                    + "            <Attribute name=\"xmlns\"/>\n"
096:                    + "            <Attribute name=\"href\" tag=\"a\"/>\n"
097:                    + "\n"
098:                    + "        <!-- Rules for Rewriting TextStrings -->\n"
099:                    + "            <TagText tag=\"baseroot\" />\n"
100:                    + "            <TagText tag=\"img\" />\n"
101:                    + "            <TagText tag=\"xsl:attribute\" attributePatterns=\"name=src\" />\n"
102:                    + "\n" + "    </XMLRules>\n" + "\n" + "</RuleSet>\n";
103:
104:            public static final String I18N_RULE_SET;
105:
106:            private String fileName;
107:
108:            static {
109:                String a = StringHelper.searchAndReplace(sampleXMLData,
110:                        "default_ruleset", i18nRuleSetName);
111:                I18N_RULE_SET = StringHelper.searchAndReplace(a, "MS932",
112:                        "UTF-8");
113:            }//static
114:
115:            public TestResource(String aName) {
116:                super (aName);
117:            }//constuctor
118:
119:            public void setUp() throws Exception {
120:                File f = File.createTempFile("TempResourceRuleSet", "xml");
121:                f.deleteOnExit();
122:                fileName = f.getAbsolutePath();
123:            }//setUp()
124:
125:            public void testRead() {
126:                Resource.save(fileName, sampleXMLData);
127:                assertEquals(sampleXMLData, Resource.read(fileName));
128:            }//testRead()
129:
130:            public void testReadBytes() {
131:                Resource.save(fileName, sampleXMLData);
132:                assertEquals(sampleXMLData, new String(Resource
133:                        .readBytes(fileName)));
134:            }//testRead()
135:
136:            public void testReadXML() throws Exception {
137:                Resource.save(fileName, sampleXMLData);
138:                String xml = Resource.readXML(fileName);
139:                assertEquals(sampleXMLData, xml);
140:            }//testRead()
141:
142:            public void testI18NReadSaveXML() {
143:                Resource.saveXML(fileName, I18N_RULE_SET);
144:                assertEquals(I18N_RULE_SET, Resource.readXML(fileName));
145:            }//testI18NReadSaveXML()
146:
147:            public void testI18NReadSaveXMLNegative() {
148:                Resource.save(fileName, I18N_RULE_SET);
149:                assertTrue(!I18N_RULE_SET.equals(Resource.readXML(fileName)));
150:            }//testI18NReadSaveXMLNegative()
151:
152:            public void testI18NReadSaveXMLNegative1() {
153:                Resource.save(fileName, I18N_RULE_SET);
154:                assertTrue(!I18N_RULE_SET.equals(Resource.read(fileName)));
155:            }//testI18NReadSaveXMLNegative1()
156:
157:            public void testI18NReadSaveXMLNegative2() {
158:                Resource.saveXML(fileName, I18N_RULE_SET);
159:                assertTrue(!I18N_RULE_SET.equals(Resource.read(fileName)));
160:            }//testI18NReadSaveXMLNegative2()
161:
162:            public static void main(String[] args) {
163:                RewriterModule.initFile();
164:                BasicTestCase.run(TestResource.class);
165:                TestSuite testSuite = new TestSuite();
166:                testSuite.addTest(new TestResource("testSplitString"));
167:                //BasicTestCase.run( testSuite );
168:            }//main()
169:
170:        }//class TestResource
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.