particalmaxoccurstest.java

来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 635 行 · 第 1/3 页

JAVA
635
字号

        testParticalSequenceMaxOccursType5Sequence[0] = new TestParticalSequenceMaxOccursType5Sequence();
        testParticalSequenceMaxOccursType5Sequence[0].setParm1(new TestCustomType[]{getNewCustomType()});
        testParticalSequenceMaxOccursType5Sequence[0].setParm3(new TestCustomType[]{getNewCustomType()});

        testParticalSequenceMaxOccursType5Sequence[1] = new TestParticalSequenceMaxOccursType5Sequence();
        testParticalSequenceMaxOccursType5Sequence[1].setParm1(new TestCustomType[]{getNewCustomType()});
        testParticalSequenceMaxOccursType5Sequence[1].setParm2("Param2");
        testParticalSequenceMaxOccursType5Sequence[1].setParm3(new TestCustomType[]{getNewCustomType()});

        testParticalSequenceMaxOccursType5Sequence[2] = new TestParticalSequenceMaxOccursType5Sequence();
        testParticalSequenceMaxOccursType5Sequence[2].setParm1(new TestCustomType[]{getNewCustomType()});
        testParticalSequenceMaxOccursType5Sequence[2].setParm3(new TestCustomType[]{getNewCustomType()});

        try {
            OMElement omElement = testParticalSequenceMaxOccurs5.getOMElement(TestParticalSequenceMaxOccurs5.MY_QNAME,
                    OMAbstractFactory.getOMFactory());
            String omElementString = omElement.toStringWithConsume();
            System.out.println("OM String ==> " + omElementString);
            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
            TestParticalSequenceMaxOccurs5 result = TestParticalSequenceMaxOccurs5.Factory.parse(xmlReader);
            TestParticalSequenceMaxOccursType5Sequence[] resultSequences =
                    result.getTestParticalSequenceMaxOccurs5().getTestParticalSequenceMaxOccursType5Sequence();
            assertTrue(isEqual(resultSequences[0].getParm1(), testParticalSequenceMaxOccursType5Sequence[0].getParm1()));
            assertTrue(isEqual(resultSequences[0].getParm2(), testParticalSequenceMaxOccursType5Sequence[0].getParm2()));
            assertTrue(isEqual(resultSequences[0].getParm3(), testParticalSequenceMaxOccursType5Sequence[0].getParm3()));

            assertTrue(isEqual(resultSequences[1].getParm1(), testParticalSequenceMaxOccursType5Sequence[1].getParm1()));
            assertTrue(isEqual(resultSequences[1].getParm2(), testParticalSequenceMaxOccursType5Sequence[1].getParm2()));
            assertTrue(isEqual(resultSequences[1].getParm3(), testParticalSequenceMaxOccursType5Sequence[1].getParm3()));

            assertTrue(isEqual(resultSequences[2].getParm1(), testParticalSequenceMaxOccursType5Sequence[2].getParm1()));
            assertTrue(isEqual(resultSequences[2].getParm2(), testParticalSequenceMaxOccursType5Sequence[2].getParm2()));
            assertTrue(isEqual(resultSequences[2].getParm3(), testParticalSequenceMaxOccursType5Sequence[2].getParm3()));

        } catch (XMLStreamException e) {
            e.printStackTrace();
            fail();
        } catch (Exception e) {
            e.printStackTrace();
            fail();
        }


    }

    public void testParticalSequenceMaxOccursTest6() {
        TestParticalSequenceMaxOccurs6 testParticalMaxOccures6 = new TestParticalSequenceMaxOccurs6();
        TestParticalSequenceMaxOccursType6 testParticalMaxOccursType6 = new TestParticalSequenceMaxOccursType6();
        testParticalMaxOccures6.setTestParticalSequenceMaxOccurs6(testParticalMaxOccursType6);

        TestParticalSequenceMaxOccursType6Sequence[] testSequences = new TestParticalSequenceMaxOccursType6Sequence[2];

        testSequences[0] = new TestParticalSequenceMaxOccursType6Sequence();
        testSequences[0].setParm1("Param11");
        testSequences[0].setParm2("Param12");

        testSequences[1] = new TestParticalSequenceMaxOccursType6Sequence();
        testSequences[1].setParm1("Param21");
        testSequences[1].setParm2("Param22");

        testParticalMaxOccursType6.setTestParticalSequenceMaxOccursType6Sequence(testSequences);
        testParticalMaxOccursType6.setAttribute1("Attribute1");
        testParticalMaxOccursType6.setAttribute2("Attribute2");

        try {
            OMElement omElement = testParticalMaxOccures6.getOMElement(TestParticalSequenceMaxOccurs6.MY_QNAME,
                     OMAbstractFactory.getOMFactory());
            String omElementString = omElement.toStringWithConsume();
            System.out.println("OM String ==> " + omElementString);
            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
            TestParticalSequenceMaxOccurs6 result = TestParticalSequenceMaxOccurs6.Factory.parse(xmlReader);
            TestParticalSequenceMaxOccursType6Sequence[] resultSequences =
                    result.getTestParticalSequenceMaxOccurs6().getTestParticalSequenceMaxOccursType6Sequence();
            assertEquals(resultSequences[0].getParm1(), "Param11");
            assertEquals(resultSequences[0].getParm2(), "Param12");
            assertEquals(resultSequences[1].getParm1(), "Param21");
            assertEquals(resultSequences[1].getParm2(), "Param22");
            assertEquals(result.getTestParticalSequenceMaxOccurs6().getAttribute1(), "Attribute1");
            assertEquals(result.getTestParticalSequenceMaxOccurs6().getAttribute2(), "Attribute2");
        } catch (XMLStreamException e) {
            fail();
        } catch (Exception e) {
            fail();
        }
    }

    public void testParticalMaxOccursTest() {
        TestParticalChoiceMaxOccurs testParticalChoiceMaxOccurs = new TestParticalChoiceMaxOccurs();
        TestParticalChoiceMaxOccursType testParticalChoiceMaxOccursType = new TestParticalChoiceMaxOccursType();
        testParticalChoiceMaxOccurs.setTestParticalChoiceMaxOccurs(testParticalChoiceMaxOccursType);

        testParticalChoiceMaxOccursType.setParm1("Param1");

        try {
            OMElement omElement =
                     testParticalChoiceMaxOccurs.getOMElement(TestParticalChoiceMaxOccurs.MY_QNAME, OMAbstractFactory.getOMFactory());
            String omElementString = omElement.toStringWithConsume();
            System.out.println("OM string ==> " + omElementString);
            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
            TestParticalChoiceMaxOccurs result = TestParticalChoiceMaxOccurs.Factory.parse(xmlReader);
            assertEquals(result.getTestParticalChoiceMaxOccurs().getParm1(), "Param1");
        } catch (XMLStreamException e) {
            fail();
        } catch (Exception e) {
            fail();
        }
    }

    public void testParticalChoiceMaxOccursTest1() {
        TestParticalChoiceMaxOccurs1 testParticalMaxOccures1 = new TestParticalChoiceMaxOccurs1();
        TestParticalChoiceMaxOccursType1 testParticalMaxOccursType1 = new TestParticalChoiceMaxOccursType1();
        testParticalMaxOccures1.setTestParticalChoiceMaxOccurs1(testParticalMaxOccursType1);

        TestParticalChoiceMaxOccursType1Choice[] testChoices = new TestParticalChoiceMaxOccursType1Choice[2];

        testChoices[0] = new TestParticalChoiceMaxOccursType1Choice();
        testChoices[0].setParm1("Param11");

        testChoices[1] = new TestParticalChoiceMaxOccursType1Choice();
        testChoices[1].setParm2("Param12");

        testParticalMaxOccursType1.setTestParticalChoiceMaxOccursType1Choice(testChoices);

       try {
            OMElement omElement = testParticalMaxOccures1.getOMElement(TestParticalChoiceMaxOccurs1.MY_QNAME,
                   OMAbstractFactory.getOMFactory());
            String omElementString = omElement.toStringWithConsume();
            System.out.println("OM String ==> " + omElementString);
            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
            TestParticalChoiceMaxOccurs1 result = TestParticalChoiceMaxOccurs1.Factory.parse(xmlReader);
            TestParticalChoiceMaxOccursType1Choice[] resultChoices =
                    result.getTestParticalChoiceMaxOccurs1().getTestParticalChoiceMaxOccursType1Choice();
            assertEquals(resultChoices[0].getParm1(), "Param11");
            assertEquals(resultChoices[1].getParm2(), "Param12");
        } catch (XMLStreamException e) {
            fail();
        } catch (Exception e) {
            fail();
        }
    }

    public void testParticleChoiceMaxOccurs2() {
        TestParticalChoiceMaxOccurs2 testParticalMaxOccures2 = new TestParticalChoiceMaxOccurs2();
        TestParticalChoiceMaxOccursType2 testParticalMaxOccursType2 = new TestParticalChoiceMaxOccursType2();
        testParticalMaxOccures2.setTestParticalChoiceMaxOccurs2(testParticalMaxOccursType2);

        TestParticalChoiceMaxOccursType2Choice[] testChoices = new TestParticalChoiceMaxOccursType2Choice[2];

        testChoices[0] = new TestParticalChoiceMaxOccursType2Choice();
        testChoices[0].setParm1(new String[]{"Param111", "Param112", "Param113"});

        testChoices[1] = new TestParticalChoiceMaxOccursType2Choice();
        testChoices[1].setParm2(new String[]{"Param121", "Param122", "Param123"});

        testParticalMaxOccursType2.setTestParticalChoiceMaxOccursType2Choice(testChoices);

         try {
             OMElement omElement = testParticalMaxOccures2.getOMElement(TestParticalChoiceMaxOccurs2.MY_QNAME,
                      OMAbstractFactory.getOMFactory());
            String omElementString = omElement.toStringWithConsume();
            System.out.println("OM String ==> " + omElementString);
            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
            TestParticalChoiceMaxOccurs2 result = TestParticalChoiceMaxOccurs2.Factory.parse(xmlReader);
            TestParticalChoiceMaxOccursType2Choice[] resultChoices =
                    result.getTestParticalChoiceMaxOccurs2().getTestParticalChoiceMaxOccursType2Choice();
            assertEquals(resultChoices[0].getParm1()[0], "Param111");
            assertEquals(resultChoices[0].getParm1()[1], "Param112");
            assertEquals(resultChoices[0].getParm1()[2], "Param113");
            assertEquals(resultChoices[1].getParm2()[0], "Param121");
            assertEquals(resultChoices[1].getParm2()[1], "Param122");
            assertEquals(resultChoices[1].getParm2()[2], "Param123");
        } catch (XMLStreamException e) {
            fail();
        } catch (Exception e) {
            fail();
        }
    }

    public void testParticleChoiceMaxOccurs3() {
        TestParticalChoiceMaxOccurs3 testParticalMaxOccures3 = new TestParticalChoiceMaxOccurs3();
        TestParticalChoiceMaxOccursType3 testParticalMaxOccursType3 = new TestParticalChoiceMaxOccursType3();
        testParticalMaxOccures3.setTestParticalChoiceMaxOccurs3(testParticalMaxOccursType3);

        TestParticalChoiceMaxOccursType3Choice[] testChoices = new TestParticalChoiceMaxOccursType3Choice[2];

        testChoices[0] = new TestParticalChoiceMaxOccursType3Choice();
        testChoices[0].setParm1(new String[]{"Param111", null, "Param113"});

        testChoices[1] = new TestParticalChoiceMaxOccursType3Choice();
        testChoices[1].setParm2(new String[]{"Param121", "Param122", null});

        testParticalMaxOccursType3.setTestParticalChoiceMaxOccursType3Choice(testChoices);

        try {
            OMElement omElement = testParticalMaxOccures3.getOMElement(TestParticalChoiceMaxOccurs3.MY_QNAME,
                     OMAbstractFactory.getOMFactory());
            String omElementString = omElement.toStringWithConsume();
            System.out.println("OM String ==> " + omElementString);
            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
            TestParticalChoiceMaxOccurs3 result = TestParticalChoiceMaxOccurs3.Factory.parse(xmlReader);
            TestParticalChoiceMaxOccursType3Choice[] resultChoices =
                    result.getTestParticalChoiceMaxOccurs3().getTestParticalChoiceMaxOccursType3Choice();
            assertEquals(resultChoices[0].getParm1()[0], "Param111");
            assertEquals(resultChoices[0].getParm1()[1], null);
            assertEquals(resultChoices[0].getParm1()[2], "Param113");
            assertEquals(resultChoices[1].getParm2()[0], "Param121");
            assertEquals(resultChoices[1].getParm2()[1], "Param122");
            assertEquals(resultChoices[1].getParm2()[2], null);
        } catch (XMLStreamException e) {
            fail();
        } catch (Exception e) {

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?