Package org.tempuri.defaultnamepaces

Examples of org.tempuri.defaultnamepaces.TestElement1


public class DefaultNamespacesTest extends TestCase {

    public void testTestElement1() {

        TestElement1 testElement1 = new TestElement1();

        TestChildType testChildType = new TestChildType();
        testChildType.setParam1(new QName("http://tempuri.org/defaultnamepaces", "param1"));
        testChildType.setParam2("Param2");
        testChildType.setParam3(new QName("http://tempuri.org/defaultnamepaces", "param3"));
        testChildType.setParam4("Param4");

        TestSimpleUnion testSimpleUnion1 = new TestSimpleUnion();
        testSimpleUnion1.setObject(new QName("http://tempuri.org/defaultnamepaces", "param5"));

        testChildType.setParam5(testSimpleUnion1);

        testChildType.setAttribute1("attribute1");
        testChildType.setAttribute2(new QName("http://tempuri.org/defaultnamepaces", "attribute2"));

        TestSimpleUnion testSimpleUnion2 = new TestSimpleUnion();
        testSimpleUnion2.setObject(new QName("http://tempuri.org/defaultnamepaces", "attribute3"));


        testElement1.setTestElement1(testChildType);
        StringWriter stringWriter = new StringWriter();

        try {

            XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(stringWriter);
            MTOMAwareXMLStreamWriter mtomAwareXMLStreamWriter = new MTOMAwareXMLSerializer(xmlStreamWriter);
            testElement1.getTestElement1().serialize(new QName("http://tempuri.org/defaultnamepaces", "TestElement1", "ns1"),
                    OMAbstractFactory.getSOAP11Factory(), mtomAwareXMLStreamWriter);
            xmlStreamWriter.flush();
            xmlStreamWriter.close();
            String omElementString = stringWriter.toString();
            System.out.println("OM String ==> " + omElementString);
            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
            TestElement1 result = TestElement1.Factory.parse(xmlReader);
            assertTrue(result.getTestElement1() instanceof TestChildType);
            TestChildType resultType = (TestChildType) result.getTestElement1();
            assertEquals(resultType.getParam1(), new QName("http://tempuri.org/defaultnamepaces", "param1"));
            assertEquals(resultType.getParam2(), "Param2");
            assertEquals(resultType.getParam3(), new QName("http://tempuri.org/defaultnamepaces", "param3"));
            assertEquals(resultType.getParam4(), "Param4");
            assertEquals(resultType.getAttribute1(), "attribute1");
View Full Code Here


public class DefaultNamespacesTest extends TestCase {

    public void testTestElement1() {

        TestElement1 testElement1 = new TestElement1();

        TestChildType testChildType = new TestChildType();
        testChildType.setParam1(new QName("http://tempuri.org/defaultnamepaces", "param1"));
        testChildType.setParam2("Param2");
        testChildType.setParam3(new QName("http://tempuri.org/defaultnamepaces", "param3"));
        testChildType.setParam4("Param4");

        TestSimpleUnion testSimpleUnion1 = new TestSimpleUnion();
        testSimpleUnion1.setObject(new QName("http://tempuri.org/defaultnamepaces", "param5"));

        testChildType.setParam5(testSimpleUnion1);

        testChildType.setAttribute1("attribute1");
        testChildType.setAttribute2(new QName("http://tempuri.org/defaultnamepaces", "attribute2"));

        TestSimpleUnion testSimpleUnion2 = new TestSimpleUnion();
        testSimpleUnion2.setObject(new QName("http://tempuri.org/defaultnamepaces", "attribute3"));


        testElement1.setTestElement1(testChildType);
        StringWriter stringWriter = new StringWriter();

        try {

            XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(stringWriter);
            MTOMAwareXMLStreamWriter mtomAwareXMLStreamWriter = new MTOMAwareXMLSerializer(xmlStreamWriter);
            testElement1.getTestElement1().serialize(new QName("http://tempuri.org/defaultnamepaces", "TestElement1", "ns1"),
                    OMAbstractFactory.getSOAP11Factory(), mtomAwareXMLStreamWriter);
            xmlStreamWriter.flush();
            xmlStreamWriter.close();
            String omElementString = stringWriter.toString();
            System.out.println("OM String ==> " + omElementString);
            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
            TestElement1 result = TestElement1.Factory.parse(xmlReader);
            assertTrue(result.getTestElement1() instanceof TestChildType);
            TestChildType resultType = (TestChildType) result.getTestElement1();
            assertEquals(resultType.getParam1(), new QName("http://tempuri.org/defaultnamepaces", "param1"));
            assertEquals(resultType.getParam2(), "Param2");
            assertEquals(resultType.getParam3(), new QName("http://tempuri.org/defaultnamepaces", "param3"));
            assertEquals(resultType.getParam4(), "Param4");
            assertEquals(resultType.getAttribute1(), "attribute1");
View Full Code Here

TOP

Related Classes of org.tempuri.defaultnamepaces.TestElement1

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.