Source Code Cross Referenced for SchemaConversionTest.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » myfaces » deployment » 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 » EJB Server geronimo » plugins » org.apache.geronimo.myfaces.deployment 
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:         */package org.apache.geronimo.myfaces.deployment;
017:
018:        import java.net.URL;
019:        import java.util.List;
020:        import java.util.ArrayList;
021:
022:        import org.apache.geronimo.testsupport.XmlBeansTestSupport;
023:        import org.apache.xmlbeans.XmlObject;
024:        import org.apache.xmlbeans.XmlOptions;
025:
026:        /**
027:         * Schema conversion tests for various faces-config XML files. These are fairly straight-forward
028:         * tests as the only tag that must be updated is the <faces-config> tab. The following DTD and XSD
029:         * schema versions are tested:
030:         *
031:         * <ol>
032:         *      <li>1.0 DTD
033:         *      <li>1.1 DTD
034:         *      <li>1.2 XSD
035:         *      <li>No schema
036:         * </ol>
037:         */
038:        public class SchemaConversionTest extends XmlBeansTestSupport {
039:
040:            private ClassLoader classLoader = this .getClass().getClassLoader();
041:            private XmlOptions options = new XmlOptions();
042:
043:            /**
044:             * Tests for empty faces-config.xml files
045:             */
046:            public void testFacesConfig10Empty() throws Exception {
047:                URL srcXML = classLoader
048:                        .getResource("1_0_dtd/faces-config-empty-src.xml");
049:                URL expectedXML = classLoader
050:                        .getResource("1_0_dtd/faces-config-empty-expected.xml");
051:                parseAndCompare(srcXML, expectedXML);
052:            }
053:
054:            public void testFacesConfig11Empty() throws Exception {
055:                URL srcXML = classLoader
056:                        .getResource("1_1_dtd/faces-config-empty-src.xml");
057:                URL expectedXML = classLoader
058:                        .getResource("1_0_dtd/faces-config-empty-expected.xml");
059:                parseAndCompare(srcXML, expectedXML);
060:            }
061:
062:            public void testFacesConfig12Empty() throws Exception {
063:                URL srcXML = classLoader
064:                        .getResource("1_2_xsd/faces-config-empty-src.xml");
065:                URL expectedXML = classLoader
066:                        .getResource("1_0_dtd/faces-config-empty-expected.xml");
067:                parseAndCompare(srcXML, expectedXML);
068:            }
069:
070:            public void testFacesConfigNoSchemaEmpty() throws Exception {
071:                URL srcXML = classLoader
072:                        .getResource("no_schema/faces-config-empty-src.xml");
073:                URL expectedXML = classLoader
074:                        .getResource("1_0_dtd/faces-config-empty-expected.xml");
075:                parseAndCompare(srcXML, expectedXML);
076:            }
077:
078:            /**
079:             * Tests for simple faces-config.xml files
080:             */
081:            public void testFacesConfig10Simple() throws Exception {
082:                URL srcXML = classLoader
083:                        .getResource("1_0_dtd/faces-config-simple-src.xml");
084:                URL expectedXML = classLoader
085:                        .getResource("1_0_dtd/faces-config-simple-expected.xml");
086:                parseAndCompare(srcXML, expectedXML);
087:            }
088:
089:            public void testFacesConfig11Simple() throws Exception {
090:                URL srcXML = classLoader
091:                        .getResource("1_1_dtd/faces-config-simple-src.xml");
092:                URL expectedXML = classLoader
093:                        .getResource("1_0_dtd/faces-config-simple-expected.xml");
094:                parseAndCompare(srcXML, expectedXML);
095:            }
096:
097:            public void testFacesConfig12Simple() throws Exception {
098:                URL srcXML = classLoader
099:                        .getResource("1_2_xsd/faces-config-simple-src.xml");
100:                URL expectedXML = classLoader
101:                        .getResource("1_0_dtd/faces-config-simple-expected.xml");
102:                parseAndCompare(srcXML, expectedXML);
103:            }
104:
105:            public void testFacesConfigNoSchemaSimple() throws Exception {
106:                URL srcXML = classLoader
107:                        .getResource("no_schema/faces-config-simple-src.xml");
108:                URL expectedXML = classLoader
109:                        .getResource("1_0_dtd/faces-config-simple-expected.xml");
110:                parseAndCompare(srcXML, expectedXML);
111:            }
112:
113:            /**
114:             * Tests for somewhat moderate faces-config.xml files
115:             */
116:            public void testFacesConfig10Moderate() throws Exception {
117:                URL srcXML = classLoader
118:                        .getResource("1_0_dtd/faces-config-moderate-src.xml");
119:                URL expectedXML = classLoader
120:                        .getResource("1_0_dtd/faces-config-moderate-expected.xml");
121:                parseAndCompare(srcXML, expectedXML);
122:            }
123:
124:            public void testFacesConfig11Moderate() throws Exception {
125:                URL srcXML = classLoader
126:                        .getResource("1_1_dtd/faces-config-moderate-src.xml");
127:                URL expectedXML = classLoader
128:                        .getResource("1_0_dtd/faces-config-moderate-expected.xml");
129:                parseAndCompare(srcXML, expectedXML);
130:            }
131:
132:            public void testFacesConfig12Moderate() throws Exception {
133:                URL srcXML = classLoader
134:                        .getResource("1_2_xsd/faces-config-moderate-src.xml");
135:                URL expectedXML = classLoader
136:                        .getResource("1_0_dtd/faces-config-moderate-expected.xml");
137:                parseAndCompare(srcXML, expectedXML);
138:            }
139:
140:            public void testFacesConfigNoSchemaModerate() throws Exception {
141:                URL srcXML = classLoader
142:                        .getResource("no_schema/faces-config-moderate-src.xml");
143:                URL expectedXML = classLoader
144:                        .getResource("1_0_dtd/faces-config-moderate-expected.xml");
145:                parseAndCompare(srcXML, expectedXML);
146:            }
147:
148:            /**
149:             * Tests for slightly more complex faces-config.xml files
150:             */
151:            public void testFacesConfig10Complex() throws Exception {
152:                URL srcXML = classLoader
153:                        .getResource("1_0_dtd/faces-config-complex-src.xml");
154:                URL expectedXML = classLoader
155:                        .getResource("1_0_dtd/faces-config-complex-expected.xml");
156:                parseAndCompare(srcXML, expectedXML);
157:            }
158:
159:            public void testFacesConfig11Complex() throws Exception {
160:                URL srcXML = classLoader
161:                        .getResource("1_1_dtd/faces-config-complex-src.xml");
162:                URL expectedXML = classLoader
163:                        .getResource("1_0_dtd/faces-config-complex-expected.xml");
164:                parseAndCompare(srcXML, expectedXML);
165:            }
166:
167:            public void testFacesConfig12Complex() throws Exception {
168:                URL srcXML = classLoader
169:                        .getResource("1_2_xsd/faces-config-complex-src.xml");
170:                URL expectedXML = classLoader
171:                        .getResource("1_0_dtd/faces-config-complex-expected.xml");
172:                parseAndCompare(srcXML, expectedXML);
173:            }
174:
175:            public void testFacesConfigNoSchemaComplex() throws Exception {
176:                URL srcXML = classLoader
177:                        .getResource("no_schema/faces-config-complex-src.xml");
178:                URL expectedXML = classLoader
179:                        .getResource("1_0_dtd/faces-config-complex-expected.xml");
180:                parseAndCompare(srcXML, expectedXML);
181:            }
182:
183:            /**
184:             * Common logic
185:             */
186:            private void parseAndCompare(URL srcXML, URL expectedXML)
187:                    throws Exception {
188:                XmlObject xmlObject = XmlObject.Factory.parse(srcXML, options);
189:                xmlObject = MyFacesModuleBuilderExtension
190:                        .convertToFacesConfigSchema(xmlObject);
191:                XmlObject expected = XmlObject.Factory.parse(expectedXML);
192:                log.debug("[Source XML] " + '\n' + xmlObject.toString() + '\n');
193:                log.debug("[Expected XML]" + '\n' + expected.toString() + '\n');
194:                List problems = new ArrayList();
195:                boolean ok = compareXmlObjects(xmlObject, expected, problems);
196:                assertTrue("Differences: " + problems, ok);
197:                xmlObject = MyFacesModuleBuilderExtension
198:                        .convertToFacesConfigSchema(xmlObject);
199:                boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
200:                assertTrue("Differences: " + problems, ok2);
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.