| 1 23 24 package org.objectweb.jorm.runtime.gcindex; 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 34 import java.util.Map ; 35 import java.util.HashMap ; 36 import java.util.Date ; 37 38 41 public class TestGcIndexStoreLoad extends TestRuntimeHelper { 42 private final static String LOGGER_NAME 43 = "test.org.objectweb.jorm.gcindex"; 44 private Map cn2Binder = new HashMap (); 45 46 public TestGcIndexStoreLoad(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 private final static String CNIBYTE = "org.objectweb.jorm.pobject.gcindex.ByteIndexCol"; 76 77 public void testIByteColEmpty() throws Exception { 78 changeLogger(LOGGER_NAME + ".ibyte"); 79 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_BYTE, 0); 80 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_BYTE, 0); 81 PBinding bind = export(CNIBYTE, null); 82 PBinding gcbind = export(CNIBYTE + "/mygc", null); 83 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 84 GcRefAccessor acc2 = new GcRefAccessor(null); 85 writeRead(bind, acc1, acc2); 86 assertEquals("Cannot read the GC reference", acc1, acc2); 87 writeRead(gcbind, gcacc1, gcacc2); 88 assertEquals("Cannot read the byte indexed GC value", gcacc1, gcacc2); 89 } 90 91 public void testIByteColNullElem() throws Exception { 92 changeLogger(LOGGER_NAME + ".ibyte"); 93 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_BYTE, 1); 94 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_BYTE, 1); 95 gcacc1.setElem(0, null); 96 PBinding bind = export(CNIBYTE, null); 97 PBinding gcbind = export(CNIBYTE + "/mygc", null); 98 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 99 GcRefAccessor acc2 = new GcRefAccessor(null); 100 writeRead(bind, acc1, acc2); 101 assertEquals("Cannot read the GC reference", acc1, acc2); 102 writeRead(gcbind, gcacc1, gcacc2); 103 assertEquals("Cannot read the byte indexed GC value", gcacc1, gcacc2); 104 } 105 106 public void testIByteColOneElem() throws Exception { 107 int NBELEM = 1; 108 changeLogger(LOGGER_NAME + ".ibyte"); 109 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_BYTE, NBELEM); 110 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_BYTE, NBELEM); 111 for (int i = 0; i < NBELEM; i++) { 112 gcacc1.setElem(i, "The string " + i); 113 } 114 PBinding bind = export(CNIBYTE, null); 115 PBinding gcbind = export(CNIBYTE + "/mygc", null); 116 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 117 GcRefAccessor acc2 = new GcRefAccessor(null); 118 writeRead(bind, acc1, acc2); 119 assertEquals("Cannot read the GC reference", acc1, acc2); 120 writeRead(gcbind, gcacc1, gcacc2); 121 assertEquals("Cannot read the byte indexed GC value", gcacc1, gcacc2); 122 } 123 124 public void testIByteColTwoElem() throws Exception { 125 int NBELEM = 2; 126 changeLogger(LOGGER_NAME + ".ibyte"); 127 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_BYTE, NBELEM); 128 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_BYTE, NBELEM); 129 for (int i = 0; i < NBELEM; i++) { 130 gcacc1.setElem(i, "The string " + i); 131 } 132 PBinding bind = export(CNIBYTE, null); 133 PBinding gcbind = export(CNIBYTE + "/mygc", null); 134 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 135 GcRefAccessor acc2 = new GcRefAccessor(null); 136 writeRead(bind, acc1, acc2); 137 assertEquals("Cannot read the GC reference", acc1, acc2); 138 writeRead(gcbind, gcacc1, gcacc2); 139 assertEquals("Cannot read the byte indexed GC value", gcacc1, gcacc2); 140 } 141 142 public void testIByteColTenElem() throws Exception { 143 int NBELEM = 10; 144 changeLogger(LOGGER_NAME + ".ibyte"); 145 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_BYTE, NBELEM); 146 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_BYTE, NBELEM); 147 for (int i = 0; i < NBELEM; i++) { 148 gcacc1.setElem(i, "The string " + i); 149 } 150 PBinding bind = export(CNIBYTE, null); 151 PBinding gcbind = export(CNIBYTE + "/mygc", null); 152 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 153 GcRefAccessor acc2 = new GcRefAccessor(null); 154 writeRead(bind, acc1, acc2); 155 assertEquals("Cannot read the GC reference", acc1, acc2); 156 writeRead(gcbind, gcacc1, gcacc2); 157 assertEquals("Cannot read the byte indexed GC value", gcacc1, gcacc2); 158 } 159 160 public void testIByteColHundredElem() throws Exception { 161 int NBELEM = 100; 162 changeLogger(LOGGER_NAME + ".ibyte"); 163 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_BYTE, NBELEM); 164 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_BYTE, NBELEM); 165 for (int i = 0; i < NBELEM; i++) { 166 gcacc1.setElem(i, "The string " + i); 167 } 168 PBinding bind = export(CNIBYTE, null); 169 PBinding gcbind = export(CNIBYTE + "/mygc", null); 170 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 171 GcRefAccessor acc2 = new GcRefAccessor(null); 172 writeRead(bind, acc1, acc2); 173 assertEquals("Cannot read the GC reference", acc1, acc2); 174 writeRead(gcbind, gcacc1, gcacc2); 175 assertEquals("Cannot read the byte indexed GC value", gcacc1, gcacc2); 176 } 177 178 private final static String CNICHAR = "org.objectweb.jorm.pobject.gcindex.CharIndexCol"; 180 181 public void testICharColEmpty() throws Exception { 182 changeLogger(LOGGER_NAME + ".ichar"); 183 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_CHAR, 0); 184 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_CHAR, 0); 185 PBinding bind = export(CNICHAR, null); 186 PBinding gcbind = export(CNICHAR + "/mygc", null); 187 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 188 GcRefAccessor acc2 = new GcRefAccessor(null); 189 writeRead(bind, acc1, acc2); 190 assertEquals("Cannot read the GC reference", acc1, acc2); 191 writeRead(gcbind, gcacc1, gcacc2); 192 assertEquals("Cannot read the char indexed GC value", gcacc1, gcacc2); 193 } 194 195 public void testICharColNullElem() throws Exception { 196 changeLogger(LOGGER_NAME + ".ichar"); 197 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_CHAR, 1); 198 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_CHAR, 1); 199 gcacc1.setElem(0, null); 200 PBinding bind = export(CNICHAR, null); 201 PBinding gcbind = export(CNICHAR + "/mygc", null); 202 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 203 GcRefAccessor acc2 = new GcRefAccessor(null); 204 writeRead(bind, acc1, acc2); 205 assertEquals("Cannot read the GC reference", acc1, acc2); 206 writeRead(gcbind, gcacc1, gcacc2); 207 assertEquals("Cannot read the char indexed GC value", gcacc1, gcacc2); 208 } 209 210 public void testICharColOneElem() throws Exception { 211 int NBELEM = 1; 212 changeLogger(LOGGER_NAME + ".ichar"); 213 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_CHAR, NBELEM); 214 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_CHAR, NBELEM); 215 for (int i = 0; i < NBELEM; i++) { 216 gcacc1.setElem(i, "The string " + i); 217 } 218 PBinding bind = export(CNICHAR, null); 219 PBinding gcbind = export(CNICHAR + "/mygc", null); 220 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 221 GcRefAccessor acc2 = new GcRefAccessor(null); 222 writeRead(bind, acc1, acc2); 223 assertEquals("Cannot read the GC reference", acc1, acc2); 224 writeRead(gcbind, gcacc1, gcacc2); 225 assertEquals("Cannot read the char indexed GC value", gcacc1, gcacc2); 226 } 227 228 public void testICharColTwoElem() throws Exception { 229 int NBELEM = 2; 230 changeLogger(LOGGER_NAME + ".ichar"); 231 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_CHAR, NBELEM); 232 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_CHAR, NBELEM); 233 for (int i = 0; i < NBELEM; i++) { 234 gcacc1.setElem(i, "The string " + i); 235 } 236 PBinding bind = export(CNICHAR, null); 237 PBinding gcbind = export(CNICHAR + "/mygc", null); 238 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 239 GcRefAccessor acc2 = new GcRefAccessor(null); 240 writeRead(bind, acc1, acc2); 241 assertEquals("Cannot read the GC reference", acc1, acc2); 242 writeRead(gcbind, gcacc1, gcacc2); 243 assertEquals("Cannot read the char indexed GC value", gcacc1, gcacc2); 244 } 245 246 public void testICharColTenElem() throws Exception { 247 int NBELEM = 10; 248 changeLogger(LOGGER_NAME + ".ichar"); 249 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_CHAR, NBELEM); 250 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_CHAR, NBELEM); 251 for (int i = 0; i < NBELEM; i++) { 252 gcacc1.setElem(i, "The string " + i); 253 } 254 PBinding bind = export(CNICHAR, null); 255 PBinding gcbind = export(CNICHAR + "/mygc", null); 256 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 257 GcRefAccessor acc2 = new GcRefAccessor(null); 258 writeRead(bind, acc1, acc2); 259 assertEquals("Cannot read the GC reference", acc1, acc2); 260 writeRead(gcbind, gcacc1, gcacc2); 261 assertEquals("Cannot read the char indexed GC value", gcacc1, gcacc2); 262 } 263 264 public void testICharCol94Elem() throws Exception { 265 int NBELEM = 94; 266 changeLogger(LOGGER_NAME + ".ichar"); 267 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_CHAR, NBELEM); 268 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_CHAR, NBELEM); 269 for (int i = 0; i < NBELEM; i++) { 270 gcacc1.setElem(i, "The string " + i); 271 } 272 PBinding bind = export(CNICHAR, null); 273 PBinding gcbind = export(CNICHAR + "/mygc", null); 274 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 275 GcRefAccessor acc2 = new GcRefAccessor(null); 276 writeRead(bind, acc1, acc2); 277 assertEquals("Cannot read the GC reference", acc1, acc2); 278 writeRead(gcbind, gcacc1, gcacc2); 279 assertEquals("Cannot read the char indexed GC value", gcacc1, gcacc2); 280 } 281 282 private final static String CNISHORT = "org.objectweb.jorm.pobject.gcindex.ShortIndexCol"; 284 285 public void testIShortColEmpty() throws Exception { 286 changeLogger(LOGGER_NAME + ".ishort"); 287 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_SHORT, 0); 288 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_SHORT, 0); 289 PBinding bind = export(CNISHORT, null); 290 PBinding gcbind = export(CNISHORT + "/mygc", null); 291 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 292 GcRefAccessor acc2 = new GcRefAccessor(null); 293 writeRead(bind, acc1, acc2); 294 assertEquals("Cannot read the GC reference", acc1, acc2); 295 writeRead(gcbind, gcacc1, gcacc2); 296 assertEquals("Cannot read the short indexed GC value", gcacc1, gcacc2); 297 } 298 299 public void testIShortColNullElem() throws Exception { 300 changeLogger(LOGGER_NAME + ".ishort"); 301 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_SHORT, 1); 302 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_SHORT, 1); 303 gcacc1.setElem(0, null); 304 PBinding bind = export(CNISHORT, null); 305 PBinding gcbind = export(CNISHORT + "/mygc", null); 306 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 307 GcRefAccessor acc2 = new GcRefAccessor(null); 308 writeRead(bind, acc1, acc2); 309 assertEquals("Cannot read the GC reference", acc1, acc2); 310 writeRead(gcbind, gcacc1, gcacc2); 311 assertEquals("Cannot read the short indexed GC value", gcacc1, gcacc2); 312 } 313 314 public void testIShortColOneElem() throws Exception { 315 int NBELEM = 1; 316 changeLogger(LOGGER_NAME + ".ishort"); 317 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_SHORT, NBELEM); 318 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_SHORT, NBELEM); 319 for (int i = 0; i < NBELEM; i++) { 320 gcacc1.setElem(i, "The string " + i); 321 } 322 PBinding bind = export(CNISHORT, null); 323 PBinding gcbind = export(CNISHORT + "/mygc", null); 324 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 325 GcRefAccessor acc2 = new GcRefAccessor(null); 326 writeRead(bind, acc1, acc2); 327 assertEquals("Cannot read the GC reference", acc1, acc2); 328 writeRead(gcbind, gcacc1, gcacc2); 329 assertEquals("Cannot read the short indexed GC value", gcacc1, gcacc2); 330 } 331 332 public void testIShortColTwoElem() throws Exception { 333 int NBELEM = 2; 334 changeLogger(LOGGER_NAME + ".ishort"); 335 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_SHORT, NBELEM); 336 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_SHORT, NBELEM); 337 for (int i = 0; i < NBELEM; i++) { 338 gcacc1.setElem(i, "The string " + i); 339 } 340 PBinding bind = export(CNISHORT, null); 341 PBinding gcbind = export(CNISHORT + "/mygc", null); 342 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 343 GcRefAccessor acc2 = new GcRefAccessor(null); 344 writeRead(bind, acc1, acc2); 345 assertEquals("Cannot read the GC reference", acc1, acc2); 346 writeRead(gcbind, gcacc1, gcacc2); 347 assertEquals("Cannot read the short indexed GC value", gcacc1, gcacc2); 348 } 349 350 public void testIShortColTenElem() throws Exception { 351 int NBELEM = 10; 352 changeLogger(LOGGER_NAME + ".ishort"); 353 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_SHORT, NBELEM); 354 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_SHORT, NBELEM); 355 for (int i = 0; i < NBELEM; i++) { 356 gcacc1.setElem(i, "The string " + i); 357 } 358 PBinding bind = export(CNISHORT, null); 359 PBinding gcbind = export(CNISHORT + "/mygc", null); 360 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 361 GcRefAccessor acc2 = new GcRefAccessor(null); 362 writeRead(bind, acc1, acc2); 363 assertEquals("Cannot read the GC reference", acc1, acc2); 364 writeRead(gcbind, gcacc1, gcacc2); 365 assertEquals("Cannot read the short indexed GC value", gcacc1, gcacc2); 366 } 367 368 public void testIShortColHundredElem() throws Exception { 369 int NBELEM = 100; 370 changeLogger(LOGGER_NAME + ".ishort"); 371 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_SHORT, NBELEM); 372 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_SHORT, NBELEM); 373 for (int i = 0; i < NBELEM; i++) { 374 gcacc1.setElem(i, "The string " + i); 375 } 376 PBinding bind = export(CNISHORT, null); 377 PBinding gcbind = export(CNISHORT + "/mygc", null); 378 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 379 GcRefAccessor acc2 = new GcRefAccessor(null); 380 writeRead(bind, acc1, acc2); 381 assertEquals("Cannot read the GC reference", acc1, acc2); 382 writeRead(gcbind, gcacc1, gcacc2); 383 assertEquals("Cannot read the short indexed GC value", gcacc1, gcacc2); 384 } 385 386 private final static String CNIINT = "org.objectweb.jorm.pobject.gcindex.IntIndexCol"; 388 389 public void testIIntColEmpty() throws Exception { 390 changeLogger(LOGGER_NAME + ".iint"); 391 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_INT, 0); 392 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_INT, 0); 393 PBinding bind = export(CNIINT, null); 394 PBinding gcbind = export(CNIINT + "/mygc", null); 395 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 396 GcRefAccessor acc2 = new GcRefAccessor(null); 397 writeRead(bind, acc1, acc2); 398 assertEquals("Cannot read the GC reference", acc1, acc2); 399 writeRead(gcbind, gcacc1, gcacc2); 400 assertEquals("Cannot read the int indexed GC value", gcacc1, gcacc2); 401 } 402 403 public void testIIntColNullElem() throws Exception { 404 changeLogger(LOGGER_NAME + ".iint"); 405 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_INT, 1); 406 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_INT, 1); 407 gcacc1.setElem(0, null); 408 PBinding bind = export(CNIINT, null); 409 PBinding gcbind = export(CNIINT + "/mygc", null); 410 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 411 GcRefAccessor acc2 = new GcRefAccessor(null); 412 writeRead(bind, acc1, acc2); 413 assertEquals("Cannot read the GC reference", acc1, acc2); 414 writeRead(gcbind, gcacc1, gcacc2); 415 assertEquals("Cannot read the int indexed GC value", gcacc1, gcacc2); 416 } 417 418 public void testIIntColOneElem() throws Exception { 419 int NBELEM = 1; 420 changeLogger(LOGGER_NAME + ".iint"); 421 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_INT, NBELEM); 422 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_INT, NBELEM); 423 for (int i = 0; i < NBELEM; i++) { 424 gcacc1.setElem(i, "The string " + i); 425 } 426 PBinding bind = export(CNIINT, null); 427 PBinding gcbind = export(CNIINT + "/mygc", null); 428 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 429 GcRefAccessor acc2 = new GcRefAccessor(null); 430 writeRead(bind, acc1, acc2); 431 assertEquals("Cannot read the GC reference", acc1, acc2); 432 writeRead(gcbind, gcacc1, gcacc2); 433 assertEquals("Cannot read the int indexed GC value", gcacc1, gcacc2); 434 } 435 436 public void testIIntColTwoElem() throws Exception { 437 int NBELEM = 2; 438 changeLogger(LOGGER_NAME + ".iint"); 439 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_INT, NBELEM); 440 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_INT, NBELEM); 441 for (int i = 0; i < NBELEM; i++) { 442 gcacc1.setElem(i, "The string " + i); 443 } 444 PBinding bind = export(CNIINT, null); 445 PBinding gcbind = export(CNIINT + "/mygc", null); 446 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 447 GcRefAccessor acc2 = new GcRefAccessor(null); 448 writeRead(bind, acc1, acc2); 449 assertEquals("Cannot read the GC reference", acc1, acc2); 450 writeRead(gcbind, gcacc1, gcacc2); 451 assertEquals("Cannot read the int indexed GC value", gcacc1, gcacc2); 452 } 453 454 public void testIIntColTenElem() throws Exception { 455 int NBELEM = 10; 456 changeLogger(LOGGER_NAME + ".iint"); 457 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_INT, NBELEM); 458 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_INT, NBELEM); 459 for (int i = 0; i < NBELEM; i++) { 460 gcacc1.setElem(i, "The string " + i); 461 } 462 PBinding bind = export(CNIINT, null); 463 PBinding gcbind = export(CNIINT + "/mygc", null); 464 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 465 GcRefAccessor acc2 = new GcRefAccessor(null); 466 writeRead(bind, acc1, acc2); 467 assertEquals("Cannot read the GC reference", acc1, acc2); 468 writeRead(gcbind, gcacc1, gcacc2); 469 assertEquals("Cannot read the int indexed GC value", gcacc1, gcacc2); 470 } 471 472 public void testIIntColHundredElem() throws Exception { 473 int NBELEM = 100; 474 changeLogger(LOGGER_NAME + ".iint"); 475 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_INT, NBELEM); 476 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_INT, NBELEM); 477 for (int i = 0; i < NBELEM; i++) { 478 gcacc1.setElem(i, "The string " + i); 479 } 480 PBinding bind = export(CNIINT, null); 481 PBinding gcbind = export(CNIINT + "/mygc", null); 482 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 483 GcRefAccessor acc2 = new GcRefAccessor(null); 484 writeRead(bind, acc1, acc2); 485 assertEquals("Cannot read the GC reference", acc1, acc2); 486 writeRead(gcbind, gcacc1, gcacc2); 487 assertEquals("Cannot read the int indexed GC value", gcacc1, gcacc2); 488 } 489 490 public void testIIntColThousandElem() throws Exception { 491 int NBELEM = 1000; 492 changeLogger(LOGGER_NAME + ".iint"); 493 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_INT, NBELEM); 494 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_INT, NBELEM); 495 for (int i = 0; i < NBELEM; i++) { 496 gcacc1.setElem(i, "The string " + i); 497 } 498 PBinding bind = export(CNIINT, null); 499 PBinding gcbind = export(CNIINT + "/mygc", null); 500 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 501 GcRefAccessor acc2 = new GcRefAccessor(null); 502 writeRead(bind, acc1, acc2); 503 assertEquals("Cannot read the GC reference", acc1, acc2); 504 writeRead(gcbind, gcacc1, gcacc2); 505 assertEquals("Cannot read the int indexed GC value", gcacc1, gcacc2); 506 } 507 508 private final static String CNILONG = "org.objectweb.jorm.pobject.gcindex.LongIndexCol"; 510 511 public void testILongColEmpty() throws Exception { 512 changeLogger(LOGGER_NAME + ".ilong"); 513 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_LONG, 0); 514 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_LONG, 0); 515 PBinding bind = export(CNILONG, null); 516 PBinding gcbind = export(CNILONG + "/mygc", null); 517 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 518 GcRefAccessor acc2 = new GcRefAccessor(null); 519 writeRead(bind, acc1, acc2); 520 assertEquals("Cannot read the GC reference", acc1, acc2); 521 writeRead(gcbind, gcacc1, gcacc2); 522 assertEquals("Cannot read the long indexed GC value", gcacc1, gcacc2); 523 } 524 525 public void testILongColNullElem() throws Exception { 526 changeLogger(LOGGER_NAME + ".ilong"); 527 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_LONG, 1); 528 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_LONG, 1); 529 gcacc1.setElem(0, null); 530 PBinding bind = export(CNILONG, null); 531 PBinding gcbind = export(CNILONG + "/mygc", null); 532 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 533 GcRefAccessor acc2 = new GcRefAccessor(null); 534 writeRead(bind, acc1, acc2); 535 assertEquals("Cannot read the GC reference", acc1, acc2); 536 writeRead(gcbind, gcacc1, gcacc2); 537 assertEquals("Cannot read the long indexed GC value", gcacc1, gcacc2); 538 } 539 540 public void testILongColOneElem() throws Exception { 541 int NBELEM = 1; 542 changeLogger(LOGGER_NAME + ".ilong"); 543 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_LONG, NBELEM); 544 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_LONG, NBELEM); 545 for (int i = 0; i < NBELEM; i++) { 546 gcacc1.setElem(i, "The string " + i); 547 } 548 PBinding bind = export(CNILONG, null); 549 PBinding gcbind = export(CNILONG + "/mygc", null); 550 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 551 GcRefAccessor acc2 = new GcRefAccessor(null); 552 writeRead(bind, acc1, acc2); 553 assertEquals("Cannot read the GC reference", acc1, acc2); 554 writeRead(gcbind, gcacc1, gcacc2); 555 assertEquals("Cannot read the long indexed GC value", gcacc1, gcacc2); 556 } 557 558 public void testILongColTwoElem() throws Exception { 559 int NBELEM = 2; 560 changeLogger(LOGGER_NAME + ".ilong"); 561 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_LONG, NBELEM); 562 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_LONG, NBELEM); 563 for (int i = 0; i < NBELEM; i++) { 564 gcacc1.setElem(i, "The string " + i); 565 } 566 PBinding bind = export(CNILONG, null); 567 PBinding gcbind = export(CNILONG + "/mygc", null); 568 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 569 GcRefAccessor acc2 = new GcRefAccessor(null); 570 writeRead(bind, acc1, acc2); 571 assertEquals("Cannot read the GC reference", acc1, acc2); 572 writeRead(gcbind, gcacc1, gcacc2); 573 assertEquals("Cannot read the long indexed GC value", gcacc1, gcacc2); 574 } 575 576 public void testILongColTenElem() throws Exception { 577 int NBELEM = 10; 578 changeLogger(LOGGER_NAME + ".ilong"); 579 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_LONG, NBELEM); 580 GcIndexAccessor gcacc2 = new GcIndexAccessor(PType.TYPECODE_LONG, NBELEM); 581 for (int i = 0; i < NBELEM; i++) { 582 gcacc1.setElem(i, "The string " + i); 583 } 584 PBinding bind = export(CNILONG, null); 585 PBinding gcbind = export(CNILONG + "/mygc", null); 586 GcRefAccessor acc1 = new GcRefAccessor(gcbind.getPName()); 587 GcRefAccessor acc2 = new GcRefAccessor(null); 588 writeRead(bind, acc1, acc2); 589 assertEquals("Cannot read the GC reference", acc1, acc2); 590 writeRead(gcbind, gcacc1, gcacc2); 591 assertEquals("Cannot read the long indexed GC value", gcacc1, gcacc2); 592 } 593 594 public void testILongColHundredElem() throws Exception { 595 int NBELEM = 100; 596 changeLogger(LOGGER_NAME + ".ilong"); 597 GcIndexAccessor gcacc1 = new GcIndexAccessor(PType.TYPECODE_LONG, NBELEM); 598 |