1 16 17 package test.wsdl.roundtrip; 18 19 import junit.framework.TestCase; 20 import test.wsdl.roundtrip.holders.BondInvestmentHolder; 21 22 import javax.xml.rpc.ServiceException ; 23 import javax.xml.rpc.holders.StringHolder ; 24 import java.math.BigDecimal ; 25 import java.math.BigInteger ; 26 import java.rmi.RemoteException ; 27 import java.util.Calendar ; 28 import java.util.Date ; 29 import java.util.HashMap ; 30 import java.util.TimeZone ; 31 32 47 public class RoundtripTestServiceTestCase extends TestCase { 48 49 private RoundtripPortType binding = null; 50 private RoundtripPortType binding2 = null; 51 private static final double DOUBLE_DELTA = 0.0D; 52 private static final float FLOAT_DELTA = 0.0F; 53 54 60 public RoundtripTestServiceTestCase(String name) { 61 super(name); 62 } 64 68 public void setUp() { 69 70 try { 71 binding = new RoundtripPortTypeServiceLocator().getRoundtripTest(); 72 binding2 = new RoundtripPortTypeServiceLocator().getRoundtripTest2(); 73 } catch (ServiceException jre) { 74 fail("JAX-RPC ServiceException caught: " + jre); 75 } 76 assertTrue("binding is null", binding != null); 77 78 } 80 85 public void testStockInvestment() throws Exception { 86 StockInvestment stock = new StockInvestment(); 87 stock.setName("International Business Machines"); 88 stock.setId(1); 89 stock.setTradeExchange("NYSE"); 90 stock.setLastTradePrice(200.55F); 91 float lastTradePrice = binding.getRealtimeLastTradePrice(stock); 92 assertEquals("The expected and actual values did not match.", 93 201.25F, 94 lastTradePrice, 95 FLOAT_DELTA); 96 try { 98 (StockInvestment.class). 99 getDeclaredMethod("getDontMapToWSDL", 100 new Class [] {}); 101 fail("Should not map static member dontMapToWSDL"); 102 } catch (NoSuchMethodException e) { 103 } 105 106 try { 108 (StockInvestment.class).getDeclaredMethod("getAvgYearlyReturn", 109 new Class [] {}); 110 fail("Should not map private member avgYearlyReturn"); 111 } catch (NoSuchMethodException e) { 112 } 114 } 116 119 public void testStockInvestmentWithPort2() throws Exception { 120 StockInvestment stock = new StockInvestment(); 121 stock.setName("International Business Machines"); 122 stock.setId(1); 123 stock.setTradeExchange("NYSE"); 124 stock.setLastTradePrice(200.55F); 125 float lastTradePrice = binding2.getRealtimeLastTradePrice(stock); 126 assertEquals("The expected and actual values did not match.", 127 201.25F, 128 lastTradePrice, 129 FLOAT_DELTA); 130 try { 132 (StockInvestment.class).getDeclaredMethod("getDontMapToWSDL", 133 new Class [] {}); 134 fail("Should not map static member dontMapToWSDL"); 135 } catch (NoSuchMethodException e) { 136 } 138 139 try { 141 (StockInvestment.class).getDeclaredMethod("getAvgYearlyReturn", 142 new Class [] {}); 143 fail("Should not map private member avgYearlyReturn"); 144 } catch (NoSuchMethodException e) { 145 } 147 } 149 154 public void testPreferredStockInvestment() throws RemoteException { 155 PreferredStockInvestment oldStock = new PreferredStockInvestment(); 156 oldStock.setName("SOAP Inc."); 157 oldStock.setId(202); 158 oldStock.setTradeExchange("NASDAQ"); 159 oldStock.setLastTradePrice(10.50F); 160 oldStock.setDividendsInArrears(100.44D); 161 oldStock.setPreferredYield(new BigDecimal ("7.00")); 162 PreferredStockInvestment newStock = binding.getDividends(oldStock); 163 assertEquals("The expected and actual values did not match.", 164 newStock.getName(), 165 "AXIS Inc."); 166 assertEquals("The expected and actual values did not match.", 167 203, 168 newStock.getId()); 169 assertEquals("The expected and actual values did not match.", 170 "NASDAQ", 171 newStock.getTradeExchange()); 172 assertEquals("The expected and actual values did not match.", 173 101.44D, 174 newStock.getDividendsInArrears(), 175 DOUBLE_DELTA); 176 assertEquals("The expected and actual values did not match.", 177 new BigDecimal ("8.00"), 178 newStock.getPreferredYield()); 179 assertEquals("The expected and actual values did not match.", 180 11.50F, 181 newStock.getLastTradePrice(), 182 FLOAT_DELTA); 183 } 185 191 public void testRoundtripBondInvestment() throws RemoteException { 192 CallOptions[] callOptions = new CallOptions[2]; 193 callOptions[0] = new CallOptions(); 194 Calendar date = Calendar.getInstance(); 195 TimeZone gmt = TimeZone.getTimeZone("GMT"); 196 date.setTimeZone(gmt); 197 date.setTime(new Date (1013441507388L)); 198 callOptions[0].setCallDate(date); 199 callOptions[1] = new CallOptions(); 200 date = Calendar.getInstance(); 201 date.setTimeZone(gmt); 202 date.setTime(new Date (1013441507390L)); 203 callOptions[1].setCallDate(date); 204 HashMap map = new HashMap (); 205 map.put("Test", "Test Works"); 206 207 short[] shortArray = {(short) 30}; 208 byte[] byteArray = {(byte) 1}; 209 Short [] wrapperShortArray = {new Short ((short) 23), new Short ((short) 56)}; 210 Byte [] wrapperByteArray = {new Byte ((byte) 2), new Byte ((byte) 15)}; 211 212 BondInvestment sendValue = new BondInvestment(); 213 214 sendValue.setMap(map); 215 sendValue.setOptions(callOptions); 216 sendValue.setOptions2(callOptions); 217 sendValue.setOptions3(callOptions[0]); 218 sendValue.setWrapperShortArray(wrapperShortArray); 219 sendValue.setWrapperByteArray(wrapperByteArray); 220 sendValue.setWrapperDouble(new Double (2323.232D)); 221 sendValue.setWrapperFloat(new Float (23.023F)); 222 sendValue.setWrapperInteger(new Integer (2093)); 223 sendValue.setWrapperShort(new Short ((short) 203)); 224 sendValue.setWrapperByte(new Byte ((byte) 20)); 225 sendValue.setWrapperBoolean(new Boolean (true)); 226 sendValue.setShortArray(shortArray); 227 sendValue.setByteArray(byteArray); 228 date = Calendar.getInstance(); 229 date.setTimeZone(gmt); 230 date.setTime(new Date (1012937861996L)); 231 sendValue.setCallableDate(date); 232 sendValue.setBondAmount(new BigDecimal ("2675.23")); 233 sendValue.setPortfolioType(new BigInteger ("2093")); 234 sendValue.setTradeExchange("NYSE"); 235 sendValue.setFiftyTwoWeekHigh(45.012D); 236 sendValue.setLastTradePrice(87895.32F); 237 sendValue.setYield(5475L); 238 sendValue.setStockBeta(32); 239 sendValue.setDocType((short) 35); 240 sendValue.setTaxIndicator((byte) 3); 241 242 BondInvestment actual = binding.methodBondInvestmentInOut(sendValue); 243 date.setTime(new Date (1013441507308L)); 244 245 assertEquals("Returned map is not correct.", 246 actual.getMap().get("Test"), "Test Works"); 247 assertEquals("The expected and actual values did not match.", 248 date, 249 actual.getOptions()[0].getCallDate()); 250 date.setTime(new Date (1013441507328L)); 251 assertEquals("The expected and actual values did not match.", 252 date, 253 actual.getOptions()[1].getCallDate()); 254 assertEquals("The expected and actual values did not match.", 255 new Short ((short) 33), 256 actual.getWrapperShortArray()[0]); 257 assertEquals("The expected and actual values did not match.", 258 new Short ((short) 86), 259 actual.getWrapperShortArray()[1]); 260 assertEquals("The expected and actual values did not match.", 261 new Byte ((byte) 4), 262 actual.getWrapperByteArray()[0]); 263 assertEquals("The expected and actual values did not match.", 264 new Byte ((byte) 18), 265 actual.getWrapperByteArray()[1]); 266 assertEquals("The expected and actual values did not match.", 267 new Double (33.232D), 268 actual.getWrapperDouble()); 269 assertEquals("The expected and actual values did not match.", 270 new Float (2.23F), 271 actual.getWrapperFloat()); 272 assertEquals("The expected and actual values did not match.", 273 new Integer (3), 274 actual.getWrapperInteger()); 275 assertEquals("The expected and actual values did not match.", 276 new Short ((short) 2), 277 actual.getWrapperShort()); 278 assertEquals("The expected and actual values did not match.", 279 new Byte ((byte) 21), 280 actual.getWrapperByte()); 281 assertEquals("The expected and actual values did not match.", 282 new Boolean (false), 283 actual.getWrapperBoolean()); 284 assertEquals("The expected and actual values did not match.", 285 (short) 36, 286 actual.getShortArray()[0]); 287 assertEquals("The expected and actual values did not match.", 288 (byte) 7, 289 actual.getByteArray()[0]); 290 date.setTime(new Date (1012937862997L)); 291 assertEquals("The expected and actual values did not match.", 292 date, 293 actual.getCallableDate()); 294 assertEquals("The expected and actual values did not match.", 295 new BigDecimal ("2735.23"), 296 actual.getBondAmount()); 297 assertEquals("The expected and actual values did not match.", 298 new BigInteger ("21093"), 299 actual.getPortfolioType()); 300 assertEquals("The expected and actual values did not match.", 301 new String ("AMEX"), 302 actual.getTradeExchange()); 303 assertEquals("The expected and actual values did not match.", 304 415.012D, 305 actual.getFiftyTwoWeekHigh(), 306 DOUBLE_DELTA); 307 assertEquals("The expected and actual values did not match.", 308 8795.32F, 309 actual.getLastTradePrice(), 310 FLOAT_DELTA); 311 assertEquals("The expected and actual values did not match.", 312 575L, 313 actual.getYield()); 314 assertEquals("The expected and actual values did not match.", 315 3, 316 actual.getStockBeta()); 317 assertEquals("The expected and actual values did not match.", 318 (short) 45, 319 actual.getDocType()); 320 assertEquals("The expected and actual values did not match.", 321 (byte) 8, 322 actual.getTaxIndicator()); 323 } 325 331 public void testBondInvestmentOut() throws RemoteException { 332 BondInvestment actual = binding.methodBondInvestmentOut(); 333 Calendar date = Calendar.getInstance(); 334 TimeZone gmt = TimeZone.getTimeZone("GMT"); 335 date.setTimeZone(gmt); 336 date.setTime(new Date (1013441507308L)); 337 assertEquals("Returned map is not correct.", 338 actual.getMap().get("Test"), "Test Works"); 339 assertEquals("The expected and actual values did not match.", 340 date, 341 actual.getOptions()[0].getCallDate()); 342 date.setTime(new Date (1013441507328L)); 343 assertEquals("The expected and actual values did not match.", 344 date, 345 actual.getOptions()[1].getCallDate()); 346 assertEquals("The expected and actual values did not match.", 347 new Short ((short) 33), 348 actual.getWrapperShortArray()[0]); 349 assertEquals("The expected and actual values did not match.", 350 new Short ((short) 86), 351 actual.getWrapperShortArray()[1]); 352 assertEquals("The expected and actual values did not match.", 353 new Byte ((byte) 4), 354 actual.getWrapperByteArray()[0]); 355 assertEquals("The expected and actual values did not match.", 356 new Byte ((byte) 18), 357 actual.getWrapperByteArray()[1]); 358 assertEquals("The expected and actual values did not match.", 359 new Double (33.232D), 360 actual.getWrapperDouble()); 361 assertEquals("The expected and actual values did not match.", 362 new Float (2.23F), 363 actual.getWrapperFloat()); 364 assertEquals("The expected and actual values did not match.", 365 new Integer (3), 366 actual.getWrapperInteger()); 367 assertEquals("The expected and actual values did not match.", 368 new Short ((short) 2), 369 actual.getWrapperShort()); 370 assertEquals("The expected and actual values did not match.", 371 new Byte ((byte) 21), 372 actual.getWrapperByte()); 373 assertEquals("The expected and actual values did not match.", 374 new Boolean (false), 375 actual.getWrapperBoolean()); 376 assertEquals("The expected and actual values did not match.", 377 (short) 36, 378 actual.getShortArray()[0]); 379 assertEquals("The expected and actual values did not match.", 380 (byte) 7, 381 actual.getByteArray()[0]); 382 date.setTime(new Date (1012937862997L)); 383 assertEquals("The expected and actual values did not match.", 384 date, 385 actual.getCallableDate()); 386 assertEquals("The expected and actual values did not match.", 387 new BigDecimal ("2735.23"), 388 actual.getBondAmount()); 389 assertEquals("The expected and actual values did not match.", 390 new BigInteger ("21093"), 391 actual.getPortfolioType()); 392 assertEquals("The expected and actual values did not match.", 393 new String ("AMEX"), 394 actual.getTradeExchange()); 395 assertEquals("The expected and actual values did not match.", 396 415.012D, 397 actual.getFiftyTwoWeekHigh(), 398 DOUBLE_DELTA); 399 assertEquals("The expected and actual values did not match.", 400 8795.32F, 401 actual.getLastTradePrice(), 402 FLOAT_DELTA); 403 assertEquals("The expected and actual values did not match.", 404 575L, 405 actual.getYield()); 406 assertEquals("The expected and actual values did not match.", 407 3, 408 actual.getStockBeta()); 409 assertEquals("The expected and actual values did not match.", 410 (short) 45, 411 actual.getDocType()); 412 assertEquals("The expected and actual values did not match.", 413 (byte) 8, 414 actual.getTaxIndicator()); 415 } 417 423 public void testBondInvestmentIn() throws RemoteException { 424 CallOptions[] callOptions = new CallOptions[2]; 425 callOptions[0] = new CallOptions(); 426 Calendar date = Calendar.getInstance(); 427 TimeZone gmt = TimeZone.getTimeZone("GMT"); 428 date.setTimeZone(gmt); 429 date.setTime(new Date (1013441507388L)); 430 callOptions[0].setCallDate(date); 431 callOptions[1] = new CallOptions(); 432 date = Calendar.getInstance(); 433 date.setTimeZone(gmt); 434 date.setTime(new Date (1013441507390L)); 435 callOptions[1].setCallDate(date); 436 HashMap map = new HashMap (); 437 map.put("Test", "Test Works"); 438 439 440 short[] shortArray = {(short) 30}; 441 byte[] byteArray = {(byte) 1}; 442 Short [] wrapperShortArray = {new Short ((short) 23), new Short ((short) 56)}; 443 Byte [] wrapperByteArray = {new Byte ((byte) 2), new Byte ((byte) 15)}; 444 445 BondInvestment sendValue = new BondInvestment(); 446 447 sendValue.setMap(map); 448 sendValue.setOptions(callOptions); 449 sendValue.setOptions2(callOptions); 450 sendValue.setOptions3(callOptions[0]); 451 sendValue.setWrapperShortArray(wrapperShortArray); 452 sendValue.setWrapperByteArray(wrapperByteArray); 453 sendValue.setWrapperDouble(new Double (2323.232D)); 454 sendValue.setWrapperFloat(new Float (23.023F)); 455 sendValue.setWrapperInteger(new Integer (2093)); 456 sendValue.setWrapperShort(new Short ((short) 203)); 457 sendValue.setWrapperByte(new Byte ((byte) 20)); 458 sendValue.setWrapperBoolean(new Boolean (true)); 459 sendValue.setShortArray(shortArray); 460 sendValue.setByteArray(byteArray); 461 date = Calendar.getInstance(); 462 date.setTimeZone(gmt); 463 date.setTime(new Date (1012937861996L)); 464 sendValue.setCallableDate(date); 465 sendValue.setBondAmount(new BigDecimal ("2675.23")); 466 sendValue.setPortfolioType(new BigInteger ("2093")); 467 sendValue.setTradeExchange("NYSE"); 468 sendValue.setFiftyTwoWeekHigh(45.012D); 469 sendValue.setLastTradePrice(87895.32F); 470 sendValue.setYield(5475L); 471 sendValue.setStockBeta(32); 472 sendValue.setDocType((short) 35); 473 sendValue.setTaxIndicator((byte) 3); 474 475 binding.methodBondInvestmentIn(sendValue); 476 } 478 481 public void testBondInvestmentGetId() throws RemoteException { 482 CallOptions[] callOptions = new CallOptions[2]; 483 callOptions[0] = new CallOptions(); 484 Calendar date = Calendar.getInstance(); 485 TimeZone gmt = TimeZone.getTimeZone("GMT"); 486 date.setTimeZone(gmt); 487 date.setTime(new Date (1013441507388L)); 488 callOptions[0].setCallDate(date); 489 callOptions[1] = new CallOptions(); 490 date = Calendar.getInstance(); 491 date.setTimeZone(gmt); 492 date.setTime(new Date (1013441507390L)); 493 callOptions[1].setCallDate(date); 494 495 short[] shortArray = {(short) 30}; 496 byte[] byteArray = {(byte) 1}; 497 Short [] wrapperShortArray = {new Short ((short) 23), new Short ((short) 56)}; 498 Byte [] wrapperByteArray = {new Byte ((byte) 2), new Byte ((byte) 15)}; 499 500 BondInvestment sendValue = new BondInvestment(); 501 502 sendValue.setOptions(callOptions); 503 sendValue.setOptions2(callOptions); 504 sendValue.setOptions3(callOptions[0]); 505 sendValue.setWrapperShortArray(wrapperShortArray); 506 sendValue.setWrapperByteArray(wrapperByteArray); 507 sendValue.setWrapperDouble(new Double (2323.232D)); 508 sendValue.setWrapperFloat(new Float (23.023F)); 509 sendValue.setWrapperInteger(new Integer (2093)); 510 sendValue.setWrapperShort(new Short ((short) 203)); 511 sendValue.setWrapperByte(new Byte ((byte) 20)); 512 sendValue.setWrapperBoolean(new Boolean (true)); 513 sendValue.setShortArray(shortArray); 514 sendValue.setByteArray(byteArray); 515 date = Calendar.getInstance(); 516 date.setTimeZone(gmt); 517 date.setTime(new Date (1012937861996L)); 518 sendValue.setCallableDate(date); 519 sendValue.setBondAmount(new BigDecimal ("2675.23")); 520 sendValue.setPortfolioType(new BigInteger ("2093")); 521 sendValue.setTradeExchange("NYSE"); 522 sendValue.setFiftyTwoWeekHigh(45.012D); 523 sendValue.setLastTradePrice(87895.32F); 524 sendValue.setYield(5475L); 525 sendValue.setStockBeta(32); 526 sendValue.setDocType((short) 35); 527 sendValue.setTaxIndicator((byte) 3); 528 sendValue.setId(-123); 529 530 int id = binding.getId(sendValue); 531 assertEquals("The wrong id was sent back", -123, id); 532 } 534 537 public void testInvestmentGetId() throws RemoteException { 538 StockInvestment stock = new StockInvestment(); 539 stock.setName("International Business Machines"); 540 stock.setId(1); 541 stock.setTradeExchange("NYSE"); 542 stock.setLastTradePrice(200.55F); 543 544 int id = binding.getId(stock); 546 assertEquals("The wrong id was sent back", 1, id); 547 } 549 553 public void testMethodStringMArrayOut() throws RemoteException { 554 String [][] expected = {{"Out-0-0"}, {"Out-1-0"}}; 555 String [][] actual = binding.methodStringMArrayOut(); 556 assertEquals("The expected and actual values did not match.", 557 expected[0][0], 558 actual[0][0]); 559 assertEquals("The expected and actual values did not match.", 560 expected[1][0], 561 actual[1][0]); 562 } 564 568 public void testMethodStringMArrayIn() throws RemoteException { 569 String [][] sendArray = {{"In-0-0", "In-0-1"}, {"In-1-0", "In-1-1"}}; 570 binding.methodStringMArrayIn(sendArray); 571 } 573 577 public void testMethodStringMArrayInOut() throws RemoteException { 578 String [][] sendArray = {{"Request-0-0", "Request-0-1"}, {"Request-1-0", "Request-1-1"}}; 579 String [][] expected = {{"Response-0-0", "Response-0-1"}, {"Response-1-0", "Response-1-1"}}; 580 String [][] actual = binding.methodStringMArrayInOut(sendArray); 581 assertEquals("The expected and actual values did not match.", 582 expected[0][0], 583 actual[0][0]); 584 assertEquals("The expected and actual values did not match.", 585 expected[0][1], 586 actual[0][1]); 587 assertEquals("The expected and actual values did not match.", 588 expected[1][0], 589 actual[1][0]); 590 assertEquals("The expected and actual values did not match.", 591 expected[1][1], 592 actual[1][1]); 593 } 595 599 public void testMethodIntArrayOut() throws RemoteException { 600 int[] expected = {3, 78, 102}; 601 int[] actual = binding.methodIntArrayOut(); 602 assertEquals("The expected and actual values did not match.", 603 expected[0], 604 actual[0]); 605 assertEquals("The expected and actual values did not match.", 606 expected[1], 607 actual[1]); 608 assertEquals("The expected and actual values did not match.", 609 expected[2], 610 actual[2]); 611 } 613 617 public void testMethodIntArrayIn() throws RemoteException { 618 int[] sendValue = {91, 54, 47, 10}; 619 binding.methodIntArrayIn(sendValue); 620 } 622 627 public void testMethodIntArrayInOut() throws RemoteException { 628 int[] sendValue = {90, 34, 45, 239, 45, 10}; 629 int[] expected = {12, 39, 50, 60, 28, 39}; 630 int[] actual = binding.methodIntArrayInOut(sendValue); 631 assertEquals("The expected and actual values did not match.", 632 expected[0], 633 actual[0]); 634 assertEquals("The expected and actual values did not match.", 635 expected[1], 636 actual[1]); 637 assertEquals("The expected and actual values did not match.", 638 expected[2], 639 actual[2]); 640 assertEquals("The expected and actual values did not match.", 641 expected[3], 642 actual[3]); 643 assertEquals("The expected and actual values did not match.", 644 expected[4], 645 actual[4]); 646 assertEquals("The expected and actual values did not match.", 647 expected[5], 648 actual[5]); 649 } 651 655 public void testMethodAllTypesIn() throws RemoteException { 656 byte[] sendByteArray = {(byte) 5, (byte) 10, (byte) 12}; 657 Byte [] sendWrapperByteArray = {new Byte ((byte) 9), new Byte ((byte) 7)}; 658 Calendar dateTime = Calendar.getInstance(); 659 TimeZone gmt = TimeZone.getTimeZone("GMT"); 660 dateTime.setTimeZone(gmt); 661 dateTime.setTime(new Date (1012937861986L)); 662 binding.methodAllTypesIn(new String ("Request methodAllTypesIn"), 663 new BigInteger ("545"), 664 new BigDecimal ("546.545"), 665 dateTime, 666 dateTime, 667 true, 668 (byte) 2, 669 (short) 14, 670 234, 671 10900L, 672 23098.23F, 673 2098098.01D, 674 sendByteArray, 675 new Boolean (false), 676 new Byte ((byte) 11), 677 new Short ((short) 45), 678 new Integer (101), 679 new Long (232309L), 680 new Float (67634.12F), 681 new Double (892387.232D), 682 sendWrapperByteArray); 683 } 685 689 public void testMethodByteArray() throws RemoteException { 690 byte[] expected = {(byte) 5, (byte) 4}; 691 byte[] sendByte = {(byte) 3, (byte) 9}; 692 byte[] actual = binding.methodByteArray(sendByte); 693 assertEquals("The expected and actual values did not match.", 694 expected[0], 695 actual[0]); 696 assertEquals("The expected and actual values did not match.", 697 expected[1], 698 actual[1]); 699 } 701 705 public void testMethodDateTime() throws RemoteException { 706 Calendar expected = Calendar.getInstance(); 707 TimeZone gmt = TimeZone.getTimeZone("GMT"); 708 expected.setTimeZone(gmt); 709 expected.setTime(new Date (1012937861800L)); 710 Calendar parameter = Calendar.getInstance(); 711 parameter.setTimeZone(gmt); 712 parameter.setTime(new Date (1012937861996L)); 713 Calendar actual = binding.methodDateTime(parameter); 714 assertEquals("The expected and actual values did not match.", 715 expected, 716 actual); 717 } 719 727 public void testMethodDate() throws RemoteException { 728 Calendar expected = Calendar.getInstance(); 729 TimeZone gmt = TimeZone.getTimeZone("GMT"); 730 expected.setTimeZone(gmt); 731 expected.setTime(new Date (1012937861800L)); 732 Calendar parameter = Calendar.getInstance(); 733 parameter.setTimeZone(gmt); 734 parameter.setTime(new Date (1012937861996L)); 735 Calendar actual = binding.methodDate(parameter); 736 assertEquals("The expected and actual values did not match.", 737 expected, 738 actual); 739 } 741 745 public void testMethodBigDecimal() throws RemoteException { 746 BigDecimal expected = new BigDecimal ("903483.304"); 747 BigDecimal actual = binding.methodBigDecimal(new BigDecimal ("3434.456")); 748 assertEquals("The expected and actual values did not match.", 749 expected, 750 actual); 751 } 753 757 public void testMethodBigInteger() throws RemoteException { 758 BigInteger expected = new BigInteger ("2323"); 759 BigInteger actual = binding.methodBigInteger(new BigInteger ("8789")); 760 assertEquals("The expected and actual values did not match.", 761 expected, 762 actual); 763 } 765 769 public void testMethodString() throws RemoteException { 770 String expected = "Response"; 771 String actual = binding.methodString(new String ("Request")); 772 assertEquals("The expected and actual values did not match.", 773 expected, 774 actual); 775 } 777 781 public void testMethodDouble() throws RemoteException { 782 double expected = 567.547D; 783 double actual = binding.methodDouble(87502.002D); 784 assertEquals("The expected and actual values did not match.", 785 expected, 786 actual, 787 DOUBLE_DELTA); 788 } 790 794 public void testMethodFloat() throws RemoteException { 795 float expected = 12325.545F; 796 float actual = binding.methodFloat(8787.25F); 797 assertEquals("The expected and actual values did not match.", 798 expected, 799 actual, 800 FLOAT_DELTA); 801 } 803 807 public void testMethodLong() throws RemoteException { 808 long expected = 787985L; 809 long actual = binding.methodLong(45425L); 810 assertEquals("The expected and actual values did not match.", 811 expected, 812 actual); 813 } 815 819 public void testMethodInt() throws RemoteException { 820 int expected = 10232; 821 int actual = binding.methodInt(1215); 822 assertEquals("The expected and actual values did not match.", 823 expected, 824 actual); 825 } 827 831 public void testMethodShort() throws RemoteException { 832 short expected = (short) 124; 833 short actual = binding.methodShort((short) 302); 834 assertEquals("The expected and actual values did not match.", 835 expected, 836 actual); 837 } 839 843 public void testMethodByte() throws RemoteException { 844 byte expected = (byte) 35; 845 byte actual = binding.methodByte((byte) 61); 846 assertEquals("The expected and actual values did not match.", 847 expected, 848 actual); 849 } 851 855 public void testMethodBoolean() throws RemoteException { 856 boolean expected = false; 857 boolean actual = binding.methodBoolean(true); 858 assertEquals("The expected and actual values did not match.", 859 expected, 860 actual); 861 } 863 864 868 public void testMethodCallOptions() throws RemoteException { 869 CallOptions[] callOptions = new CallOptions[1]; 870 callOptions[0] = new CallOptions(); 871 Calendar cal = Calendar.getInstance(); 872 TimeZone gmt = TimeZone.getTimeZone("GMT"); 873 cal.setTimeZone(gmt); 874 cal.setTime(new Date (1013459984577L)); 875 callOptions[0].setCallDate(cal); 876 877 CallOptions[] actual = binding.methodCallOptions(callOptions); 878 cal.setTime(new Date (1013459984507L)); 879 assertEquals("The expected and actual values did not match.", 880 cal, 881 actual[0].getCallDate()); 882 } 884 888 public void testMethodSoapFloat() throws RemoteException { 889 Float actual = binding.methodSoapFloat(new Float (23423.234F)); 890 assertEquals("The expected and actual values did not match.", 891 new Float (232.23F), 892 actual); 893 } 895 899 public void testMethodSoapDouble() throws RemoteException { 900 Double actual = binding.methodSoapDouble(new Double (123423.234D)); 901 assertEquals("The expected and actual values did not match.", 902 new Double (2232.23D), 903 actual); 904 } 906 910 public void testMethodSoapBoolean() throws RemoteException { 911 Boolean actual = binding.methodSoapBoolean(new Boolean (true)); 912 assertEquals("The expected and actual values did not match.", 913 new Boolean (false), 914 actual); 915 } 917 921 public void testMethodSoapByte() throws RemoteException { 922 Byte actual = binding.methodSoapByte(new Byte ((byte) 9)); 923 assertEquals("The expected and actual values did not match.", 924 new Byte ((byte) 10), 925 actual); 926 } 928 932 public void testMethodSoapShort() throws RemoteException { 933 Short actual = binding.methodSoapShort(new Short ((short) 32)); 934 assertEquals("The expected and actual values did not match.", 935 new Short ((short) 44), 936 actual); 937 } 939 943 public void testMethodSoapInt() throws RemoteException { 944 Integer actual = binding.methodSoapInt(new Integer (332)); 945 assertEquals("The expected and actual values did not match.", 946 new Integer (441), 947 actual); 948 } 950 954 public void testMethodSoapLong() throws RemoteException { 955 Long actual = binding.methodSoapLong(new Long (3321L)); 956 assertEquals("The expected and actual values did not match.", 957 new Long (4412L), 958 actual); 959 } 961 965 public void testInvalidTickerSymbol() throws RemoteException { 966 try { 967 binding.throwInvalidTickerException(); 968 fail("Should have received an InvalidTickerSymbol exception."); 969 } catch (InvalidTickerSymbol its) { 970 assertEquals("The expected and actual values did not match.", 972 "ABC", 973 its.getTickerSymbol()); 974 } 975 } 977 981 public void testInvalidTradeExchange() throws RemoteException { 982 try { 983 binding.throwInvalidTradeExchange(); 984 fail("TRY: Should have received an InvalidTradeExchange exception."); 985 } catch (InvalidTradeExchange ite) { 986 assertEquals("The expected and actual values did not match.", 988 "XYZ", 989 ite.getTradeExchange()); 990 } catch (InvalidTickerSymbol its) { 991 fail("ITS: Should have received an InvalidTradeExchange exception."); 992 } catch (InvalidCompanyId ici) { 993 fail("ICI: Should have received an InvalidTradeExchange exception."); 994 } 995 } 997 1000 public void testHolderTest() throws RemoteException { 1001 StringHolder sh = new StringHolder ("hi there"); 1002 BondInvestment bi = new BondInvestment(); 1003 BondInvestmentHolder bih = new BondInvestmentHolder(bi); 1004 binding.holderTest(sh, bih); 1005 } 1007} | Popular Tags |