1 23 24 package org.objectweb.jorm.runtime.gcbasictypeelem; 25 26 import org.objectweb.jorm.runtime.TestRuntimeHelper; 27 import org.objectweb.jorm.naming.api.PBinder; 28 import org.objectweb.jorm.facility.naming.basidir.BasidBinder; 29 import org.objectweb.jorm.api.PClassMapping; 30 import org.objectweb.jorm.api.PException; 31 import org.objectweb.jorm.api.PBinding; 32 import org.objectweb.jorm.type.api.PType; 33 import org.objectweb.util.monolog.api.BasicLevel; 34 35 import java.util.Map ; 36 import java.util.HashMap ; 37 38 41 public class TestGcBasicTypeElem extends TestRuntimeHelper { 42 private final static String LOGGER_NAME 43 = "test.org.objectweb.jorm.gcbasictypeelem"; 44 private Map cn2Binder = new HashMap (); 45 46 public TestGcBasicTypeElem(String name) throws Exception { 47 super(name); 48 } 49 50 protected String getLoggerName() { 51 return LOGGER_NAME; 52 } 53 54 protected PBinder getBinder(String className) throws Exception { 55 try { 56 PBinder pb = (PBinder) cn2Binder.get(className); 57 if (pb == null) { 58 pb = new BasidBinder(mapper, className, PClassMapping.CLEANUP_REMOVEALL); 59 cn2Binder.put(className, pb); 60 } 61 return pb; 62 } catch (PException e) { 63 Exception current = e; 64 while (current instanceof PException 65 && ((PException) current).getNestedException() != null) { 66 current = ((PException) current).getNestedException(); 67 } 68 throw current; 69 } 70 } 71 72 74 public void commonTestSet(GcBasicTypeAccessor gcacc1, 75 String classname, 76 String loggername) throws Exception { 77 GcBasicTypeAccessor gcacc2 = new GcBasicTypeAccessor( 78 gcacc1.getTypeCode(), gcacc1.paGetNbElem()); 79 changeLogger(loggername); 80 logger.log(BasicLevel.DEBUG, "export the genClassRef"); 81 PBinding bind = export(classname, null); 82 logger.log(BasicLevel.DEBUG, "export the genClass"); 83 PBinding gcbind = export(classname + "/mygc", null); 84 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 85 GcRefAccessor acc2 = new GcRefAccessor(null); 86 logger.log(BasicLevel.DEBUG, "write and read the genClassRef"); 87 writeRead(bind, acc1, acc2); 88 assertEquals("Cannot read the GC reference", acc1, acc2); 89 logger.log(BasicLevel.DEBUG, "write and read the genClass"); 90 writeRead(gcbind, gcacc1, gcacc2); 91 assertEquals("Cannot read the boolean GC value", gcacc1, gcacc2); 92 logger.log(BasicLevel.DEBUG, "unexport GenClassRef"); 93 unexport(bind, acc1); 94 logger.log(BasicLevel.DEBUG, "unexport GenClass"); 95 unexport(gcbind, gcacc1); 96 } 97 98 100 private final static String CNBOOLEAN 101 = "org.objectweb.jorm.pobject.gcbasictypeelem.BooleanSet"; 102 103 public void commonTestBooleanSet(GcBasicTypeAccessor gcacc1) 104 throws Exception { 105 commonTestSet(gcacc1, CNBOOLEAN, LOGGER_NAME + ".boolean"); 106 } 107 public void testBooleanSetEmpty() throws Exception { 108 commonTestBooleanSet( 109 new GcBasicTypeAccessor(PType.TYPECODE_BOOLEAN, 0)); 110 } 111 public void testBooleanSetOne() throws Exception { 112 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BOOLEAN, 1); 113 gcacc1.setElem(0, true); 114 commonTestBooleanSet(gcacc1); 115 } 116 public void testBooleanSetSeveral() throws Exception { 117 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BOOLEAN, 2); 118 gcacc1.setElem(0, false); 119 gcacc1.setElem(1, true); 120 commonTestBooleanSet(gcacc1); 121 } 122 123 125 private final static String CNOBOOLEAN 126 = "org.objectweb.jorm.pobject.gcbasictypeelem.ObooleanSet"; 127 128 public void commonTestObooleanSet(GcBasicTypeAccessor gcacc1) 129 throws Exception { 130 commonTestSet(gcacc1, CNOBOOLEAN, LOGGER_NAME + ".oboolean"); 131 } 132 public void testObooleanSetEmpty() throws Exception { 133 commonTestObooleanSet( 134 new GcBasicTypeAccessor(PType.TYPECODE_OBJBOOLEAN, 0)); 135 } 136 public void testObooleanSetOne() throws Exception { 137 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJBOOLEAN, 1); 138 gcacc1.setElem(0, Boolean.TRUE); 139 commonTestObooleanSet(gcacc1); 140 } 141 public void __testObooleanSetNull() throws Exception { 142 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJBOOLEAN, 1); 143 gcacc1.setElem(0, null); 144 commonTestObooleanSet(gcacc1); 145 } 146 public void testObooleanSetSeveral() throws Exception { 147 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJBOOLEAN, 2); 148 gcacc1.setElem(0, Boolean.FALSE); 149 gcacc1.setElem(1, Boolean.TRUE); 150 commonTestObooleanSet(gcacc1); 151 } 152 154 private final static String CNBYTE 155 = "org.objectweb.jorm.pobject.gcbasictypeelem.ByteSet"; 156 157 public void commonTestByteSet(GcBasicTypeAccessor gcacc1) 158 throws Exception { 159 commonTestSet(gcacc1, CNBYTE, LOGGER_NAME + ".byte"); 160 } 161 public void testByteSetEmpty() throws Exception { 162 commonTestByteSet( 163 new GcBasicTypeAccessor(PType.TYPECODE_BYTE, 0)); 164 } 165 public void testByteSetOne() throws Exception { 166 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BYTE, 1); 167 gcacc1.setElem(0, (byte) 23); 168 commonTestByteSet(gcacc1); 169 } 170 public void testByteSetSeveral() throws Exception { 171 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BYTE, 2); 172 gcacc1.setElem(0, (byte) 45); 173 gcacc1.setElem(1, (byte) 67); 174 commonTestByteSet(gcacc1); 175 } 176 177 179 private final static String CNOBYTE 180 = "org.objectweb.jorm.pobject.gcbasictypeelem.ObyteSet"; 181 182 public void commonTestObyteSet(GcBasicTypeAccessor gcacc1) 183 throws Exception { 184 commonTestSet(gcacc1, CNOBYTE, LOGGER_NAME + ".obyte"); 185 } 186 public void testObyteSetEmpty() throws Exception { 187 commonTestObyteSet( 188 new GcBasicTypeAccessor(PType.TYPECODE_OBJBYTE, 0)); 189 } 190 public void testObyteSetOne() throws Exception { 191 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJBYTE, 1); 192 gcacc1.setElem(0, new Byte ((byte)23)); 193 commonTestObyteSet(gcacc1); 194 } 195 public void __testObyteSetNull() throws Exception { 196 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJBYTE, 1); 197 gcacc1.setElem(0, null); 198 commonTestObyteSet(gcacc1); 199 } 200 public void testObyteSetSeveral() throws Exception { 201 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJBYTE, 2); 202 gcacc1.setElem(0, new Byte ((byte) 45)); 203 gcacc1.setElem(1, new Byte ((byte) 67)); 204 commonTestObyteSet(gcacc1); 205 } 206 208 private final static String CNSHORT 209 = "org.objectweb.jorm.pobject.gcbasictypeelem.ShortSet"; 210 211 public void commonTestShortSet(GcBasicTypeAccessor gcacc1) 212 throws Exception { 213 commonTestSet(gcacc1, CNSHORT, LOGGER_NAME + ".short"); 214 } 215 public void testShortSetEmpty() throws Exception { 216 commonTestShortSet( 217 new GcBasicTypeAccessor(PType.TYPECODE_SHORT, 0)); 218 } 219 public void testShortSetOne() throws Exception { 220 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_SHORT, 1); 221 gcacc1.setElem(0, (short) 23); 222 commonTestShortSet(gcacc1); 223 } 224 public void testShortSetSeveral() throws Exception { 225 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_SHORT, 2); 226 gcacc1.setElem(0, (short) 45); 227 gcacc1.setElem(1, (short) 67); 228 commonTestShortSet(gcacc1); 229 } 230 231 233 private final static String CNOSHORT 234 = "org.objectweb.jorm.pobject.gcbasictypeelem.OshortSet"; 235 236 public void commonTestOshortSet(GcBasicTypeAccessor gcacc1) 237 throws Exception { 238 commonTestSet(gcacc1, CNOSHORT, LOGGER_NAME + ".oshort"); 239 } 240 public void testOshortSetEmpty() throws Exception { 241 commonTestOshortSet( 242 new GcBasicTypeAccessor(PType.TYPECODE_OBJSHORT, 0)); 243 } 244 public void testOshortSetOne() throws Exception { 245 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJSHORT, 1); 246 gcacc1.setElem(0, new Short ((short)23)); 247 commonTestOshortSet(gcacc1); 248 } 249 public void __testOshortSetNull() throws Exception { 250 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJSHORT, 1); 251 gcacc1.setElem(0, null); 252 commonTestOshortSet(gcacc1); 253 } 254 public void testOshortSetSeveral() throws Exception { 255 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJSHORT, 2); 256 gcacc1.setElem(0, new Short ((short) 45)); 257 gcacc1.setElem(1, new Short ((short) 67)); 258 commonTestOshortSet(gcacc1); 259 } 260 262 private final static String CNINT 263 = "org.objectweb.jorm.pobject.gcbasictypeelem.IntSet"; 264 265 public void commonTestIntSet(GcBasicTypeAccessor gcacc1) 266 throws Exception { 267 commonTestSet(gcacc1, CNINT, LOGGER_NAME + ".int"); 268 } 269 public void testIntSetEmpty() throws Exception { 270 commonTestIntSet( 271 new GcBasicTypeAccessor(PType.TYPECODE_INT, 0)); 272 } 273 public void testIntSetOne() throws Exception { 274 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_INT, 1); 275 gcacc1.setElem(0, 23); 276 commonTestIntSet(gcacc1); 277 } 278 public void testIntSetSeveral() throws Exception { 279 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_INT, 2); 280 gcacc1.setElem(0, 45); 281 gcacc1.setElem(1, 67); 282 commonTestIntSet(gcacc1); 283 } 284 285 287 private final static String CNOINT 288 = "org.objectweb.jorm.pobject.gcbasictypeelem.OintSet"; 289 290 public void commonTestOintSet(GcBasicTypeAccessor gcacc1) 291 throws Exception { 292 commonTestSet(gcacc1, CNOINT, LOGGER_NAME + ".oint"); 293 } 294 public void testOintSetEmpty() throws Exception { 295 commonTestOintSet( 296 new GcBasicTypeAccessor(PType.TYPECODE_OBJINT, 0)); 297 } 298 public void testOintSetOne() throws Exception { 299 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJINT, 1); 300 gcacc1.setElem(0, new Integer (23)); 301 commonTestOintSet(gcacc1); 302 } 303 public void __testOintSetNull() throws Exception { 304 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJINT, 1); 305 gcacc1.setElem(0, null); 306 commonTestOintSet(gcacc1); 307 } 308 public void testOintSetSeveral() throws Exception { 309 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJINT, 2); 310 gcacc1.setElem(0, new Integer (45)); 311 gcacc1.setElem(1, new Integer (67)); 312 commonTestOintSet(gcacc1); 313 } 314 316 private final static String CNLONG 317 = "org.objectweb.jorm.pobject.gcbasictypeelem.LongSet"; 318 319 public void commonTestLongSet(GcBasicTypeAccessor gcacc1) 320 throws Exception { 321 commonTestSet(gcacc1, CNLONG, LOGGER_NAME + ".long"); 322 } 323 public void testLongSetEmpty() throws Exception { 324 commonTestLongSet( 325 new GcBasicTypeAccessor(PType.TYPECODE_LONG, 0)); 326 } 327 public void testLongSetOne() throws Exception { 328 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_LONG, 1); 329 gcacc1.setElem(0, (long) 23); 330 commonTestLongSet(gcacc1); 331 } 332 public void testLongSetSeveral() throws Exception { 333 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_LONG, 2); 334 gcacc1.setElem(0, (long) 45); 335 gcacc1.setElem(1, (long) 67); 336 commonTestLongSet(gcacc1); 337 } 338 339 341 private final static String CNOLONG 342 = "org.objectweb.jorm.pobject.gcbasictypeelem.OlongSet"; 343 344 public void commonTestOlongSet(GcBasicTypeAccessor gcacc1) 345 throws Exception { 346 commonTestSet(gcacc1, CNOLONG, LOGGER_NAME + ".olong"); 347 } 348 public void testOlongSetEmpty() throws Exception { 349 commonTestOlongSet( 350 new GcBasicTypeAccessor(PType.TYPECODE_OBJLONG, 0)); 351 } 352 public void testOlongSetOne() throws Exception { 353 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJLONG, 1); 354 gcacc1.setElem(0, new Long ((long)23)); 355 commonTestOlongSet(gcacc1); 356 } 357 public void __testOlongSetNull() throws Exception { 358 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJLONG, 1); 359 gcacc1.setElem(0, null); 360 commonTestOlongSet(gcacc1); 361 } 362 public void testOlongSetSeveral() throws Exception { 363 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJLONG, 2); 364 gcacc1.setElem(0, new Long ((long) 45)); 365 gcacc1.setElem(1, new Long ((long) 67)); 366 commonTestOlongSet(gcacc1); 367 } 368 370 private final static String CNFLOAT 371 = "org.objectweb.jorm.pobject.gcbasictypeelem.FloatSet"; 372 373 public void commonTestFloatSet(GcBasicTypeAccessor gcacc1) 374 throws Exception { 375 commonTestSet(gcacc1, CNFLOAT, LOGGER_NAME + ".float"); 376 } 377 public void testFloatSetEmpty() throws Exception { 378 commonTestFloatSet( 379 new GcBasicTypeAccessor(PType.TYPECODE_FLOAT, 0)); 380 } 381 public void testFloatSetOne() throws Exception { 382 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_FLOAT, 1); 383 gcacc1.setElem(0, (float) 23); 384 commonTestFloatSet(gcacc1); 385 } 386 public void testFloatSetSeveral() throws Exception { 387 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_FLOAT, 2); 388 gcacc1.setElem(0, (float) 45); 389 gcacc1.setElem(1, (float) 67); 390 commonTestFloatSet(gcacc1); 391 } 392 393 395 private final static String CNOFLOAT 396 = "org.objectweb.jorm.pobject.gcbasictypeelem.OfloatSet"; 397 398 public void commonTestOfloatSet(GcBasicTypeAccessor gcacc1) 399 throws Exception { 400 commonTestSet(gcacc1, CNOFLOAT, LOGGER_NAME + ".ofloat"); 401 } 402 public void testOfloatSetEmpty() throws Exception { 403 commonTestOfloatSet( 404 new GcBasicTypeAccessor(PType.TYPECODE_OBJFLOAT, 0)); 405 } 406 public void testOfloatSetOne() throws Exception { 407 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJFLOAT, 1); 408 gcacc1.setElem(0, new Float ((float)23)); 409 commonTestOfloatSet(gcacc1); 410 } 411 public void __testOfloatSetNull() throws Exception { 412 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJFLOAT, 1); 413 gcacc1.setElem(0, null); 414 commonTestOfloatSet(gcacc1); 415 } 416 public void testOfloatSetSeveral() throws Exception { 417 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJFLOAT, 2); 418 gcacc1.setElem(0, new Float ((float) 45)); 419 gcacc1.setElem(1, new Float ((float) 67)); 420 commonTestOfloatSet(gcacc1); 421 } 422 424 private final static String CNDOUBLE 425 = "org.objectweb.jorm.pobject.gcbasictypeelem.DoubleSet"; 426 427 public void commonTestDoubleSet(GcBasicTypeAccessor gcacc1) 428 throws Exception { 429 commonTestSet(gcacc1, CNDOUBLE, LOGGER_NAME + ".double"); 430 } 431 public void testDoubleSetEmpty() throws Exception { 432 commonTestDoubleSet( 433 new GcBasicTypeAccessor(PType.TYPECODE_DOUBLE, 0)); 434 } 435 public void testDoubleSetOne() throws Exception { 436 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_DOUBLE, 1); 437 gcacc1.setElem(0, (double) 23); 438 commonTestDoubleSet(gcacc1); 439 } 440 public void testDoubleSetSeveral() throws Exception { 441 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_DOUBLE, 2); 442 gcacc1.setElem(0, (double) 45); 443 gcacc1.setElem(1, (double) 67); 444 commonTestDoubleSet(gcacc1); 445 } 446 447 449 private final static String CNODOUBLE 450 = "org.objectweb.jorm.pobject.gcbasictypeelem.OdoubleSet"; 451 452 public void commonTestOdoubleSet(GcBasicTypeAccessor gcacc1) 453 throws Exception { 454 commonTestSet(gcacc1, CNODOUBLE, LOGGER_NAME + ".odouble"); 455 } 456 public void testOdoubleSetEmpty() throws Exception { 457 commonTestOdoubleSet( 458 new GcBasicTypeAccessor(PType.TYPECODE_OBJDOUBLE, 0)); 459 } 460 public void testOdoubleSetOne() throws Exception { 461 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJDOUBLE, 1); 462 gcacc1.setElem(0, new Double ((double)23)); 463 commonTestOdoubleSet(gcacc1); 464 } 465 public void __testOdoubleSetNull() throws Exception { 466 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJDOUBLE, 1); 467 gcacc1.setElem(0, null); 468 commonTestOdoubleSet(gcacc1); 469 } 470 public void testOdoubleSetSeveral() throws Exception { 471 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJDOUBLE, 2); 472 gcacc1.setElem(0, new Double ((double) 45)); 473 gcacc1.setElem(1, new Double ((double) 67)); 474 commonTestOdoubleSet(gcacc1); 475 } 476 478 private final static String CNCHAR 479 = "org.objectweb.jorm.pobject.gcbasictypeelem.CharSet"; 480 481 public void commonTestCharSet(GcBasicTypeAccessor gcacc1) 482 throws Exception { 483 commonTestSet(gcacc1, CNCHAR, LOGGER_NAME + ".char"); 484 } 485 public void testCharSetEmpty() throws Exception { 486 commonTestCharSet( 487 new GcBasicTypeAccessor(PType.TYPECODE_CHAR, 0)); 488 } 489 public void testCharSetOne() throws Exception { 490 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_CHAR, 1); 491 gcacc1.setElem(0, 'e'); 492 commonTestCharSet(gcacc1); 493 } 494 public void testCharSetSeveral() throws Exception { 495 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_CHAR, 2); 496 gcacc1.setElem(0, 'a'); 497 gcacc1.setElem(1, 'b'); 498 commonTestCharSet(gcacc1); 499 } 500 501 503 private final static String CNOCHAR 504 = "org.objectweb.jorm.pobject.gcbasictypeelem.OcharSet"; 505 506 public void commonTestOcharSet(GcBasicTypeAccessor gcacc1) 507 throws Exception { 508 commonTestSet(gcacc1, CNOCHAR, LOGGER_NAME + ".ochar"); 509 } 510 public void testOcharSetEmpty() throws Exception { 511 commonTestOcharSet( 512 new GcBasicTypeAccessor(PType.TYPECODE_OBJCHAR, 0)); 513 } 514 public void testOcharSetOne() throws Exception { 515 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJCHAR, 1); 516 gcacc1.setElem(0, new Character ('e')); 517 commonTestOcharSet(gcacc1); 518 } 519 public void __testOcharSetNull() throws Exception { 520 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJCHAR, 1); 521 gcacc1.setElem(0, null); 522 commonTestOcharSet(gcacc1); 523 } 524 public void testOcharSetSeveral() throws Exception { 525 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_OBJCHAR, 2); 526 gcacc1.setElem(0, new Character ('a')); 527 gcacc1.setElem(1, new Character ('b')); 528 commonTestOcharSet(gcacc1); 529 } 530 532 private final static String CNSTRING 533 = "org.objectweb.jorm.pobject.gcbasictypeelem.StringSet"; 534 535 public void commonTestStringSet(GcBasicTypeAccessor gcacc1) 536 throws Exception { 537 commonTestSet(gcacc1, CNSTRING, LOGGER_NAME + ".string"); 538 } 539 public void testStringSetEmpty() throws Exception { 540 commonTestStringSet( 541 new GcBasicTypeAccessor(PType.TYPECODE_STRING, 0)); 542 } 543 public void testStringSetOne() throws Exception { 544 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_STRING, 1); 545 gcacc1.setElem(0, new String ("azerty")); 546 commonTestStringSet(gcacc1); 547 } 548 public void __testStringSetNull() throws Exception { 549 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_STRING, 1); 550 gcacc1.setElem(0, null); 551 commonTestStringSet(gcacc1); 552 } 553 public void testStringSetSeveral() throws Exception { 554 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_STRING, 2); 555 gcacc1.setElem(0, new String ("qsdfgh")); 556 gcacc1.setElem(1, new String ("wxcvbn")); 557 commonTestStringSet(gcacc1); 558 } 559 560 562 private final static String CNDATE 563 = "org.objectweb.jorm.pobject.gcbasictypeelem.DateSet"; 564 565 public void commonTestDateSet(GcBasicTypeAccessor gcacc1) 566 throws Exception { 567 commonTestSet(gcacc1, CNDATE, LOGGER_NAME + ".date"); 568 } 569 public void testDateSetEmpty() throws Exception { 570 commonTestDateSet( 571 new GcBasicTypeAccessor(PType.TYPECODE_DATE, 0)); 572 } 573 public void testDateSetOne() throws Exception { 574 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_DATE, 1); 575 gcacc1.setElem(0, getTime()); 576 commonTestDateSet(gcacc1); 577 } 578 public void __testDateSetNull() throws Exception { 579 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_DATE, 1); 580 gcacc1.setElem(0, null); 581 commonTestDateSet(gcacc1); 582 } 583 public void testDateSetSeveral() throws Exception { 584 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_DATE, 2); 585 gcacc1.setElem(0, getTime()); 586 Thread.sleep(1000); 587 gcacc1.setElem(1, getTime()); 588 commonTestDateSet(gcacc1); 589 } 590 591 593 private final static String CNBYTEARRAY 594 = "org.objectweb.jorm.pobject.gcbasictypeelem.BytearraySet"; 595 596 public void commonTestByteArraySet(GcBasicTypeAccessor gcacc1) 597 throws Exception { 598 commonTestSet(gcacc1, CNBYTEARRAY, LOGGER_NAME + ".bytearray"); 599 } 600 public void testByteArraySetEmpty() throws Exception { 601 commonTestByteArraySet( 602 new GcBasicTypeAccessor(PType.TYPECODE_BYTEARRAY, 0)); 603 } 604 public void testByteArraySetOne() throws Exception { 605 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BYTEARRAY, 1); 606 gcacc1.setElem(0, new byte[]{1,2,3}); 607 commonTestByteArraySet(gcacc1); 608 } 609 public void __testByteArraySetNull() throws Exception { 610 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BYTEARRAY, 1); 611 gcacc1.setElem(0, null); 612 commonTestByteArraySet(gcacc1); 613 } 614 public void testByteArraySetSeveral() throws Exception { 615 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_BYTEARRAY, 2); 616 gcacc1.setElem(0, new byte[]{4,5,6}); 617 gcacc1.setElem(1, new byte[]{7,8,9}); 618 commonTestByteArraySet(gcacc1); 619 } 620 621 623 private final static String CNCHARARRAY 624 = "org.objectweb.jorm.pobject.gcbasictypeelem.ChararraySet"; 625 626 public void commonTestCharArraySet(GcBasicTypeAccessor gcacc1) 627 throws Exception { 628 commonTestSet(gcacc1, CNCHARARRAY, LOGGER_NAME + ".chararray"); 629 } 630 public void testCharArraySetEmpty() throws Exception { 631 commonTestCharArraySet( 632 new GcBasicTypeAccessor(PType.TYPECODE_CHARARRAY, 0)); 633 } 634 public void testCharArraySetOne() throws Exception { 635 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_CHARARRAY, 1); 636 gcacc1.setElem(0, new char[]{'w','x','c','v','b','n'}); 637 commonTestCharArraySet(gcacc1); 638 } 639 public void __testCharArraySetNull() throws Exception { 640 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_CHARARRAY, 1); 641 gcacc1.setElem(0, null); 642 commonTestCharArraySet(gcacc1); 643 } 644 public void testCharArraySetSeveral() throws Exception { 645 GcBasicTypeAccessor gcacc1 = new GcBasicTypeAccessor(PType.TYPECODE_CHARARRAY, 2); 646 gcacc1.setElem(0, new char[]{'a','z','e','r','t','y'}); 647 gcacc1.setElem(1, new char[]{'q','s','d','f','g','h'}); 648 commonTestCharArraySet(gcacc1); 649 } 650 } 651 | Popular Tags |