Source Code Cross Referenced for SchemaReadWriteTest.java in  » IDE-Netbeans » xml » org » netbeans » modules » xml » wsdl » model » readwrite » 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 » IDE Netbeans » xml » org.netbeans.modules.xml.wsdl.model.readwrite 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SchemaTest.java
003:         *
004:         * Created on December 9, 2005, 11:53 AM
005:         *
006:         * To change this template, choose Tools | Template Manager
007:         * and open the template in the editor.
008:         */
009:
010:        package org.netbeans.modules.xml.wsdl.model.readwrite;
011:
012:        import java.util.Collection;
013:        import java.util.Iterator;
014:        import junit.framework.TestCase;
015:        import org.netbeans.modules.xml.schema.model.GlobalElement;
016:        import org.netbeans.modules.xml.schema.model.Schema;
017:        import org.netbeans.modules.xml.schema.model.SchemaModel;
018:        import org.netbeans.modules.xml.wsdl.model.Binding;
019:        import org.netbeans.modules.xml.wsdl.model.BindingInput;
020:        import org.netbeans.modules.xml.wsdl.model.BindingOperation;
021:        import org.netbeans.modules.xml.wsdl.model.Definitions;
022:        import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement;
023:        import org.netbeans.modules.xml.wsdl.model.Message;
024:        import org.netbeans.modules.xml.wsdl.model.Part;
025:        import org.netbeans.modules.xml.wsdl.model.TestCatalogModel;
026:        import org.netbeans.modules.xml.wsdl.model.Types;
027:        import org.netbeans.modules.xml.wsdl.model.Util;
028:        import org.netbeans.modules.xml.wsdl.model.WSDLComponentFactory;
029:        import org.netbeans.modules.xml.wsdl.model.WSDLModel;
030:        import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPHeader;
031:        import org.netbeans.modules.xml.wsdl.model.extensions.xsd.WSDLSchema;
032:        import org.netbeans.modules.xml.wsdl.model.extensions.xsd.impl.WSDLSchemaImpl;
033:        import org.netbeans.modules.xml.wsdl.model.impl.WSDLComponentFactoryImpl;
034:        import org.netbeans.modules.xml.wsdl.model.impl.WSDLModelImpl;
035:        import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
036:
037:        /**
038:         *
039:         * @author rico
040:         */
041:        public class SchemaReadWriteTest extends TestCase implements 
042:                TestReadWrite {
043:
044:            /** Creates a new instance of SchemaTest */
045:            public SchemaReadWriteTest(String testName) {
046:                super (testName);
047:            }
048:
049:            protected void setUp() throws Exception {
050:            }
051:
052:            protected void tearDown() throws Exception {
053:                TestCatalogModel.getDefault().clearDocumentPool();
054:            }
055:
056:            /**
057:             * Reconstruct the schema pointed by #getSchemaResourcePath from empty schema.
058:             */
059:            public void testWrite() throws Exception {
060:
061:                WSDLModel model = Util.loadWSDLModel(getTestResourcePath2());
062:                WSDLComponentFactory fact = model.getFactory();
063:                this .assertNotNull(model);
064:                Definitions d = model.getDefinitions();
065:                this .assertNotNull(d);
066:
067:                model.startTransaction();
068:                d.setName("StockQuote");
069:                d.setTargetNamespace("http://example.com/stockquote.wsdl");
070:                Types types = fact.createTypes();
071:                WSDLComponentFactoryImpl factory = new WSDLComponentFactoryImpl(
072:                        (WSDLModelImpl) model);
073:                WSDLSchema wsdlSchema = factory.createWSDLSchema();
074:                types.addExtensibilityElement(wsdlSchema);
075:                model.endTransaction();
076:                Collection<ExtensibilityElement> ees = types
077:                        .getExtensibilityElements();
078:                assertEquals("number of EE", 1, ees.size());
079:                SchemaModel schemaModel = wsdlSchema.getSchemaModel();
080:                assertNotNull("schemaModel not null", schemaModel);
081:                Schema schema = schemaModel.getSchema();
082:                assertNotNull("schema not null", schema);
083:                GlobalElement ge = schemaModel.getFactory()
084:                        .createGlobalElement();
085:                model.startTransaction();
086:                schema.addElement(ge);
087:                model.endTransaction();
088:                //File dumpFile = Util.dumpToTempFile(((WSDLModelImpl)model).getBaseDocument());
089:                //System.out.println("dumpFile; " + dumpFile.getCanonicalPath());
090:                Collection<Schema> schemas = types.getSchemas();
091:                assertEquals("number of schemas ", 1, schemas.size());
092:            }
093:
094:            /**
095:             * Test reading in the schema specified by #getSchemaResourcePath.
096:             * Verifying the resulted model using a visitor or 
097:             * FindSchemaComponentFromDOM#findComponent method.
098:             */
099:            public void testRead() throws Exception {
100:                WSDLModel model = Util.loadWSDLModel(getTestResourcePath());
101:                this .assertNotNull(model);
102:                Definitions d = model.getDefinitions();
103:                this .assertNotNull(d);
104:                Types types = d.getTypes();
105:                this .assertNotNull(types);
106:                Collection<ExtensibilityElement> ee = types
107:                        .getExtensibilityElements();
108:                System.out.println("number of EE: " + ee.size());
109:                assertTrue("ExtensibilityElement instanceof WSDLSchemaImpl", ee
110:                        .iterator().next() instanceof  WSDLSchemaImpl);
111:                WSDLSchemaImpl wsdlSchema = (WSDLSchemaImpl) ee.iterator()
112:                        .next();
113:                SchemaModel schemaModel = wsdlSchema.getSchemaModel();
114:                assertNotNull("schema model is not null", schemaModel);
115:                Schema schema = schemaModel.getSchema();
116:                assertNotNull("schema not null", schema);
117:                Collection<GlobalElement> gElements = schema.getElements();
118:                assertEquals("number of global elements", 2, gElements.size());
119:
120:                Binding binding = d.getBindings().iterator().next();
121:                BindingOperation bo = binding.getBindingOperations().iterator()
122:                        .next();
123:                BindingInput bi = bo.getBindingInput();
124:                SOAPHeader sh = (SOAPHeader) bi.getExtensibilityElements(
125:                        SOAPHeader.class).iterator().next();
126:                assertNotNull(sh.getMessage().get());
127:            }
128:
129:            public void testReadSchemaReference() throws Exception {
130:                WSDLModel model = Util.loadWSDLModel(getTestResourcePath());
131:                this .assertNotNull(model);
132:                Definitions d = model.getDefinitions();
133:                this .assertNotNull(d);
134:                Types types = d.getTypes();
135:                this .assertNotNull(types);
136:                Collection<Message> messages = d.getMessages();
137:                assertEquals("number of messages", 2, messages.size());
138:                //get the first message
139:                Message message = messages.iterator().next();
140:                Collection<Part> parts = message.getParts();
141:                assertEquals("number of parts", 1, parts.size());
142:                //get the part
143:                Part part = parts.iterator().next();
144:                //retrieve the referenced element
145:                NamedComponentReference<GlobalElement> ref = part.getElement();
146:                assertEquals("namespace of reference",
147:                        "http://example.com/stockquote.xsd", ref
148:                                .getEffectiveNamespace());
149:                GlobalElement ge = ref.get();
150:                assertEquals("name of global element", "TradePriceRequest", ge
151:                        .getName());
152:            }
153:
154:            public void testWriteSchemaReference() throws Exception {
155:                WSDLModel model = Util.loadWSDLModel(getTestResourcePath());
156:                this .assertNotNull(model);
157:                Definitions d = model.getDefinitions();
158:                this .assertNotNull(d);
159:                Types types = d.getTypes();
160:                Collection<Schema> schemas = types.getSchemas();
161:                Schema schema = schemas.iterator().next();
162:                Collection<GlobalElement> elements = schema.getElements();
163:                GlobalElement ge = elements.iterator().next();
164:
165:                this .assertNotNull(types);
166:                WSDLComponentFactory factory = model.getFactory();
167:                Message message = factory.createMessage();
168:                model.startTransaction();
169:                message.setName("BogusMessage");
170:                Part part = factory.createPart();
171:                part.setName("BogusPart");
172:                NamedComponentReference<GlobalElement> ref = part
173:                        .createSchemaReference(ge, GlobalElement.class);
174:                part.setElement(ref);
175:                message.addPart(part);
176:                d.addMessage(message);
177:                model.endTransaction();
178:
179:                //read back the message
180:                Collection<Message> messages = d.getMessages();
181:                assertEquals("number of messages", 3, messages.size());
182:                Iterator<Message> mIterator = messages.iterator();
183:                mIterator.next();
184:                mIterator.next();
185:                //get the third message
186:                Message m = mIterator.next();
187:                Collection<Part> parts = m.getParts();
188:                part = parts.iterator().next();
189:                NamedComponentReference<GlobalElement> gRef = part.getElement();
190:                assertNotNull("global reference to part element is not null",
191:                        gRef);
192:                GlobalElement rsc = gRef.get();
193:                assertNotNull(
194:                        "ReferenceableSchemaComponent should not be null", rsc);
195:                //File dumpFile = Util.dumpToTempFile(((WSDLModelImpl)model).getBaseDocument());
196:                //System.out.println("dumpFile; " + dumpFile.getCanonicalPath());
197:            }
198:
199:            public String getTestResourcePath() {
200:                return "resources/stockquote.xml";
201:            }
202:
203:            public String getTestResourcePath2() {
204:                return "resources/emptyStockquote.xml";
205:            }
206:        }
ww___w__.___j_a_v__a_2_s__._c__om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.