Source Code Cross Referenced for TestSchemaTranscriber.java in  » Library » Apache-commons-betwixt-0.8-src » org » apache » commons » betwixt » schema » 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.schema 
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.schema;
019:
020:        import org.apache.commons.betwixt.AbstractTestCase;
021:        import org.apache.commons.betwixt.strategy.HyphenatedNameMapper;
022:
023:        /**
024:         * Tests for the SchemaTranscriber.
025:         * @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a>
026:         * @version $Revision: 438373 $
027:         */
028:        public class TestSchemaTranscriber extends AbstractTestCase {
029:
030:            public TestSchemaTranscriber(String testName) {
031:                super (testName);
032:            }
033:
034:            public void testEmpty() {
035:            }
036:
037:            public void testSimplestBeanAttribute() throws Exception {
038:                Schema expected = new Schema();
039:
040:                GlobalComplexType simplestBeanType = new GlobalComplexType();
041:                simplestBeanType
042:                        .setName("org.apache.commons.betwixt.schema.SimplestBean");
043:                simplestBeanType.addAttribute(new Attribute("name",
044:                        "xsd:string"));
045:
046:                GlobalElement root = new GlobalElement("SimplestBean",
047:                        "org.apache.commons.betwixt.schema.SimplestBean");
048:                expected.addComplexType(simplestBeanType);
049:                expected.addElement(root);
050:
051:                SchemaTranscriber transcriber = new SchemaTranscriber();
052:                transcriber.getXMLIntrospector().getConfiguration()
053:                        .setAttributesForPrimitives(true);
054:                Schema out = transcriber.generate(SimplestBean.class);
055:
056:                assertEquals("Simplest bean schema", expected, out);
057:            }
058:
059:            public void testSimplestBeanElement() throws Exception {
060:                Schema expected = new Schema();
061:
062:                GlobalComplexType simplestBeanType = new GlobalComplexType();
063:                simplestBeanType
064:                        .setName("org.apache.commons.betwixt.schema.SimplestElementBean");
065:                simplestBeanType.addElement(new SimpleLocalElement("name",
066:                        "xsd:string"));
067:
068:                GlobalElement root = new GlobalElement("SimplestBean",
069:                        "org.apache.commons.betwixt.schema.SimplestElementBean");
070:                expected.addComplexType(simplestBeanType);
071:                expected.addElement(root);
072:
073:                SchemaTranscriber transcriber = new SchemaTranscriber();
074:                transcriber.getXMLIntrospector().getConfiguration()
075:                        .setAttributesForPrimitives(false);
076:                Schema out = transcriber.generate(SimplestElementBean.class);
077:
078:                assertEquals("Simplest bean schema", expected, out);
079:            }
080:
081:            public void testSimpleBean() throws Exception {
082:                SchemaTranscriber transcriber = new SchemaTranscriber();
083:                Schema out = transcriber.generate(SimpleBean.class);
084:
085:                Schema expected = new Schema();
086:                GlobalComplexType simpleBeanType = new GlobalComplexType();
087:                simpleBeanType
088:                        .setName("org.apache.commons.betwixt.schema.SimpleBean");
089:                simpleBeanType.addAttribute(new Attribute("one", "xsd:string"));
090:                simpleBeanType.addAttribute(new Attribute("two", "xsd:string"));
091:                simpleBeanType.addElement(new SimpleLocalElement("three",
092:                        "xsd:string"));
093:                simpleBeanType.addElement(new SimpleLocalElement("four",
094:                        "xsd:string"));
095:                expected.addComplexType(simpleBeanType);
096:                expected.addElement(new GlobalElement("simple",
097:                        "org.apache.commons.betwixt.schema.SimpleBean"));
098:
099:                assertEquals("Simple bean schema", expected, out);
100:
101:            }
102:
103:            public void testOrderLine() throws Exception {
104:                SchemaTranscriber transcriber = new SchemaTranscriber();
105:                transcriber.getXMLIntrospector().getConfiguration()
106:                        .setAttributeNameMapper(new HyphenatedNameMapper());
107:                transcriber.getXMLIntrospector().getConfiguration()
108:                        .setAttributesForPrimitives(true);
109:                Schema out = transcriber.generate(OrderLineBean.class);
110:
111:                Schema expected = new Schema();
112:
113:                GlobalComplexType productBeanType = new GlobalComplexType();
114:                productBeanType.setName(ProductBean.class.getName());
115:                productBeanType.addAttribute(new Attribute("barcode",
116:                        "xsd:string"));
117:                productBeanType
118:                        .addAttribute(new Attribute("code", "xsd:string"));
119:                productBeanType
120:                        .addAttribute(new Attribute("name", "xsd:string"));
121:                productBeanType.addAttribute(new Attribute("display-name",
122:                        "xsd:string"));
123:                expected.addComplexType(productBeanType);
124:
125:                GlobalComplexType orderLineType = new GlobalComplexType();
126:                orderLineType.setName(OrderLineBean.class.getName());
127:                orderLineType.addAttribute(new Attribute("quantity",
128:                        "xsd:string"));
129:                orderLineType.addElement(new ElementReference("product",
130:                        productBeanType));
131:                expected.addComplexType(orderLineType);
132:                expected.addElement(new GlobalElement("OrderLineBean",
133:                        OrderLineBean.class.getName()));
134:
135:                assertEquals("Transcriber schema", expected, out);
136:            }
137:
138:            public void testOrder() throws Exception {
139:                SchemaTranscriber transcriber = new SchemaTranscriber();
140:                transcriber.getXMLIntrospector().getConfiguration()
141:                        .setElementNameMapper(new HyphenatedNameMapper());
142:                transcriber.getXMLIntrospector().getConfiguration()
143:                        .setAttributeNameMapper(new HyphenatedNameMapper());
144:                transcriber.getXMLIntrospector().getConfiguration()
145:                        .setAttributesForPrimitives(true);
146:                transcriber.getXMLIntrospector().getConfiguration()
147:                        .setWrapCollectionsInElement(false);
148:                Schema out = transcriber.generate(OrderBean.class);
149:
150:                Schema expected = new Schema();
151:
152:                GlobalComplexType customerBeanType = new GlobalComplexType();
153:                customerBeanType.setName(CustomerBean.class.getName());
154:                customerBeanType.addAttribute(new Attribute("code",
155:                        "xsd:string"));
156:                customerBeanType.addAttribute(new Attribute("name",
157:                        "xsd:string"));
158:                customerBeanType.addAttribute(new Attribute("street",
159:                        "xsd:string"));
160:                customerBeanType.addAttribute(new Attribute("town",
161:                        "xsd:string"));
162:                customerBeanType.addAttribute(new Attribute("country",
163:                        "xsd:string"));
164:                customerBeanType.addAttribute(new Attribute("postcode",
165:                        "xsd:string"));
166:                expected.addComplexType(customerBeanType);
167:
168:                GlobalComplexType productBeanType = new GlobalComplexType();
169:                productBeanType.setName(ProductBean.class.getName());
170:                productBeanType.addAttribute(new Attribute("barcode",
171:                        "xsd:string"));
172:                productBeanType
173:                        .addAttribute(new Attribute("code", "xsd:string"));
174:                productBeanType
175:                        .addAttribute(new Attribute("name", "xsd:string"));
176:                productBeanType.addAttribute(new Attribute("display-name",
177:                        "xsd:string"));
178:                expected.addComplexType(productBeanType);
179:
180:                GlobalComplexType orderLineType = new GlobalComplexType();
181:                orderLineType.setName(OrderLineBean.class.getName());
182:                orderLineType.addAttribute(new Attribute("quantity",
183:                        "xsd:string"));
184:                orderLineType.addElement(new ElementReference("product",
185:                        productBeanType));
186:                expected.addComplexType(orderLineType);
187:
188:                GlobalComplexType orderType = new GlobalComplexType();
189:                orderType.setName(OrderBean.class.getName());
190:                orderType.addAttribute(new Attribute("code", "xsd:string"));
191:                orderType.addElement(new ElementReference("customer",
192:                        customerBeanType));
193:                orderType
194:                        .addElement(new ElementReference("line", orderLineType));
195:                expected.addComplexType(orderType);
196:                expected.addElement(new GlobalElement("order-bean",
197:                        OrderBean.class.getName()));
198:
199:                assertEquals("Transcriber schema", expected, out);
200:            }
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.