1 23 24 package org.objectweb.jorm.runtime.basictype; 25 26 import org.objectweb.jorm.runtime.TestRuntimeHelper; 27 import org.objectweb.jorm.type.api.PTypeSpace; 28 import org.objectweb.jorm.api.PClassMapping; 29 import org.objectweb.jorm.api.PException; 30 import org.objectweb.jorm.facility.naming.basidir.BasidBinder; 31 import org.objectweb.jorm.naming.api.PBinder; 32 33 import java.util.Date ; 34 import java.math.BigDecimal ; 35 import java.math.BigInteger ; 36 37 40 public class TestBasicType extends TestRuntimeHelper { 41 private final static String LOGGER_NAME 42 = "test.org.objectweb.jorm.basictype"; 43 44 public TestBasicType(String name) throws Exception { 45 super(name); 46 } 47 48 protected String getLoggerName() { 49 return LOGGER_NAME; 50 } 51 52 protected PBinder getBinder(String className) throws Exception { 53 try { 54 return new BasidBinder(mapper, 55 "org.objectweb.jorm.runtime.basictype.TestBasicType", 56 PClassMapping.CLEANUP_REMOVEALL); 57 } catch (PException e) { 58 Exception current = e; 59 while (current instanceof PException 60 && ((PException) current).getNestedException() != null) { 61 current = ((PException) current).getNestedException(); 62 } 63 throw current; 64 } 65 } 66 67 69 private final static String CNBOOLEAN = "org.objectweb.jorm.pobject.basictype.Boolean"; 71 72 public void testBooleanTrue() throws Exception { 73 changeLogger(LOGGER_NAME + ".boolean"); 74 BasicTypeAccessor acc1 = new BasicTypeAccessor(true); 75 BasicTypeAccessor acc2 = new BasicTypeAccessor(false); 76 if (performIO(CNBOOLEAN, acc1, acc2)) { 77 assertEquals("Cannot read written boolean value", 78 true, acc2.paGetBooleanValue()); 79 } 80 } 81 82 public void testBooleanFalse() throws Exception { 83 changeLogger(LOGGER_NAME + ".boolean"); 84 BasicTypeAccessor acc1 = new BasicTypeAccessor(false); 85 BasicTypeAccessor acc2 = new BasicTypeAccessor(true); 86 if (performIO(CNBOOLEAN, acc1, acc2)) { 87 assertEquals("Cannot read written boolean value", 88 false, acc2.paGetBooleanValue()); 89 } 90 } 91 92 public void testBooleanGen() throws Exception { 93 changeLogger(LOGGER_NAME + ".boolean"); 94 GenericAccessor acc1 = new GenericAccessor( 95 PTypeSpace.BOOLEAN, "booleanValue", Boolean.TRUE); 96 GenericAccessor acc2 = new GenericAccessor( 97 PTypeSpace.BOOLEAN, "booleanValue"); 98 if (performIO(CNBOOLEAN, acc1, acc2)) { 99 assertEquals("Cannot read written boolean value", 100 true, acc2.paGetBooleanField("booleanValue")); 101 } 102 } 103 104 private final static String CNOBOOLEAN = "org.objectweb.jorm.pobject.basictype.Oboolean"; 106 107 public void testObooleanNull() throws Exception { 108 changeLogger(LOGGER_NAME + ".boolean"); 109 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 110 BasicTypeAccessor acc2 = new BasicTypeAccessor(new Boolean (false)); 111 if (performIO(CNOBOOLEAN, acc1, acc2)) { 112 assertEquals("Cannot read written boolean value", 113 null, acc2.paGetObooleanValue()); 114 } 115 } 116 117 public void testObooleanTrue() throws Exception { 118 changeLogger(LOGGER_NAME + ".boolean"); 119 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Boolean (true)); 120 BasicTypeAccessor acc2 = new BasicTypeAccessor(new Boolean (false)); 121 if (performIO(CNOBOOLEAN, acc1, acc2)) { 122 assertEquals("Cannot read written boolean value", 123 true, acc2.paGetObooleanValue().booleanValue()); 124 } 125 } 126 127 public void testObooleanFalse() throws Exception { 128 changeLogger(LOGGER_NAME + ".boolean"); 129 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Boolean (false)); 130 BasicTypeAccessor acc2 = new BasicTypeAccessor(new Boolean (true)); 131 if (performIO(CNOBOOLEAN, acc1, acc2)) { 132 assertEquals("Cannot read written boolean value", 133 false, acc2.paGetObooleanValue().booleanValue()); 134 } 135 } 136 137 public void test0booleanGen() throws Exception { 138 changeLogger(LOGGER_NAME + ".boolean"); 139 GenericAccessor acc1 = new GenericAccessor( 140 PTypeSpace.OBJBOOLEAN, "obooleanValue", Boolean.TRUE); 141 GenericAccessor acc2 = new GenericAccessor( 142 PTypeSpace.OBJBOOLEAN, "obooleanValue"); 143 if (performIO(CNOBOOLEAN, acc1, acc2)) { 144 assertEquals("Cannot read written boolean value", 145 Boolean.TRUE, acc2.paGetObooleanField("obooleanValue")); 146 } 147 } 148 149 private final static String CNBYTE = "org.objectweb.jorm.pobject.basictype.Byte"; 151 152 public void testByte0() throws Exception { 153 changeLogger(LOGGER_NAME + ".byte"); 154 BasicTypeAccessor acc1 = new BasicTypeAccessor((byte) 0); 155 BasicTypeAccessor acc2 = new BasicTypeAccessor((byte) -1); 156 if (performIO(CNBYTE, acc1, acc2)) { 157 assertEquals("Cannot read written byte value", 158 (byte) 0, acc2.paGetByteValue()); 159 } 160 } 161 162 public void testByteMin() throws Exception { 163 changeLogger(LOGGER_NAME + ".byte"); 164 BasicTypeAccessor acc1 = new BasicTypeAccessor(Byte.MIN_VALUE); 165 BasicTypeAccessor acc2 = new BasicTypeAccessor((byte) 0); 166 if (performIO(CNBYTE, acc1, acc2)) { 167 assertEquals("Cannot read written byte value", 168 Byte.MIN_VALUE, acc2.paGetByteValue()); 169 } 170 } 171 172 public void testByteMax() throws Exception { 173 changeLogger(LOGGER_NAME + ".byte"); 174 BasicTypeAccessor acc1 = new BasicTypeAccessor(Byte.MAX_VALUE); 175 BasicTypeAccessor acc2 = new BasicTypeAccessor((byte) 0); 176 if (performIO(CNBYTE, acc1, acc2)) { 177 assertEquals("Cannot read written byte value", 178 Byte.MAX_VALUE, acc2.paGetByteValue()); 179 } 180 } 181 public void testByteGen() throws Exception { 182 changeLogger(LOGGER_NAME + ".byte"); 183 GenericAccessor acc1 = new GenericAccessor( 184 PTypeSpace.BYTE, "byteValue", new Byte ((byte)34)); 185 GenericAccessor acc2 = new GenericAccessor( 186 PTypeSpace.BYTE, "byteValue"); 187 if (performIO(CNBYTE, acc1, acc2)) { 188 assertEquals("Cannot read written byte value", 189 (byte)34, acc2.paGetByteField("byteValue")); 190 } 191 } 192 193 195 private final static String CNOBYTE = "org.objectweb.jorm.pobject.basictype.Obyte"; 197 198 public void testObyteNull() throws Exception { 199 changeLogger(LOGGER_NAME + ".byte"); 200 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 201 BasicTypeAccessor acc2 = new BasicTypeAccessor(new Byte ((byte) -1)); 202 if (performIO(CNOBYTE, acc1, acc2)) { 203 assertEquals("Cannot read written Byte value", 204 null, acc2.paGetObyteValue()); 205 } 206 } 207 208 public void testObyte0() throws Exception { 209 changeLogger(LOGGER_NAME + ".byte"); 210 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Byte ((byte) 0)); 211 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 212 if (performIO(CNOBYTE, acc1, acc2)) { 213 assertEquals("Cannot read written Byte value", 214 (byte) 0, acc2.paGetObyteValue().byteValue()); 215 } 216 } 217 218 public void testObyteMin() throws Exception { 219 changeLogger(LOGGER_NAME + ".byte"); 220 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Byte (Byte.MIN_VALUE)); 221 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 222 if (performIO(CNOBYTE, acc1, acc2)) { 223 assertEquals("Cannot read written Byte value", 224 Byte.MIN_VALUE, acc2.paGetObyteValue().byteValue()); 225 } 226 } 227 228 public void testObyteMax() throws Exception { 229 changeLogger(LOGGER_NAME + ".byte"); 230 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Byte (Byte.MAX_VALUE)); 231 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 232 if (performIO(CNOBYTE, acc1, acc2)) { 233 assertEquals("Cannot read written Byte value", 234 Byte.MAX_VALUE, acc2.paGetObyteValue().byteValue()); 235 } 236 } 237 238 public void testObyteGen() throws Exception { 239 changeLogger(LOGGER_NAME + ".byte"); 240 GenericAccessor acc1 = new GenericAccessor( 241 PTypeSpace.OBJBYTE, "obyteValue", new Byte ((byte)34)); 242 GenericAccessor acc2 = new GenericAccessor( 243 PTypeSpace.OBJBYTE, "obyteValue"); 244 if (performIO(CNOBYTE, acc1, acc2)) { 245 assertEquals("Cannot read written byte value", 246 new Byte ((byte)34), acc2.paGetObyteField("obyteValue")); 247 } 248 } 249 250 private final static String CNCHAR = "org.objectweb.jorm.pobject.basictype.Char"; 252 253 public void testCharSP() throws Exception { 254 changeLogger(LOGGER_NAME + ".char"); 255 BasicTypeAccessor acc1 = new BasicTypeAccessor(' '); 256 BasicTypeAccessor acc2 = new BasicTypeAccessor('.'); 257 if (performIO(CNCHAR, acc1, acc2)) { 258 assertEquals("Cannot read written char value", 259 ' ', acc2.paGetCharValue()); 260 } 261 } 262 263 public void testCharDOT() throws Exception { 264 changeLogger(LOGGER_NAME + ".char"); 265 BasicTypeAccessor acc1 = new BasicTypeAccessor('.'); 266 BasicTypeAccessor acc2 = new BasicTypeAccessor(' '); 267 if (performIO(CNCHAR, acc1, acc2)) { 268 assertEquals("Cannot read written char value", 269 '.', acc2.paGetCharValue()); 270 } 271 } 272 public void testCharGen() throws Exception { 273 changeLogger(LOGGER_NAME + ".char"); 274 GenericAccessor acc1 = new GenericAccessor( 275 PTypeSpace.CHAR, "charValue", new Character ('a')); 276 GenericAccessor acc2 = new GenericAccessor( 277 PTypeSpace.CHAR, "charValue"); 278 if (performIO(CNCHAR, acc1, acc2)) { 279 assertEquals("Cannot read written char value", 280 'a', acc2.paGetCharField("charValue")); 281 } 282 } 283 284 private final static String CNOCHAR = "org.objectweb.jorm.pobject.basictype.Ochar"; 286 287 public void testOcharNull() throws Exception { 288 changeLogger(LOGGER_NAME + ".char"); 289 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 290 BasicTypeAccessor acc2 = new BasicTypeAccessor(new Character (' ')); 291 if (performIO(CNOCHAR, acc1, acc2)) { 292 assertEquals("Cannot read written Char value", 293 null, acc2.paGetOcharValue()); 294 } 295 } 296 297 public void testOcharSP() throws Exception { 298 changeLogger(LOGGER_NAME + ".char"); 299 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Character (' ')); 300 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 301 if (performIO(CNOCHAR, acc1, acc2)) { 302 assertEquals("Cannot read written Char value", 303 ' ', acc2.paGetOcharValue().charValue()); 304 } 305 } 306 307 public void testOcharDOT() throws Exception { 308 changeLogger(LOGGER_NAME + ".char"); 309 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Character ('.')); 310 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 311 if (performIO(CNOCHAR, acc1, acc2)) { 312 assertEquals("Cannot read written Char value", 313 '.', acc2.paGetOcharValue().charValue()); 314 } 315 } 316 public void testOcharGen() throws Exception { 317 changeLogger(LOGGER_NAME + ".char"); 318 GenericAccessor acc1 = new GenericAccessor( 319 PTypeSpace.OBJCHAR, "ocharValue", new Character ('a')); 320 GenericAccessor acc2 = new GenericAccessor( 321 PTypeSpace.OBJCHAR, "ocharValue"); 322 if (performIO(CNOCHAR, acc1, acc2)) { 323 assertEquals("Cannot read written char value", 324 new Character ('a'), acc2.paGetOcharField("ocharValue")); 325 } 326 } 327 328 private final static String CNSHORT = "org.objectweb.jorm.pobject.basictype.Short"; 330 331 public void testShort0() throws Exception { 332 changeLogger(LOGGER_NAME + ".short"); 333 BasicTypeAccessor acc1 = new BasicTypeAccessor((short) 0); 334 BasicTypeAccessor acc2 = new BasicTypeAccessor((short) -1); 335 if (performIO(CNSHORT, acc1, acc2)) { 336 assertEquals("Cannot read written short value", 337 (short) 0, acc2.paGetShortValue()); 338 } 339 } 340 341 public void testShortMin() throws Exception { 342 changeLogger(LOGGER_NAME + ".short"); 343 BasicTypeAccessor acc1 = new BasicTypeAccessor(Short.MIN_VALUE); 344 BasicTypeAccessor acc2 = new BasicTypeAccessor((short) 0); 345 if (performIO(CNSHORT, acc1, acc2)) { 346 assertEquals("Cannot read written short value", 347 Short.MIN_VALUE, acc2.paGetShortValue()); 348 } 349 } 350 351 public void testShortMax() throws Exception { 352 changeLogger(LOGGER_NAME + ".short"); 353 BasicTypeAccessor acc1 = new BasicTypeAccessor(Short.MAX_VALUE); 354 BasicTypeAccessor acc2 = new BasicTypeAccessor((short) 0); 355 if (performIO(CNSHORT, acc1, acc2)) { 356 assertEquals("Cannot read written short value", 357 Short.MAX_VALUE, acc2.paGetShortValue()); 358 } 359 } 360 public void testShortGen() throws Exception { 361 changeLogger(LOGGER_NAME + ".short"); 362 GenericAccessor acc1 = new GenericAccessor( 363 PTypeSpace.SHORT, "shortValue", new Short ((short) 2)); 364 GenericAccessor acc2 = new GenericAccessor( 365 PTypeSpace.SHORT, "shortValue"); 366 if (performIO(CNSHORT, acc1, acc2)) { 367 assertEquals("Cannot read written short value", 368 (short) 2, acc2.paGetShortField("shortValue")); 369 } 370 } 371 372 private final static String CNOSHORT = "org.objectweb.jorm.pobject.basictype.Oshort"; 374 375 public void testOshortNull() throws Exception { 376 changeLogger(LOGGER_NAME + ".short"); 377 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 378 BasicTypeAccessor acc2 = new BasicTypeAccessor(new Short ((short) 0)); 379 if (performIO(CNOSHORT, acc1, acc2)) { 380 assertEquals("Cannot read written short value", 381 null, acc2.paGetOshortValue()); 382 } 383 } 384 385 public void testOshort0() throws Exception { 386 changeLogger(LOGGER_NAME + ".short"); 387 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Short ((short) 0)); 388 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 389 if (performIO(CNOSHORT, acc1, acc2)) { 390 assertEquals("Cannot read written short value", 391 (short) 0, acc2.paGetOshortValue().shortValue()); 392 } 393 } 394 395 public void testOshortMin() throws Exception { 396 changeLogger(LOGGER_NAME + ".short"); 397 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Short (Short.MIN_VALUE)); 398 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 399 if (performIO(CNOSHORT, acc1, acc2)) { 400 assertEquals("Cannot read written short value", 401 Short.MIN_VALUE, acc2.paGetOshortValue().shortValue()); 402 } 403 } 404 405 public void testOshortMax() throws Exception { 406 changeLogger(LOGGER_NAME + ".short"); 407 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Short (Short.MAX_VALUE)); 408 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 409 if (performIO(CNOSHORT, acc1, acc2)) { 410 assertEquals("Cannot read written short value", 411 Short.MAX_VALUE, acc2.paGetOshortValue().shortValue()); 412 } 413 } 414 public void testOshortGen() throws Exception { 415 changeLogger(LOGGER_NAME + ".short"); 416 GenericAccessor acc1 = new GenericAccessor( 417 PTypeSpace.OBJSHORT, "oshortValue", new Short ((short) 2)); 418 GenericAccessor acc2 = new GenericAccessor( 419 PTypeSpace.OBJSHORT, "oshortValue"); 420 if (performIO(CNOSHORT, acc1, acc2)) { 421 assertEquals("Cannot read written short value", 422 new Short ((short) 2), acc2.paGetOshortField("oshortValue")); 423 } 424 } 425 426 private final static String CNINT = "org.objectweb.jorm.pobject.basictype.Int"; 428 429 public void testInt0() throws Exception { 430 changeLogger(LOGGER_NAME + ".int"); 431 BasicTypeAccessor acc1 = new BasicTypeAccessor(0); 432 BasicTypeAccessor acc2 = new BasicTypeAccessor(-1); 433 if (performIO(CNINT, acc1, acc2)) { 434 assertEquals("Cannot read written int value", 435 0, acc2.paGetIntValue()); 436 } 437 } 438 439 public void testIntMin() throws Exception { 440 changeLogger(LOGGER_NAME + ".int"); 441 BasicTypeAccessor acc1 = new BasicTypeAccessor(Integer.MIN_VALUE); 442 BasicTypeAccessor acc2 = new BasicTypeAccessor(0); 443 if (performIO(CNINT, acc1, acc2)) { 444 assertEquals("Cannot read written int value", 445 Integer.MIN_VALUE, acc2.paGetIntValue()); 446 } 447 } 448 449 public void testIntMax() throws Exception { 450 changeLogger(LOGGER_NAME + ".int"); 451 BasicTypeAccessor acc1 = new BasicTypeAccessor(Integer.MAX_VALUE); 452 BasicTypeAccessor acc2 = new BasicTypeAccessor(0); 453 if (performIO(CNINT, acc1, acc2)) { 454 assertEquals("Cannot read written int value", 455 Integer.MAX_VALUE, acc2.paGetIntValue()); 456 } 457 } 458 public void testIntGen() throws Exception { 459 changeLogger(LOGGER_NAME + ".int"); 460 GenericAccessor acc1 = new GenericAccessor( 461 PTypeSpace.INT, "intValue", new Integer (45678)); 462 GenericAccessor acc2 = new GenericAccessor( 463 PTypeSpace.INT, "intValue"); 464 if (performIO(CNINT, acc1, acc2)) { 465 assertEquals("Cannot read written int value", 466 45678, acc2.paGetIntField("intValue")); 467 } 468 } 469 470 private final static String CNOINT = "org.objectweb.jorm.pobject.basictype.Oint"; 472 473 public void testOintNull() throws Exception { 474 changeLogger(LOGGER_NAME + ".int"); 475 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 476 BasicTypeAccessor acc2 = new BasicTypeAccessor(new Integer (0)); 477 if (performIO(CNOINT, acc1, acc2)) { 478 assertEquals("Cannot read written int value", 479 null, acc2.paGetOintValue()); 480 } 481 } 482 483 public void testOint0() throws Exception { 484 changeLogger(LOGGER_NAME + ".int"); 485 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Integer (0)); 486 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 487 if (performIO(CNOINT, acc1, acc2)) { 488 assertEquals("Cannot read written int value", 489 0, acc2.paGetOintValue().intValue()); 490 } 491 } 492 493 public void testOintMin() throws Exception { 494 changeLogger(LOGGER_NAME + ".int"); 495 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Integer (Integer.MIN_VALUE)); 496 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 497 if (performIO(CNOINT, acc1, acc2)) { 498 assertEquals("Cannot read written int value", 499 Integer.MIN_VALUE, acc2.paGetOintValue().intValue()); 500 } 501 } 502 503 public void testOintMax() throws Exception { 504 changeLogger(LOGGER_NAME + ".int"); 505 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Integer (Integer.MAX_VALUE)); 506 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 507 if (performIO(CNOINT, acc1, acc2)) { 508 assertEquals("Cannot read written int value", 509 Integer.MAX_VALUE, acc2.paGetOintValue().intValue()); 510 } 511 } 512 public void testOintGen() throws Exception { 513 changeLogger(LOGGER_NAME + ".int"); 514 GenericAccessor acc1 = new GenericAccessor( 515 PTypeSpace.OBJINT, "ointValue", new Integer (45678)); 516 GenericAccessor acc2 = new GenericAccessor( 517 PTypeSpace.OBJINT, "ointValue"); 518 if (performIO(CNOINT, acc1, acc2)) { 519 assertEquals("Cannot read written oint value", 520 new Integer (45678), acc2.paGetOintField("ointValue")); 521 } 522 } 523 524 525 private final static String CNLONG = "org.objectweb.jorm.pobject.basictype.Long"; 527 528 public void testLong0() throws Exception { 529 changeLogger(LOGGER_NAME + ".long"); 530 BasicTypeAccessor acc1 = new BasicTypeAccessor((long) 0); 531 BasicTypeAccessor acc2 = new BasicTypeAccessor((long) -1); 532 if (performIO(CNLONG, acc1, acc2)) { 533 assertEquals("Cannot read written long value", 534 (long) 0, acc2.paGetLongValue()); 535 } 536 } 537 538 public void testLongMin() throws Exception { 539 changeLogger(LOGGER_NAME + ".long"); 540 BasicTypeAccessor acc1 = new BasicTypeAccessor(Long.MIN_VALUE); 541 BasicTypeAccessor acc2 = new BasicTypeAccessor((long) 0); 542 if (performIO(CNLONG, acc1, acc2)) { 543 assertEquals("Cannot read written long value", 544 Long.MIN_VALUE, acc2.paGetLongValue()); 545 } 546 } 547 548 public void testLongMax() throws Exception { 549 changeLogger(LOGGER_NAME + ".long"); 550 BasicTypeAccessor acc1 = new BasicTypeAccessor(Long.MAX_VALUE); 551 BasicTypeAccessor acc2 = new BasicTypeAccessor((long) 0); 552 if (performIO(CNLONG, acc1, acc2)) { 553 assertEquals("Cannot read written long value", 554 Long.MAX_VALUE, acc2.paGetLongValue()); 555 } 556 } 557 public void testLongGen() throws Exception { 558 changeLogger(LOGGER_NAME + ".long"); 559 GenericAccessor acc1 = new GenericAccessor( 560 PTypeSpace.LONG, "longValue", new Long (100000000000L)); 561 GenericAccessor acc2 = new GenericAccessor( 562 PTypeSpace.LONG, "longValue"); 563 if (performIO(CNLONG, acc1, acc2)) { 564 assertEquals("Cannot read written long value", 565 100000000000L, acc2.paGetLongField("longValue")); 566 } 567 } 568 569 570 private final static String CNOLONG = "org.objectweb.jorm.pobject.basictype.Olong"; 572 573 public void testOlongNull() throws Exception { 574 changeLogger(LOGGER_NAME + ".long"); 575 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 576 BasicTypeAccessor acc2 = new BasicTypeAccessor(new Long (0)); 577 if (performIO(CNOLONG, acc1, acc2)) { 578 assertEquals("Cannot read written long value", 579 null, acc2.paGetOlongValue()); 580 } 581 } 582 583 public void testOlong0() throws Exception { 584 changeLogger(LOGGER_NAME + ".long"); 585 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Long (0)); 586 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 587 if (performIO(CNOLONG, acc1, acc2)) { 588 assertEquals("Cannot read written long value", 589 (long) 0, acc2.paGetOlongValue().longValue()); 590 } 591 } 592 593 public void testOlongMin() throws Exception { 594 changeLogger(LOGGER_NAME + ".long"); 595 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Long (Long.MIN_VALUE)); 596 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 597 if (performIO(CNOLONG, acc1, acc2)) { 598 assertEquals("Cannot read written long value", 599 Long.MIN_VALUE, acc2.paGetOlongValue().longValue()); 600 } 601 } 602 603 public void testOlongMax() throws Exception { 604 changeLogger(LOGGER_NAME + ".long"); 605 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Long (Long.MAX_VALUE)); 606 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 607 if (performIO(CNOLONG, acc1, acc2)) { 608 assertEquals("Cannot read written long value", 609 Long.MAX_VALUE, acc2.paGetOlongValue().longValue()); 610 } 611 } 612 public void testOlongGen() throws Exception { 613 changeLogger(LOGGER_NAME + ".long"); 614 GenericAccessor acc1 = new GenericAccessor( 615 PTypeSpace.OBJLONG, "olongValue", new Long (100000000000L)); 616 GenericAccessor acc2 = new GenericAccessor( 617 PTypeSpace.OBJLONG, "olongValue"); 618 if (performIO(CNOLONG, acc1, acc2)) { 619 assertEquals("Cannot read written long value", 620 new Long (100000000000L), acc2.paGetOlongField("olongValue")); 621 } 622 } 623 624 private final static String CNFLOAT = "org.objectweb.jorm.pobject.basictype.Float"; 626 627 public void testFloat0() throws Exception { 628 changeLogger(LOGGER_NAME + ".float"); 629 BasicTypeAccessor acc1 = new BasicTypeAccessor((float) 0); 630 BasicTypeAccessor acc2 = new BasicTypeAccessor((float) -1); 631 if (performIO(CNFLOAT, acc1, acc2)) { 632 assertEquals("Cannot read written float value", 633 (float) 0, acc2.paGetFloatValue(), (float) 0); 634 } 635 } 636 637 public void testFloatMin() throws PException { 638 changeLogger(LOGGER_NAME + ".float"); 639 BasicTypeAccessor acc1 = new BasicTypeAccessor(Float.MIN_VALUE + 1); 640 BasicTypeAccessor acc2 = new BasicTypeAccessor((float) 0); 641 if (performIO(CNFLOAT, acc1, acc2)) { 642 assertEquals("Cannot read written float value", 643 Float.MIN_VALUE + 1, acc2.paGetFloatValue(), (float) 0); 644 } 645 } 646 647 public void testFloatMax() throws PException { 648 changeLogger(LOGGER_NAME + ".float"); 649 float f = (float) 1.7E20; 650 BasicTypeAccessor acc1 = new BasicTypeAccessor(f); 651 BasicTypeAccessor acc2 = new BasicTypeAccessor((float) 0); 652 if (performIO(CNFLOAT, acc1, acc2)) { 653 assertEquals("Cannot read written float value", 654 f, acc2.paGetFloatValue(), (float) 0); 655 } 656 } 657 public void testFloatGen() throws Exception { 658 changeLogger(LOGGER_NAME + ".float"); 659 GenericAccessor acc1 = new GenericAccessor( 660 PTypeSpace.FLOAT, "floatValue", new Float (1.3)); 661 GenericAccessor acc2 = new GenericAccessor( 662 PTypeSpace.FLOAT, "floatValue"); 663 if (performIO(CNFLOAT, acc1, acc2)) { 664 assertEquals("Cannot read written float value", 665 new Float (1.3), new Float (acc2.paGetFloatField("floatValue"))); 666 } 667 } 668 669 private final static String CNOFLOAT = "org.objectweb.jorm.pobject.basictype.Ofloat"; 671 672 public void testOfloatNull() throws Exception { 673 changeLogger(LOGGER_NAME + ".float"); 674 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 675 BasicTypeAccessor acc2 = new BasicTypeAccessor(new Float (0)); 676 if (performIO(CNOFLOAT, acc1, acc2)) { 677 assertEquals("Cannot read written float value", 678 null, acc2.paGetOfloatValue()); 679 } 680 } 681 682 public void testOfloat0() throws Exception { 683 changeLogger(LOGGER_NAME + ".float"); 684 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Float (0)); 685 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 686 if (performIO(CNOFLOAT, acc1, acc2)) { 687 assertEquals("Cannot read written float value", 688 (float) 0, acc2.paGetOfloatValue().floatValue(), (float) 0); 689 } 690 } 691 692 public void testOfloatMin() throws Exception { 693 changeLogger(LOGGER_NAME + ".float"); 694 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Float (Float.MIN_VALUE+1)); 695 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 696 if (performIO(CNOFLOAT, acc1, acc2)) { 697 assertEquals("Cannot read written float value", Float.MIN_VALUE + 1, 698 acc2.paGetOfloatValue().floatValue(), (float) 0); 699 } 700 } 701 702 public void testOfloatMax() throws Exception { 703 changeLogger(LOGGER_NAME + ".float"); 704 float f = (float) 1.7E20; 705 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Float (f)); 706 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 707 if (performIO(CNOFLOAT, acc1, acc2)) { 708 assertEquals("Cannot read written float value", f, 709 acc2.paGetOfloatValue().floatValue(), (float) 0); 710 } 711 } 712 713 public void testOfloatGen() throws Exception { 714 changeLogger(LOGGER_NAME + ".float"); 715 GenericAccessor acc1 = new GenericAccessor( 716 PTypeSpace.OBJFLOAT, "ofloatValue", new Float (1.3)); 717 GenericAccessor acc2 = new GenericAccessor( 718 PTypeSpace.OBJFLOAT, "ofloatValue"); 719 if (performIO(CNOFLOAT, acc1, acc2)) { 720 assertEquals("Cannot read written float value", 721 new Float (1.3), acc2.paGetOfloatField("ofloatValue")); 722 } 723 } 724 725 private final static String CNDOUBLE = "org.objectweb.jorm.pobject.basictype.Double"; 727 728 public void testDouble0() throws Exception { 729 changeLogger(LOGGER_NAME + ".double"); 730 BasicTypeAccessor acc1 = new BasicTypeAccessor((double) 0); 731 BasicTypeAccessor acc2 = new BasicTypeAccessor((double) -1); 732 if (performIO(CNDOUBLE, acc1, acc2)) { 733 assertEquals("Cannot read written double value", 734 (double) 0, acc2.paGetDoubleValue(), (double) 0); 735 } 736 } 737 738 public void testDoubleMin() throws Exception { 739 changeLogger(LOGGER_NAME + ".double"); 740 Double d = new Double (1.79769313486E-300); 741 BasicTypeAccessor acc1 = new BasicTypeAccessor(d.doubleValue()); 742 BasicTypeAccessor acc2 = new BasicTypeAccessor((double) 0); 743 if (performIO(CNDOUBLE, acc1, acc2)) { 744 assertEquals("Cannot read written double value", 745 d.doubleValue(), acc2.paGetDoubleValue(), (double) 0); 746 } 747 } 748 749 public void testDoubleMax() throws Exception { 750 changeLogger(LOGGER_NAME + ".double"); 751 BasicTypeAccessor acc1 = new BasicTypeAccessor(1.79769313486E300); 752 BasicTypeAccessor acc2 = new BasicTypeAccessor((double) 0); 753 if (performIO(CNDOUBLE, acc1, acc2)) { 754 assertTrue("Cannot read written double value expected: " + 755 "1.79769313486E300, found: " + acc2.paGetDoubleValue(), 756 1.79769313486E300 == acc2.paGetDoubleValue()); 757 } 758 } 759 public void testDoubleGen() throws Exception { 760 changeLogger(LOGGER_NAME + ".double"); 761 GenericAccessor acc1 = new GenericAccessor( 762 PTypeSpace.DOUBLE, "doubleValue", new Double (1.3)); 763 GenericAccessor acc2 = new GenericAccessor( 764 PTypeSpace.DOUBLE, "doubleValue"); 765 if (performIO(CNDOUBLE, acc1, acc2)) { 766 assertEquals("Cannot read written float value", 767 new Double (1.3), new Double (acc2.paGetDoubleField("doubleValue"))); 768 } 769 } 770 771 private final static String CNODOUBLE = "org.objectweb.jorm.pobject.basictype.Odouble"; 773 774 public void testOdoubleNull() throws Exception { 775 changeLogger(LOGGER_NAME + ".double"); 776 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 777 BasicTypeAccessor acc2 = new BasicTypeAccessor(new Double (0)); 778 if (performIO(CNODOUBLE, acc1, acc2)) { 779 assertEquals("Cannot read written double value", 780 null, acc2.paGetOdoubleValue()); 781 } 782 } 783 784 public void testOdouble0() throws Exception { 785 changeLogger(LOGGER_NAME + ".double"); 786 BasicTypeAccessor acc1 = new BasicTypeAccessor(new Double (0)); 787 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 788 if (performIO(CNODOUBLE, acc1, acc2)) { 789 assertEquals("Cannot read written double value [0]", 790 (double) 0, acc2.paGetOdoubleValue().doubleValue(), (double) 0); 791 } 792 } 793 794 public void testOdoubleMin() throws Exception { 795 changeLogger(LOGGER_NAME + ".double"); 796 Double d = new Double (1.79769313486E-300); 797 BasicTypeAccessor acc1 = new BasicTypeAccessor(d); 798 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 799 if (performIO(CNODOUBLE, acc1, acc2)) { 800 assertEquals("Cannot read written double value", 801 d.doubleValue(), acc2.paGetOdoubleValue().doubleValue(), (double) 0); 802 } 803 } 804 805 public void testOdoubleMax() throws Exception { 806 changeLogger(LOGGER_NAME + ".double"); 807 Double d = new Double (1.79769313486E300); 808 BasicTypeAccessor acc1 = new BasicTypeAccessor(d); 809 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 810 if (performIO(CNODOUBLE, acc1, acc2)) { 811 assertEquals("Cannot read written double value", 812 d, acc2.paGetOdoubleValue()); 813 } 814 } 815 public void testOdoubleGen() throws Exception { 816 changeLogger(LOGGER_NAME + ".double"); 817 GenericAccessor acc1 = new GenericAccessor( 818 PTypeSpace.OBJDOUBLE, "odoubleValue", new Double (1.3)); 819 GenericAccessor acc2 = new GenericAccessor( 820 PTypeSpace.OBJDOUBLE, "odoubleValue"); 821 if (performIO(CNODOUBLE, acc1, acc2)) { 822 assertEquals("Cannot read written float value", 823 new Double (1.3), acc2.paGetOdoubleField("odoubleValue")); 824 } 825 } 826 827 private final static String CNSTRING = "org.objectweb.jorm.pobject.basictype.String"; 829 830 public void testStringNull() throws Exception { 831 changeLogger(LOGGER_NAME + ".string"); 832 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 833 BasicTypeAccessor acc2 = new BasicTypeAccessor("toto"); 834 if (performIO(CNSTRING, acc1, acc2)) { 835 assertEquals("Cannot read written string value", 836 null, acc2.paGetStringValue()); 837 } 838 } 839 840 public void testStringEmpty() throws Exception { 841 changeLogger(LOGGER_NAME + ".string"); 842 BasicTypeAccessor acc1 = new BasicTypeAccessor(""); 843 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 844 if (performIO(CNSTRING, acc1, acc2)) { 845 assertEquals("Cannot read written string value", 846 "", acc2.paGetStringValue()); 847 } 848 } 849 850 public void testStringazerty() throws Exception { 851 changeLogger(LOGGER_NAME + ".string"); 852 BasicTypeAccessor acc1 = new BasicTypeAccessor("azerty"); 853 BasicTypeAccessor acc2 = new BasicTypeAccessor("toto"); 854 if (performIO(CNSTRING, acc1, acc2)) { 855 assertEquals("Cannot read written string value", 856 "azerty", acc2.paGetStringValue()); 857 } 858 } 859 public void testStringGen() throws Exception { 860 changeLogger(LOGGER_NAME + ".string"); 861 GenericAccessor acc1 = new GenericAccessor( 862 PTypeSpace.STRING, "stringValue", "toto"); 863 GenericAccessor acc2 = new GenericAccessor( 864 PTypeSpace.STRING, "stringValue"); 865 if (performIO(CNSTRING, acc1, acc2)) { 866 assertEquals("Cannot read written string value", 867 "toto", acc2.paGetStringField("stringValue")); 868 } 869 } 870 871 private final static String CNDATE = "org.objectweb.jorm.pobject.basictype.Date"; 873 874 public void testDateNull() throws Exception { 875 testDateValue(null); 876 } 877 878 public void testDateNanos() throws Exception { 879 testDateValue(new Date (1)); 880 } 881 882 public void testDateNow() throws Exception { 883 testDateValue(getTime()); 884 } 885 886 private void testDateValue(Date d) throws Exception { 887 changeLogger(LOGGER_NAME + ".date"); 888 BasicTypeAccessor acc1 = new BasicTypeAccessor(d); 889 BasicTypeAccessor acc2 = 890 new BasicTypeAccessor(d == null ? "toto" : null); 891 if (performIO(CNDATE, acc1, acc2)) { 892 assertEquals("Cannot read written date value", 893 d, acc2.paGetDateValue()); 894 assertEquals("Cannot read written date value", 895 acc2.paGetDateValue(), d); 896 } 897 } 898 public void testDateSql() throws Exception { 899 changeLogger(LOGGER_NAME + ".date"); 900 java.sql.Time d = new java.sql.Time (getTime().getTime()); 901 BasicTypeAccessor acc1 = new BasicTypeAccessor(d); 902 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 903 if (performIO(CNDATE, acc1, acc2)) { 904 assertNotNull("Null date found, expected: " + d, acc2.paGetDateValue()); 905 assertEquals("Cannot read written date value", 906 d.getTime(), acc2.paGetDateValue().getTime()); 907 } 908 } 909 public void testDateGen() throws Exception { 910 changeLogger(LOGGER_NAME + ".date"); 911 Date d = getTime(); 912 GenericAccessor acc1 = new GenericAccessor( 913 PTypeSpace.DATE, "dateValue", d); 914 GenericAccessor acc2 = new GenericAccessor( 915 PTypeSpace.DATE, "dateValue"); 916 if (performIO(CNDATE, acc1, acc2)) { 917 assertEquals("Cannot read written date value", 918 d.getTime(), acc2.paGetDateField("dateValue").getTime()); 919 } 920 } 921 922 923 private final static String CNSERIALIZED = "org.objectweb.jorm.pobject.basictype.Serialized"; 925 926 public void testSerializedNull() throws Exception { 927 changeLogger(LOGGER_NAME + ".serialized"); 928 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 929 BasicTypeAccessor acc2 = new BasicTypeAccessor("toto"); 930 if (performIO(CNSERIALIZED, acc1, acc2)) { 931 assertEquals("Cannot read written serialized value", 932 null, acc2.paGetSerializedValue()); 933 } 934 } 935 936 public void testSerializedAzerty() throws Exception { 937 changeLogger(LOGGER_NAME + ".serialized"); 938 Object o = "azertyuiop"; 939 BasicTypeAccessor acc1 = new BasicTypeAccessor(o); 940 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 941 if (performIO(CNSERIALIZED, acc1, acc2)) { 942 assertEquals("Cannot read written serialized value", 943 o, acc2.paGetSerializedValue()); 944 } 945 } 946 947 public void testSerialized10000KB() throws Exception { 948 changeLogger(LOGGER_NAME + ".serialized"); 949 StringBuffer sb = new StringBuffer (10004); 950 String s10 = "azertyuiop"; 951 for (int i = 0; i < 1000; i++) { 952 sb.append(s10); 953 } 954 Object o = sb.toString(); 955 BasicTypeAccessor acc1 = new BasicTypeAccessor(o); 956 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 957 if (performIO(CNSERIALIZED, acc1, acc2)) { 958 assertEquals("Cannot read written serialized value", 959 o, acc2.paGetSerializedValue()); 960 } 961 } 962 963 public void testSerializedGen() throws Exception { 964 changeLogger(LOGGER_NAME + ".serialized"); 965 Object o = "azertyuiop"; 966 GenericAccessor acc1 = new GenericAccessor( 967 PTypeSpace.SERIALIZED, "serializedValue", o); 968 GenericAccessor acc2 = new GenericAccessor( 969 PTypeSpace.SERIALIZED, "serializedValue"); 970 if (performIO(CNSERIALIZED, acc1, acc2)) { 971 assertEquals("Cannot read written serialized value", 972 o, acc2.paGetSerializedField("serializedValue")); 973 } 974 } 975 976 private final static String CNBYTEARRAY = "org.objectweb.jorm.pobject.basictype.Bytearray"; 978 979 public void testByteArrayNull() throws Exception { 980 changeLogger(LOGGER_NAME + ".bytearray"); 981 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 982 BasicTypeAccessor acc2 = new BasicTypeAccessor("toto"); 983 if (performIO(CNBYTEARRAY, acc1, acc2)) { 984 assertEquals("Cannot read written byte[] value", 985 null, acc2.paGetSerializedValue()); 986 } 987 } 988 989 public void testByteArrayazerty() throws Exception { 990 changeLogger(LOGGER_NAME + ".bytearray"); 991 byte[] o = "azertyuiop".getBytes(); 992 BasicTypeAccessor acc1 = new BasicTypeAccessor(o); 993 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 994 if (performIO(CNBYTEARRAY, acc1, acc2)) { 995 byte[] res = acc2.paGetBytearrayValue(); 996 assertNotNull("Read written byte[] is null", res); 997 assertEquals("Bad size", o.length, res.length); 998 for(int i=0; i<o.length; i++) { 999 assertEquals("Bad element " + i, o[i], res[i]); 1000 } 1001 } 1002 } 1003 1004 public void testByteArrayEmpty() throws Exception { 1005 changeLogger(LOGGER_NAME + ".bytearray"); 1006 byte[] o = new byte[0]; 1007 BasicTypeAccessor acc1 = new BasicTypeAccessor(o); 1008 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1009 if (performIO(CNBYTEARRAY, acc1, acc2)) { 1010 byte[] res = acc2.paGetBytearrayValue(); 1011 assertNotNull("Read written byte[] is null", res); 1012 assertEquals("Bad size", 0, res.length); 1013 } 1014 } 1015 public void testByteArrayGen() throws Exception { 1016 changeLogger(LOGGER_NAME + ".bytearray"); 1017 byte[] o = "azertyuiop".getBytes(); 1018 GenericAccessor acc1 = new GenericAccessor( 1019 PTypeSpace.BYTEARRAY, "bytearrayValue", o); 1020 GenericAccessor acc2 = new GenericAccessor( 1021 PTypeSpace.BYTEARRAY, "bytearrayValue"); 1022 if (performIO(CNBYTEARRAY, acc1, acc2)) { 1023 byte[] res = acc2.paGetByteArrayField("bytearrayValue"); 1024 assertNotNull("Read written byte[] is null", res); 1025 assertEquals("Bad size", o.length, res.length); 1026 for(int i=0; i<o.length; i++) { 1027 assertEquals("Bad element " + i, o[i], res[i]); 1028 } 1029 } 1030 } 1031 1032 private final static String CNCHARARRAY = "org.objectweb.jorm.pobject.basictype.Chararray"; 1034 1035 public void testCharArrayNull() throws Exception { 1036 changeLogger(LOGGER_NAME + ".chararray"); 1037 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 1038 BasicTypeAccessor acc2 = new BasicTypeAccessor("toto"); 1039 if (performIO(CNCHARARRAY, acc1, acc2)) { 1040 assertEquals("Cannot read written char[] value", 1041 null, acc2.paGetSerializedValue()); 1042 } 1043 } 1044 1045 public void testCharArrayazerty() throws Exception { 1046 changeLogger(LOGGER_NAME + ".chararray"); 1047 char[] o = "azertyuiop".toCharArray(); 1048 BasicTypeAccessor acc1 = new BasicTypeAccessor(o); 1049 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1050 if (performIO(CNCHARARRAY, acc1, acc2)) { 1051 char[] res = acc2.paGetChararrayValue(); 1052 assertNotNull("Read written char[] is null", res); 1053 assertEquals("Bad size", o.length, res.length); 1054 for(int i=0; i<o.length; i++) { 1055 assertEquals("Bad element " + i, o[i], res[i]); 1056 } 1057 } 1058 } 1059 1060 public void testCharArrayEmpty() throws Exception { 1061 changeLogger(LOGGER_NAME + ".chararray"); 1062 char[] o = new char[0]; 1063 BasicTypeAccessor acc1 = new BasicTypeAccessor(o); 1064 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1065 if (performIO(CNCHARARRAY, acc1, acc2)) { 1066 char[] res = acc2.paGetChararrayValue(); 1067 assertNotNull("Read written char[] is null", res); 1068 assertEquals("Bad size", 0, res.length); 1069 } 1070 } 1071 public void testCharArrayGen() throws Exception { 1072 changeLogger(LOGGER_NAME + ".chararray"); 1073 char[] o = "azertyuiop".toCharArray(); 1074 GenericAccessor acc1 = new GenericAccessor( 1075 PTypeSpace.CHARARRAY, "chararrayValue", o); 1076 GenericAccessor acc2 = new GenericAccessor( 1077 PTypeSpace.CHARARRAY, "chararrayValue"); 1078 if (performIO(CNCHARARRAY, acc1, acc2)) { 1079 char[] res = acc2.paGetCharArrayField("chararrayValue"); 1080 assertNotNull("Read written char[] is null", res); 1081 assertEquals("Bad size", o.length, res.length); 1082 for(int i=0; i<o.length; i++) { 1083 assertEquals("Bad element " + i, o[i], res[i]); 1084 } 1085 } 1086 } 1087 1088 private final static String CNBIGDECIMAL = "org.objectweb.jorm.pobject.basictype.BigDecimal"; 1090 1091 public void testBigDecimalNull() throws Exception { 1092 changeLogger(LOGGER_NAME + ".bigdecimal"); 1093 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 1094 BasicTypeAccessor acc2 = new BasicTypeAccessor(new BigDecimal (0)); 1095 if (performIO(CNBIGDECIMAL, acc1, acc2)) { 1096 assertEquals("Cannot read written bigdecimal value", 1097 null, acc2.paGetBigDecimalValue()); 1098 } 1099 } 1100 1101 public void testBigDecimal0() throws Exception { 1102 changeLogger(LOGGER_NAME + ".bigdecimal"); 1103 BigDecimal bd = new BigDecimal ("0.0000"); 1104 BigDecimal bd0 = new BigDecimal ("0"); 1105 BasicTypeAccessor acc1 = new BasicTypeAccessor(bd); 1106 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1107 if (performIO(CNBIGDECIMAL, acc1, acc2)) { 1108 assertTrue("Cannot read written bigdecimal value expected:<0> but was:<" 1109 + acc2.paGetBigDecimalValue() + ">", 1110 acc2.paGetBigDecimalValue().equals(bd) 1111 || acc2.paGetBigDecimalValue().equals(bd0)); 1112 } 1113 } 1114 1115 public void testBigDecimalVP4() throws Exception { 1116 changeLogger(LOGGER_NAME + ".bigdecimal"); 1117 BigDecimal bd = new BigDecimal ("6747645764.8796"); 1118 BasicTypeAccessor acc1 = new BasicTypeAccessor(bd); 1119 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1120 if (performIO(CNBIGDECIMAL, acc1, acc2)) { 1121 assertEquals("Cannot read written bigdecimal value", 1122 bd, acc2.paGetBigDecimalValue()); 1123 } 1124 } 1125 1126 public void testBigDecimalVN4() throws Exception { 1127 changeLogger(LOGGER_NAME + ".bigdecimal"); 1128 BigDecimal bd = new BigDecimal ("-6747645764.8796"); 1129 BasicTypeAccessor acc1 = new BasicTypeAccessor(bd); 1130 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1131 if (performIO(CNBIGDECIMAL, acc1, acc2)) { 1132 assertEquals("Cannot read written bigdecimal value", 1133 bd, acc2.paGetBigDecimalValue()); 1134 } 1135 } 1136 1137 public void testBigDecimalVP() throws Exception { 1138 changeLogger(LOGGER_NAME + ".bigdecimal"); 1139 BigDecimal bd = new BigDecimal ("6747645764.8796764453"); 1140 BasicTypeAccessor acc1 = new BasicTypeAccessor(bd); 1141 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1142 if (performIO(CNBIGDECIMAL, acc1, acc2)) { 1143 assertEquals("Cannot read written bigdecimal value", 1144 bd, acc2.paGetBigDecimalValue()); 1145 } 1146 } 1147 1148 public void testBigDecimalVN() throws Exception { 1149 changeLogger(LOGGER_NAME + ".bigdecimal"); 1150 BigDecimal bd = new BigDecimal ("-6747645764.8796764453"); 1151 BasicTypeAccessor acc1 = new BasicTypeAccessor(bd); 1152 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1153 if (performIO(CNBIGDECIMAL, acc1, acc2)) { 1154 assertEquals("Cannot read written bigdecimal value", 1155 bd, acc2.paGetBigDecimalValue()); 1156 } 1157 } 1158 1159 public void testBigDecimalGen() throws Exception { 1160 changeLogger(LOGGER_NAME + ".bigdecimal"); 1161 GenericAccessor acc1 = new GenericAccessor( 1162 PTypeSpace.BIGDECIMAL, "bigDecimalValue", new BigDecimal ("1765765564564.756757657653")); 1163 GenericAccessor acc2 = new GenericAccessor( 1164 PTypeSpace.BIGDECIMAL, "bigDecimalValue"); 1165 if (performIO(CNBIGDECIMAL, acc1, acc2)) { 1166 assertEquals("Cannot read written bigdecimal value", 1167 new BigDecimal ("1765765564564.756757657653"), acc2.paGetBigDecimalField("bigDecimalValue")); 1168 } 1169 } 1170 1171 private final static String CNBIGINTEGER = "org.objectweb.jorm.pobject.basictype.BigInteger"; 1173 1174 public void testBigIntegerNull() throws Exception { 1175 changeLogger(LOGGER_NAME + ".biginteger"); 1176 BasicTypeAccessor acc1 = new BasicTypeAccessor(null); 1177 BasicTypeAccessor acc2 = new BasicTypeAccessor(new BigInteger ("0")); 1178 if (performIO(CNBIGINTEGER, acc1, acc2)) { 1179 assertEquals("Cannot read written biginteger value", 1180 null, acc2.paGetBigIntegerValue()); 1181 } 1182 } 1183 1184 public void testBigInteger0() throws Exception { 1185 changeLogger(LOGGER_NAME + ".biginteger"); 1186 BigInteger bd = new BigInteger ("0"); 1187 BigInteger bd0 = new BigInteger ("0"); 1188 BasicTypeAccessor acc1 = new BasicTypeAccessor(bd); 1189 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1190 if (performIO(CNBIGINTEGER, acc1, acc2)) { 1191 assertTrue("Cannot read written biginteger value expected:<0> but was:<" 1192 + acc2.paGetBigIntegerValue() + ">", 1193 acc2.paGetBigIntegerValue().equals(bd) 1194 || acc2.paGetBigIntegerValue().equals(bd0)); 1195 } 1196 } 1197 1198 public void testBigIntegerVPS() throws Exception { 1199 changeLogger(LOGGER_NAME + ".biginteger"); 1200 BigInteger bd = new BigInteger ("6747645764"); 1201 BasicTypeAccessor acc1 = new BasicTypeAccessor(bd); 1202 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1203 if (performIO(CNBIGINTEGER, acc1, acc2)) { 1204 assertEquals("Cannot read written biginteger value", 1205 bd, acc2.paGetBigIntegerValue()); 1206 } 1207 } 1208 1209 public void testBigIntegerVNS() throws Exception { 1210 changeLogger(LOGGER_NAME + ".biginteger"); 1211 BigInteger bd = new BigInteger ("-6747645764"); 1212 BasicTypeAccessor acc1 = new BasicTypeAccessor(bd); 1213 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1214 if (performIO(CNBIGINTEGER, acc1, acc2)) { 1215 assertEquals("Cannot read written biginteger value", 1216 bd, acc2.paGetBigIntegerValue()); 1217 } 1218 } 1219 1220 public void testBigIntegerVPL() throws Exception { 1221 changeLogger(LOGGER_NAME + ".biginteger"); 1222 BigInteger bd = new BigInteger ("67476457648796764453"); 1223 BasicTypeAccessor acc1 = new BasicTypeAccessor(bd); 1224 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1225 if (performIO(CNBIGINTEGER, acc1, acc2)) { 1226 assertEquals("Cannot read written biginteger value", 1227 bd, acc2.paGetBigIntegerValue()); 1228 } 1229 } 1230 1231 public void testBigIntegerVNL() throws Exception { 1232 changeLogger(LOGGER_NAME + ".biginteger"); 1233 BigInteger bd = new BigInteger ("-67476457648796764453"); 1234 BasicTypeAccessor acc1 = new BasicTypeAccessor(bd); 1235 BasicTypeAccessor acc2 = new BasicTypeAccessor(null); 1236 if (performIO(CNBIGINTEGER, acc1, acc2)) { 1237 assertEquals("Cannot read written biginteger value", 1238 bd, acc2.paGetBigIntegerValue()); 1239 } 1240 } 1241 1242 public void testBigIntegerGen() throws Exception { 1243 changeLogger(LOGGER_NAME + ".biginteger"); 1244 GenericAccessor acc1 = new GenericAccessor( 1245 PTypeSpace.BIGINTEGER, "bigIntegerValue", new BigInteger ("1765765564564756757657653")); 1246 GenericAccessor acc2 = new GenericAccessor( 1247 PTypeSpace.BIGINTEGER, "bigIntegerValue"); 1248 if (performIO(CNBIGINTEGER, acc1, acc2)) { 1249 assertEquals("Cannot read written biginteger value", 1250 new BigInteger ("1765765564564756757657653"), acc2.paGetBigIntegerField("bigIntegerValue")); 1251 } 1252 } 1253} 1254 | Popular Tags |