Methods Summary |
---|
public java.lang.Object[] | echoArray(java.lang.Object[] array)
return array;
|
public java.util.LinkedList | echoLinkedList(java.util.LinkedList l)Service methods - this class is also deployed as an Axis RPC
service for convenience. These guys just echo various things.
return l;
|
public java.util.Vector | echoVector(java.util.Vector v)
return v;
|
private static boolean | equals(java.util.List list, java.lang.Object obj)
if ((list == null) || (obj == null))
return false;
if (!obj.getClass().isArray()) return false;
Object[] array = (Object[]) obj;
Iterator iter = list.iterator();
for (int i = 0; i < array.length; i++) {
if (!(array[i].equals(iter.next()))) {
return false;
}
}
return true;
|
public static void | main(java.lang.String[] args)
TestArrayListConversions tester = new TestArrayListConversions("TestArrayListConversions");
try {
tester.setUp();
tester.testArrayConversion();
tester.testLinkedListConversion();
tester.testVectorConversion();
tester.testReturnAsVector();
} catch (Exception e) {
e.printStackTrace();
}
|
protected void | setUp()
try {
SimpleProvider provider = new SimpleProvider();
server = new AxisServer(provider);
transport = new LocalTransport(server);
SOAPService service = new SOAPService(new RPCProvider());
service.setEngine(server);
service.setOption("className", "test.encoding.TestArrayListConversions");
service.setOption("allowedMethods", "*");
ServiceDesc desc = service.getInitializedServiceDesc(null);
desc.setDefaultNamespace(SERVICE_NAME);
provider.deployService(SERVICE_NAME, service);
} catch (Exception exp) {
exp.printStackTrace();
}
|
public void | testArrayConversion()
Call call = new Call(new Service());
call.setTransport(transport);
Vector v = new Vector();
v.addElement("Hi there!");
v.addElement("This'll be a SOAP Array");
call.setOperationName(new QName(SERVICE_NAME, "echoArray"));
Object ret = call.invoke(new Object[]{v});
if (!equals(v, ret)) assertEquals("Echo Array mangled the result. Result is underneath\n" + ret, v, ret);
|
public void | testLinkedListConversion()
Call call = new Call(new Service());
call.setTransport(transport);
LinkedList l = new LinkedList();
l.add("Linked list item #1");
l.add("Second linked list item");
l.add("This will be a SOAP Array then a Vector!");
call.setOperationName(new QName(SERVICE_NAME, "echoVector"));
Object ret = call.invoke(new Object[]{l});
if (!equals(l, ret)) assertEquals("Echo Vector mangled the result. Result is underneath.\n" + ret, l, ret);
|
public void | testReturnAsVector()Test the setReturnClass() API on Call by asking the runtime to
give us back a Vector instead of an array. Confirm we get a Vector
back, and that it matches the data we send.
Call call = new Call(new Service());
call.setTransport(transport);
LinkedList l = new LinkedList();
l.add("Linked list item #1");
l.add("Second linked list item");
l.add("This will be a SOAP Array then a Vector!");
call.setOperationName(new QName(SERVICE_NAME, "echoArray"));
call.addParameter("arg0", null, LinkedList.class, ParameterMode.IN);
call.setReturnClass(Vector.class);
Object ret = call.invoke(new Object[]{l});
assertEquals("Return wasn't a Vector!", Vector.class, ret.getClass());
Vector v = (Vector)ret;
assertEquals("Sizes were different", l.size(), v.size());
for (int i = 0; i < l.size(); i++) {
String s = (String)l.get(i);
assertEquals("Value " + i + " didn't match", s, v.get(i));
}
|
public void | testVectorConversion()
Call call = new Call(new Service());
call.setTransport(transport);
Vector v = new Vector();
v.addElement("Hi there!");
v.addElement("This'll be a SOAP Array and then a LinkedList!");
call.setOperationName(new QName(SERVICE_NAME, "echoLinkedList"));
Object ret = call.invoke(new Object[]{v});
if (!equals(v, ret)) assertEquals("Echo LinkedList mangled the result. Result is underneath.\n" + ret, v, ret);
|