Source Code Cross Referenced for TestXMLUtils.java in  » Library » Apache-commons-betwixt-0.8-src » org » apache » commons » betwixt » 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 » Library » Apache commons betwixt 0.8 src » org.apache.commons.betwixt 
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:
018:        package org.apache.commons.betwixt;
019:
020:        import junit.framework.Test;
021:        import junit.framework.TestSuite;
022:        import junit.textui.TestRunner;
023:
024:        /** Test harness for the XMLUtils
025:         *
026:         * @author Robert Burrell Donkin
027:         * @version $Revision: 438373 $
028:         */
029:        public class TestXMLUtils extends AbstractTestCase {
030:
031:            public static void main(String[] args) {
032:                TestRunner.run(suite());
033:            }
034:
035:            public static Test suite() {
036:                return new TestSuite(TestXMLUtils.class);
037:            }
038:
039:            public TestXMLUtils(String testName) {
040:                super (testName);
041:            }
042:
043:            /**
044:             * Test for some common xml naming 
045:             */
046:            public void testXMLNameTest() {
047:                // just go through some common cases to make sure code is working
048:                assertEquals("Testing name 'Name<'", false, XMLUtils
049:                        .isWellFormedXMLName("Name<"));
050:                assertEquals("Testing name 'Name>'", false, XMLUtils
051:                        .isWellFormedXMLName("Name>"));
052:                assertEquals("Testing name 'Name''", false, XMLUtils
053:                        .isWellFormedXMLName("Name'"));
054:                assertEquals("Testing name 'Name_:-.'", true, XMLUtils
055:                        .isWellFormedXMLName("Name_:-."));
056:                assertEquals("Testing name '.Name'", false, XMLUtils
057:                        .isWellFormedXMLName(".Name"));
058:                assertEquals("Testing name '-Name'", false, XMLUtils
059:                        .isWellFormedXMLName("-Name"));
060:                assertEquals("Testing name ':Name'", true, XMLUtils
061:                        .isWellFormedXMLName(":Name"));
062:                assertEquals("Testing name '_Name'", true, XMLUtils
063:                        .isWellFormedXMLName("_Name"));
064:                assertEquals("Testing name 'A0123456789Name", true, XMLUtils
065:                        .isWellFormedXMLName("A0123456789Name"));
066:            }
067:
068:            /** Test attribute escaping */
069:            public void testAttributeEscaping() {
070:                assertEquals("Escaping: <", "&lt;", XMLUtils
071:                        .escapeAttributeValue("<"));
072:                assertEquals("Escaping: >", "&gt;", XMLUtils
073:                        .escapeAttributeValue(">"));
074:                assertEquals("Escaping: '", "&apos;", XMLUtils
075:                        .escapeAttributeValue("'"));
076:                assertEquals("Escaping: \"", "&quot;", XMLUtils
077:                        .escapeAttributeValue("\""));
078:                assertEquals("Escaping: &", "&amp;", XMLUtils
079:                        .escapeAttributeValue("&"));
080:                assertEquals("Escaping: 1<", "1&lt;", XMLUtils
081:                        .escapeAttributeValue("1<"));
082:                assertEquals("Escaping: 1>", "1&gt;", XMLUtils
083:                        .escapeAttributeValue("1>"));
084:                assertEquals("Escaping: 1'", "1&apos;", XMLUtils
085:                        .escapeAttributeValue("1'"));
086:                assertEquals("Escaping: 1\"", "1&quot;", XMLUtils
087:                        .escapeAttributeValue("1\""));
088:                assertEquals("Escaping: 1&", "1&amp;", XMLUtils
089:                        .escapeAttributeValue("1&"));
090:                assertEquals("Escaping: <2", "&lt;2", XMLUtils
091:                        .escapeAttributeValue("<2"));
092:                assertEquals("Escaping: >2", "&gt;2", XMLUtils
093:                        .escapeAttributeValue(">2"));
094:                assertEquals("Escaping: '2", "&apos;2", XMLUtils
095:                        .escapeAttributeValue("'2"));
096:                assertEquals("Escaping: \"2", "&quot;2", XMLUtils
097:                        .escapeAttributeValue("\"2"));
098:                assertEquals("Escaping: &2", "&amp;2", XMLUtils
099:                        .escapeAttributeValue("&2"));
100:                assertEquals("Escaping: a<b", "a&lt;b", XMLUtils
101:                        .escapeAttributeValue("a<b"));
102:                assertEquals("Escaping: a>b", "a&gt;b", XMLUtils
103:                        .escapeAttributeValue("a>b"));
104:                assertEquals("Escaping: a'b", "a&apos;b", XMLUtils
105:                        .escapeAttributeValue("a'b"));
106:                assertEquals("Escaping: a\"b", "a&quot;b", XMLUtils
107:                        .escapeAttributeValue("a\"b"));
108:                assertEquals("Escaping: a&b", "a&amp;b", XMLUtils
109:                        .escapeAttributeValue("a&b"));
110:                assertEquals("Escaping: <<abba", "&lt;&lt;abba", XMLUtils
111:                        .escapeAttributeValue("<<abba"));
112:                assertEquals("Escaping: >>abba", "&gt;&gt;abba", XMLUtils
113:                        .escapeAttributeValue(">>abba"));
114:                assertEquals("Escaping: ''abba", "&apos;&apos;abba", XMLUtils
115:                        .escapeAttributeValue("''abba"));
116:                assertEquals("Escaping: \"\"abba", "&quot;&quot;abba", XMLUtils
117:                        .escapeAttributeValue("\"\"abba"));
118:                assertEquals("Escaping: &&abba", "&amp;&amp;abba", XMLUtils
119:                        .escapeAttributeValue("&&abba"));
120:                assertEquals("Escaping: a<>b''c\"e>f'&g",
121:                        "a&lt;&gt;b&apos;&apos;c&quot;e&gt;f&apos;&amp;g",
122:                        XMLUtils.escapeAttributeValue("a<>b''c\"e>f'&g"));
123:
124:            }
125:
126:            /** 
127:             * Test CDATA escaping 
128:             * Within a CDATA section, only the CDEnd
129:             * string ']]>' is recognized as markup.
130:             * Angle brackets and amphersands may occur in their literal form.
131:             */
132:            public void testCDATAEscaping() {
133:                assertEquals("Escaping: <", "<", XMLUtils
134:                        .escapeCDATAContent("<"));
135:                assertEquals("Escaping: >", ">", XMLUtils
136:                        .escapeCDATAContent(">"));
137:                assertEquals("Escaping: '", "'", XMLUtils
138:                        .escapeCDATAContent("'"));
139:                assertEquals("Escaping: \"", "\"", XMLUtils
140:                        .escapeCDATAContent("\""));
141:                assertEquals("Escaping: &", "&", XMLUtils
142:                        .escapeCDATAContent("&"));
143:                assertEquals("Escaping: ]]", "]]", XMLUtils
144:                        .escapeCDATAContent("]]"));
145:                assertEquals("Escaping: ]>", "]>", XMLUtils
146:                        .escapeCDATAContent("]>"));
147:                assertEquals("Escaping: ]]>", "]]&gt;", XMLUtils
148:                        .escapeCDATAContent("]]>"));
149:                assertEquals("Escaping: ]]>]]>", "]]&gt;]]&gt;", XMLUtils
150:                        .escapeCDATAContent("]]>]]>"));
151:                assertEquals("Escaping: ]>]]>", "]>]]&gt;", XMLUtils
152:                        .escapeCDATAContent("]>]]>"));
153:                assertEquals("Escaping: ]]>]]]>", "]]&gt;]]]&gt;", XMLUtils
154:                        .escapeCDATAContent("]]>]]]>"));
155:                assertEquals("Escaping: ", "", XMLUtils.escapeCDATAContent(""));
156:            }
157:
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.