1 7 8 package test.wsdl.ram; 9 10 public class RamServiceTestCase extends junit.framework.TestCase { 11 public RamServiceTestCase(String name) { 12 super(name); 13 } 14 15 public void testRamWSDL() throws Exception { 16 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance(); 17 java.net.URL url = new java.net.URL (new test.wsdl.ram.RamServiceLocator().getRamAddress() + "?WSDL"); 18 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.ram.RamServiceLocator().getServiceName()); 19 assertTrue(service != null); 20 } 21 22 public void test1RamValidate() { 23 Ram binding; 24 try { 25 binding = new RamServiceLocator().getRam(); 26 } 27 catch (javax.xml.rpc.ServiceException jre) { 28 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 29 } 30 assertTrue("binding is null", binding != null); 31 32 try { 33 RamData[] input = new RamData[1]; 34 35 input[0] = new RamData(); 36 input[0].setBankInfoPaymentType("BIPT"); 37 input[0].setBankInfoRequestType("BIRT"); 38 input[0].setCallingClientPortNumber("CCPN"); 39 input[0].setCallingClientUserIdentifier("CCUI"); 40 41 CreditCard cc = new CreditCard(); 42 cc.setName("NAME"); 43 cc.setNumber("NUMBER"); 44 cc.setExpires(new java.util.Date ()); 45 cc.setPostalCode("PC"); 46 input[0].setCreditCard(cc); 47 48 Fee[] fees = new Fee[1]; 49 fees[0] = new Fee(); 50 fees[0].setAmount(20.0); 51 fees[0].setQuantity(50); 52 fees[0].setCode("CODE"); 53 input[0].setFees(fees); 54 55 input[0].setMailRoomDate(new java.util.Date ()); 56 input[0].setSaleOtherPaymentTotalAmount(100.0); 57 input[0].setSalePostingReferenceText("SPRT"); 58 59 Response[] output = binding.validate(input); 60 java.util.Date resDate = output[0].getAccountingDate(); 61 java.util.Date now = new java.util.Date (); 62 assertTrue("Time check failed. Result date = " + resDate + ", current time = " + now, resDate.before(now)); 63 } 64 catch (java.rmi.RemoteException re) { 65 throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re); 66 } 67 } 68 69 public static void main(String [] args){ 70 RamServiceTestCase test = new RamServiceTestCase("RamServiceTestCase"); 71 test.test1RamValidate(); 72 } 73 } 74 | Popular Tags |