0001: package org.objectweb.celtix.systest.type_test;
0002:
0003: import java.math.BigDecimal;
0004: import java.math.BigInteger;
0005: import java.net.URL;
0006: import java.util.ArrayList;
0007: import java.util.Arrays;
0008: import java.util.List;
0009:
0010: import javax.xml.datatype.DatatypeConstants;
0011: import javax.xml.datatype.Duration;
0012: import javax.xml.datatype.XMLGregorianCalendar;
0013: import javax.xml.namespace.QName;
0014: import javax.xml.ws.Holder;
0015: import javax.xml.ws.WebServiceException;
0016:
0017: import org.objectweb.celtix.systest.common.ClientServerTestBase;
0018: import org.objectweb.type_test.types1.AnyURIEnum; //import org.objectweb.type_test.types1.ColourEnum;
0019: import org.objectweb.type_test.types1.DecimalEnum;
0020: import org.objectweb.type_test.types1.NMTokenEnum;
0021: import org.objectweb.type_test.types1.NumberEnum;
0022: import org.objectweb.type_test.types1.StringEnum;
0023:
0024: public abstract class AbstractTypeTestClient extends
0025: ClientServerTestBase implements TypeTestTester {
0026: protected static org.objectweb.type_test.doc.TypeTestPortType docClient;
0027: protected static org.objectweb.type_test.rpc.TypeTestPortType rpcClient;
0028: protected static boolean testDocLiteral;
0029: protected static boolean testXMLBinding;
0030:
0031: protected boolean perfTestOnly;
0032:
0033: private final QName serviceName;
0034: private final QName portName;
0035: private final String wsdlPath;
0036:
0037: public AbstractTypeTestClient(String name, QName theServicename,
0038: QName thePort, String theWsdlPath) {
0039: super (name);
0040:
0041: System.setProperty("javax.xml.ws.spi.Provider",
0042: "org.objectweb.celtix.bus.jaxws.spi.ProviderImpl");
0043: serviceName = theServicename;
0044: portName = thePort;
0045: wsdlPath = theWsdlPath;
0046: }
0047:
0048: public void setPerformanceTestOnly() {
0049: perfTestOnly = true;
0050: }
0051:
0052: public void setUp() throws Exception {
0053: super .setUp();
0054:
0055: //
0056: // Check the name of the wsdlPath to decide whether to test doc
0057: // literal or rpc literal style.
0058: //
0059: URL wsdlLocation = getClass().getResource(wsdlPath);
0060: assertNotNull("Could not load wsdl " + wsdlPath, wsdlLocation);
0061: testDocLiteral = wsdlPath.contains("doclit");
0062: testXMLBinding = wsdlPath.contains("_xml");
0063: if (testXMLBinding) {
0064: testDocLiteral = true;
0065: org.objectweb.type_test.doc.XMLService docService = new org.objectweb.type_test.doc.XMLService(
0066: wsdlLocation, serviceName);
0067: docClient = docService.getPort(portName,
0068: org.objectweb.type_test.doc.TypeTestPortType.class);
0069: assertNotNull("Could not create docClient", docClient);
0070: } else {
0071: if (testDocLiteral) {
0072: org.objectweb.type_test.doc.SOAPService docService = new org.objectweb.type_test.doc.SOAPService(
0073: wsdlLocation, serviceName);
0074: docClient = docService
0075: .getPort(
0076: portName,
0077: org.objectweb.type_test.doc.TypeTestPortType.class);
0078: assertNotNull("Could not create docClient", docClient);
0079: } else {
0080: org.objectweb.type_test.rpc.SOAPService rpcService = new org.objectweb.type_test.rpc.SOAPService(
0081: wsdlLocation, serviceName);
0082: rpcClient = rpcService
0083: .getPort(
0084: portName,
0085: org.objectweb.type_test.rpc.TypeTestPortType.class);
0086: assertNotNull("Could not create rpcClient", rpcClient);
0087: }
0088: }
0089: }
0090:
0091: protected boolean equalsDate(XMLGregorianCalendar orig,
0092: XMLGregorianCalendar actual) {
0093: boolean result = false;
0094:
0095: if ((orig.getYear() == actual.getYear())
0096: && (orig.getMonth() == actual.getMonth())
0097: && (orig.getDay() == actual.getDay())
0098: && (actual.getHour() == DatatypeConstants.FIELD_UNDEFINED)
0099: && (actual.getMinute() == DatatypeConstants.FIELD_UNDEFINED)
0100: && (actual.getSecond() == DatatypeConstants.FIELD_UNDEFINED)
0101: && (actual.getMillisecond() == DatatypeConstants.FIELD_UNDEFINED)) {
0102:
0103: result = orig.getTimezone() == actual.getTimezone();
0104: }
0105: return result;
0106: }
0107:
0108: protected boolean equalsTime(XMLGregorianCalendar orig,
0109: XMLGregorianCalendar actual) {
0110: boolean result = false;
0111: if ((orig.getHour() == actual.getHour())
0112: && (orig.getMinute() == actual.getMinute())
0113: && (orig.getSecond() == actual.getSecond())
0114: && (orig.getMillisecond() == actual.getMillisecond())
0115: && (orig.getTimezone() == actual.getTimezone())) {
0116: result = true;
0117: }
0118: return result;
0119: }
0120:
0121: protected boolean equalsDateTime(XMLGregorianCalendar orig,
0122: XMLGregorianCalendar actual) {
0123: boolean result = false;
0124: if ((orig.getYear() == actual.getYear())
0125: && (orig.getMonth() == actual.getMonth())
0126: && (orig.getDay() == actual.getDay())
0127: && (orig.getHour() == actual.getHour())
0128: && (orig.getMinute() == actual.getMinute())
0129: && (orig.getSecond() == actual.getSecond())
0130: && (orig.getMillisecond() == actual.getMillisecond())) {
0131:
0132: result = orig.getTimezone() == actual.getTimezone();
0133: }
0134: return result;
0135: }
0136:
0137: public void testVoid() throws Exception {
0138: if (testDocLiteral) {
0139: docClient.testVoid();
0140: } else {
0141: rpcClient.testVoid();
0142: }
0143: }
0144:
0145: public void testOneway() throws Exception {
0146: String x = "hello";
0147: String y = "oneway";
0148: if (testDocLiteral) {
0149: docClient.testOneway(x, y);
0150: } else {
0151: rpcClient.testOneway(x, y);
0152: }
0153: }
0154:
0155: public void testByte() throws Exception {
0156: byte valueSets[][] = { { 0, 1 }, { -1, 0 },
0157: { Byte.MIN_VALUE, Byte.MAX_VALUE } };
0158:
0159: for (int i = 0; i < valueSets.length; i++) {
0160: byte x = valueSets[i][0];
0161: Holder<Byte> yOrig = new Holder<Byte>(valueSets[i][1]);
0162: Holder<Byte> y = new Holder<Byte>(valueSets[i][1]);
0163: Holder<Byte> z = new Holder<Byte>();
0164:
0165: byte ret;
0166: if (testDocLiteral) {
0167: ret = docClient.testByte(x, y, z);
0168: } else {
0169: ret = rpcClient.testByte(x, y, z);
0170: }
0171: if (!perfTestOnly) {
0172: assertEquals(
0173: "testByte(): Incorrect value for inout param",
0174: Byte.valueOf(x), y.value);
0175: assertEquals(
0176: "testByte(): Incorrect value for out param",
0177: yOrig.value, z.value);
0178: assertEquals("testByte(): Incorrect return value", x,
0179: ret);
0180: }
0181: }
0182: }
0183:
0184: public void testShort() throws Exception {
0185: short valueSets[][] = { { 0, 1 }, { -1, 0 },
0186: { Short.MIN_VALUE, Short.MAX_VALUE } };
0187:
0188: for (int i = 0; i < valueSets.length; i++) {
0189: short x = valueSets[i][0];
0190: Holder<Short> yOrig = new Holder<Short>(valueSets[i][1]);
0191: Holder<Short> y = new Holder<Short>(valueSets[i][1]);
0192: Holder<Short> z = new Holder<Short>();
0193:
0194: short ret;
0195: if (testDocLiteral) {
0196: ret = docClient.testShort(x, y, z);
0197: } else {
0198: ret = rpcClient.testShort(x, y, z);
0199: }
0200: if (!perfTestOnly) {
0201: assertEquals(
0202: "testShort(): Incorrect value for inout param",
0203: Short.valueOf(x), y.value);
0204: assertEquals(
0205: "testShort(): Incorrect value for out param",
0206: yOrig.value, z.value);
0207: assertEquals("testShort(): Incorrect return value", x,
0208: ret);
0209: }
0210: }
0211: }
0212:
0213: public void testUnsignedShort() throws Exception {
0214: int valueSets[][] = { { 0, 1 }, { 1, 0 },
0215: { 0, Short.MAX_VALUE * 2 + 1 } };
0216:
0217: for (int i = 0; i < valueSets.length; i++) {
0218: int x = valueSets[i][0];
0219: Holder<Integer> yOrig = new Holder<Integer>(valueSets[i][1]);
0220: Holder<Integer> y = new Holder<Integer>(valueSets[i][1]);
0221: Holder<Integer> z = new Holder<Integer>();
0222:
0223: int ret;
0224: if (testDocLiteral) {
0225: ret = docClient.testUnsignedShort(x, y, z);
0226: } else {
0227: ret = rpcClient.testUnsignedShort(x, y, z);
0228: }
0229: if (!perfTestOnly) {
0230: assertEquals(
0231: "testUnsignedShort(): Incorrect value for inout param",
0232: Integer.valueOf(x), y.value);
0233: assertEquals(
0234: "testUnsignedShort(): Incorrect value for out param",
0235: yOrig.value, z.value);
0236: assertEquals(
0237: "testUnsignedShort(): Incorrect return value",
0238: x, ret);
0239: }
0240: }
0241: }
0242:
0243: public void testInt() throws Exception {
0244: int valueSets[][] = { { 5, 10 }, { -10, 50 },
0245: { Integer.MIN_VALUE, Integer.MAX_VALUE } };
0246:
0247: for (int i = 0; i < valueSets.length; i++) {
0248: int x = valueSets[i][0];
0249: Holder<Integer> yOrig = new Holder<Integer>(valueSets[i][1]);
0250: Holder<Integer> y = new Holder<Integer>(valueSets[i][1]);
0251: Holder<Integer> z = new Holder<Integer>();
0252:
0253: int ret;
0254: if (testDocLiteral) {
0255: ret = docClient.testInt(x, y, z);
0256: } else {
0257: ret = rpcClient.testInt(x, y, z);
0258: }
0259: if (!perfTestOnly) {
0260: assertEquals(
0261: "testInt(): Incorrect value for inout param",
0262: Integer.valueOf(x), y.value);
0263: assertEquals(
0264: "testInt(): Incorrect value for out param",
0265: yOrig.value, z.value);
0266: assertEquals("testInt(): Incorrect return value", x,
0267: ret);
0268: }
0269: }
0270: }
0271:
0272: public void testUnsignedInt() throws Exception {
0273: long valueSets[][] = { { 11, 20 }, { 1, 0 },
0274: { 0, ((long) Integer.MAX_VALUE) * 2 + 1 } };
0275:
0276: for (int i = 0; i < valueSets.length; i++) {
0277: long x = valueSets[i][0];
0278: long yOrig = valueSets[i][1];
0279: Holder<Long> y = new Holder<Long>(valueSets[i][1]);
0280: Holder<Long> z = new Holder<Long>();
0281:
0282: long ret;
0283: if (testDocLiteral) {
0284: ret = docClient.testUnsignedInt(x, y, z);
0285: } else {
0286: ret = rpcClient.testUnsignedInt(x, y, z);
0287: }
0288: if (!perfTestOnly) {
0289: assertEquals(
0290: "testUnsignedInt(): Incorrect value for inout param",
0291: Long.valueOf(x), y.value);
0292: assertEquals(
0293: "testUnsignedInt(): Incorrect value for out param",
0294: Long.valueOf(yOrig), z.value);
0295: assertEquals(
0296: "testUnsignedInt(): Incorrect return value", x,
0297: ret);
0298: }
0299: }
0300: }
0301:
0302: public void testLong() throws Exception {
0303: long valueSets[][] = { { 0, 1 }, { -1, 0 },
0304: { Long.MIN_VALUE, Long.MAX_VALUE } };
0305:
0306: for (int i = 0; i < valueSets.length; i++) {
0307: long x = valueSets[i][0];
0308: Holder<Long> yOrig = new Holder<Long>(valueSets[i][1]);
0309: Holder<Long> y = new Holder<Long>(valueSets[i][1]);
0310: Holder<Long> z = new Holder<Long>();
0311:
0312: long ret;
0313: if (testDocLiteral) {
0314: ret = docClient.testLong(x, y, z);
0315: } else {
0316: ret = rpcClient.testLong(x, y, z);
0317: }
0318: if (!perfTestOnly) {
0319: assertEquals(
0320: "testLong(): Incorrect value for inout param",
0321: Long.valueOf(x), y.value);
0322: assertEquals(
0323: "testLong(): Incorrect value for out param",
0324: yOrig.value, z.value);
0325: assertEquals("testLong(): Incorrect return value", x,
0326: ret);
0327: }
0328: }
0329: }
0330:
0331: public void testUnsignedLong() throws Exception {
0332: BigInteger valueSets[][] = {
0333: { new BigInteger("0"), new BigInteger("1") },
0334: { new BigInteger("1"), new BigInteger("0") },
0335: {
0336: new BigInteger("0"),
0337: new BigInteger(String.valueOf(Long.MAX_VALUE
0338: * Long.MAX_VALUE)) } };
0339:
0340: for (int i = 0; i < valueSets.length; i++) {
0341: BigInteger x = valueSets[i][0];
0342: Holder<BigInteger> yOrig = new Holder<BigInteger>(
0343: valueSets[i][1]);
0344: Holder<BigInteger> y = new Holder<BigInteger>(
0345: valueSets[i][1]);
0346: Holder<BigInteger> z = new Holder<BigInteger>();
0347:
0348: BigInteger ret;
0349: if (testDocLiteral) {
0350: ret = docClient.testUnsignedLong(x, y, z);
0351: } else {
0352: ret = rpcClient.testUnsignedLong(x, y, z);
0353: }
0354: if (!perfTestOnly) {
0355: assertEquals(
0356: "testUnsignedLong(): Incorrect value for inout param",
0357: x, y.value);
0358: assertEquals(
0359: "testUnsignedLong(): Incorrect value for out param",
0360: yOrig.value, z.value);
0361: assertEquals(
0362: "testUnsignedLong(): Incorrect return value",
0363: x, ret);
0364: }
0365: }
0366: }
0367:
0368: public void testFloat() throws Exception {
0369: float delta = 0.0f;
0370: float valueSets[][] = { { 0.0f, 1.0f },
0371: { -1.0f, (float) java.lang.Math.PI },
0372: { -100.0f, 100.0f },
0373: { Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }, };
0374:
0375: for (int i = 0; i < valueSets.length; i++) {
0376: float x = valueSets[i][0];
0377: Holder<Float> yOrig = new Holder<Float>(valueSets[i][1]);
0378: Holder<Float> y = new Holder<Float>(valueSets[i][1]);
0379: Holder<Float> z = new Holder<Float>();
0380:
0381: float ret;
0382: if (testDocLiteral) {
0383: ret = docClient.testFloat(x, y, z);
0384: } else {
0385: ret = rpcClient.testFloat(x, y, z);
0386: }
0387: if (!perfTestOnly) {
0388: assertEquals(i
0389: + ": testFloat(): Wrong value for inout param",
0390: x, y.value, delta);
0391: assertEquals(i
0392: + ": testFloat(): Wrong value for out param",
0393: yOrig.value, z.value, delta);
0394: assertEquals(i + ": testFloat(): Wrong return value",
0395: x, ret, delta);
0396: }
0397: }
0398:
0399: float x = Float.NaN;
0400: Holder<Float> yOrig = new Holder<Float>(0.0f);
0401: Holder<Float> y = new Holder<Float>(0.0f);
0402: Holder<Float> z = new Holder<Float>();
0403: float ret;
0404: if (testDocLiteral) {
0405: ret = docClient.testFloat(x, y, z);
0406: } else {
0407: ret = rpcClient.testFloat(x, y, z);
0408: }
0409: if (!perfTestOnly) {
0410: assertTrue("testFloat(): Incorrect value for inout param",
0411: Float.isNaN(y.value));
0412: assertEquals("testFloat(): Incorrect value for out param",
0413: yOrig.value, z.value, delta);
0414: assertTrue("testFloat(): Incorrect return value", Float
0415: .isNaN(ret));
0416: }
0417: }
0418:
0419: public void testDouble() throws Exception {
0420: double delta = 0.0d;
0421: double valueSets[][] = { { 0.0f, 1.0f },
0422: { -1, java.lang.Math.PI }, { -100.0, 100.0 },
0423: { Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY },
0424: //{Double.MIN_VALUE, 0},
0425: //{Double.MAX_VALUE,0},
0426: };
0427: for (int i = 0; i < valueSets.length; i++) {
0428: double x = valueSets[i][0];
0429: Holder<Double> yOrig = new Holder<Double>(valueSets[i][1]);
0430: Holder<Double> y = new Holder<Double>(valueSets[i][1]);
0431: Holder<Double> z = new Holder<Double>();
0432:
0433: double ret;
0434: if (testDocLiteral) {
0435: ret = docClient.testDouble(x, y, z);
0436: } else {
0437: ret = rpcClient.testDouble(x, y, z);
0438: }
0439: if (!perfTestOnly) {
0440: assertEquals(
0441: "testDouble(): Incorrect value for inout param",
0442: x, y.value, delta);
0443: assertEquals(
0444: "testDouble(): Incorrect value for out param",
0445: yOrig.value, z.value, delta);
0446: assertEquals("testDouble(): Incorrect return value", x,
0447: ret, delta);
0448: }
0449: }
0450:
0451: double x = Double.NaN;
0452: Holder<Double> yOrig = new Holder<Double>(0.0);
0453: Holder<Double> y = new Holder<Double>(0.0);
0454: Holder<Double> z = new Holder<Double>();
0455: double ret;
0456: if (testDocLiteral) {
0457: ret = docClient.testDouble(x, y, z);
0458: } else {
0459: ret = rpcClient.testDouble(x, y, z);
0460: }
0461: if (!perfTestOnly) {
0462: assertTrue("testDouble(): Incorrect value for inout param",
0463: Double.isNaN(y.value));
0464: assertEquals("testDouble(): Incorrect value for out param",
0465: yOrig.value, z.value, delta);
0466: assertTrue("testDouble(): Incorrect return value", Double
0467: .isNaN(ret));
0468: }
0469: }
0470:
0471: public void testUnsignedByte() throws Exception {
0472: short valueSets[][] = { { 0, 1 }, { 1, 0 },
0473: { 0, Byte.MAX_VALUE * 2 + 1 } };
0474:
0475: for (int i = 0; i < valueSets.length; i++) {
0476: short x = valueSets[i][0];
0477: Holder<Short> yOrig = new Holder<Short>(valueSets[i][1]);
0478: Holder<Short> y = new Holder<Short>(valueSets[i][1]);
0479: Holder<Short> z = new Holder<Short>();
0480:
0481: short ret;
0482: if (testDocLiteral) {
0483: ret = docClient.testUnsignedByte(x, y, z);
0484: } else {
0485: ret = rpcClient.testUnsignedByte(x, y, z);
0486: }
0487: if (!perfTestOnly) {
0488: assertEquals(
0489: "testUnsignedByte(): Incorrect value for inout param",
0490: Short.valueOf(x), y.value);
0491: assertEquals(
0492: "testUnsignedByte(): Incorrect value for out param",
0493: yOrig.value, z.value);
0494: assertEquals(
0495: "testUnsignedByte(): Incorrect return value",
0496: x, ret);
0497: }
0498: }
0499: }
0500:
0501: public void testBoolean() throws Exception {
0502: boolean valueSets[][] = { { true, false }, { true, true },
0503: { false, true }, { false, false } };
0504:
0505: for (int i = 0; i < valueSets.length; i++) {
0506: boolean x = valueSets[i][0];
0507: Holder<Boolean> yOrig = new Holder<Boolean>(valueSets[i][1]);
0508: Holder<Boolean> y = new Holder<Boolean>(valueSets[i][1]);
0509: Holder<Boolean> z = new Holder<Boolean>();
0510:
0511: boolean ret;
0512: if (testDocLiteral) {
0513: ret = docClient.testBoolean(x, y, z);
0514: } else {
0515: ret = rpcClient.testBoolean(x, y, z);
0516: }
0517: if (!perfTestOnly) {
0518: assertEquals(
0519: "testBoolean(): Incorrect value for inout param",
0520: Boolean.valueOf(x), y.value);
0521: assertEquals(
0522: "testBoolean(): Incorrect value for out param",
0523: yOrig.value, z.value);
0524: assertEquals("testBoolean(): Incorrect return value",
0525: x, ret);
0526: }
0527: }
0528: }
0529:
0530: public void testString() throws Exception {
0531: int bufferSize = 1000;
0532: StringBuffer buffer = new StringBuffer(bufferSize);
0533: StringBuffer buffer2 = new StringBuffer(bufferSize);
0534: for (int x = 0; x < bufferSize; x++) {
0535: buffer.append((char) ('a' + (x % 26)));
0536: buffer2.append((char) ('A' + (x % 26)));
0537: }
0538:
0539: String valueSets[][] = { { "hello", "world" },
0540: { "is pi > 3 ?", " is pi < 4\\\"" },
0541: { "<illegal_tag/>", "" },
0542: { buffer.toString(), buffer2.toString() } };
0543:
0544: for (int i = 0; i < valueSets.length; i++) {
0545: String x = valueSets[i][0];
0546: Holder<String> yOrig = new Holder<String>(valueSets[i][1]);
0547: Holder<String> y = new Holder<String>(valueSets[i][1]);
0548: Holder<String> z = new Holder<String>();
0549:
0550: String ret;
0551: if (testDocLiteral) {
0552: ret = docClient.testString(x, y, z);
0553: } else {
0554: ret = rpcClient.testString(x, y, z);
0555: }
0556: if (!perfTestOnly) {
0557: assertEquals(
0558: "testString(): Incorrect value for inout param",
0559: x, y.value);
0560: assertEquals(
0561: "testString(): Incorrect value for out param",
0562: yOrig.value, z.value);
0563: assertEquals("testString(): Incorrect return value", x,
0564: ret);
0565: }
0566: }
0567: }
0568:
0569: public void testStringI18N() throws Exception {
0570: String valueSets[][] = {
0571: { "hello", I18NStrings.CHINESE_COMPLEX_STRING },
0572: { "hello", I18NStrings.JAP_SIMPLE_STRING }, };
0573:
0574: for (int i = 0; i < valueSets.length; i++) {
0575: String x = valueSets[i][0];
0576: Holder<String> yOrig = new Holder<String>(valueSets[i][1]);
0577: Holder<String> y = new Holder<String>(valueSets[i][1]);
0578: Holder<String> z = new Holder<String>();
0579:
0580: String ret;
0581: if (testDocLiteral) {
0582: ret = docClient.testString(x, y, z);
0583: } else {
0584: ret = rpcClient.testString(x, y, z);
0585: }
0586: if (!perfTestOnly) {
0587: assertEquals(
0588: "testStringI18N(): Incorrect value for inout param",
0589: x, y.value);
0590: assertEquals(
0591: "testStringI18N(): Incorrect value for out param",
0592: yOrig.value, z.value);
0593: assertEquals(
0594: "testStringI18N(): Incorrect return value", x,
0595: ret);
0596: }
0597: }
0598: }
0599:
0600: public void testQName() throws Exception {
0601: String valueSets[][] = {
0602: { "NoNamespaceService", "" },
0603: { "HelloWorldService", "http://www.iona.com/services" },
0604: { I18NStrings.JAP_SIMPLE_STRING,
0605: "http://www.iona.com/iona" },
0606: { "MyService", "http://www.iona.com/iona" } };
0607: for (int i = 0; i < valueSets.length; i++) {
0608: QName x = new QName(valueSets[i][1], valueSets[i][0]);
0609: QName yOrig = new QName("http://www.iona.com/inoutqname",
0610: "InOutQName");
0611: Holder<QName> y = new Holder<QName>(yOrig);
0612: Holder<QName> z = new Holder<QName>();
0613:
0614: QName ret;
0615: if (testDocLiteral) {
0616: ret = docClient.testQName(x, y, z);
0617: } else {
0618: ret = rpcClient.testQName(x, y, z);
0619: }
0620:
0621: if (!perfTestOnly) {
0622: assertEquals(
0623: "testQName(): Incorrect value for inout param",
0624: x, y.value);
0625: assertEquals(
0626: "testQName(): Incorrect value for out param",
0627: yOrig, z.value);
0628: assertEquals("testQName(): Incorrect return value", x,
0629: ret);
0630: }
0631: }
0632: }
0633:
0634: public void testDate() throws Exception {
0635: javax.xml.datatype.DatatypeFactory datatypeFactory = javax.xml.datatype.DatatypeFactory
0636: .newInstance();
0637:
0638: XMLGregorianCalendar x = datatypeFactory
0639: .newXMLGregorianCalendar();
0640: x.setYear(1975);
0641: x.setMonth(5);
0642: x.setDay(5);
0643: XMLGregorianCalendar yOrig = datatypeFactory
0644: .newXMLGregorianCalendar();
0645: yOrig.setYear(2004);
0646: yOrig.setMonth(4);
0647: yOrig.setDay(1);
0648:
0649: Holder<XMLGregorianCalendar> y = new Holder<XMLGregorianCalendar>(
0650: yOrig);
0651: Holder<XMLGregorianCalendar> z = new Holder<XMLGregorianCalendar>();
0652:
0653: XMLGregorianCalendar ret;
0654: if (testDocLiteral) {
0655: ret = docClient.testDate(x, y, z);
0656: } else {
0657: // XXX - TODO getting a marshalling exception with rpc-lit for the
0658: // xsd:date tests (ClassCastException in jaxb).
0659: //ret = rpcClient.testDate(x, y, z);
0660: return;
0661: }
0662: if (!perfTestOnly) {
0663: assertTrue("testDate(): Incorrect value for inout param "
0664: + x + " != " + y.value, equalsDate(x, y.value));
0665: assertTrue("testDate(): Incorrect value for out param",
0666: equalsDate(yOrig, z.value));
0667: assertTrue("testDate(): Incorrect return value",
0668: equalsDate(x, ret));
0669: }
0670:
0671: x = datatypeFactory.newXMLGregorianCalendar();
0672: yOrig = datatypeFactory.newXMLGregorianCalendar();
0673:
0674: y = new Holder<XMLGregorianCalendar>(yOrig);
0675: z = new Holder<XMLGregorianCalendar>();
0676:
0677: try {
0678: if (testDocLiteral) {
0679: ret = docClient.testDate(x, y, z);
0680: } else {
0681: ret = rpcClient.testDate(x, y, z);
0682: }
0683: fail("Expected to catch WebServiceException when calling"
0684: + " testDate() with uninitialized parameters.");
0685: } catch (WebServiceException e) {
0686: // Ignore expected failure.
0687: }
0688: }
0689:
0690: public void testDateTime() throws Exception {
0691: javax.xml.datatype.DatatypeFactory datatypeFactory = javax.xml.datatype.DatatypeFactory
0692: .newInstance();
0693:
0694: XMLGregorianCalendar x = datatypeFactory
0695: .newXMLGregorianCalendar();
0696: x.setYear(1975);
0697: x.setMonth(5);
0698: x.setDay(5);
0699: x.setHour(12);
0700: x.setMinute(30);
0701: x.setSecond(15);
0702: XMLGregorianCalendar yOrig = datatypeFactory
0703: .newXMLGregorianCalendar();
0704: yOrig.setYear(2005);
0705: yOrig.setMonth(4);
0706: yOrig.setDay(1);
0707: yOrig.setHour(17);
0708: yOrig.setMinute(59);
0709: yOrig.setSecond(30);
0710:
0711: Holder<XMLGregorianCalendar> y = new Holder<XMLGregorianCalendar>(
0712: yOrig);
0713: Holder<XMLGregorianCalendar> z = new Holder<XMLGregorianCalendar>();
0714:
0715: XMLGregorianCalendar ret;
0716: if (testDocLiteral) {
0717: ret = docClient.testDateTime(x, y, z);
0718: } else {
0719: // XXX - TODO getting a marshalling exception with rpc-lit for the
0720: // xsd:date tests (ClassCastException in jaxb).
0721: //ret = rpcClient.testDateTime(x, y, z);
0722: return;
0723: }
0724: if (!perfTestOnly) {
0725: assertTrue(
0726: "testDateTime(): Incorrect value for inout param",
0727: equalsDateTime(x, y.value));
0728: assertTrue("testDateTime(): Incorrect value for out param",
0729: equalsDateTime(yOrig, z.value));
0730: assertTrue("testDateTime(): Incorrect return value",
0731: equalsDateTime(x, ret));
0732: }
0733: }
0734:
0735: public void testTime() throws Exception {
0736: javax.xml.datatype.DatatypeFactory datatypeFactory = javax.xml.datatype.DatatypeFactory
0737: .newInstance();
0738:
0739: XMLGregorianCalendar x = datatypeFactory
0740: .newXMLGregorianCalendar();
0741: x.setHour(12);
0742: x.setMinute(14);
0743: x.setSecond(5);
0744: XMLGregorianCalendar yOrig = datatypeFactory
0745: .newXMLGregorianCalendar();
0746: yOrig.setHour(22);
0747: yOrig.setMinute(4);
0748: yOrig.setSecond(15);
0749: yOrig.setMillisecond(250);
0750:
0751: Holder<XMLGregorianCalendar> y = new Holder<XMLGregorianCalendar>(
0752: yOrig);
0753: Holder<XMLGregorianCalendar> z = new Holder<XMLGregorianCalendar>();
0754:
0755: XMLGregorianCalendar ret;
0756: if (testDocLiteral) {
0757: ret = docClient.testTime(x, y, z);
0758: } else {
0759: // XXX - TODO getting a marshalling exception with rpc-lit for the
0760: // xsd:date tests.
0761: //ret = rpcClient.testTime(x, y, z);
0762: return;
0763: }
0764: if (!perfTestOnly) {
0765: assertTrue("testTime(): Incorrect value for inout param",
0766: equalsTime(x, y.value));
0767: assertTrue("testTime(): Incorrect value for out param",
0768: equalsTime(yOrig, z.value));
0769: assertTrue("testTime(): Incorrect return value",
0770: equalsTime(x, ret));
0771: }
0772: }
0773:
0774: public void testGYear() throws Exception {
0775: javax.xml.datatype.DatatypeFactory datatypeFactory = javax.xml.datatype.DatatypeFactory
0776: .newInstance();
0777:
0778: XMLGregorianCalendar x = datatypeFactory
0779: .newXMLGregorianCalendar("2004");
0780: XMLGregorianCalendar yOrig = datatypeFactory
0781: .newXMLGregorianCalendar("2003+05:00");
0782:
0783: Holder<XMLGregorianCalendar> y = new Holder<XMLGregorianCalendar>(
0784: yOrig);
0785: Holder<XMLGregorianCalendar> z = new Holder<XMLGregorianCalendar>();
0786:
0787: XMLGregorianCalendar ret;
0788: if (testDocLiteral) {
0789: ret = docClient.testGYear(x, y, z);
0790: } else {
0791: // XXX - TODO getting a marshalling exception with rpc-lit for the
0792: // xsd:date tests (ClassCastException in jaxb).
0793: //ret = rpcClient.testGYear(x, y, z);
0794: return;
0795: }
0796: assertTrue("testGYear(): Incorrect value for inout param", x
0797: .equals(y.value));
0798: assertTrue("testGYear(): Incorrect value for out param", yOrig
0799: .equals(z.value));
0800: assertTrue("testGYear(): Incorrect return value", x.equals(ret));
0801: }
0802:
0803: public void testGYearMonth() throws Exception {
0804: javax.xml.datatype.DatatypeFactory datatypeFactory = javax.xml.datatype.DatatypeFactory
0805: .newInstance();
0806:
0807: XMLGregorianCalendar x = datatypeFactory
0808: .newXMLGregorianCalendar("2004-08");
0809: XMLGregorianCalendar yOrig = datatypeFactory
0810: .newXMLGregorianCalendar("2003-12+05:00");
0811:
0812: Holder<XMLGregorianCalendar> y = new Holder<XMLGregorianCalendar>(
0813: yOrig);
0814: Holder<XMLGregorianCalendar> z = new Holder<XMLGregorianCalendar>();
0815:
0816: XMLGregorianCalendar ret;
0817: if (testDocLiteral) {
0818: ret = docClient.testGYearMonth(x, y, z);
0819: } else {
0820: // XXX - TODO getting a marshalling exception with rpc-lit for the
0821: // xsd:date tests (ClassCastException in jaxb).
0822: //ret = rpcClient.testGYearMonth(x, y, z);
0823: return;
0824: }
0825: assertTrue("testGYearMonth(): Incorrect value for inout param",
0826: x.equals(y.value));
0827: assertTrue("testGYearMonth(): Incorrect value for out param",
0828: yOrig.equals(z.value));
0829: assertTrue("testGYearMonth(): Incorrect return value", x
0830: .equals(ret));
0831: }
0832:
0833: public void testGMonth() throws Exception {
0834: javax.xml.datatype.DatatypeFactory datatypeFactory = javax.xml.datatype.DatatypeFactory
0835: .newInstance();
0836:
0837: XMLGregorianCalendar x = datatypeFactory
0838: .newXMLGregorianCalendar("--08--");
0839: XMLGregorianCalendar yOrig = datatypeFactory
0840: .newXMLGregorianCalendar("--12--+05:00");
0841:
0842: Holder<XMLGregorianCalendar> y = new Holder<XMLGregorianCalendar>(
0843: yOrig);
0844: Holder<XMLGregorianCalendar> z = new Holder<XMLGregorianCalendar>();
0845:
0846: XMLGregorianCalendar ret;
0847: if (testDocLiteral) {
0848: ret = docClient.testGMonth(x, y, z);
0849: } else {
0850: // XXX - TODO getting a marshalling exception with rpc-lit for the
0851: // xsd:date tests (ClassCastException in jaxb).
0852: //ret = rpcClient.testGMonth(x, y, z);
0853: return;
0854: }
0855: assertTrue("testGMonth(): Incorrect value for inout param", x
0856: .equals(y.value));
0857: assertTrue("testGMonth(): Incorrect value for out param", yOrig
0858: .equals(z.value));
0859: assertTrue("testGMonth(): Incorrect return value", x
0860: .equals(ret));
0861: }
0862:
0863: public void testGMonthDay() throws Exception {
0864: javax.xml.datatype.DatatypeFactory datatypeFactory = javax.xml.datatype.DatatypeFactory
0865: .newInstance();
0866:
0867: XMLGregorianCalendar x = datatypeFactory
0868: .newXMLGregorianCalendar("--08-21");
0869: XMLGregorianCalendar yOrig = datatypeFactory
0870: .newXMLGregorianCalendar("--12-05+05:00");
0871:
0872: Holder<XMLGregorianCalendar> y = new Holder<XMLGregorianCalendar>(
0873: yOrig);
0874: Holder<XMLGregorianCalendar> z = new Holder<XMLGregorianCalendar>();
0875:
0876: XMLGregorianCalendar ret;
0877: if (testDocLiteral) {
0878: ret = docClient.testGMonthDay(x, y, z);
0879: } else {
0880: // XXX - TODO getting a marshalling exception with rpc-lit for the
0881: // xsd:date tests (ClassCastException in jaxb).
0882: //ret = rpcClient.testGMonthDay(x, y, z);
0883: return;
0884: }
0885: assertTrue("testGMonthDay(): Incorrect value for inout param",
0886: x.equals(y.value));
0887: assertTrue("testGMonthDay(): Incorrect value for out param",
0888: yOrig.equals(z.value));
0889: assertTrue("testGMonthDay(): Incorrect return value", x
0890: .equals(ret));
0891: }
0892:
0893: public void testGDay() throws Exception {
0894: javax.xml.datatype.DatatypeFactory datatypeFactory = javax.xml.datatype.DatatypeFactory
0895: .newInstance();
0896:
0897: XMLGregorianCalendar x = datatypeFactory
0898: .newXMLGregorianCalendar("---21");
0899: XMLGregorianCalendar yOrig = datatypeFactory
0900: .newXMLGregorianCalendar("---05+05:00");
0901:
0902: Holder<XMLGregorianCalendar> y = new Holder<XMLGregorianCalendar>(
0903: yOrig);
0904: Holder<XMLGregorianCalendar> z = new Holder<XMLGregorianCalendar>();
0905:
0906: XMLGregorianCalendar ret;
0907: if (testDocLiteral) {
0908: ret = docClient.testGDay(x, y, z);
0909: } else {
0910: // XXX - TODO getting a marshalling exception with rpc-lit for the
0911: // xsd:date tests (ClassCastException in jaxb).
0912: //ret = rpcClient.testGDay(x, y, z);
0913: return;
0914: }
0915: assertTrue("testGDay(): Incorrect value for inout param", x
0916: .equals(y.value));
0917: assertTrue("testGDay(): Incorrect value for out param", yOrig
0918: .equals(z.value));
0919: assertTrue("testGDay(): Incorrect return value", x.equals(ret));
0920: }
0921:
0922: public void testDuration() throws Exception {
0923: javax.xml.datatype.DatatypeFactory datatypeFactory = javax.xml.datatype.DatatypeFactory
0924: .newInstance();
0925:
0926: Duration x = datatypeFactory.newDuration("P1Y35DT60M60.500S");
0927: Duration yOrig = datatypeFactory.newDuration("-P2MT24H60S");
0928:
0929: Holder<Duration> y = new Holder<Duration>(yOrig);
0930: Holder<Duration> z = new Holder<Duration>();
0931:
0932: Duration ret;
0933: if (testDocLiteral) {
0934: ret = docClient.testDuration(x, y, z);
0935: } else {
0936: // XXX - TODO getting a MarshalException with rpc-lit for the
0937: // xsd:duration test [DurationImpl is not known to this context].
0938: //ret = rpcClient.testDuration(x, y, z);
0939: return;
0940: }
0941: assertTrue("testDuration(): Incorrect value for inout param", x
0942: .equals(y.value));
0943: assertTrue("testDuration(): Incorrect value for out param",
0944: yOrig.equals(z.value));
0945: assertTrue("testDuration(): Incorrect return value", x
0946: .equals(ret));
0947: }
0948:
0949: public void testNormalizedString() throws Exception {
0950: String x = " normalized string ";
0951: String yOrig = " another normalized string ";
0952:
0953: Holder<String> y = new Holder<String>(yOrig);
0954: Holder<String> z = new Holder<String>();
0955:
0956: String ret;
0957: if (testDocLiteral) {
0958: ret = docClient.testNormalizedString(x, y, z);
0959: } else {
0960: ret = rpcClient.testNormalizedString(x, y, z);
0961: }
0962: assertTrue(
0963: "testNormalizedString(): Incorrect value for inout param",
0964: x.equals(y.value));
0965: assertTrue(
0966: "testNormalizedString(): Incorrect value for out param",
0967: yOrig.equals(z.value));
0968: assertTrue("testNormalizedString(): Incorrect return value", x
0969: .equals(ret));
0970: }
0971:
0972: public void testToken() throws Exception {
0973: String x = "token";
0974: String yOrig = "another token";
0975:
0976: Holder<String> y = new Holder<String>(yOrig);
0977: Holder<String> z = new Holder<String>();
0978:
0979: String ret;
0980: if (testDocLiteral) {
0981: ret = docClient.testToken(x, y, z);
0982: } else {
0983: ret = rpcClient.testToken(x, y, z);
0984: }
0985: assertTrue("testToken(): Incorrect value for inout param", x
0986: .equals(y.value));
0987: assertTrue("testToken(): Incorrect value for out param", yOrig
0988: .equals(z.value));
0989: assertTrue("testToken(): Incorrect return value", x.equals(ret));
0990: }
0991:
0992: public void testLanguage() throws Exception {
0993: String x = "abc";
0994: String yOrig = "abc-def";
0995:
0996: Holder<String> y = new Holder<String>(yOrig);
0997: Holder<String> z = new Holder<String>();
0998:
0999: String ret;
1000: if (testDocLiteral) {
1001: ret = docClient.testLanguage(x, y, z);
1002: } else {
1003: ret = rpcClient.testLanguage(x, y, z);
1004: }
1005: assertTrue("testLanguage(): Incorrect value for inout param", x
1006: .equals(y.value));
1007: assertTrue("testLanguage(): Incorrect value for out param",
1008: yOrig.equals(z.value));
1009: assertTrue("testLanguage(): Incorrect return value", x
1010: .equals(ret));
1011: }
1012:
1013: public void testNMTOKEN() throws Exception {
1014: String x = "123:abc";
1015: String yOrig = "abc.-_:";
1016:
1017: Holder<String> y = new Holder<String>(yOrig);
1018: Holder<String> z = new Holder<String>();
1019:
1020: String ret;
1021: if (testDocLiteral) {
1022: ret = docClient.testNMTOKEN(x, y, z);
1023: } else {
1024: ret = rpcClient.testNMTOKEN(x, y, z);
1025: }
1026: assertTrue("testNMTOKEN(): Incorrect value for inout param", x
1027: .equals(y.value));
1028: assertTrue("testNMTOKEN(): Incorrect value for out param",
1029: yOrig.equals(z.value));
1030: assertTrue("testNMTOKEN(): Incorrect return value", x
1031: .equals(ret));
1032: }
1033:
1034: public void testNMTOKENS() throws Exception {
1035: //
1036: // XXX - The jaxb ri code generation produces different method
1037: // signatures for the NMTOKENS type between using rpc literal
1038: // and doc literal styles.
1039: //
1040: if (testDocLiteral) {
1041: List<String> x = Arrays.asList("123:abc");
1042: List<String> yOrig = Arrays.asList("abc.-_:", "a");
1043:
1044: Holder<List<String>> y = new Holder<List<String>>(yOrig);
1045: Holder<List<String>> z = new Holder<List<String>>();
1046:
1047: List<String> ret = docClient.testNMTOKENS(x, y, z);
1048: assertTrue(
1049: "testNMTOKENS(): Incorrect value for inout param",
1050: x.equals(y.value));
1051: assertTrue("testNMTOKENS(): Incorrect value for out param",
1052: yOrig.equals(z.value));
1053: assertTrue("testNMTOKENS(): Incorrect return value", x
1054: .equals(ret));
1055: } else {
1056: String[] x = new String[1];
1057: x[0] = "123:abc";
1058: String[] yOrig = new String[2];
1059: yOrig[0] = "abc.-_:";
1060: yOrig[1] = "a";
1061:
1062: Holder<String[]> y = new Holder<String[]>(yOrig);
1063: Holder<String[]> z = new Holder<String[]>();
1064:
1065: String[] ret = rpcClient.testNMTOKENS(x, y, z);
1066: assertTrue(
1067: "testNMTOKENS(): Incorrect value for inout param",
1068: Arrays.equals(x, y.value));
1069: assertTrue("testNMTOKENS(): Incorrect value for out param",
1070: Arrays.equals(yOrig, z.value));
1071: assertTrue("testNMTOKENS(): Incorrect return value", Arrays
1072: .equals(x, ret));
1073: }
1074: }
1075:
1076: public void testName() throws Exception {
1077: String x = "abc:123";
1078: String yOrig = "abc.-_";
1079:
1080: Holder<String> y = new Holder<String>(yOrig);
1081: Holder<String> z = new Holder<String>();
1082:
1083: String ret;
1084: if (testDocLiteral) {
1085: ret = docClient.testName(x, y, z);
1086: } else {
1087: ret = rpcClient.testName(x, y, z);
1088: }
1089: assertTrue("testName(): Incorrect value for inout param", x
1090: .equals(y.value));
1091: assertTrue("testName(): Incorrect value for out param", yOrig
1092: .equals(z.value));
1093: assertTrue("testName(): Incorrect return value", x.equals(ret));
1094: }
1095:
1096: public void testNCName() throws Exception {
1097: String x = "abc-123";
1098: String yOrig = "abc.-";
1099:
1100: Holder<String> y = new Holder<String>(yOrig);
1101: Holder<String> z = new Holder<String>();
1102:
1103: String ret;
1104: if (testDocLiteral) {
1105: ret = docClient.testNCName(x, y, z);
1106: } else {
1107: ret = rpcClient.testNCName(x, y, z);
1108: }
1109: assertTrue("testNCName(): Incorrect value for inout param", x
1110: .equals(y.value));
1111: assertTrue("testNCName(): Incorrect value for out param", yOrig
1112: .equals(z.value));
1113: assertTrue("testNCName(): Incorrect return value", x
1114: .equals(ret));
1115: }
1116:
1117: public void testID() throws Exception {
1118: // n.b. to be valid, elements with an ID in the response message
1119: // must have a unique ID, so this test does not return x as the
1120: // return value (like the other tests).
1121: String valueSets[][] = {
1122: { "root.id-testartix.2", "L.-type_test" },
1123: { "_iona.com", "zoo-5_wolf" },
1124: { "x-_liberty", "_-.-_" } };
1125:
1126: for (int i = 0; i < valueSets.length; i++) {
1127: String x = valueSets[i][0];
1128: String yOrig = valueSets[i][1];
1129: Holder<String> y = new Holder<String>(yOrig);
1130: Holder<String> z = new Holder<String>();
1131:
1132: if (testDocLiteral) {
1133: /*String ret =*/docClient.testID(x, y, z);
1134: } else {
1135: /*String ret =*/rpcClient.testID(x, y, z);
1136: }
1137: if (!perfTestOnly) {
1138: assertEquals(
1139: "testID(): Incorrect value for inout param", x,
1140: y.value);
1141: assertEquals("testID(): Incorrect value for out param",
1142: yOrig, z.value);
1143: }
1144: }
1145: }
1146:
1147: public void testDecimal() throws Exception {
1148: BigDecimal valueSets[][] = {
1149: { new BigDecimal("-1234567890.000000"),
1150: new BigDecimal("1234567890.000000") },
1151: {
1152: new BigDecimal("-"
1153: + String.valueOf(Long.MAX_VALUE
1154: * Long.MAX_VALUE) + ".000000"),
1155: new BigDecimal(String.valueOf(Long.MAX_VALUE
1156: * Long.MAX_VALUE)
1157: + ".000000") } };
1158:
1159: for (int i = 0; i < valueSets.length; i++) {
1160: BigDecimal x = valueSets[i][0];
1161: Holder<BigDecimal> yOrig = new Holder<BigDecimal>(
1162: valueSets[i][1]);
1163: Holder<BigDecimal> y = new Holder<BigDecimal>(
1164: valueSets[i][1]);
1165: Holder<BigDecimal> z = new Holder<BigDecimal>();
1166:
1167: BigDecimal ret;
1168: if (testDocLiteral) {
1169: ret = docClient.testDecimal(x, y, z);
1170: } else {
1171: ret = rpcClient.testDecimal(x, y, z);
1172: }
1173: if (!perfTestOnly) {
1174: assertEquals(
1175: "testDecimal(): Incorrect value for inout param",
1176: x, y.value);
1177: assertEquals(
1178: "testDecimal(): Incorrect value for out param",
1179: yOrig.value, z.value);
1180: assertEquals("testDecimal(): Incorrect return value",
1181: x, ret);
1182: }
1183: }
1184: }
1185:
1186: public void testInteger() throws Exception {
1187: BigInteger valueSets[][] = {
1188: { new BigInteger("-1234567890"),
1189: new BigInteger("1234567890") },
1190: {
1191: new BigInteger("-"
1192: + String.valueOf(Long.MAX_VALUE
1193: * Long.MAX_VALUE)),
1194: new BigInteger(String.valueOf(Long.MAX_VALUE
1195: * Long.MAX_VALUE)) } };
1196:
1197: for (int i = 0; i < valueSets.length; i++) {
1198: BigInteger x = valueSets[i][0];
1199: Holder<BigInteger> yOrig = new Holder<BigInteger>(
1200: valueSets[i][1]);
1201: Holder<BigInteger> y = new Holder<BigInteger>(
1202: valueSets[i][1]);
1203: Holder<BigInteger> z = new Holder<BigInteger>();
1204:
1205: BigInteger ret;
1206: if (testDocLiteral) {
1207: ret = docClient.testInteger(x, y, z);
1208: } else {
1209: ret = rpcClient.testInteger(x, y, z);
1210: }
1211: if (!perfTestOnly) {
1212: assertEquals(
1213: "testInteger(): Incorrect value for inout param",
1214: x, y.value);
1215: assertEquals(
1216: "testInteger(): Incorrect value for out param",
1217: yOrig.value, z.value);
1218: assertEquals("testInteger(): Incorrect return value",
1219: x, ret);
1220: }
1221: }
1222: }
1223:
1224: public void testPositiveInteger() throws Exception {
1225: BigInteger valueSets[][] = {
1226: { new BigInteger("1"), new BigInteger("1234567890") },
1227: {
1228: new BigInteger(String.valueOf(Integer.MAX_VALUE
1229: * Integer.MAX_VALUE)),
1230: new BigInteger(String.valueOf(Long.MAX_VALUE
1231: * Long.MAX_VALUE)) } };
1232:
1233: for (int i = 0; i < valueSets.length; i++) {
1234: BigInteger x = valueSets[i][0];
1235: Holder<BigInteger> yOrig = new Holder<BigInteger>(
1236: valueSets[i][1]);
1237: Holder<BigInteger> y = new Holder<BigInteger>(
1238: valueSets[i][1]);
1239: Holder<BigInteger> z = new Holder<BigInteger>();
1240:
1241: BigInteger ret;
1242: if (testDocLiteral) {
1243: ret = docClient.testPositiveInteger(x, y, z);
1244: } else {
1245: ret = rpcClient.testPositiveInteger(x, y, z);
1246: }
1247: if (!perfTestOnly) {
1248: assertEquals(
1249: "testPositiveInteger(): Incorrect value for inout param",
1250: x, y.value);
1251: assertEquals(
1252: "testPositiveInteger(): Incorrect value for out param",
1253: yOrig.value, z.value);
1254: assertEquals(
1255: "testPositiveInteger(): Incorrect return value",
1256: x, ret);
1257: }
1258: }
1259: }
1260:
1261: public void testNonPositiveInteger() throws Exception {
1262: BigInteger valueSets[][] = {
1263: { new BigInteger("0"), new BigInteger("-1234567890") },
1264: {
1265: new BigInteger("-"
1266: + String.valueOf(Integer.MAX_VALUE
1267: * Integer.MAX_VALUE)),
1268: new BigInteger("-"
1269: + String.valueOf(Long.MAX_VALUE
1270: * Long.MAX_VALUE)) } };
1271:
1272: for (int i = 0; i < valueSets.length; i++) {
1273: BigInteger x = valueSets[i][0];
1274: Holder<BigInteger> yOrig = new Holder<BigInteger>(
1275: valueSets[i][1]);
1276: Holder<BigInteger> y = new Holder<BigInteger>(
1277: valueSets[i][1]);
1278: Holder<BigInteger> z = new Holder<BigInteger>();
1279:
1280: BigInteger ret;
1281: if (testDocLiteral) {
1282: ret = docClient.testNonPositiveInteger(x, y, z);
1283: } else {
1284: ret = rpcClient.testNonPositiveInteger(x, y, z);
1285: }
1286: if (!perfTestOnly) {
1287: assertEquals(
1288: "testNonPositiveInteger(): Incorrect value for inout param",
1289: x, y.value);
1290: assertEquals(
1291: "testNonPositiveInteger(): Incorrect value for out param",
1292: yOrig.value, z.value);
1293: assertEquals(
1294: "testNonPositiveInteger(): Incorrect return value",
1295: x, ret);
1296: }
1297: }
1298: }
1299:
1300: public void testNegativeInteger() throws Exception {
1301: BigInteger valueSets[][] = {
1302: { new BigInteger("-1"), new BigInteger("-1234567890") },
1303: {
1304: new BigInteger("-"
1305: + String.valueOf(Integer.MAX_VALUE
1306: * Integer.MAX_VALUE)),
1307: new BigInteger("-"
1308: + String.valueOf(Long.MAX_VALUE
1309: * Long.MAX_VALUE)) } };
1310:
1311: for (int i = 0; i < valueSets.length; i++) {
1312: BigInteger x = valueSets[i][0];
1313: Holder<BigInteger> yOrig = new Holder<BigInteger>(
1314: valueSets[i][1]);
1315: Holder<BigInteger> y = new Holder<BigInteger>(
1316: valueSets[i][1]);
1317: Holder<BigInteger> z = new Holder<BigInteger>();
1318:
1319: BigInteger ret;
1320: if (testDocLiteral) {
1321: ret = docClient.testNegativeInteger(x, y, z);
1322: } else {
1323: ret = rpcClient.testNegativeInteger(x, y, z);
1324: }
1325: if (!perfTestOnly) {
1326: assertEquals(
1327: "testNegativeInteger(): Incorrect value for inout param",
1328: x, y.value);
1329: assertEquals(
1330: "testNegativeInteger(): Incorrect value for out param",
1331: yOrig.value, z.value);
1332: assertEquals(
1333: "testNegativeInteger(): Incorrect return value",
1334: x, ret);
1335: }
1336: }
1337: }
1338:
1339: public void testNonNegativeInteger() throws Exception {
1340: BigInteger valueSets[][] = {
1341: { new BigInteger("0"), new BigInteger("1234567890") },
1342: {
1343: new BigInteger(String.valueOf(Integer.MAX_VALUE
1344: * Integer.MAX_VALUE)),
1345: new BigInteger(String.valueOf(Long.MAX_VALUE
1346: * Long.MAX_VALUE)) } };
1347:
1348: for (int i = 0; i < valueSets.length; i++) {
1349: BigInteger x = valueSets[i][0];
1350: Holder<BigInteger> yOrig = new Holder<BigInteger>(
1351: valueSets[i][1]);
1352: Holder<BigInteger> y = new Holder<BigInteger>(
1353: valueSets[i][1]);
1354: Holder<BigInteger> z = new Holder<BigInteger>();
1355:
1356: BigInteger ret;
1357: if (testDocLiteral) {
1358: ret = docClient.testNonNegativeInteger(x, y, z);
1359: } else {
1360: ret = rpcClient.testNonNegativeInteger(x, y, z);
1361: }
1362: if (!perfTestOnly) {
1363: assertEquals(
1364: "testNonNegativeInteger(): Incorrect value for inout param",
1365: x, y.value);
1366: assertEquals(
1367: "testNonNegativeInteger(): Incorrect value for out param",
1368: yOrig.value, z.value);
1369: assertEquals(
1370: "testNonNegativeInteger(): Incorrect return value",
1371: x, ret);
1372: }
1373: }
1374: }
1375:
1376: public void testHexBinary() throws Exception {
1377: byte[] x = "hello".getBytes();
1378: Holder<byte[]> y = new Holder<byte[]>("goodbye".getBytes());
1379: Holder<byte[]> yOriginal = new Holder<byte[]>("goodbye"
1380: .getBytes());
1381: Holder<byte[]> z = new Holder<byte[]>();
1382: byte[] ret;
1383: if (testDocLiteral) {
1384: ret = docClient.testHexBinary(x, y, z);
1385: } else {
1386: ret = rpcClient.testHexBinary(x, y, z);
1387: }
1388: if (!perfTestOnly) {
1389: assertTrue(
1390: "testHexBinary(): Incorrect value for inout param",
1391: Arrays.equals(x, y.value));
1392: assertTrue(
1393: "testHexBinary(): Incorrect value for out param",
1394: Arrays.equals(yOriginal.value, z.value));
1395: assertTrue("testHexBinary(): Incorrect return value",
1396: Arrays.equals(x, ret));
1397: }
1398: }
1399:
1400: public void testBase64Binary() throws Exception {
1401: byte[] x = "hello".getBytes();
1402: Holder<byte[]> y = new Holder<byte[]>("goodbye".getBytes());
1403: Holder<byte[]> yOriginal = new Holder<byte[]>("goodbye"
1404: .getBytes());
1405: Holder<byte[]> z = new Holder<byte[]>();
1406: byte[] ret;
1407: if (testDocLiteral) {
1408: ret = docClient.testBase64Binary(x, y, z);
1409: } else {
1410: ret = rpcClient.testBase64Binary(x, y, z);
1411: }
1412: if (!perfTestOnly) {
1413: assertTrue(
1414: "testBase64Binary(): Incorrect value for inout param",
1415: Arrays.equals(x, y.value));
1416: assertTrue(
1417: "testBase64Binary(): Incorrect value for out param",
1418: Arrays.equals(yOriginal.value, z.value));
1419: assertTrue("testBase64Binary(): Incorrect return value",
1420: Arrays.equals(x, ret));
1421: }
1422:
1423: // Test uninitialized holder value
1424: try {
1425: y = new Holder<byte[]>();
1426: z = new Holder<byte[]>();
1427: if (testDocLiteral) {
1428: docClient.testBase64Binary(x, y, z);
1429: } else {
1430: rpcClient.testBase64Binary(x, y, z);
1431: }
1432: fail("Uninitialized Holder for inout parameter should have thrown an error.");
1433: } catch (Exception e) {
1434: // Ignore expected failure.
1435: }
1436: }
1437:
1438: public void testAnyURI() throws Exception {
1439: String valueSets[][] = {
1440: { "file:///root%20%20/-;?&+",
1441: "file:///w:/test!artix~java*" },
1442: { "http://iona.com/",
1443: "file:///z:/mail_iona=com,\'xmlbus\'" },
1444: { "mailto:windows@systems", "file:///" } };
1445:
1446: for (int i = 0; i < valueSets.length; i++) {
1447: String x = new String(valueSets[i][0]);
1448: String yOrig = new String(valueSets[i][1]);
1449: Holder<String> y = new Holder<String>(yOrig);
1450: Holder<String> z = new Holder<String>();
1451:
1452: String ret;
1453: if (testDocLiteral) {
1454: ret = docClient.testAnyURI(x, y, z);
1455: } else {
1456: ret = rpcClient.testAnyURI(x, y, z);
1457: }
1458: if (!perfTestOnly) {
1459: assertEquals(
1460: "testAnyURI(): Incorrect value for inout param",
1461: x, y.value);
1462: assertEquals(
1463: "testAnyURI(): Incorrect value for out param",
1464: yOrig, z.value);
1465: assertEquals("testAnyURI(): Incorrect return value", x,
1466: ret);
1467: }
1468: }
1469: }
1470:
1471: /**
1472: * XXX - In the generated code for ColourEnum, the fromValue() method
1473: * is not declared static - fixed in jaxb-ri-20060421 nightly build.
1474: */
1475: public void testColourEnum() throws Exception {
1476: /*
1477: String[] xx = {"RED", "GREEN", "BLUE"};
1478: String[] yy = {"GREEN", "BLUE", "RED"};
1479:
1480: Holder<ColourEnum> z = new Holder<ColourEnum>();
1481:
1482: for (int i = 0; i < 3; i++) {
1483: ColourEnum x = ColourEnum.fromValue(xx[i]);
1484: ColourEnum yOrig = ColourEnum.fromValue(yy[i]);
1485: Holder<ColourEnum> y = new Holder<ColourEnum>(yOrig);
1486:
1487: ColourEnum ret;
1488: if (testDocLiteral) {
1489: ret = docClient.testColourEnum(x, y, z);
1490: } else {
1491: ret = rpcClient.testColourEnum(x, y, z);
1492: }
1493: if (!perfTestOnly) {
1494: assertEquals("testColourEnum(): Incorrect value for inout param",
1495: x.value(), y.value.value());
1496: assertEquals("testColourEnum(): Incorrect value for out param",
1497: yOrig.value(), z.value.value());
1498: assertEquals("testColourEnum(): Incorrect return value",
1499: x.value(), ret.value());
1500: }
1501: }
1502: */
1503: }
1504:
1505: public void testNumberEnum() throws Exception {
1506: int[] xx = { 1, 2, 3 };
1507: int[] yy = { 3, 1, 2 };
1508:
1509: Holder<NumberEnum> z = new Holder<NumberEnum>();
1510:
1511: for (int i = 0; i < 3; i++) {
1512: NumberEnum x = NumberEnum.fromValue(xx[i]);
1513: NumberEnum yOrig = NumberEnum.fromValue(yy[i]);
1514: Holder<NumberEnum> y = new Holder<NumberEnum>(yOrig);
1515:
1516: NumberEnum ret;
1517: if (testDocLiteral) {
1518: ret = docClient.testNumberEnum(x, y, z);
1519: } else {
1520: ret = rpcClient.testNumberEnum(x, y, z);
1521: }
1522: if (!perfTestOnly) {
1523: assertEquals(
1524: "testNumberEnum(): Incorrect value for inout param",
1525: x.value(), y.value.value());
1526: assertEquals(
1527: "testNumberEnum(): Incorrect value for out param",
1528: yOrig.value(), z.value.value());
1529: assertEquals(
1530: "testNumberEnum(): Incorrect return value", x
1531: .value(), ret.value());
1532: }
1533: }
1534: }
1535:
1536: public void testStringEnum() throws Exception {
1537: String[] xx = { "a b c", "d e f", "g h i" };
1538: String[] yy = { "g h i", "a b c", "d e f" };
1539:
1540: Holder<StringEnum> z = new Holder<StringEnum>();
1541: for (int i = 0; i < 3; i++) {
1542: StringEnum x = StringEnum.fromValue(xx[i]);
1543: StringEnum yOrig = StringEnum.fromValue(yy[i]);
1544: Holder<StringEnum> y = new Holder<StringEnum>(yOrig);
1545:
1546: StringEnum ret;
1547: if (testDocLiteral) {
1548: ret = docClient.testStringEnum(x, y, z);
1549: } else {
1550: ret = rpcClient.testStringEnum(x, y, z);
1551: }
1552: if (!perfTestOnly) {
1553: assertEquals(
1554: "testStringEnum(): Incorrect value for inout param",
1555: x.value(), y.value.value());
1556: assertEquals(
1557: "testStringEnum(): Incorrect value for out param",
1558: yOrig.value(), z.value.value());
1559: assertEquals(
1560: "testStringEnum(): Incorrect return value", x
1561: .value(), ret.value());
1562: }
1563: }
1564: }
1565:
1566: public void testDecimalEnum() throws Exception {
1567: BigDecimal[] xx = { new BigDecimal("-10.34"),
1568: new BigDecimal("11.22"), new BigDecimal("14.55") };
1569: BigDecimal[] yy = { new BigDecimal("14.55"),
1570: new BigDecimal("-10.34"), new BigDecimal("11.22") };
1571:
1572: Holder<DecimalEnum> z = new Holder<DecimalEnum>();
1573:
1574: for (int i = 0; i < 3; i++) {
1575: DecimalEnum x = DecimalEnum.fromValue(xx[i]);
1576: DecimalEnum yOrig = DecimalEnum.fromValue(yy[i]);
1577: Holder<DecimalEnum> y = new Holder<DecimalEnum>(yOrig);
1578:
1579: DecimalEnum ret;
1580: if (testDocLiteral) {
1581: ret = docClient.testDecimalEnum(x, y, z);
1582: } else {
1583: ret = rpcClient.testDecimalEnum(x, y, z);
1584: }
1585: if (!perfTestOnly) {
1586: assertEquals(
1587: "testDecimalEnum(): Incorrect value for inout param",
1588: x.value(), y.value.value());
1589: assertEquals(
1590: "testDecimalEnum(): Incorrect value for out param",
1591: yOrig.value(), z.value.value());
1592: assertEquals(
1593: "testDecimalEnum(): Incorrect return value", x
1594: .value(), ret.value());
1595: }
1596: }
1597: }
1598:
1599: public void testNMTokenEnum() throws Exception {
1600: String[] xx = { "hello", "there" };
1601: String[] yy = { "there", "hello" };
1602:
1603: Holder<NMTokenEnum> z = new Holder<NMTokenEnum>();
1604:
1605: for (int i = 0; i < 2; i++) {
1606: NMTokenEnum x = NMTokenEnum.fromValue(xx[i]);
1607: NMTokenEnum yOrig = NMTokenEnum.fromValue(yy[i]);
1608: Holder<NMTokenEnum> y = new Holder<NMTokenEnum>(yOrig);
1609:
1610: NMTokenEnum ret;
1611: if (testDocLiteral) {
1612: ret = docClient.testNMTokenEnum(x, y, z);
1613: } else {
1614: ret = rpcClient.testNMTokenEnum(x, y, z);
1615: }
1616: if (!perfTestOnly) {
1617: assertEquals(
1618: "testNMTokenEnum(): Incorrect value for inout param",
1619: x.value(), y.value.value());
1620: assertEquals(
1621: "testNMTokenEnum(): Incorrect value for out param",
1622: yOrig.value(), z.value.value());
1623: assertEquals(
1624: "testNMTokenEnum(): Incorrect return value", x
1625: .value(), ret.value());
1626: }
1627: }
1628: }
1629:
1630: public void testAnyURIEnum() throws Exception {
1631: String[] xx = { "http://www.iona.com", "http://www.google.com" };
1632: String[] yy = { "http://www.google.com", "http://www.iona.com" };
1633:
1634: Holder<AnyURIEnum> z = new Holder<AnyURIEnum>();
1635: for (int i = 0; i < 2; i++) {
1636: AnyURIEnum x = AnyURIEnum.fromValue(xx[i]);
1637: AnyURIEnum yOrig = AnyURIEnum.fromValue(yy[i]);
1638: Holder<AnyURIEnum> y = new Holder<AnyURIEnum>(yOrig);
1639:
1640: AnyURIEnum ret;
1641: if (testDocLiteral) {
1642: ret = docClient.testAnyURIEnum(x, y, z);
1643: } else {
1644: ret = rpcClient.testAnyURIEnum(x, y, z);
1645: }
1646: if (!perfTestOnly) {
1647: assertEquals(
1648: "testAnyURIEnum(): Incorrect value for inout param",
1649: x.value(), y.value.value());
1650: assertEquals(
1651: "testAnyURIEnum(): Incorrect value for out param",
1652: yOrig.value(), z.value.value());
1653: assertEquals(
1654: "testAnyURIEnum(): Incorrect return value", x
1655: .value(), ret.value());
1656: }
1657: }
1658: }
1659:
1660: public void testSimpleRestriction() throws Exception {
1661: // normal case, maxLength=10
1662: String x = "string_x";
1663: String yOrig = "string_y";
1664: Holder<String> y = new Holder<String>(yOrig);
1665: Holder<String> z = new Holder<String>();
1666: String ret;
1667: if (testDocLiteral) {
1668: ret = docClient.testSimpleRestriction(x, y, z);
1669: } else {
1670: ret = rpcClient.testSimpleRestriction(x, y, z);
1671: }
1672: if (!perfTestOnly) {
1673: assertEquals(
1674: "testSimpleRestriction(): Incorrect value for inout param",
1675: x, y.value);
1676: assertEquals(
1677: "testSimpleRestriction(): Incorrect value for out param",
1678: yOrig, z.value);
1679: assertEquals(
1680: "testSimpleRestriction(): Incorrect return value",
1681: x, ret);
1682: }
1683:
1684: // Enabled schema validation for doc literal tests
1685: if (testDocLiteral) {
1686: // abnormal case
1687: x = "string_xxxxx";
1688: y = new Holder<String>(yOrig);
1689: z = new Holder<String>();
1690: try {
1691: ret = docClient.testSimpleRestriction(x, y, z);
1692: fail("x parameter maxLength=10 restriction is violated.");
1693: } catch (Exception ex) {
1694: //ex.printStackTrace();
1695: }
1696:
1697: // abnormal case
1698: x = "string_x";
1699: yOrig = "string_yyyyyy";
1700: y = new Holder<String>(yOrig);
1701: z = new Holder<String>();
1702: try {
1703: ret = docClient.testSimpleRestriction(x, y, z);
1704: fail("y parameter maxLength=10 restriction is violated.");
1705: } catch (Exception ex) {
1706: //ex.printStackTrace();
1707: }
1708: }
1709: }
1710:
1711: public void testSimpleRestriction2() throws Exception {
1712: // normal case, minLength=5
1713: String x = "str_x";
1714: String yOrig = "string_yyy";
1715: Holder<String> y = new Holder<String>(yOrig);
1716: Holder<String> z = new Holder<String>();
1717:
1718: String ret;
1719: if (testDocLiteral) {
1720: ret = docClient.testSimpleRestriction2(x, y, z);
1721: } else {
1722: ret = rpcClient.testSimpleRestriction2(x, y, z);
1723: }
1724: if (!perfTestOnly) {
1725: assertEquals(
1726: "testSimpleRestriction2(): Incorrect value for inout param",
1727: x, y.value);
1728: assertEquals(
1729: "testSimpleRestriction2(): Incorrect value for out param",
1730: yOrig, z.value);
1731: assertEquals(
1732: "testSimpleRestriction2(): Incorrect return value",
1733: x, ret);
1734: }
1735:
1736: // Schema validation is enabled for doc-literal
1737: if (testDocLiteral) {
1738: // abnormal case
1739: x = "str";
1740: y = new Holder<String>(yOrig);
1741: z = new Holder<String>();
1742: try {
1743: ret = docClient.testSimpleRestriction2(x, y, z);
1744: fail("minLength=5 restriction is violated.");
1745: } catch (Exception ex) {
1746: //ex.printStackTrace();
1747: }
1748: }
1749: }
1750:
1751: public void testSimpleRestriction3() throws Exception {
1752: // normal case, maxLength=10 && minLength=5
1753: String x = "str_x";
1754: String yOrig = "string_yyy";
1755: Holder<String> y = new Holder<String>(yOrig);
1756: Holder<String> z = new Holder<String>();
1757:
1758: String ret;
1759: if (testDocLiteral) {
1760: ret = docClient.testSimpleRestriction3(x, y, z);
1761: } else {
1762: ret = rpcClient.testSimpleRestriction3(x, y, z);
1763: }
1764: if (!perfTestOnly) {
1765: assertEquals(
1766: "testSimpleRestriction3(): Incorrect value for inout param",
1767: x, y.value);
1768: assertEquals(
1769: "testSimpleRestriction3(): Incorrect value for out param",
1770: yOrig, z.value);
1771: assertEquals(
1772: "testSimpleRestriction3(): Incorrect return value",
1773: x, ret);
1774: }
1775:
1776: // Schema validation is enabled for doc-literal
1777: if (testDocLiteral) {
1778: // abnormal case
1779: x = "str";
1780: y = new Holder<String>(yOrig);
1781: z = new Holder<String>();
1782: try {
1783: ret = docClient.testSimpleRestriction3(x, y, z);
1784: fail("x parameter maxLength=10 && minLength=5 restriction is violated.");
1785: } catch (Exception ex) {
1786: //ex.printStackTrace();
1787: }
1788:
1789: // abnormal case
1790: x = "string_x";
1791: yOrig = "string_yyyyyy";
1792: y = new Holder<String>(yOrig);
1793: z = new Holder<String>();
1794: try {
1795: ret = docClient.testSimpleRestriction3(x, y, z);
1796: fail("y parameter maxLength=10 && minLength=5 restriction is violated.");
1797: } catch (Exception ex) {
1798: //ex.printStackTrace();
1799: }
1800: }
1801: }
1802:
1803: public void testSimpleRestriction4() throws Exception {
1804: // normal case, length=1
1805: String x = "x";
1806: String yOrig = "y";
1807: Holder<String> y = new Holder<String>(yOrig);
1808: Holder<String> z = new Holder<String>();
1809:
1810: String ret;
1811: if (testDocLiteral) {
1812: ret = docClient.testSimpleRestriction4(x, y, z);
1813: } else {
1814: ret = rpcClient.testSimpleRestriction4(x, y, z);
1815: }
1816: if (!perfTestOnly) {
1817: assertEquals(
1818: "testSimpleRestriction4(): Incorrect value for inout param",
1819: x, y.value);
1820: assertEquals(
1821: "testSimpleRestriction4(): Incorrect value for out param",
1822: yOrig, z.value);
1823: assertEquals(
1824: "testSimpleRestriction4(): Incorrect return value",
1825: x, ret);
1826: }
1827:
1828: // Schema validation is enabled for doc-literal
1829: if (testDocLiteral) {
1830: // abnormal case
1831: x = "str";
1832: y = new Holder<String>(yOrig);
1833: z = new Holder<String>();
1834: try {
1835: ret = docClient.testSimpleRestriction4(x, y, z);
1836: fail("x parameter minLength=5 restriction is violated.");
1837: } catch (Exception ex) {
1838: //ex.printStackTrace();
1839: }
1840: }
1841: }
1842:
1843: public void testSimpleRestriction5() throws Exception {
1844: // normal case, maxLength=10 for SimpleRestrction
1845: // && minLength=5 for SimpleRestriction5
1846: String x = "str_x";
1847: String yOrig = "string_yyy";
1848: Holder<String> y = new Holder<String>(yOrig);
1849: Holder<String> z = new Holder<String>();
1850:
1851: String ret;
1852: if (testDocLiteral) {
1853: ret = docClient.testSimpleRestriction5(x, y, z);
1854: } else {
1855: ret = rpcClient.testSimpleRestriction5(x, y, z);
1856: }
1857: if (!perfTestOnly) {
1858: assertEquals(
1859: "testSimpleRestriction5(): Incorrect value for inout param",
1860: x, y.value);
1861: assertEquals(
1862: "testSimpleRestriction5(): Incorrect value for out param",
1863: yOrig, z.value);
1864: assertEquals(
1865: "testSimpleRestriction5(): Incorrect return value",
1866: x, ret);
1867: }
1868:
1869: // Schema validation is enabled for doc-literal
1870: if (testDocLiteral) {
1871: // abnormal case
1872: x = "str";
1873: y = new Holder<String>(yOrig);
1874: z = new Holder<String>();
1875: try {
1876: ret = docClient.testSimpleRestriction5(x, y, z);
1877: fail("maxLength=10 && minLength=5 restriction is violated.");
1878: } catch (Exception ex) {
1879: //ex.printStackTrace();
1880: }
1881:
1882: // abnormal case
1883: x = "string_x";
1884: yOrig = "string_yyyyyy";
1885: y = new Holder<String>(yOrig);
1886: z = new Holder<String>();
1887: try {
1888: ret = docClient.testSimpleRestriction5(x, y, z);
1889: fail("maxLength=10 && minLength=5 restriction is violated.");
1890: } catch (Exception ex) {
1891: //ex.printStackTrace();
1892: }
1893: }
1894: }
1895:
1896: public void testSimpleRestriction6() throws Exception {
1897: // normal case, maxLength=10 for SimpleRestriction
1898: // && maxLength=5 for SimpleRestriction6
1899: String x = "str_x";
1900: String yOrig = "y";
1901: Holder<String> y = new Holder<String>(yOrig);
1902: Holder<String> z = new Holder<String>();
1903:
1904: String ret;
1905: if (testDocLiteral) {
1906: ret = docClient.testSimpleRestriction6(x, y, z);
1907: } else {
1908: ret = rpcClient.testSimpleRestriction6(x, y, z);
1909: }
1910: if (!perfTestOnly) {
1911: assertEquals(
1912: "testSimpleRestriction6(): Incorrect value for inout param",
1913: x, y.value);
1914: assertEquals(
1915: "testSimpleRestriction6(): Incorrect value for out param",
1916: yOrig, z.value);
1917: assertEquals(
1918: "testSimpleRestriction6(): Incorrect return value",
1919: x, ret);
1920: }
1921:
1922: // Schema validation is enabled for doc-literal
1923: if (testDocLiteral) {
1924: // abnormal case
1925: x = "string_x";
1926: yOrig = "string_y";
1927: y = new Holder<String>(yOrig);
1928: z = new Holder<String>();
1929: try {
1930: ret = docClient.testSimpleRestriction6(x, y, z);
1931: fail("maxLength=10 && minLength=5 restriction is violated.");
1932: } catch (Exception ex) {
1933: //ex.printStackTrace();
1934: }
1935: }
1936: }
1937:
1938: public void testHexBinaryRestriction() throws Exception {
1939: // normal case, maxLength=10 && minLength=1
1940: byte[] x = "x".getBytes();
1941: byte[] yOrig = "string_yyy".getBytes();
1942: Holder<byte[]> y = new Holder<byte[]>(yOrig);
1943: Holder<byte[]> z = new Holder<byte[]>();
1944:
1945: byte[] ret;
1946: if (testDocLiteral) {
1947: ret = docClient.testHexBinaryRestriction(x, y, z);
1948: } else {
1949: ret = rpcClient.testHexBinaryRestriction(x, y, z);
1950: }
1951: if (!perfTestOnly) {
1952: assertTrue(
1953: "testHexBinaryRestriction(): Incorrect value for inout param",
1954: equals(x, y.value));
1955: assertTrue(
1956: "testHexBinaryRestriction(): Incorrect value for out param",
1957: equals(yOrig, z.value));
1958: assertTrue(
1959: "testHexBinaryRestriction(): Incorrect return value",
1960: equals(x, ret));
1961: }
1962:
1963: // Schema validation is enabled for doc-literal
1964: if (testDocLiteral) {
1965: // abnormal case
1966: x = "".getBytes();
1967: y = new Holder<byte[]>(yOrig);
1968: z = new Holder<byte[]>();
1969: try {
1970: ret = docClient.testHexBinaryRestriction(x, y, z);
1971: fail("maxLength=10 && minLength=1 restriction is violated.");
1972: } catch (Exception ex) {
1973: //ex.printStackTrace();
1974: }
1975:
1976: // abnormal case
1977: x = "string_x".getBytes();
1978: yOrig = "string_yyyyyy".getBytes();
1979: y = new Holder<byte[]>(yOrig);
1980: z = new Holder<byte[]>();
1981: try {
1982: ret = docClient.testHexBinaryRestriction(x, y, z);
1983: fail("maxLength=10 && minLength=1 restriction is violated.");
1984: } catch (Exception ex) {
1985: //ex.printStackTrace();
1986: }
1987: }
1988: }
1989:
1990: protected boolean equals(byte[] x, byte[] y) {
1991: String xx = new String(x);
1992: String yy = new String(y);
1993: return xx.equals(yy);
1994: }
1995:
1996: public void testBase64BinaryRestriction() throws Exception {
1997: // normal case, length=10
1998: byte[] x = "string_xxx".getBytes();
1999: byte[] yOrig = "string_yyy".getBytes();
2000: Holder<byte[]> y = new Holder<byte[]>(yOrig);
2001: Holder<byte[]> z = new Holder<byte[]>();
2002:
2003: byte[] ret;
2004: if (testDocLiteral) {
2005: ret = docClient.testBase64BinaryRestriction(x, y, z);
2006: } else {
2007: ret = rpcClient.testBase64BinaryRestriction(x, y, z);
2008: }
2009: if (!perfTestOnly) {
2010: assertTrue(
2011: "testBase64BinaryRestriction(): Incorrect value for inout param",
2012: equals(x, y.value));
2013: assertTrue(
2014: "testBase64BinaryRestriction(): Incorrect value for out param",
2015: equals(yOrig, z.value));
2016: assertTrue(
2017: "testBase64BinaryRestriction(): Incorrect return value",
2018: equals(x, ret));
2019: }
2020:
2021: // Schema validation is enabled for doc-literal
2022: if (testDocLiteral) {
2023: // abnormal case
2024: x = "string_xxxxx".getBytes();
2025: y = new Holder<byte[]>(yOrig);
2026: z = new Holder<byte[]>();
2027: try {
2028: ret = docClient.testBase64BinaryRestriction(x, y, z);
2029: fail("length=10 restriction is violated.");
2030: } catch (Exception ex) {
2031: //ex.printStackTrace();
2032: }
2033: }
2034: }
2035:
2036: public void testSimpleListRestriction2() throws Exception {
2037: // XXX - jaxb ri generated code has different method signature
2038: // between doc-literal and rpc-literal styles.
2039: if (testDocLiteral) {
2040: List<String> x = Arrays.asList("I", "am", "SimpleList");
2041: List<String> yOrig = Arrays.asList("Does", "SimpleList",
2042: "Work");
2043: Holder<List<String>> y = new Holder<List<String>>(yOrig);
2044: Holder<List<String>> z = new Holder<List<String>>();
2045:
2046: // normal case, maxLength=10 && minLength=1
2047: List<String> ret = docClient.testSimpleListRestriction2(x,
2048: y, z);
2049: if (!perfTestOnly) {
2050: assertTrue(
2051: "testStringList(): Incorrect value for inout param",
2052: x.equals(y.value));
2053: assertTrue(
2054: "testStringList(): Incorrect value for out param",
2055: yOrig.equals(z.value));
2056: assertTrue("testStringList(): Incorrect return value",
2057: x.equals(ret));
2058: }
2059:
2060: // abnormal case
2061: x = new ArrayList<String>();
2062: y = new Holder<List<String>>(yOrig);
2063: z = new Holder<List<String>>();
2064: try {
2065: ret = docClient.testSimpleListRestriction2(x, y, z);
2066: fail("length=10 restriction is violated.");
2067: } catch (Exception ex) {
2068: //ex.printStackTrace();
2069: }
2070: } else {
2071: String[] x = { "I", "am", "SimpleList" };
2072: String[] yOrig = { "Does", "SimpleList", "Work" };
2073: Holder<String[]> y = new Holder<String[]>(yOrig);
2074: Holder<String[]> z = new Holder<String[]>();
2075:
2076: // normal case, maxLength=10 && minLength=1
2077: String[] ret = rpcClient
2078: .testSimpleListRestriction2(x, y, z);
2079:
2080: assertTrue(y.value.length == 3);
2081: assertTrue(z.value.length == 3);
2082: assertTrue(ret.length == 3);
2083: if (!perfTestOnly) {
2084: for (int i = 0; i < 3; i++) {
2085: assertEquals(
2086: "testStringList(): Incorrect value for inout param",
2087: x[i], y.value[i]);
2088: assertEquals(
2089: "testStringList(): Incorrect value for out param",
2090: yOrig[i], z.value[i]);
2091: assertEquals(
2092: "testStringList(): Incorrect return value",
2093: x[i], ret[i]);
2094: }
2095: }
2096: }
2097: }
2098:
2099: public void testStringList() throws Exception {
2100: if (testDocLiteral) {
2101: List<String> x = Arrays.asList("I", "am", "SimpleList");
2102: List<String> yOrig = Arrays.asList("Does", "SimpleList",
2103: "Work");
2104: Holder<List<String>> y = new Holder<List<String>>(yOrig);
2105: Holder<List<String>> z = new Holder<List<String>>();
2106:
2107: List<String> ret = docClient.testStringList(x, y, z);
2108: if (!perfTestOnly) {
2109: assertTrue(
2110: "testStringList(): Incorrect value for inout param",
2111: x.equals(y.value));
2112: assertTrue(
2113: "testStringList(): Incorrect value for out param",
2114: yOrig.equals(z.value));
2115: assertTrue("testStringList(): Incorrect return value",
2116: x.equals(ret));
2117: }
2118: } else {
2119: String[] x = { "I", "am", "SimpleList" };
2120: String[] yOrig = { "Does", "SimpleList", "Work" };
2121: Holder<String[]> y = new Holder<String[]>(yOrig);
2122: Holder<String[]> z = new Holder<String[]>();
2123:
2124: String[] ret = rpcClient.testStringList(x, y, z);
2125:
2126: assertTrue(y.value.length == 3);
2127: assertTrue(z.value.length == 3);
2128: assertTrue(ret.length == 3);
2129: if (!perfTestOnly) {
2130: for (int i = 0; i < 3; i++) {
2131: assertEquals(
2132: "testStringList(): Incorrect value for inout param",
2133: x[i], y.value[i]);
2134: assertEquals(
2135: "testStringList(): Incorrect value for out param",
2136: yOrig[i], z.value[i]);
2137: assertEquals(
2138: "testStringList(): Incorrect return value",
2139: x[i], ret[i]);
2140: }
2141: }
2142: }
2143: }
2144:
2145: public void testNumberList() throws Exception {
2146: if (testDocLiteral) {
2147: List<Integer> x = Arrays.asList(1, 2, 3);
2148: List<Integer> yOrig = Arrays.asList(10, 100, 1000);
2149: Holder<List<Integer>> y = new Holder<List<Integer>>(yOrig);
2150: Holder<List<Integer>> z = new Holder<List<Integer>>();
2151:
2152: List<Integer> ret = docClient.testNumberList(x, y, z);
2153: if (!perfTestOnly) {
2154: assertTrue(
2155: "testNumberList(): Incorrect value for inout param",
2156: x.equals(y.value));
2157: assertTrue(
2158: "testNumberList(): Incorrect value for out param",
2159: yOrig.equals(z.value));
2160: assertTrue("testNumberList(): Incorrect return value",
2161: x.equals(ret));
2162: }
2163: } else {
2164: Integer[] x = { 1, 2, 3 };
2165: Integer[] yOrig = { 10, 100, 1000 };
2166: Holder<Integer[]> y = new Holder<Integer[]>(yOrig);
2167: Holder<Integer[]> z = new Holder<Integer[]>();
2168:
2169: Integer[] ret = rpcClient.testNumberList(x, y, z);
2170:
2171: assertTrue(y.value.length == 3);
2172: assertTrue(z.value.length == 3);
2173: assertTrue(ret.length == 3);
2174: if (!perfTestOnly) {
2175: for (int i = 0; i < 3; i++) {
2176: assertEquals(
2177: "testNumberList(): Incorrect value for inout param",
2178: x[i], y.value[i]);
2179: assertEquals(
2180: "testNumberList(): Incorrect value for out param",
2181: yOrig[i], z.value[i]);
2182: assertEquals(
2183: "testNumberList(): Incorrect return value",
2184: x[i], ret[i]);
2185: }
2186: }
2187: }
2188: }
2189:
2190: public void testQNameList() throws Exception {
2191: if (testDocLiteral) {
2192: List<QName> x = Arrays.asList(new QName(
2193: "http://schemas.iona.com/type_test", "testqname1"),
2194: new QName("http://schemas.iona.com/type_test",
2195: "testqname2"), new QName(
2196: "http://schemas.iona.com/type_test",
2197: "testqname3"));
2198: List<QName> yOrig = Arrays.asList(new QName(
2199: "http://schemas.iona.com/type_test", "testqname4"),
2200: new QName("http://schemas.iona.com/type_test",
2201: "testqname5"), new QName(
2202: "http://schemas.iona.com/type_test",
2203: "testqname6"));
2204: Holder<List<QName>> y = new Holder<List<QName>>(yOrig);
2205: Holder<List<QName>> z = new Holder<List<QName>>();
2206:
2207: List<QName> ret = docClient.testQNameList(x, y, z);
2208: if (!perfTestOnly) {
2209: assertTrue(
2210: "testQNameList(): Incorrect value for inout param",
2211: x.equals(y.value));
2212: assertTrue(
2213: "testQNameList(): Incorrect value for out param",
2214: yOrig.equals(z.value));
2215: assertTrue("testQNameList(): Incorrect return value", x
2216: .equals(ret));
2217: }
2218: } else {
2219: QName[] x = {
2220: new QName("http://schemas.iona.com/type_test",
2221: "testqname1"),
2222: new QName("http://schemas.iona.com/type_test",
2223: "testqname2"),
2224: new QName("http://schemas.iona.com/type_test",
2225: "testqname3") };
2226: QName[] yOrig = {
2227: new QName("http://schemas.iona.com/type_test",
2228: "testqname4"),
2229: new QName("http://schemas.iona.com/type_test",
2230: "testqname5"),
2231: new QName("http://schemas.iona.com/type_test",
2232: "testqname6") };
2233: Holder<QName[]> y = new Holder<QName[]>(yOrig);
2234: Holder<QName[]> z = new Holder<QName[]>();
2235:
2236: QName[] ret = rpcClient.testQNameList(x, y, z);
2237:
2238: assertTrue(y.value.length == 3);
2239: assertTrue(z.value.length == 3);
2240: assertTrue(ret.length == 3);
2241: if (!perfTestOnly) {
2242: for (int i = 0; i < 3; i++) {
2243: assertEquals(
2244: "testQNameList(): Incorrect value for inout param",
2245: x[i], y.value[i]);
2246: assertEquals(
2247: "testQNameList(): Incorrect value for out param",
2248: yOrig[i], z.value[i]);
2249: assertEquals(
2250: "testQNameList(): Incorrect return value",
2251: x[i], ret[i]);
2252: }
2253: }
2254: }
2255: }
2256:
2257: public void testSimpleUnionList() throws Exception {
2258: if (testDocLiteral) {
2259: List<String> x = Arrays.asList("5", "-7");
2260: List<String> yOrig = Arrays.asList("-9", "7");
2261:
2262: Holder<List<String>> y = new Holder<List<String>>(yOrig);
2263: Holder<List<String>> z = new Holder<List<String>>();
2264:
2265: List<String> ret = docClient.testSimpleUnionList(x, y, z);
2266: if (!perfTestOnly) {
2267: assertTrue(
2268: "testSimpleUnionList(): Incorrect value for inout param",
2269: x.equals(y.value));
2270: assertTrue(
2271: "testSimpleUnionList(): Incorrect value for out param",
2272: yOrig.equals(z.value));
2273: assertTrue(
2274: "testSimpleUnionList(): Incorrect return value",
2275: x.equals(ret));
2276: }
2277: } else {
2278: String[] x = { "5", "-7" };
2279: String[] yOrig = { "-9", "7" };
2280:
2281: Holder<String[]> y = new Holder<String[]>(yOrig);
2282: Holder<String[]> z = new Holder<String[]>();
2283:
2284: String[] ret = rpcClient.testSimpleUnionList(x, y, z);
2285:
2286: assertTrue(y.value.length == 2);
2287: assertTrue(z.value.length == 2);
2288: assertTrue(ret.length == 2);
2289: if (!perfTestOnly) {
2290: for (int i = 0; i < 2; i++) {
2291: assertEquals(
2292: "testSimpleUnionList(): Incorrect value for inout param",
2293: x[i], y.value[i]);
2294: assertEquals(
2295: "testSimpleUnionList(): Incorrect value for out param",
2296: yOrig[i], z.value[i]);
2297: assertEquals(
2298: "testSimpleUnionList(): Incorrect return value",
2299: x[i], ret[i]);
2300: }
2301: }
2302: }
2303: }
2304:
2305: public void testAnonEnumList() throws Exception {
2306: if (testDocLiteral) {
2307: List<Short> x = Arrays.asList((short) 10, (short) 100);
2308: List<Short> yOrig = Arrays.asList((short) 1000, (short) 10);
2309:
2310: Holder<List<Short>> y = new Holder<List<Short>>(yOrig);
2311: Holder<List<Short>> z = new Holder<List<Short>>();
2312:
2313: List<Short> ret = docClient.testAnonEnumList(x, y, z);
2314: if (!perfTestOnly) {
2315: assertTrue(
2316: "testAnonEnumList(): Incorrect value for inout param",
2317: x.equals(y.value));
2318: assertTrue(
2319: "testAnonEnumList(): Incorrect value for out param",
2320: yOrig.equals(z.value));
2321: assertTrue(
2322: "testAnonEnumList(): Incorrect return value", x
2323: .equals(ret));
2324: }
2325: } else {
2326: Short[] x = { (short) 10, (short) 100 };
2327: Short[] yOrig = { (short) 1000, (short) 10 };
2328:
2329: Holder<Short[]> y = new Holder<Short[]>(yOrig);
2330: Holder<Short[]> z = new Holder<Short[]>();
2331:
2332: Short[] ret = rpcClient.testAnonEnumList(x, y, z);
2333:
2334: assertTrue(y.value.length == 2);
2335: assertTrue(z.value.length == 2);
2336: assertTrue(ret.length == 2);
2337: if (!perfTestOnly) {
2338: for (int i = 0; i < 2; i++) {
2339: assertEquals(
2340: "testAnonEnumList(): Incorrect value for inout param",
2341: x[i].shortValue(), y.value[i].shortValue());
2342: assertEquals(
2343: "testAnonEnumList(): Incorrect value for out param",
2344: yOrig[i].shortValue(), z.value[i]
2345: .shortValue());
2346: assertEquals(
2347: "testAnonEnumList(): Incorrect return value",
2348: x[i].shortValue(), ret[i].shortValue());
2349: }
2350: }
2351: }
2352: }
2353:
2354: public void testUnionWithAnonEnum() throws Exception {
2355: String x = "5";
2356: String yOrig = "n/a";
2357:
2358: Holder<String> y = new Holder<String>(yOrig);
2359: Holder<String> z = new Holder<String>();
2360: String ret;
2361: if (testDocLiteral) {
2362: ret = docClient.testUnionWithAnonEnum(x, y, z);
2363: } else {
2364: ret = rpcClient.testUnionWithAnonEnum(x, y, z);
2365: }
2366: assertEquals(
2367: "testUnionWithAnonEnum(): Incorrect value for inout param",
2368: x, y.value);
2369: assertEquals(
2370: "testUnionWithAnonEnum(): Incorrect value for out param",
2371: yOrig, z.value);
2372: assertEquals("testUnionWithAnonEnum(): Incorrect return value",
2373: x, ret);
2374: }
2375:
2376: }
|