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.all;
20:
21: import org.tempuri.Update;
22: import org.apache.axiom.om.OMElement;
23: import org.apache.axiom.om.OMAbstractFactory;
24: import org.apache.axiom.om.util.StAXUtils;
25:
26: import javax.xml.stream.XMLStreamException;
27: import javax.xml.stream.XMLStreamReader;
28:
29: import junit.framework.TestCase;
30:
31: import java.io.ByteArrayInputStream;
32:
33: public class AllTest extends TestCase {
34:
35: public void testAll() {
36: Update update = new Update();
37: update.setArg0("test");
38: update.setArg1(true);
39: update.setId(2);
40:
41: try {
42: OMElement omElement = update.getOMElement(Update.MY_QNAME,
43: OMAbstractFactory.getOMFactory());
44: String omElementString = omElement.toStringWithConsume();
45: System.out.println("om string ==> " + omElementString);
46: omElementString = "<ns1:Update xmlns:ns1=\"http://tempuri.org/\"><ns1:arg1>true</ns1:arg1><ns1:id>2</ns1:id><ns1:arg0>test</ns1:arg0></ns1:Update>";
47: XMLStreamReader xmlReader = StAXUtils
48: .createXMLStreamReader(new ByteArrayInputStream(
49: omElementString.getBytes()));
50: Update newUpdate = Update.Factory.parse(xmlReader);
51: assertEquals(update.getArg0(), newUpdate.getArg0());
52: assertEquals(update.getArg1(), newUpdate.getArg1());
53: assertEquals(update.getId(), newUpdate.getId());
54: } catch (Exception e) {
55: assertFalse(true);
56: }
57: }
58: }
|