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.innerparticles;
020:
021: import com.mynamespace.testinnerparticle.*;
022: import org.apache.axiom.om.OMElement;
023: import org.apache.axiom.om.OMAbstractFactory;
024: import org.apache.axiom.om.util.StAXUtils;
025: import org.apache.axis2.databinding.ADBException;
026:
027: import javax.xml.stream.XMLStreamException;
028: import javax.xml.stream.XMLStreamReader;
029:
030: import junit.framework.TestCase;
031:
032: import java.io.ByteArrayInputStream;
033:
034: public class InnerParticlesTest extends TestCase {
035:
036: public void testInnerParticle1() {
037:
038: TestInnerParticle1 testInnerParticle1 = new TestInnerParticle1();
039: testInnerParticle1.setParam1("Param1");
040: TestInnerParticle1Sequence_type0 testInnerParticle1Sequence_type0 = new TestInnerParticle1Sequence_type0();
041: testInnerParticle1Sequence_type0.setParam2("Param2");
042: testInnerParticle1Sequence_type0.setParam3("Param3");
043: testInnerParticle1
044: .setTestInnerParticle1Sequence_type0(testInnerParticle1Sequence_type0);
045: testInnerParticle1.setParam4("Param4");
046:
047: try {
048: OMElement omElement = testInnerParticle1.getOMElement(
049: TestInnerParticle1.MY_QNAME, OMAbstractFactory
050: .getOMFactory());
051: String omElementString = omElement.toStringWithConsume();
052: System.out.println("OM String ==> " + omElementString);
053: XMLStreamReader xmlReader = StAXUtils
054: .createXMLStreamReader(new ByteArrayInputStream(
055: omElementString.getBytes()));
056: TestInnerParticle1 result = TestInnerParticle1.Factory
057: .parse(xmlReader);
058: assertEquals(result.getParam1(), "Param1");
059: assertEquals(result.getTestInnerParticle1Sequence_type0()
060: .getParam2(), "Param2");
061: assertEquals(result.getTestInnerParticle1Sequence_type0()
062: .getParam3(), "Param3");
063: assertEquals(result.getParam4(), "Param4");
064: } catch (XMLStreamException e) {
065: fail();
066: } catch (Exception e) {
067: fail();
068: }
069:
070: }
071:
072: public void testInnerParticle2() {
073:
074: TestInnerParticle2 testInnerParticle2 = new TestInnerParticle2();
075: testInnerParticle2.setParam1("Param1");
076: TestInnerParticle2Choice_type0 testInnerParticle2Choice_type1 = new TestInnerParticle2Choice_type0();
077: testInnerParticle2Choice_type1.setParam2("Param2");
078: testInnerParticle2Choice_type1.setParam3("Param3");
079: testInnerParticle2
080: .setTestInnerParticle2Choice_type0(testInnerParticle2Choice_type1);
081: testInnerParticle2.setParam4("Param4");
082:
083: try {
084: OMElement omElement = testInnerParticle2.getOMElement(
085: TestInnerParticle2.MY_QNAME, OMAbstractFactory
086: .getOMFactory());
087: String omElementString = omElement.toStringWithConsume();
088: System.out.println("OM String ==> " + omElementString);
089: XMLStreamReader xmlReader = StAXUtils
090: .createXMLStreamReader(new ByteArrayInputStream(
091: omElementString.getBytes()));
092: TestInnerParticle2 result = TestInnerParticle2.Factory
093: .parse(xmlReader);
094: assertEquals(result.getParam1(), "Param1");
095: assertEquals(result.getTestInnerParticle2Choice_type0()
096: .getParam3(), "Param3");
097: assertEquals(result.getParam4(), "Param4");
098: } catch (XMLStreamException e) {
099: fail();
100: } catch (Exception e) {
101: fail();
102: }
103:
104: }
105:
106: public void testInnerParticle31() {
107:
108: TestInnerParticle3 testInnerParticle3 = new TestInnerParticle3();
109: testInnerParticle3.setParam1("Param1");
110:
111: try {
112: OMElement omElement = testInnerParticle3.getOMElement(
113: TestInnerParticle3.MY_QNAME, OMAbstractFactory
114: .getOMFactory());
115: String omElementString = omElement.toStringWithConsume();
116: System.out.println("OM String ==> " + omElementString);
117: XMLStreamReader xmlReader = StAXUtils
118: .createXMLStreamReader(new ByteArrayInputStream(
119: omElementString.getBytes()));
120: TestInnerParticle3 result = TestInnerParticle3.Factory
121: .parse(xmlReader);
122: assertEquals(result.getParam1(), "Param1");
123: } catch (XMLStreamException e) {
124: fail();
125: } catch (Exception e) {
126: fail();
127: }
128:
129: }
130:
131: public void testInnerParticle32() {
132:
133: TestInnerParticle3 testInnerParticle3 = new TestInnerParticle3();
134: TestInnerParticle3Choice_type0 testInnerParticle3Choice_type1 = new TestInnerParticle3Choice_type0();
135: testInnerParticle3Choice_type1.setParam2("Param2");
136: testInnerParticle3Choice_type1.setParam3("Param3");
137: testInnerParticle3
138: .setTestInnerParticle3Choice_type0(testInnerParticle3Choice_type1);
139:
140: try {
141: OMElement omElement = testInnerParticle3.getOMElement(
142: TestInnerParticle3.MY_QNAME, OMAbstractFactory
143: .getOMFactory());
144: String omElementString = omElement.toStringWithConsume();
145: System.out.println("OM String ==> " + omElementString);
146: XMLStreamReader xmlReader = StAXUtils
147: .createXMLStreamReader(new ByteArrayInputStream(
148: omElementString.getBytes()));
149: TestInnerParticle3 result = TestInnerParticle3.Factory
150: .parse(xmlReader);
151: assertEquals(result.getTestInnerParticle3Choice_type0()
152: .getParam3(), "Param3");
153: } catch (XMLStreamException e) {
154: e.printStackTrace();
155: fail();
156: } catch (Exception e) {
157: e.printStackTrace();
158: fail();
159: }
160:
161: }
162:
163: public void testInnerParticle33() {
164:
165: TestInnerParticle3 testInnerParticle3 = new TestInnerParticle3();
166: testInnerParticle3.setParam1("Param1");
167: TestInnerParticle3Choice_type0 testInnerParticle3Choice_type1 = new TestInnerParticle3Choice_type0();
168: testInnerParticle3Choice_type1.setParam2("Param2");
169: testInnerParticle3Choice_type1.setParam3("Param3");
170: testInnerParticle3
171: .setTestInnerParticle3Choice_type0(testInnerParticle3Choice_type1);
172: testInnerParticle3.setParam4("Param4");
173:
174: try {
175: OMElement omElement = testInnerParticle3.getOMElement(
176: TestInnerParticle3.MY_QNAME, OMAbstractFactory
177: .getOMFactory());
178: String omElementString = omElement.toStringWithConsume();
179: System.out.println("OM String ==> " + omElementString);
180: XMLStreamReader xmlReader = StAXUtils
181: .createXMLStreamReader(new ByteArrayInputStream(
182: omElementString.getBytes()));
183: TestInnerParticle3 result = TestInnerParticle3.Factory
184: .parse(xmlReader);
185: assertEquals(result.getParam4(), "Param4");
186: } catch (XMLStreamException e) {
187: fail();
188: } catch (Exception e) {
189: fail();
190: }
191:
192: }
193:
194: public void testInnerParticle41() {
195:
196: TestInnerParticle4 testInnerParticle4 = new TestInnerParticle4();
197: testInnerParticle4.setParam1("Param1");
198:
199: try {
200: OMElement omElement = testInnerParticle4.getOMElement(
201: TestInnerParticle4.MY_QNAME, OMAbstractFactory
202: .getOMFactory());
203: String omElementString = omElement.toStringWithConsume();
204: System.out.println("OM String ==> " + omElementString);
205: XMLStreamReader xmlReader = StAXUtils
206: .createXMLStreamReader(new ByteArrayInputStream(
207: omElementString.getBytes()));
208: TestInnerParticle4 result = TestInnerParticle4.Factory
209: .parse(xmlReader);
210: assertEquals(result.getParam1(), "Param1");
211: } catch (XMLStreamException e) {
212: e.printStackTrace();
213: fail();
214: } catch (Exception e) {
215: e.printStackTrace();
216: fail();
217: }
218:
219: }
220:
221: public void testInnerParticle42() {
222:
223: TestInnerParticle4 testInnerParticle4 = new TestInnerParticle4();
224: TestInnerParticle4Sequence_type0 TestInnerParticle4Sequence_type0 = new TestInnerParticle4Sequence_type0();
225: TestInnerParticle4Sequence_type0.setParam2("Param2");
226: TestInnerParticle4Sequence_type0.setParam3("Param3");
227: testInnerParticle4
228: .setTestInnerParticle4Sequence_type0(TestInnerParticle4Sequence_type0);
229:
230: try {
231: OMElement omElement = testInnerParticle4.getOMElement(
232: TestInnerParticle4.MY_QNAME, OMAbstractFactory
233: .getOMFactory());
234: String omElementString = omElement.toStringWithConsume();
235: System.out.println("OM String ==> " + omElementString);
236: XMLStreamReader xmlReader = StAXUtils
237: .createXMLStreamReader(new ByteArrayInputStream(
238: omElementString.getBytes()));
239: TestInnerParticle4 result = TestInnerParticle4.Factory
240: .parse(xmlReader);
241: assertEquals(result.getTestInnerParticle4Sequence_type0()
242: .getParam2(), "Param2");
243: assertEquals(result.getTestInnerParticle4Sequence_type0()
244: .getParam3(), "Param3");
245: } catch (XMLStreamException e) {
246: e.printStackTrace();
247: fail();
248: } catch (Exception e) {
249: e.printStackTrace();
250: fail();
251: }
252:
253: }
254:
255: public void testInnerParticle43() {
256:
257: TestInnerParticle4 testInnerParticle4 = new TestInnerParticle4();
258: testInnerParticle4.setParam4("Param4");
259:
260: try {
261: OMElement omElement = testInnerParticle4.getOMElement(
262: TestInnerParticle4.MY_QNAME, OMAbstractFactory
263: .getOMFactory());
264: String omElementString = omElement.toStringWithConsume();
265: System.out.println("OM String ==> " + omElementString);
266: XMLStreamReader xmlReader = StAXUtils
267: .createXMLStreamReader(new ByteArrayInputStream(
268: omElementString.getBytes()));
269: TestInnerParticle4 result = TestInnerParticle4.Factory
270: .parse(xmlReader);
271: assertEquals(result.getParam4(), "Param4");
272: } catch (XMLStreamException e) {
273: e.printStackTrace();
274: fail();
275: } catch (Exception e) {
276: e.printStackTrace();
277: fail();
278: }
279:
280: }
281:
282: public void testInnerParticle5() {
283:
284: TestInnerParticle5 testInnerParticle5 = new TestInnerParticle5();
285: testInnerParticle5.setParam1("Param1");
286: TestInnerParticle5Sequence_type1 testInnerParticle2Choice_type1 = new TestInnerParticle5Sequence_type1();
287: testInnerParticle2Choice_type1.setParam2("Param2");
288: testInnerParticle2Choice_type1.setParam3("Param3");
289:
290: TestInnerParticle5Sequence_type0 innerParticle5Sequence_type0 = new TestInnerParticle5Sequence_type0();
291: innerParticle5Sequence_type0.setParam4("Param4");
292: innerParticle5Sequence_type0.setParam5("Param5");
293:
294: testInnerParticle2Choice_type1
295: .setTestInnerParticle5Sequence_type0(innerParticle5Sequence_type0);
296: testInnerParticle5
297: .setTestInnerParticle5Sequence_type1(testInnerParticle2Choice_type1);
298: testInnerParticle5.setParam6("Param6");
299:
300: try {
301: OMElement omElement = testInnerParticle5.getOMElement(
302: TestInnerParticle5.MY_QNAME, OMAbstractFactory
303: .getOMFactory());
304: String omElementString = omElement.toStringWithConsume();
305: System.out.println("OM String ==> " + omElementString);
306: XMLStreamReader xmlReader = StAXUtils
307: .createXMLStreamReader(new ByteArrayInputStream(
308: omElementString.getBytes()));
309: TestInnerParticle5 result = TestInnerParticle5.Factory
310: .parse(xmlReader);
311: assertEquals(result.getParam1(), "Param1");
312: assertEquals(result.getTestInnerParticle5Sequence_type1()
313: .getParam2(), "Param2");
314: assertEquals(result.getTestInnerParticle5Sequence_type1()
315: .getParam3(), "Param3");
316: assertEquals(result.getTestInnerParticle5Sequence_type1()
317: .getTestInnerParticle5Sequence_type0().getParam4(),
318: "Param4");
319: assertEquals(result.getTestInnerParticle5Sequence_type1()
320: .getTestInnerParticle5Sequence_type0().getParam5(),
321: "Param5");
322: assertEquals(result.getParam6(), "Param6");
323: } catch (XMLStreamException e) {
324: fail();
325: } catch (Exception e) {
326: fail();
327: }
328:
329: }
330:
331: public void testIntterParticalExtension() {
332: TestInnterParticleExtension testInnterParticleExtension = new TestInnterParticleExtension();
333:
334: TestInnterParticleExtensionChildComplexType testInnterParticleExtensionChildComplexType = new TestInnterParticleExtensionChildComplexType();
335: testInnterParticleExtension
336: .setTestInnterParticleExtension(testInnterParticleExtensionChildComplexType);
337:
338: TestInnterParticleExtensionParentComplexTypeChoice_type0 testInnterParticleExtensionParentComplexTypeChoice_type0 = new TestInnterParticleExtensionParentComplexTypeChoice_type0();
339: testInnterParticleExtensionChildComplexType
340: .setTestInnterParticleExtensionParentComplexTypeChoice_type0(testInnterParticleExtensionParentComplexTypeChoice_type0);
341:
342: testInnterParticleExtensionParentComplexTypeChoice_type0
343: .setParam1("param1");
344: testInnterParticleExtensionParentComplexTypeChoice_type0
345: .setParam2("param2");
346:
347: try {
348: OMElement omElement = testInnterParticleExtension
349: .getOMElement(TestInnterParticleExtension.MY_QNAME,
350: OMAbstractFactory.getOMFactory());
351: String omElementString = omElement.toStringWithConsume();
352: System.out.println("OM String ==> " + omElementString);
353: XMLStreamReader xmlReader = StAXUtils
354: .createXMLStreamReader(new ByteArrayInputStream(
355: omElementString.getBytes()));
356: TestInnterParticleExtension result = TestInnterParticleExtension.Factory
357: .parse(xmlReader);
358: assertTrue(result.getTestInnterParticleExtension() instanceof TestInnterParticleExtensionChildComplexType);
359: TestInnterParticleExtensionChildComplexType resultComplexType = (TestInnterParticleExtensionChildComplexType) result
360: .getTestInnterParticleExtension();
361: assertEquals(
362: resultComplexType
363: .getTestInnterParticleExtensionParentComplexTypeChoice_type0()
364: .getParam2(), "param2");
365: } catch (ADBException e) {
366: fail();
367: } catch (XMLStreamException e) {
368: fail();
369: } catch (Exception e) {
370: fail();
371: }
372: }
373:
374: }
|