particalmaxoccurstest.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 635 行 · 第 1/3 页
JAVA
635 行
fail();
}
}
public void testParticleChoiceMaxOccurs4() {
TestParticalChoiceMaxOccurs4 testParticalChoiceMaxOccurs4 = new TestParticalChoiceMaxOccurs4();
TestParticalChoiceMaxOccursType4 testParticalChoiceMaxOccursType4 = new TestParticalChoiceMaxOccursType4();
testParticalChoiceMaxOccurs4.setTestParticalChoiceMaxOccurs4(testParticalChoiceMaxOccursType4);
TestParticalChoiceMaxOccursType4Choice[] testParticalChoiceMaxOccursType4Choice =
new TestParticalChoiceMaxOccursType4Choice[3];
testParticalChoiceMaxOccursType4.setTestParticalChoiceMaxOccursType4Choice(testParticalChoiceMaxOccursType4Choice);
testParticalChoiceMaxOccursType4Choice[0] = new TestParticalChoiceMaxOccursType4Choice();
testParticalChoiceMaxOccursType4Choice[0].setParm1(getNewCustomType());
testParticalChoiceMaxOccursType4Choice[1] = new TestParticalChoiceMaxOccursType4Choice();
testParticalChoiceMaxOccursType4Choice[1].setParm2("Param2");
testParticalChoiceMaxOccursType4Choice[2] = new TestParticalChoiceMaxOccursType4Choice();
testParticalChoiceMaxOccursType4Choice[2].setParm3(getNewCustomType());
try {
OMElement omElement = testParticalChoiceMaxOccurs4.getOMElement(TestParticalChoiceMaxOccurs4.MY_QNAME,
OMAbstractFactory.getOMFactory());
String omElementString = omElement.toStringWithConsume();
System.out.println("OM String ==> " + omElementString);
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
TestParticalChoiceMaxOccurs4 result = TestParticalChoiceMaxOccurs4.Factory.parse(xmlReader);
TestParticalChoiceMaxOccursType4Choice[] resultChoices =
result.getTestParticalChoiceMaxOccurs4().getTestParticalChoiceMaxOccursType4Choice();
assertTrue(isEqual(resultChoices[0].getParm1(), testParticalChoiceMaxOccursType4Choice[0].getParm1()));
assertTrue(isEqual(resultChoices[0].getParm2(), testParticalChoiceMaxOccursType4Choice[0].getParm2()));
assertTrue(isEqual(resultChoices[0].getParm3(), testParticalChoiceMaxOccursType4Choice[0].getParm3()));
assertTrue(isEqual(resultChoices[1].getParm1(), testParticalChoiceMaxOccursType4Choice[1].getParm1()));
assertTrue(isEqual(resultChoices[1].getParm2(), testParticalChoiceMaxOccursType4Choice[1].getParm2()));
assertTrue(isEqual(resultChoices[1].getParm3(), testParticalChoiceMaxOccursType4Choice[1].getParm3()));
assertTrue(isEqual(resultChoices[2].getParm1(), testParticalChoiceMaxOccursType4Choice[2].getParm1()));
assertTrue(isEqual(resultChoices[2].getParm2(), testParticalChoiceMaxOccursType4Choice[2].getParm2()));
assertTrue(isEqual(resultChoices[2].getParm3(), testParticalChoiceMaxOccursType4Choice[2].getParm3()));
} catch (XMLStreamException e) {
fail();
} catch (Exception e) {
fail();
}
}
public void testParticleChoiceMaxOccurs5() {
TestParticalChoiceMaxOccurs5 testParticalChoiceMaxOccurs5 = new TestParticalChoiceMaxOccurs5();
TestParticalChoiceMaxOccursType5 testParticalChoiceMaxOccursType5 = new TestParticalChoiceMaxOccursType5();
testParticalChoiceMaxOccurs5.setTestParticalChoiceMaxOccurs5(testParticalChoiceMaxOccursType5);
TestParticalChoiceMaxOccursType5Choice[] testParticalChoiceMaxOccursType5Choice =
new TestParticalChoiceMaxOccursType5Choice[3];
testParticalChoiceMaxOccursType5.setTestParticalChoiceMaxOccursType5Choice(testParticalChoiceMaxOccursType5Choice);
testParticalChoiceMaxOccursType5Choice[0] = new TestParticalChoiceMaxOccursType5Choice();
testParticalChoiceMaxOccursType5Choice[0].setParm1(new TestCustomType[]{getNewCustomType()});
testParticalChoiceMaxOccursType5Choice[1] = new TestParticalChoiceMaxOccursType5Choice();
testParticalChoiceMaxOccursType5Choice[1].setParm2("Param2");
testParticalChoiceMaxOccursType5Choice[2] = new TestParticalChoiceMaxOccursType5Choice();
testParticalChoiceMaxOccursType5Choice[2].setParm3(new TestCustomType[]{getNewCustomType()});
try {
OMElement omElement = testParticalChoiceMaxOccurs5.getOMElement(TestParticalChoiceMaxOccurs5.MY_QNAME,
OMAbstractFactory.getOMFactory());
String omElementString = omElement.toStringWithConsume();
System.out.println("OM String ==> " + omElementString);
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
TestParticalChoiceMaxOccurs5 result = TestParticalChoiceMaxOccurs5.Factory.parse(xmlReader);
TestParticalChoiceMaxOccursType5Choice[] resultChoices =
result.getTestParticalChoiceMaxOccurs5().getTestParticalChoiceMaxOccursType5Choice();
assertTrue(isEqual(resultChoices[0].getParm1(), testParticalChoiceMaxOccursType5Choice[0].getParm1()));
assertTrue(isEqual(resultChoices[0].getParm2(), testParticalChoiceMaxOccursType5Choice[0].getParm2()));
assertTrue(isEqual(resultChoices[0].getParm3(), testParticalChoiceMaxOccursType5Choice[0].getParm3()));
assertTrue(isEqual(resultChoices[1].getParm1(), testParticalChoiceMaxOccursType5Choice[1].getParm1()));
assertTrue(isEqual(resultChoices[1].getParm2(), testParticalChoiceMaxOccursType5Choice[1].getParm2()));
assertTrue(isEqual(resultChoices[1].getParm3(), testParticalChoiceMaxOccursType5Choice[1].getParm3()));
assertTrue(isEqual(resultChoices[2].getParm1(), testParticalChoiceMaxOccursType5Choice[2].getParm1()));
assertTrue(isEqual(resultChoices[2].getParm2(), testParticalChoiceMaxOccursType5Choice[2].getParm2()));
assertTrue(isEqual(resultChoices[2].getParm3(), testParticalChoiceMaxOccursType5Choice[2].getParm3()));
} catch (XMLStreamException e) {
e.printStackTrace();
fail();
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
public void testParticalChoiceMaxOccursTest6() {
TestParticalChoiceMaxOccurs6 testParticalMaxOccures6 = new TestParticalChoiceMaxOccurs6();
TestParticalChoiceMaxOccursType6 testParticalMaxOccursType6 = new TestParticalChoiceMaxOccursType6();
testParticalMaxOccures6.setTestParticalChoiceMaxOccurs6(testParticalMaxOccursType6);
TestParticalChoiceMaxOccursType6Choice[] testChoices = new TestParticalChoiceMaxOccursType6Choice[2];
testChoices[0] = new TestParticalChoiceMaxOccursType6Choice();
testChoices[0].setParm1("Param11");
testChoices[1] = new TestParticalChoiceMaxOccursType6Choice();
testChoices[1].setParm2("Param12");
testParticalMaxOccursType6.setTestParticalChoiceMaxOccursType6Choice(testChoices);
testParticalMaxOccursType6.setAttribute1("Attribute1");
testParticalMaxOccursType6.setAttribute2("Attribute2");
try {
OMElement omElement = testParticalMaxOccures6.getOMElement(TestParticalChoiceMaxOccurs6.MY_QNAME,
OMAbstractFactory.getOMFactory());
String omElementString = omElement.toStringWithConsume();
System.out.println("OM String ==> " + omElementString);
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
TestParticalChoiceMaxOccurs6 result = TestParticalChoiceMaxOccurs6.Factory.parse(xmlReader);
TestParticalChoiceMaxOccursType6Choice[] resultChoices =
result.getTestParticalChoiceMaxOccurs6().getTestParticalChoiceMaxOccursType6Choice();
assertEquals(resultChoices[0].getParm1(), "Param11");
assertEquals(resultChoices[1].getParm2(), "Param12");
assertEquals(result.getTestParticalChoiceMaxOccurs6().getAttribute1(), "Attribute1");
assertEquals(result.getTestParticalChoiceMaxOccurs6().getAttribute2(), "Attribute2");
} catch (XMLStreamException e) {
fail();
} catch (Exception e) {
fail();
}
}
private TestCustomType getNewCustomType() {
i++;
TestCustomType testCustomType = new TestCustomType();
testCustomType.setParam1("Param" + i + "2");
testCustomType.setParam2(new String[]{"Param" + i + "21", "Param" + i + "22", "Param" + i + "23"});
testCustomType.setParam3("Param" + i + "3");
return testCustomType;
}
private boolean isEqual(TestCustomType object1, TestCustomType object2) {
boolean isEqual = false;
if ((object1 != null) && (object2 != null)) {
isEqual = isEqual(object1.getParam1(), object2.getParam1()) &&
isEqual(object1.getParam2(), object2.getParam2()) &&
isEqual(object1.getParam3(), object2.getParam3());
} else if ((object1 == null) && (object2 == null)) {
isEqual = true;
}
return isEqual;
}
private boolean isEqual(TestCustomType[] object1, TestCustomType[] object2) {
boolean isEqual = false;
if ((object1 != null) && (object2 != null)) {
if (object1.length == object2.length) {
isEqual = true;
for (int i = 0; i < object1.length; i++) {
if (!isEqual(object1[i], object2[i])) {
isEqual = false;
break;
}
}
}
} else if ((object1 == null) && (object2 == null)) {
isEqual = true;
}
return isEqual;
}
private boolean isEqual(String[] object1, String[] object2) {
boolean isEqual = false;
if ((object1 != null) && (object2 != null)) {
if (object1.length == object2.length) {
isEqual = true;
for (int i = 0; i < object1.length; i++) {
if (!isEqual(object1[i], object2[i])) {
isEqual = false;
break;
}
}
}
} else if ((object1 == null) && (object2 == null)) {
isEqual = true;
}
return isEqual;
}
private boolean isEqual(String object1, String object2) {
boolean isEqual = false;
if ((object1 != null) && (object2 != null)) {
isEqual = object1.equals(object2);
} else if ((object1 == null) && (object2 == null)) {
isEqual = true;
}
return isEqual;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?