01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.schema.booleantest;
20:
21: import junit.framework.TestCase;
22: import org.apache.axiom.om.OMAbstractFactory;
23: import org.apache.axiom.om.OMElement;
24: import org.apache.axiom.om.util.StAXUtils;
25: import org.tempuri.boolean1.TestBoolean1;
26: import org.tempuri.boolean1.TestBoolean2;
27:
28: import javax.xml.stream.XMLStreamReader;
29: import java.io.ByteArrayInputStream;
30:
31: public class BooleanTest extends TestCase {
32:
33: public void testBooleanTest1() {
34: TestBoolean1 testBoolean = new TestBoolean1();
35: testBoolean.setTestBoolean1(true);
36:
37: try {
38: OMElement omElement = testBoolean.getOMElement(
39: TestBoolean1.MY_QNAME, OMAbstractFactory
40: .getOMFactory());
41: String omElementString = omElement.toStringWithConsume();
42: System.out.println("String ==> " + omElementString);
43: XMLStreamReader xmlReader = StAXUtils
44: .createXMLStreamReader(new ByteArrayInputStream(
45: omElementString.getBytes()));
46: TestBoolean1 result = TestBoolean1.Factory.parse(xmlReader);
47: assertEquals(result.getTestBoolean1(), true);
48: } catch (Exception e) {
49: fail();
50: }
51: }
52:
53: public void testBooleanTest2() {
54: TestBoolean2 testBoolean = new TestBoolean2();
55: testBoolean.setParam1(false);
56: testBoolean.setAttribute1(true);
57:
58: try {
59: OMElement omElement = testBoolean.getOMElement(
60: TestBoolean2.MY_QNAME, OMAbstractFactory
61: .getOMFactory());
62: String omElementString = omElement.toStringWithConsume();
63: System.out.println("String ==> " + omElementString);
64: XMLStreamReader xmlReader = StAXUtils
65: .createXMLStreamReader(new ByteArrayInputStream(
66: omElementString.getBytes()));
67: TestBoolean2 result = TestBoolean2.Factory.parse(xmlReader);
68: assertEquals(result.getParam1(), false);
69: assertEquals(result.getAttribute1(), true);
70: } catch (Exception e) {
71: fail();
72: }
73: }
74:
75: }
|