1 7 8 package test.wsdl.datatypes; 9 10 import javax.xml.namespace.QName ; 11 12 public class DataTypesTestCase extends junit.framework.TestCase { 13 public DataTypesTestCase(String name) { 14 super(name); 15 } 16 public void test1DataTypesSoapSayHello() { 17 DataTypes_PortType binding; 18 try { 19 binding = new DataTypes_ServiceLocator().getDataTypes(); 20 } 21 catch (javax.xml.rpc.ServiceException jre) { 22 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 23 } 24 assertTrue("binding is null", binding != null); 25 26 try { 27 java.lang.String value = null; 28 value = binding.sayHello(); 29 assertTrue("sayHello should be \"Hello World!\", but instead is " + value, "Hello World!".equals(value)); 30 } 31 catch (java.rmi.RemoteException re) { 32 throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re); 33 } 34 } 35 36 public void test2DataTypesSoapSayHelloName() { 37 DataTypes_PortType binding; 38 try { 39 binding = new DataTypes_ServiceLocator().getDataTypes(); 40 } 41 catch (javax.xml.rpc.ServiceException jre) { 42 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 43 } 44 assertTrue("binding is null", binding != null); 45 46 try { 47 java.lang.String value = null; 48 value = binding.sayHelloName(new java.lang.String ("Axis")); 49 assertTrue("sayHelloName should be \"Hello Axis\", but instead is " + value, "Hello Axis".equals(value)); 50 } 51 catch (java.rmi.RemoteException re) { 52 throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re); 53 } 54 } 55 56 public void test3DataTypesSoapGetIntArray() { 57 DataTypes_PortType binding; 58 try { 59 binding = new DataTypes_ServiceLocator().getDataTypes(); 60 } 61 catch (javax.xml.rpc.ServiceException jre) { 62 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 63 } 64 assertTrue("binding is null", binding != null); 65 66 try { 67 ArrayOfInt value = null; 68 value = binding.getIntArray(); 69 int[] array = value.get_int(); 70 assertTrue("getIntArray size should be 5, instead is " + array.length, array.length == 5); 71 for(int i=0;i<array.length;i++) { 72 assertTrue("getIntArray[" + i + "] should be " + (i * 10) + ", instead is " + array[i], array[i] == i * 10); 73 } 74 } 75 catch (java.rmi.RemoteException re) { 76 throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re); 77 } 78 } 79 80 public void test4DataTypesSoapGetMode() { 81 DataTypes_PortType binding; 82 try { 83 binding = new DataTypes_ServiceLocator().getDataTypes(); 84 } 85 catch (javax.xml.rpc.ServiceException jre) { 86 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 87 } 88 assertTrue("binding is null", binding != null); 89 90 try { 91 Mode value = null; 92 value = binding.getMode(); 93 assertTrue("getMode should be Off, instead it is " + value.toString(), "Off".equals(value.toString())); 94 } 95 catch (java.rmi.RemoteException re) { 96 throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re); 97 } 98 } 99 100 public void test5DataTypesSoapGetOrder() { 101 DataTypes_PortType binding; 102 try { 103 binding = new DataTypes_ServiceLocator().getDataTypes(); 104 } 105 catch (javax.xml.rpc.ServiceException jre) { 106 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 107 } 108 assertTrue("binding is null", binding != null); 109 110 try { 111 Order value = null; 112 value = binding.getOrder(); 113 assertTrue("getOrder.getOrderID should be 323232, instead it is " + value.getOrderID(), value.getOrderID() == 323232); 114 assertTrue("getOrder.getPrice should be 34.5, instead it is " + value.getPrice(), value.getPrice() == 34.5); 115 } 116 catch (java.rmi.RemoteException re) { 117 throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re); 118 } 119 } 120 121 public void test6DataTypesSoapGetOrders() { 122 DataTypes_PortType binding; 123 try { 124 binding = new DataTypes_ServiceLocator().getDataTypes(); 125 } 126 catch (javax.xml.rpc.ServiceException jre) { 127 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 128 } 129 assertTrue("binding is null", binding != null); 130 131 try { 132 ArrayOfOrder value = null; 133 value = binding.getOrders(); 134 Order[] orders = value.getOrder(); 135 assertTrue("getOrders size should be 2, instead is " + orders.length, orders.length == 2); 136 for(int i=0;i<orders.length;i++) { 137 if (i == 0) { 138 assertTrue("getOrders[0].getOrderID should be 323232, instead it is " + orders[i].getOrderID(), orders[i].getOrderID() == 323232); 139 assertTrue("getOrders[0].getPrice should be 34.5, instead it is " + orders[i].getPrice(), orders[i].getPrice() == 34.5); 140 } 141 else if (i == 1) { 142 assertTrue("getOrders[1].getOrderID should be 645645, instead it is " + orders[i].getOrderID(), orders[i].getOrderID() == 645645); 143 assertTrue("getOrders[1].getPrice should be 99.4, instead it is " + orders[i].getPrice(), orders[i].getPrice() == 99.4); 144 } 145 } 146 } 147 catch (java.rmi.RemoteException re) { 148 throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re); 149 } 150 } 151 152 public void test7DataTypesSoapGetSimpleList() { 153 DataTypes_PortType binding; 154 try { 155 binding = new DataTypes_ServiceLocator().getDataTypes(); 156 } 157 catch (javax.xml.rpc.ServiceException jre) { 158 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 159 } 160 assertTrue("binding is null", binding != null); 161 162 try { 163 java.lang.String [] inputList = new java.lang.String [3]; 164 inputList[0] = "one"; 165 inputList[1] = "two"; 166 inputList[2] = "three"; 167 java.lang.String [] outputList = binding.getSimpleList(inputList); 168 assertTrue("outputList[0] should be \"one_response\", but instead is " + outputList[0], 169 "one_response".equals(outputList[0])); 170 assertTrue("outputList[1] should be \"two_response\", but instead is " + outputList[1], 171 "two_response".equals(outputList[1])); 172 assertTrue("outputList[2] should be \"three_response\", but instead is " + outputList[2], 173 "three_response".equals(outputList[2])); 174 } 175 catch (java.rmi.RemoteException re) { 176 throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re); 177 } 178 } 179 180 public void test5DataTypesGetUsageType() throws Exception { 181 DataTypes_PortType binding; 182 try { 183 binding = new DataTypes_ServiceLocator().getDataTypes(); 184 } 185 catch (javax.xml.rpc.ServiceException jre) { 186 if(jre.getLinkedCause()!=null) 187 jre.getLinkedCause().printStackTrace(); 188 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 189 } 190 assertNotNull("binding is null", binding); 191 192 UsageType value = null; 194 value = binding.getUsageType(); 195 System.out.println(value); 196 assertEquals(value.getValue(), new QName ("http://schemas.xmlsoap.org/ws/2002/12/policy","Required")); 197 } 199 } 200 201 | Popular Tags |