1 7 8 package test.wsdl.types; 9 10 import junit.framework.AssertionFailedError; 11 import junit.framework.TestCase; 12 import org.apache.axis.holders.DayHolder; 13 import org.apache.axis.holders.MonthDayHolder; 14 import org.apache.axis.holders.MonthHolder; 15 import org.apache.axis.holders.NegativeIntegerHolder; 16 import org.apache.axis.holders.NonNegativeIntegerHolder; 17 import org.apache.axis.holders.NonPositiveIntegerHolder; 18 import org.apache.axis.holders.PositiveIntegerHolder; 19 import org.apache.axis.holders.TimeHolder; 20 import org.apache.axis.holders.URIHolder; 21 import org.apache.axis.holders.UnsignedByteHolder; 22 import org.apache.axis.holders.UnsignedIntHolder; 23 import org.apache.axis.holders.UnsignedLongHolder; 24 import org.apache.axis.holders.UnsignedShortHolder; 25 import org.apache.axis.holders.YearHolder; 26 import org.apache.axis.holders.YearMonthHolder; 27 import org.apache.axis.types.Day; 28 import org.apache.axis.types.Month; 29 import org.apache.axis.types.MonthDay; 30 import org.apache.axis.types.NegativeInteger; 31 import org.apache.axis.types.NonNegativeInteger; 32 import org.apache.axis.types.NonPositiveInteger; 33 import org.apache.axis.types.PositiveInteger; 34 import org.apache.axis.types.Time; 35 import org.apache.axis.types.URI; 36 import org.apache.axis.types.UnsignedByte; 37 import org.apache.axis.types.UnsignedInt; 38 import org.apache.axis.types.UnsignedLong; 39 import org.apache.axis.types.UnsignedShort; 40 import org.apache.axis.types.Year; 41 import org.apache.axis.types.YearMonth; 42 import test.wsdl.types.comprehensive_service.TypeTest; 43 44 import javax.xml.namespace.QName ; 45 import javax.xml.rpc.Service ; 46 import javax.xml.rpc.ServiceException ; 47 import javax.xml.rpc.ServiceFactory ; 48 import javax.xml.rpc.Stub ; 49 import javax.xml.rpc.holders.BigDecimalHolder ; 50 import javax.xml.rpc.holders.BigIntegerHolder ; 51 import javax.xml.rpc.holders.BooleanHolder ; 52 import javax.xml.rpc.holders.BooleanWrapperHolder ; 53 import javax.xml.rpc.holders.ByteArrayHolder ; 54 import javax.xml.rpc.holders.ByteHolder ; 55 import javax.xml.rpc.holders.CalendarHolder ; 56 import javax.xml.rpc.holders.DoubleHolder ; 57 import javax.xml.rpc.holders.DoubleWrapperHolder ; 58 import javax.xml.rpc.holders.FloatHolder ; 59 import javax.xml.rpc.holders.FloatWrapperHolder ; 60 import javax.xml.rpc.holders.IntHolder ; 61 import javax.xml.rpc.holders.IntegerWrapperHolder ; 62 import javax.xml.rpc.holders.LongHolder ; 63 import javax.xml.rpc.holders.QNameHolder ; 64 import javax.xml.rpc.holders.ShortHolder ; 65 import javax.xml.rpc.holders.ShortWrapperHolder ; 66 import javax.xml.rpc.holders.StringHolder ; 67 import java.math.BigDecimal ; 68 import java.math.BigInteger ; 69 import java.net.MalformedURLException ; 70 import java.net.URL ; 71 import java.rmi.RemoteException ; 72 import java.util.Calendar ; 73 74 public class DynamicProxyTestCase extends TestCase { 75 public DynamicProxyTestCase(String name) { 76 super(name); 77 } 78 79 private TypeTest getProxyWithWSDL() { 80 try { 81 Service service = ServiceFactory.newInstance().createService( 82 new URL ("file", "", "test/wsdl/types/ComprehensiveTypes.wsdl"), 83 new QName ("urn:comprehensive-service.types.wsdl.test", 84 "TypeTestService")); 85 return (TypeTest) service.getPort( 86 new QName ("", "TypeTest"), TypeTest.class); 87 } 88 catch (MalformedURLException mue) { 89 throw new AssertionFailedError( 90 "MalformedURLException caught: " + mue); 91 } 92 catch (ServiceException jre) { 93 throw new AssertionFailedError("ServiceException caught: " + jre); 94 } 95 } 97 private TypeTest getProxy() { 98 try { 99 Service service = ServiceFactory.newInstance().createService(null); 100 Stub binding = (Stub ) service.getPort(TypeTest.class); 101 binding._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, 102 "http://localhost:8080/axis/services/TypeTest"); 103 throw new AssertionFailedError("Should not get a binding"); 104 } 105 catch (ServiceException jre) { 106 return null; 107 } 108 } 110 private void allPrimitivesIn(TypeTest binding) { 111 assertTrue("binding is null", binding != null); 112 try { 113 114 binding.allPrimitivesIn( 115 new String (), 116 new BigInteger ("0"), 117 0, 118 0, 119 (short)0, 120 new BigDecimal (0), 121 0, 122 0, 123 true, 124 (byte)0, 125 new QName ("http://double-double", "toil-and-trouble"), 126 Calendar.getInstance(), 127 new byte[0], 128 new byte[0], 129 new String (), 130 new Boolean (false), 131 new Float (0), 132 new Double (0), 133 new BigDecimal (0), 134 new Integer (0), 135 new Short ((short)0), 136 new byte[0], 137 new Time("12:01:30.150Z"), 138 new UnsignedLong(0), 139 new UnsignedInt(0), 140 new UnsignedShort(0), 141 new UnsignedByte(0), 142 new NonNegativeInteger("0"), 143 new PositiveInteger("1"), 144 new NonPositiveInteger("0"), 145 new NegativeInteger("-1"), 146 new URI("urn:this-is-a-test"), 147 new Year(1995), 148 new Month(7), 149 new Day(13), 150 new YearMonth(2002, 8), 151 new MonthDay(8, 26) 152 ); 153 } 154 catch (RemoteException re) { 155 re.printStackTrace(); 156 throw new AssertionFailedError("Remote Exception caught: " + re); 157 } 158 catch (Exception e) { 159 } 162 163 } 165 public void test1TypeTestAllPrimitivesIn() { 166 TypeTest binding = getProxyWithWSDL(); 167 allPrimitivesIn(binding); 168 binding = getProxy(); 169 assertTrue(binding == null); 170 } 172 private void allPrimitivesInout(TypeTest binding) { 173 assertTrue("binding is null", binding != null); 174 try { 175 176 binding.allPrimitivesInout( 177 new StringHolder (new String ()), 178 new BigIntegerHolder (new BigInteger ("0")), 179 new IntHolder(0), 180 new LongHolder(0), 181 new ShortHolder((short)0), 182 new BigDecimalHolder (new BigDecimal (0)), 183 new FloatHolder (0), 184 new DoubleHolder (0), 185 new BooleanHolder (true), 186 new ByteHolder((byte)0), 187 new QNameHolder (new QName ("http://double-double", 188 "toil-and-trouble")), 189 new CalendarHolder (Calendar.getInstance()), 190 new ByteArrayHolder (new byte[0]), 191 new ByteArrayHolder (new byte[0]), 192 new StringHolder (new String ()), 193 new BooleanWrapperHolder (new Boolean (false)), 194 new FloatWrapperHolder (new Float (0)), 195 new DoubleWrapperHolder (new Double (0)), 196 new BigDecimalHolder (new BigDecimal (0)), 197 new IntegerWrapperHolder (new Integer (0)), 198 new ShortWrapperHolder (new Short ((short)0)), 199 new ByteArrayHolder (new byte[0]), 200 new TimeHolder(new Time("12:01:30.150Z")), 201 new UnsignedLongHolder(new UnsignedLong(0)), 202 new UnsignedIntHolder(new UnsignedInt(0)), 203 new UnsignedShortHolder(new UnsignedShort(0)), 204 new UnsignedByteHolder(new UnsignedByte(0)), 205 new NonNegativeIntegerHolder(new NonNegativeInteger("0")), 206 new PositiveIntegerHolder(new PositiveInteger("1")), 207 new NonPositiveIntegerHolder(new NonPositiveInteger("0")), 208 new NegativeIntegerHolder(new NegativeInteger("-1")), 209 new URIHolder(new URI("urn:this-is-a-test")), 210 new YearHolder(new Year(1995)), 211 new MonthHolder(new Month(7)), 212 new DayHolder(new Day(13)), 213 new YearMonthHolder(new YearMonth(2002, 8)), 214 new MonthDayHolder(new MonthDay(8, 26)) 215 216 ); 217 } 218 catch (RemoteException re) { 219 re.printStackTrace(); 220 throw new AssertionFailedError("Remote Exception caught: " + re); 221 } 222 catch (Exception e) { 223 } 226 } 228 public void test2TypeTestAllPrimitivesInout() { 229 235 } 237 private void allPrimitivesOut(TypeTest binding) { 238 assertTrue("binding is null", binding != null); 239 try { 240 binding.allPrimitivesOut( 241 new StringHolder (), 242 new BigIntegerHolder (), 243 new IntHolder(), 244 new LongHolder(), 245 new ShortHolder(), 246 new BigDecimalHolder (), 247 new FloatHolder (), 248 new DoubleHolder (), 249 new BooleanHolder (), 250 new ByteHolder(), 251 new QNameHolder (), 252 new CalendarHolder (), 253 new ByteArrayHolder (), 254 new ByteArrayHolder (), 255 new StringHolder (), 256 new BooleanWrapperHolder (), 257 new FloatWrapperHolder (), 258 new DoubleWrapperHolder (), 259 new BigDecimalHolder (), 260 new IntegerWrapperHolder (), 261 new ShortWrapperHolder (), 262 new ByteArrayHolder (), 263 new TimeHolder(), 264 new UnsignedLongHolder(), 265 new UnsignedIntHolder(), 266 new UnsignedShortHolder(), 267 new UnsignedByteHolder(), 268 new NonNegativeIntegerHolder(), 269 new PositiveIntegerHolder(), 270 new NonPositiveIntegerHolder(), 271 new NegativeIntegerHolder(), 272 new URIHolder(), 273 new YearHolder(), 274 new MonthHolder(), 275 new DayHolder(), 276 new YearMonthHolder(), 277 new MonthDayHolder() 278 279 ); 280 } 281 catch (RemoteException re) { 282 throw new AssertionFailedError("Remote Exception caught: " + re); 283 } 284 } 286 public void test3TypeTestAllPrimitivesOut() { 287 293 } 295 1387} 1388 1389 | Popular Tags |