1 package org.jacorb.test.orb; 2 3 22 23 import junit.framework.*; 24 import junit.extensions.*; 25 26 import org.jacorb.test.common.*; 27 import org.omg.CORBA.*; 28 import org.jacorb.test.*; 29 30 public class BasicTest extends ClientServerTestCase 31 { 32 private BasicServer server; 33 34 public BasicTest(String name, ClientServerSetup setup) 35 { 36 super(name, setup); 37 } 38 39 public void setUp() throws Exception 40 { 41 server = BasicServerHelper.narrow( setup.getServerObject() ); 42 } 43 44 public static Test suite() 45 { 46 TestSuite suite = new JacORBTestSuite("Basic client/server tests", 47 BasicTest.class); 48 ClientServerSetup setup = 49 new ClientServerSetup( suite, 50 "org.jacorb.test.orb.BasicServerImpl" ); 51 52 suite.addTest( new BasicTest( "test_ping", setup )); 53 54 suite.addTest( new BasicTest( "test_pass_in_short", setup ) ); 56 suite.addTest( new BasicTest( "test_pass_out_short", setup ) ); 57 suite.addTest( new BasicTest( "test_pass_inout_short", setup ) ); 58 suite.addTest( new BasicTest( "test_return_short", setup ) ); 59 suite.addTest( new BasicTest( "test_bounce_short", setup ) ); 60 suite.addTest( new BasicTest( "test_min_short", setup ) ); 61 suite.addTest( new BasicTest( "test_max_short", setup ) ); 62 suite.addTest( new BasicTest( "test_zero_short", setup ) ); 63 64 suite.addTest( new BasicTest( "test_pass_in_unsigned_short", setup ) ); 66 suite.addTest( new BasicTest( "test_pass_out_unsigned_short", setup ) ); 67 suite.addTest( new BasicTest( "test_pass_inout_unsigned_short", setup ) ); 68 suite.addTest( new BasicTest( "test_return_unsigned_short", setup ) ); 69 suite.addTest( new BasicTest( "test_bounce_unsigned_short", setup ) ); 70 suite.addTest( new BasicTest( "test_max_unsigned_short", setup ) ); 71 suite.addTest( new BasicTest( "test_zero_unsigned_short", setup ) ); 72 73 suite.addTest( new BasicTest( "test_pass_in_long", setup ) ); 75 suite.addTest( new BasicTest( "test_pass_out_long", setup ) ); 76 suite.addTest( new BasicTest( "test_pass_inout_long", setup ) ); 77 suite.addTest( new BasicTest( "test_return_long", setup ) ); 78 suite.addTest( new BasicTest( "test_bounce_long", setup ) ); 79 suite.addTest( new BasicTest( "test_min_long", setup ) ); 80 suite.addTest( new BasicTest( "test_max_long", setup ) ); 81 suite.addTest( new BasicTest( "test_zero_long", setup ) ); 82 83 suite.addTest( new BasicTest( "test_pass_in_unsigned_long", setup ) ); 85 suite.addTest( new BasicTest( "test_pass_out_unsigned_long", setup ) ); 86 suite.addTest( new BasicTest( "test_pass_inout_unsigned_long", setup ) ); 87 suite.addTest( new BasicTest( "test_return_unsigned_long", setup ) ); 88 suite.addTest( new BasicTest( "test_bounce_unsigned_long", setup ) ); 89 suite.addTest( new BasicTest( "test_max_unsigned_long", setup ) ); 90 suite.addTest( new BasicTest( "test_zero_unsigned_long", setup ) ); 91 92 suite.addTest( new BasicTest( "test_pass_in_long_long", setup ) ); 94 suite.addTest( new BasicTest( "test_pass_out_long_long", setup ) ); 95 suite.addTest( new BasicTest( "test_pass_inout_long_long", setup ) ); 96 suite.addTest( new BasicTest( "test_return_long_long", setup ) ); 97 suite.addTest( new BasicTest( "test_bounce_long_long", setup ) ); 98 suite.addTest( new BasicTest( "test_min_long_long", setup ) ); 99 suite.addTest( new BasicTest( "test_max_long_long", setup ) ); 100 suite.addTest( new BasicTest( "test_zero_long_long", setup ) ); 101 102 suite.addTest( new BasicTest( "test_pass_in_unsigned_long_long", setup ) ); 104 suite.addTest( new BasicTest( "test_pass_out_unsigned_long_long", setup ) ); 105 suite.addTest( new BasicTest( "test_pass_inout_unsigned_long_long", setup ) ); 106 suite.addTest( new BasicTest( "test_return_unsigned_long_long", setup ) ); 107 suite.addTest( new BasicTest( "test_bounce_unsigned_long_long", setup ) ); 108 suite.addTest( new BasicTest( "test_max_unsigned_long_long", setup ) ); 109 suite.addTest( new BasicTest( "test_zero_unsigned_long_long", setup ) ); 110 111 suite.addTest( new BasicTest( "test_pass_in_boolean", setup ) ); 113 suite.addTest( new BasicTest( "test_pass_out_boolean", setup ) ); 114 suite.addTest( new BasicTest( "test_pass_inout_boolean", setup ) ); 115 suite.addTest( new BasicTest( "test_return_boolean", setup ) ); 116 suite.addTest( new BasicTest( "test_bounce_boolean", setup ) ); 117 118 suite.addTest( new BasicTest( "test_pass_in_octet", setup ) ); 120 suite.addTest( new BasicTest( "test_pass_out_octet", setup ) ); 121 suite.addTest( new BasicTest( "test_pass_inout_octet", setup ) ); 122 suite.addTest( new BasicTest( "test_return_octet", setup ) ); 123 suite.addTest( new BasicTest( "test_bounce_octet", setup ) ); 124 125 suite.addTest( new BasicTest( "test_pass_in_float", setup ) ); 127 suite.addTest( new BasicTest( "test_pass_out_float", setup ) ); 128 suite.addTest( new BasicTest( "test_pass_inout_float", setup ) ); 129 suite.addTest( new BasicTest( "test_return_float", setup ) ); 130 suite.addTest( new BasicTest( "test_bounce_float", setup ) ); 131 132 suite.addTest( new BasicTest( "test_pass_in_double", setup ) ); 134 suite.addTest( new BasicTest( "test_pass_out_double", setup ) ); 135 suite.addTest( new BasicTest( "test_pass_inout_double", setup ) ); 136 suite.addTest( new BasicTest( "test_return_double", setup ) ); 137 suite.addTest( new BasicTest( "test_bounce_double", setup ) ); 138 139 return setup; 140 } 141 142 public void test_ping() 143 { 144 server.ping(); 145 } 146 147 149 public void test_pass_in_short() 150 { 151 server.pass_in_short( ( short ) 14 ); 152 } 153 154 public void test_pass_out_short() 155 { 156 ShortHolder x = new ShortHolder(); 157 server.pass_out_short( x ); 158 assertEquals( 82, x.value ); 159 } 160 161 public void test_pass_inout_short() 162 { 163 ShortHolder x = new ShortHolder( ( short ) -4 ); 164 server.pass_inout_short( x ); 165 assertEquals( ( short ) -3, x.value ); 166 } 167 168 public void test_return_short() 169 { 170 short result = server.return_short(); 171 assertEquals( ( short ) -4, result ); 172 } 173 174 public void test_bounce_short() 175 { 176 short result = server.bounce_short( ( short ) 14 ); 177 assertEquals( ( short ) 14, result ); 178 } 179 180 public void test_min_short() 181 { 182 short result = server.bounce_short( ( short ) 0x8000 ); 183 assertEquals( ( short ) 0x8000, result ); 184 } 185 186 public void test_max_short() 187 { 188 short result = server.bounce_short( ( short ) 0xffff ); 189 assertEquals( ( short ) 0xffff, result ); 190 } 191 192 public void test_zero_short() 193 { 194 short result = server.bounce_short( ( short ) 0 ); 195 assertEquals( ( short ) 0, result ); 196 } 197 198 200 public void test_pass_in_unsigned_short() 201 { 202 server.pass_in_unsigned_short( ( short ) 14 ); 203 } 204 205 public void test_pass_out_unsigned_short() 206 { 207 ShortHolder x = new ShortHolder(); 208 server.pass_out_unsigned_short( x ); 209 assertEquals( 79, x.value ); 210 } 211 212 public void test_pass_inout_unsigned_short() 213 { 214 ShortHolder x = new ShortHolder( ( short ) 88 ); 215 server.pass_inout_unsigned_short( x ); 216 assertEquals( 89, x.value ); 217 } 218 219 public void test_return_unsigned_short() 220 { 221 short result = server.return_unsigned_short(); 222 assertEquals( 87, result ); 223 } 224 225 public void test_bounce_unsigned_short() 226 { 227 short result = server.bounce_unsigned_short( ( short ) 14 ); 228 assertEquals( 14, result ); 229 } 230 231 public void test_max_unsigned_short() 232 { 233 short result = server.bounce_unsigned_short( ( short ) 0xffff ); 234 assertEquals( ( short ) 0xffff, result ); 235 } 236 237 public void test_zero_unsigned_short() 238 { 239 short result = server.bounce_unsigned_short( ( short ) 0 ); 240 assertEquals( ( short ) 0, result ); 241 } 242 243 245 public void test_pass_in_long() 246 { 247 server.pass_in_long( 14 ); 248 } 249 250 public void test_pass_out_long() 251 { 252 IntHolder x = new IntHolder(); 253 server.pass_out_long( x ); 254 assertEquals( 83, x.value ); 255 } 256 257 public void test_pass_inout_long() 258 { 259 IntHolder x = new IntHolder( -4 ); 260 server.pass_inout_long( x ); 261 assertEquals( -3, x.value ); 262 } 263 264 public void test_return_long() 265 { 266 int result = server.return_long(); 267 assertEquals( -17, result ); 268 } 269 270 public void test_bounce_long() 271 { 272 int result = server.bounce_long( 14 ); 273 assertEquals( 14, result ); 274 } 275 276 public void test_min_long() 277 { 278 int result = server.bounce_long( 0x8000000 ); 279 assertEquals( 0x8000000, result ); 280 } 281 282 public void test_max_long() 283 { 284 int result = server.bounce_long( 0xffffffff ); 285 assertEquals( 0xffffffff, result ); 286 } 287 288 public void test_zero_long() 289 { 290 int result = server.bounce_long( 0 ); 291 assertEquals( 0, result ); 292 } 293 294 296 public void test_pass_in_unsigned_long() 297 { 298 server.pass_in_unsigned_long( 76542 ); 299 } 300 301 public void test_pass_out_unsigned_long() 302 { 303 IntHolder x = new IntHolder(); 304 server.pass_out_unsigned_long( x ); 305 assertEquals( 80, x.value ); 306 } 307 308 public void test_pass_inout_unsigned_long() 309 { 310 IntHolder x = new IntHolder( 5 ); 311 server.pass_inout_unsigned_long( x ); 312 assertEquals( 6, x.value ); 313 } 314 315 public void test_return_unsigned_long() 316 { 317 int result = server.return_unsigned_long(); 318 assertEquals( 43, result ); 319 } 320 321 public void test_bounce_unsigned_long() 322 { 323 int result = server.bounce_unsigned_long( 123456 ); 324 assertEquals( 123456, result ); 325 } 326 327 public void test_max_unsigned_long() 328 { 329 int result = server.bounce_unsigned_long( 0xffffffff ); 330 assertEquals( 0xffffffff, result ); 331 } 332 333 public void test_zero_unsigned_long() 334 { 335 int result = server.bounce_unsigned_long( 0 ); 336 assertEquals( 0, result ); 337 } 338 339 341 public void test_pass_in_long_long() 342 { 343 server.pass_in_long_long( 14L ); 344 } 345 346 public void test_pass_out_long_long() 347 { 348 LongHolder x = new LongHolder(); 349 server.pass_out_long_long( x ); 350 assertEquals( 84L, x.value ); 351 } 352 353 public void test_pass_inout_long_long() 354 { 355 LongHolder x = new LongHolder( -12345678889L ); 356 server.pass_inout_long_long( x ); 357 assertEquals( -12345678888L, x.value ); 358 } 359 360 public void test_return_long_long() 361 { 362 long result = server.return_long_long(); 363 assertEquals( 0xffeeddccbbaa0099L, result ); 364 } 365 366 public void test_bounce_long_long() 367 { 368 long result = server.bounce_long_long( 14 ); 369 assertEquals( 14L, result ); 370 } 371 372 public void test_min_long_long() 373 { 374 long result = server.bounce_long_long( 0x8000000000000000L ); 375 assertEquals( 0x8000000000000000L, result ); 376 } 377 378 public void test_max_long_long() 379 { 380 long result = server.bounce_long_long( 0xffffffffffffffffL ); 381 assertEquals( 0xffffffffffffffffL, result ); 382 } 383 384 public void test_zero_long_long() 385 { 386 long result = server.bounce_long_long( 0L ); 387 assertEquals( 0L, result ); 388 } 389 390 392 public void test_pass_in_unsigned_long_long() 393 { 394 server.pass_in_unsigned_long_long( 14L ); 395 } 396 397 public void test_pass_out_unsigned_long_long() 398 { 399 LongHolder x = new LongHolder(); 400 server.pass_out_unsigned_long_long( x ); 401 assertEquals( 81L, x.value ); 402 } 403 404 public void test_pass_inout_unsigned_long_long() 405 { 406 LongHolder x = new LongHolder( 9876543210L ); 407 server.pass_inout_unsigned_long_long( x ); 408 assertEquals( 9876543211L, x.value ); 409 } 410 411 public void test_return_unsigned_long_long() 412 { 413 long result = server.return_unsigned_long_long(); 414 assertEquals( 0xffeeddccbbaa0088L, result ); 415 } 416 417 public void test_bounce_unsigned_long_long() 418 { 419 long result = server.bounce_unsigned_long_long( 14L ); 420 assertEquals( 14L, result ); 421 } 422 423 public void test_max_unsigned_long_long() 424 { 425 long result = server.bounce_unsigned_long_long( 0xffffffffffffffffL ); 426 assertEquals( 0xffffffffffffffffL, result ); 427 } 428 429 public void test_zero_unsigned_long_long() 430 { 431 long result = server.bounce_unsigned_long_long( 0L ); 432 assertEquals( 0L, result ); 433 } 434 435 437 public void test_pass_in_boolean() 438 { 439 server.pass_in_boolean ( false ); 440 } 441 442 public void test_pass_out_boolean() 443 { 444 BooleanHolder x = new BooleanHolder( false ); 445 server.pass_out_boolean( x ); 446 assertEquals( true, x.value ); 447 } 448 449 public void test_pass_inout_boolean() 450 { 451 BooleanHolder x = new BooleanHolder( true ); 452 server.pass_inout_boolean( x ); 453 assertEquals( false, x.value ); 454 } 455 456 public void test_return_boolean() 457 { 458 boolean result = server.return_boolean(); 459 assertEquals( true, result ); 460 } 461 462 public void test_bounce_boolean() 463 { 464 boolean result = server.bounce_boolean( false ); 465 assertEquals( false, result ); 466 result = server.bounce_boolean( true ); 467 assertEquals( true, result ); 468 } 469 470 472 public void test_pass_in_octet() 473 { 474 server.pass_in_octet ( (byte)127 ); 475 } 476 477 public void test_pass_out_octet() 478 { 479 ByteHolder x = new ByteHolder( (byte) -1 ); 480 server.pass_out_octet( x ); 481 assertEquals( (byte)23, x.value ); 482 } 483 484 public void test_pass_inout_octet() 485 { 486 ByteHolder x = new ByteHolder( (byte) -1 ); 487 server.pass_inout_octet( x ); 488 assertEquals( (byte)0, x.value ); 489 } 490 491 public void test_return_octet() 492 { 493 byte result = server.return_octet(); 494 assertEquals( (byte)0xf0, result ); 495 } 496 497 public void test_bounce_octet() 498 { 499 byte result = server.bounce_octet( (byte)0xff ); 500 assertEquals( (byte)0xff, result ); 501 } 502 503 505 public void test_pass_in_float() 506 { 507 server.pass_in_float ( 1.234F ); 508 } 509 510 public void test_pass_out_float() 511 { 512 FloatHolder x = new FloatHolder( 1.0F ); 513 server.pass_out_float( x ); 514 assertEquals( 0.005F, x.value, 0 ); 515 } 516 517 public void test_pass_inout_float() 518 { 519 FloatHolder x = new FloatHolder( -23.4F ); 520 server.pass_inout_float( x ); 521 assertEquals( -22.4F, x.value, 0 ); 522 } 523 524 public void test_return_float() 525 { 526 float result = server.return_float(); 527 assertEquals( 1.5E-1F, result, 0 ); 528 } 529 530 public void test_bounce_float() 531 { 532 float result = server.bounce_float( 0.0F ); 533 assertEquals( 0.0F, result, 0 ); 534 result = server.bounce_float( -1234.56F ); 535 assertEquals( -1234.56F, result, 0 ); 536 result = server.bounce_float( Float.MIN_VALUE ); 537 assertEquals( Float.MIN_VALUE, result, 0 ); 538 result = server.bounce_float( Float.MAX_VALUE ); 539 assertEquals( Float.MAX_VALUE, result, 0 ); 540 result = server.bounce_float( Float.NaN ); 541 assertTrue( Float.isNaN( result ) ); 542 result = server.bounce_float( Float.NEGATIVE_INFINITY ); 543 assertEquals( Float.NEGATIVE_INFINITY, result, 0 ); 544 result = server.bounce_float( Float.POSITIVE_INFINITY ); 545 assertEquals( Float.POSITIVE_INFINITY, result, 0 ); 546 } 547 548 550 public void test_pass_in_double() 551 { 552 server.pass_in_double ( 1.234 ); 553 } 554 555 public void test_pass_out_double() 556 { 557 DoubleHolder x = new DoubleHolder( 1.0 ); 558 server.pass_out_double( x ); 559 assertEquals( 1234E12, x.value, 0 ); 560 } 561 562 public void test_pass_inout_double() 563 { 564 DoubleHolder x = new DoubleHolder( -23.4 ); 565 server.pass_inout_double( x ); 566 assertEquals( -22.4, x.value, 0 ); 567 } 568 569 public void test_return_double() 570 { 571 double result = server.return_double(); 572 assertEquals( 1E-100, result, 0 ); 573 } 574 575 public void test_bounce_double() 576 { 577 double result = server.bounce_double( 0.0 ); 578 assertEquals( 0.0F, result, 0 ); 579 result = server.bounce_double( -1234.56789 ); 580 assertEquals( -1234.56789, result, 0 ); 581 result = server.bounce_double( Double.MIN_VALUE ); 582 assertEquals( Double.MIN_VALUE, result, 0 ); 583 result = server.bounce_double( Double.MAX_VALUE ); 584 assertEquals( Double.MAX_VALUE, result, 0 ); 585 result = server.bounce_double( Double.NaN ); 586 assertTrue( Double.isNaN( result ) ); 587 result = server.bounce_double( Double.NEGATIVE_INFINITY ); 588 assertEquals( Double.NEGATIVE_INFINITY, result, 0 ); 589 result = server.bounce_double( Double.POSITIVE_INFINITY ); 590 assertEquals( Double.POSITIVE_INFINITY, result, 0 ); 591 } 592 593 } 594 | Popular Tags |