1 package org.apache.ws.jaxme.js.junit; 2 3 import java.io.IOException ; 4 import java.lang.reflect.UndeclaredThrowableException ; 5 import java.util.Vector ; 6 7 import org.apache.ws.jaxme.js.apps.XmlRpcCaller; 8 import org.apache.ws.jaxme.js.junit.xmlrpcclient.Dispatcher; 9 10 import junit.framework.TestCase; 11 12 13 16 public class XmlRpcClientTest extends TestCase { 17 private final XmlRpcCaller caller = new XmlRpcCaller(){ 18 Dispatcher dispatcher = new Dispatcher(); 19 public Object xmlRpcCall(String pName, Vector pVector) { 20 try { 21 return dispatcher.execute(pName, pVector); 22 } catch (RuntimeException e) { 23 throw e; 24 } catch (Throwable t) { 25 throw new UndeclaredThrowableException (t); 26 } 27 } 28 }; 29 private final XmlRpcClientTestRemoteClass server = new XmlRpcClientTestRemoteClass(); 30 private final org.apache.ws.jaxme.js.junit.xmlrpcclient.XmlRpcClientTestRemoteClass client 31 = new org.apache.ws.jaxme.js.junit.xmlrpcclient.XmlRpcClientTestRemoteClass(caller); 32 33 35 public XmlRpcClientTest(String pArg0) { 36 super(pArg0); 37 } 38 39 private void checkSum(int pSum) { 40 assertEquals(pSum, server.getSum()); 41 assertEquals(pSum, client.getSum()); 42 String sumAsString = Integer.toString(pSum); 43 try { 44 assertEquals(sumAsString, server.getSumAsString()); 45 } catch (IOException e) { 46 } 50 try { 51 assertEquals(sumAsString, client.getSumAsString()); 52 } catch (IOException e) { 53 } 57 } 58 59 62 public void testXmlRpcClient() { 63 checkSum(0); 64 server.add(1); 65 checkSum(1); 66 client.add(1); 67 checkSum(2); 68 server.add(new int[]{2,3,2}); 69 checkSum(9); 70 client.add(new int[]{0,-1,0,2}); 71 checkSum(10); 72 server.add("4"); 73 checkSum(14); 74 client.add("-8"); 75 checkSum(6); 76 } 77 } 78 | Popular Tags |