Source Code Cross Referenced for InnerChoiceTest.java in  » Web-Services-AXIS2 » adb » org » apache » axis2 » schema » innerChoice » 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 » Web Services AXIS2 » adb » org.apache.axis2.schema.innerChoice 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */
019:        package org.apache.axis2.schema.innerChoice;
020:
021:        import junit.framework.TestCase;
022:        import org.apache.axiom.om.OMAbstractFactory;
023:        import org.apache.axiom.om.OMElement;
024:        import org.apache.axiom.om.util.StAXUtils;
025:        import org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter;
026:        import org.apache.axis2.databinding.utils.writer.MTOMAwareXMLSerializer;
027:        import test.axis2.apache.org.*;
028:
029:        import javax.xml.stream.XMLStreamReader;
030:        import javax.xml.stream.XMLStreamWriter;
031:        import java.io.ByteArrayInputStream;
032:
033:        import com.mynamespace.testinnerparticle.TestInnerParticle1Sequence_type0;
034:
035:        public class InnerChoiceTest extends TestCase {
036:
037:            public void testInnerChoice1() {
038:                TestInnerSequence1 testSequence = new TestInnerSequence1();
039:                testSequence.setSequence1("test sequence");
040:                testSequence.setSequence2(3);
041:
042:                TestInnerSequence1Choice_type0 TestInnerSequence1Choice_type0 = new TestInnerSequence1Choice_type0();
043:                TestInnerSequence1Choice_type0.setChoice1("test choice");
044:                TestInnerSequence1Choice_type0.setChoice2(5);
045:                testSequence
046:                        .setTestInnerSequence1Choice_type0(TestInnerSequence1Choice_type0);
047:
048:                try {
049:                    OMElement omElement = testSequence.getOMElement(
050:                            TestInnerSequence1.MY_QNAME, OMAbstractFactory
051:                                    .getSOAP12Factory());
052:                    String omElementString = omElement.toStringWithConsume();
053:                    System.out.println("OMelement ==> " + omElementString);
054:                    XMLStreamReader xmlReader = StAXUtils
055:                            .createXMLStreamReader(new ByteArrayInputStream(
056:                                    omElementString.getBytes()));
057:                    TestInnerSequence1 result = TestInnerSequence1.Factory
058:                            .parse(xmlReader);
059:                    assertEquals(result.getSequence1(), "test sequence");
060:                    assertEquals(result.getSequence2(), 3);
061:                    assertEquals(result.getTestInnerSequence1Choice_type0()
062:                            .getChoice2(), 5);
063:
064:                    // writtig result back
065:                    XMLStreamWriter xmlStreamWriter = StAXUtils
066:                            .createXMLStreamWriter(System.out);
067:                    MTOMAwareXMLStreamWriter mtomAwareXMLStreamWriter = new MTOMAwareXMLSerializer(
068:                            xmlStreamWriter);
069:                    result.serialize(new javax.xml.namespace.QName(
070:                            "org.apache.axis2.test", "TestInnerSequence1",
071:                            "foo"), OMAbstractFactory.getSOAP11Factory(),
072:                            mtomAwareXMLStreamWriter);
073:                    xmlStreamWriter.flush();
074:
075:                } catch (Exception e) {
076:                    fail();
077:                }
078:            }
079:
080:            public void testInnerChoice21() {
081:                TestInnerSequence2 testSequence = new TestInnerSequence2();
082:                testSequence.setSequence1("sequence");
083:                testSequence.setSequence2(3);
084:                TestInnerSequence2Choice_type0 testInnerSequence2Choice_type1 = new TestInnerSequence2Choice_type0();
085:                testInnerSequence2Choice_type1.setChoice1(new String[] {
086:                        "choice1", "choice2" });
087:                testSequence
088:                        .setTestInnerSequence2Choice_type0(testInnerSequence2Choice_type1);
089:
090:                try {
091:                    OMElement omElement = testSequence.getOMElement(
092:                            TestInnerSequence2.MY_QNAME, OMAbstractFactory
093:                                    .getSOAP12Factory());
094:                    String omElementString = omElement.toStringWithConsume();
095:                    System.out.println("OMelement ==> " + omElementString);
096:                    XMLStreamReader xmlReader = StAXUtils
097:                            .createXMLStreamReader(new ByteArrayInputStream(
098:                                    omElementString.getBytes()));
099:                    TestInnerSequence2 result = TestInnerSequence2.Factory
100:                            .parse(xmlReader);
101:                    assertEquals(result.getSequence1(), "sequence");
102:                    assertEquals(result.getSequence2(), 3);
103:                    assertTrue(isEqual(result
104:                            .getTestInnerSequence2Choice_type0().getChoice1(),
105:                            new String[] { "choice1", "choice2" }));
106:                } catch (Exception e) {
107:                    fail();
108:                }
109:            }
110:
111:            public void testInnerChoice22() {
112:                TestInnerSequence2 testSequence = new TestInnerSequence2();
113:                testSequence.setSequence1("sequence");
114:                testSequence.setSequence2(3);
115:                TestInnerSequence2Choice_type0 testInnerSequence2Choice_type1 = new TestInnerSequence2Choice_type0();
116:                testInnerSequence2Choice_type1.setChoice2(new int[] { 2, 4 });
117:                testSequence
118:                        .setTestInnerSequence2Choice_type0(testInnerSequence2Choice_type1);
119:
120:                try {
121:                    OMElement omElement = testSequence.getOMElement(
122:                            TestInnerSequence2.MY_QNAME, OMAbstractFactory
123:                                    .getSOAP12Factory());
124:                    String omElementString = omElement.toStringWithConsume();
125:                    System.out.println("OMelement ==> " + omElementString);
126:                    XMLStreamReader xmlReader = StAXUtils
127:                            .createXMLStreamReader(new ByteArrayInputStream(
128:                                    omElementString.getBytes()));
129:                    TestInnerSequence2 result = TestInnerSequence2.Factory
130:                            .parse(xmlReader);
131:                    assertEquals(result.getSequence1(), "sequence");
132:                    assertEquals(result.getSequence2(), 3);
133:                    assertTrue(isEqual(result
134:                            .getTestInnerSequence2Choice_type0().getChoice2(),
135:                            new int[] { 2, 4 }));
136:                } catch (Exception e) {
137:                    fail();
138:                }
139:            }
140:
141:            public void testInnerChoice31() {
142:                TestInnerSequence3 testSequence = new TestInnerSequence3();
143:                testSequence.setSequence1("sequence");
144:                testSequence.setSequence2(3);
145:                TestInnerSequence3Choice_type0 testInnerSequence3Choice_type0 = new TestInnerSequence3Choice_type0();
146:                testInnerSequence3Choice_type0.setChoice1(new String[] {
147:                        "choice1", null, "choice2" });
148:                testSequence
149:                        .setTestInnerSequence3Choice_type0(testInnerSequence3Choice_type0);
150:
151:                try {
152:                    OMElement omElement = testSequence.getOMElement(
153:                            TestInnerSequence3.MY_QNAME, OMAbstractFactory
154:                                    .getSOAP12Factory());
155:                    String omElementString = omElement.toStringWithConsume();
156:                    System.out.println("OMelement ==> " + omElementString);
157:                    XMLStreamReader xmlReader = StAXUtils
158:                            .createXMLStreamReader(new ByteArrayInputStream(
159:                                    omElementString.getBytes()));
160:                    TestInnerSequence3 result = TestInnerSequence3.Factory
161:                            .parse(xmlReader);
162:                    assertEquals(result.getSequence1(), "sequence");
163:                    assertEquals(result.getSequence2(), 3);
164:                    assertTrue(isEqual(result
165:                            .getTestInnerSequence3Choice_type0().getChoice1(),
166:                            new String[] { "choice1", null, "choice2" }));
167:                } catch (Exception e) {
168:                    fail();
169:                }
170:            }
171:
172:            public void testInnerChoice32() {
173:                TestInnerSequence3 testSequence = new TestInnerSequence3();
174:                testSequence.setSequence1("sequence");
175:                testSequence.setSequence2(3);
176:                TestInnerSequence3Choice_type0 testInnerSequence3Choice_type0 = new TestInnerSequence3Choice_type0();
177:                testInnerSequence3Choice_type0.setChoice2(new int[] { 2,
178:                        Integer.MIN_VALUE, 6 });
179:                testSequence
180:                        .setTestInnerSequence3Choice_type0(testInnerSequence3Choice_type0);
181:
182:                try {
183:                    OMElement omElement = testSequence.getOMElement(
184:                            TestInnerSequence3.MY_QNAME, OMAbstractFactory
185:                                    .getSOAP12Factory());
186:                    String omElementString = omElement.toStringWithConsume();
187:                    System.out.println("OMelement ==> " + omElementString);
188:                    XMLStreamReader xmlReader = StAXUtils
189:                            .createXMLStreamReader(new ByteArrayInputStream(
190:                                    omElementString.getBytes()));
191:                    TestInnerSequence3 result = TestInnerSequence3.Factory
192:                            .parse(xmlReader);
193:                    assertEquals(result.getSequence1(), "sequence");
194:                    assertEquals(result.getSequence2(), 3);
195:                    assertTrue(isEqual(result
196:                            .getTestInnerSequence3Choice_type0().getChoice2(),
197:                            new int[] { 2, Integer.MIN_VALUE, 6 }));
198:                } catch (Exception e) {
199:                    fail();
200:                }
201:            }
202:
203:            private boolean isEqual(String[] test1, String[] test2) {
204:                boolean isEqual = true;
205:                if (test1.length != test2.length) {
206:                    isEqual = false;
207:                } else {
208:                    for (int i = 0; i < test1.length; i++) {
209:                        if (test1[i] != null) {
210:                            if (!test1[i].equals(test2[i])) {
211:                                isEqual = false;
212:                                break;
213:                            }
214:                        } else {
215:                            if (test2[i] != null) {
216:                                isEqual = false;
217:                                break;
218:                            }
219:                        }
220:
221:                    }
222:                }
223:
224:                return isEqual;
225:            }
226:
227:            private boolean isEqual(int[] test1, int[] test2) {
228:                boolean isEqual = true;
229:                if (test1.length != test2.length) {
230:                    isEqual = false;
231:                } else {
232:                    for (int i = 0; i < test1.length; i++) {
233:                        if (test1[i] != test2[i]) {
234:                            isEqual = false;
235:                            break;
236:                        }
237:                    }
238:                }
239:
240:                return isEqual;
241:            }
242:
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.