Package net.sf.joafip.store.service.objectfortest

Examples of net.sf.joafip.store.service.objectfortest.Bob1


  @Override
  protected Object[] modifyObjectToSerialize(final Object object) {
    final BobWithSerializeMethod bobWithSerializeMethod = (BobWithSerializeMethod) object;
    final Object bobContainer = bobWithSerializeMethod.getObject1();
    final Bob1 bob1 = new Bob1();
    bobWithSerializeMethod.setObject2(bob1);
    return new Object[] { bobContainer, bob1 };
  }
View Full Code Here


  public void test() throws StoreException, GarbageException,
      StoreInvalidClassException, StoreNotSerializableException,
      StoreClassNotFoundException, StoreDataCorruptedException,
      ReferenceLinkGarbageException, StoreTooBigForSerializationException {

    Bob1 bob1 = new Bob1();
    store.setRoot(bob1);
    store.save(true, false);

    bob1 = (Bob1) store.readAndGetRoot();
    DataRecordIdentifier dataRecordIdentifierForBob1 = getDataRecordIdentifier(bob1);
    if (logger.debugEnabled) {
      logger.debug("data record if of bob1 is "
          + dataRecordIdentifierForBob1);
    }
    /* check only StoreRoot referencing bob1 */
    assertReferencing(dataRecordIdentifierForBob1,
        new DataRecordIdentifier[] { StoreForTest.IDENTIFIER_FOR_ROOT });

    /* add bob1 --> bob2 */
    Bob2 bob2 = new Bob2();
    bob1.setBob2(bob2);
    store.save(true, false);

    /* check bob1 --> bob2 */
    assertRef1();

    /* add bob1 --> bob3 */
    bob1 = (Bob1) store.readAndGetRoot();
    Bob3 bob3 = new Bob3();
    bob1.setBob3(bob3);
    store.save(true, false);

    /* check bob1 --> bob2, bob1 --> bob3 */
    assertRef2();

    /* add bob2 --> bob1 */
    bob1 = (Bob1) store.readAndGetRoot();
    bob2 = bob1.getBob2();
    bob2.setBob1(bob1);
    store.save(true, false);

    /* check bob1 --> bob2, bob1 --> bob3,bob2 --> bob1 */
    assertRef3();

    /* add bob2 --> bob3 */
    bob1 = (Bob1) store.readAndGetRoot();
    bob2 = bob1.getBob2();
    bob3 = bob1.getBob3();
    bob2.setBob3(bob3);
    store.save(true, false);

    /* check bob1 --> bob2, bob1 --> bob3,bob2 --> bob1,bob2 --> bob3 */
    assertRef4();

    /* add bob3 --> bob1 */
    bob1 = (Bob1) store.readAndGetRoot();
    bob3 = bob1.getBob3();
    bob3.setBob1(bob1);
    store.save(true, false);

    /*
     * check bob1 --> bob2, bob1 --> bob3, bob2 --> bob1, bob2 --> bob3,
     * bob3 --> bob1
     */
    assertRef5();

    /* add bob3 --> bob2 */
    bob1 = (Bob1) store.readAndGetRoot();
    bob2 = bob1.getBob2();
    bob3 = bob1.getBob3();
    bob3.setBob2(bob2);
    store.save(true, false);

    /*
     * check bob1 --> bob2, bob1 --> bob3, bob2 --> bob1, bob2 --> bob3,
     * bob3 --> bob1, bob3 --> bob2
     */
    assertRef6();

    /* remove bob3 --> bob2 */
    bob1 = (Bob1) store.readAndGetRoot();
    bob3 = bob1.getBob3();
    bob3.setBob2(null);
    store.save(true, false);

    /*
     * check bob1 --> bob2, bob1 --> bob3, bob2 --> bob1, bob2 --> bob3,
     * bob3 --> bob1
     */
    assertRef5();

    /* remove bob3 --> bob1 */
    bob1 = (Bob1) store.readAndGetRoot();
    bob3 = bob1.getBob3();
    bob3.setBob1(null);
    store.save(true, false);

    /* check bob1 --> bob2, bob1 --> bob3,bob2 --> bob1,bob2 --> bob3 */
    assertRef4();

    /* remove bob2 --> bob3 */
    bob1 = (Bob1) store.readAndGetRoot();
    bob2 = bob1.getBob2();
    bob2.setBob3(null);
    store.save(true, false);

    /* check bob1 --> bob2, bob1 --> bob3,bob2 --> bob1 */
    assertRef3();

    /* remove bob2 --> bob1 */
    bob1 = (Bob1) store.readAndGetRoot();
    bob2 = bob1.getBob2();
    bob2.setBob1(null);
    store.save(true, false);

    /* check bob1 --> bob2, bob1 --> bob3 */
    assertRef2();

    /* remove bob1 --> bob3 */
    bob1 = (Bob1) store.readAndGetRoot();
    bob1.setBob3(null);
    store.save(true, false);

    /* check bob1 --> bob2 */
    assertRef1();

    /* remove bob1 --> bob2 */
    bob1 = (Bob1) store.readAndGetRoot();
    bob1.setBob2(null);
    store.save(true, false);

    bob1 = (Bob1) store.readAndGetRoot();
    dataRecordIdentifierForBob1 = getDataRecordIdentifier(bob1);

View Full Code Here

   */
  private void assertRef1() throws StoreException, GarbageException,
      StoreClassNotFoundException, StoreInvalidClassException,
      StoreDataCorruptedException, StoreNotSerializableException,
      ReferenceLinkGarbageException {
    final Bob1 bob1 = (Bob1) store.readAndGetRoot();
    final DataRecordIdentifier dataRecordIdentifierForBob1 = getDataRecordIdentifier(bob1);
    final Bob2 bob2 = bob1.getBob2();
    final DataRecordIdentifier dataRecordIdentifierForBob2 = getDataRecordIdentifier(bob2);

    /* check only StoreRoot referencing bob1 */
    assertReferencing(dataRecordIdentifierForBob1,
        new DataRecordIdentifier[] { StoreForTest.IDENTIFIER_FOR_ROOT });
View Full Code Here

   */
  private void assertRef2() throws StoreException, GarbageException,
      StoreClassNotFoundException, StoreInvalidClassException,
      StoreDataCorruptedException, StoreNotSerializableException,
      ReferenceLinkGarbageException {
    final Bob1 bob1 = (Bob1) store.readAndGetRoot();
    final DataRecordIdentifier dataRecordIdentifierForBob1 = getDataRecordIdentifier(bob1);
    final Bob2 bob2 = bob1.getBob2();
    final DataRecordIdentifier dataRecordIdentifierForBob2 = getDataRecordIdentifier(bob2);
    final Bob3 bob3 = bob1.getBob3();
    final DataRecordIdentifier dataRecordIdentifierForBob3 = getDataRecordIdentifier(bob3);

    /* check only StoreRoot referencing bob1 */
    assertReferencing(dataRecordIdentifierForBob1,
        new DataRecordIdentifier[] { StoreForTest.IDENTIFIER_FOR_ROOT });
View Full Code Here

   */
  private void assertRef3() throws StoreException, GarbageException,
      StoreClassNotFoundException, StoreInvalidClassException,
      StoreDataCorruptedException, StoreNotSerializableException,
      ReferenceLinkGarbageException {
    final Bob1 bob1 = (Bob1) store.readAndGetRoot();
    final DataRecordIdentifier dataRecordIdentifierForBob1 = getDataRecordIdentifier(bob1);
    final Bob2 bob2 = bob1.getBob2();
    final DataRecordIdentifier dataRecordIdentifierForBob2 = getDataRecordIdentifier(bob2);
    final Bob3 bob3 = bob1.getBob3();
    final DataRecordIdentifier dataRecordIdentifierForBob3 = getDataRecordIdentifier(bob3);

    assertSame(MUST_BE_SAME_INSTANCE, bob1, bob2.getBob1());

    /* bob2 referencing bob1 */
 
View Full Code Here

   */
  private void assertRef4() throws StoreException, GarbageException,
      StoreClassNotFoundException, StoreInvalidClassException,
      StoreDataCorruptedException, StoreNotSerializableException,
      ReferenceLinkGarbageException {
    final Bob1 bob1 = (Bob1) store.readAndGetRoot();
    final DataRecordIdentifier dataRecordIdentifierForBob1 = getDataRecordIdentifier(bob1);
    final Bob2 bob2 = bob1.getBob2();
    final DataRecordIdentifier dataRecordIdentifierForBob2 = getDataRecordIdentifier(bob2);
    final Bob3 bob3 = bob1.getBob3();
    final DataRecordIdentifier dataRecordIdentifierForBob3 = getDataRecordIdentifier(bob3);

    assertSame(MUST_BE_SAME_INSTANCE, bob1, bob2.getBob1());
    assertSame(MUST_BE_SAME_INSTANCE, bob3, bob2.getBob3());

View Full Code Here

   */
  private void assertRef5() throws StoreException, GarbageException,
      StoreClassNotFoundException, StoreInvalidClassException,
      StoreDataCorruptedException, StoreNotSerializableException,
      ReferenceLinkGarbageException {
    final Bob1 bob1 = (Bob1) store.readAndGetRoot();
    final DataRecordIdentifier dataRecordIdentifierForBob1 = getDataRecordIdentifier(bob1);
    final Bob2 bob2 = bob1.getBob2();
    final DataRecordIdentifier dataRecordIdentifierForBob2 = getDataRecordIdentifier(bob2);
    final Bob3 bob3 = bob1.getBob3();
    final DataRecordIdentifier dataRecordIdentifierForBob3 = getDataRecordIdentifier(bob3);

    assertSame(MUST_BE_SAME_INSTANCE, bob1, bob2.getBob1());
    assertSame(MUST_BE_SAME_INSTANCE, bob3, bob2.getBob3());
    assertSame(MUST_BE_SAME_INSTANCE, bob1, bob3.getBob1());
View Full Code Here

   */
  private void assertRef6() throws StoreException, GarbageException,
      StoreClassNotFoundException, StoreInvalidClassException,
      StoreDataCorruptedException, StoreNotSerializableException,
      ReferenceLinkGarbageException {
    final Bob1 bob1 = (Bob1) store.readAndGetRoot();
    final DataRecordIdentifier dataRecordIdentifierForBob1 = getDataRecordIdentifier(bob1);
    final Bob2 bob2 = bob1.getBob2();
    final DataRecordIdentifier dataRecordIdentifierForBob2 = getDataRecordIdentifier(bob2);
    final Bob3 bob3 = bob1.getBob3();
    final DataRecordIdentifier dataRecordIdentifierForBob3 = getDataRecordIdentifier(bob3);

    assertSame(MUST_BE_SAME_INSTANCE, bob1, bob2.getBob1());
    assertSame(MUST_BE_SAME_INSTANCE, bob3, bob2.getBob3());
    assertSame(MUST_BE_SAME_INSTANCE, bob1, bob3.getBob1());
View Full Code Here

        .getNoProxyClassInfo(objectClass);
    final StorageInfo storageInfo = new StorageInfo();
    final ClassLoaderProvider classLoaderProvider = new ClassLoaderProvider();
    final ProxyManager2 proxyManager2 = new ProxyManager2(
        classLoaderProvider, classInfoFactory);
    Bob1 bob1 = (Bob1) proxyManager2.newInstanceNoConstruction(classInfo,
        storageInfo, this, null, false).getObject();
    assertFalse("must not set object state", setted);
    bob1.setVal(10);
    assertTrue("must set object state", setted);

    setted = false;
    bob1.setBob2(null);
    assertFalse("must not set object state again", setted);

    bob1 = (Bob1) proxyManager2.newInstanceNoConstruction(classInfo,
        storageInfo, this, null, false).getObject();
    assertFalse("must not set object state", setted);
    bob1.setBob3(null);
    assertTrue("must set object state", setted);

    ProxyManager2.unload(bob1);
    assertFalse("must be unsetted", setted);
    setted = true;
View Full Code Here

      StoreNotSerializableException, StoreClassNotFoundException,
      StoreDataCorruptedException, ObjectIOClassNotFoundException,
      ObjectIODataCorruptedException, HeapException,
      StoreTooBigForSerializationException {
    store.addToNotCheckMethod(Bob1.class);
    Bob1 bob1 = new Bob1();
    store.setRoot(bob1);
    store.save(true, false);

    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);
    // ?

    bob1 = (Bob1) store.readAndGetRoot();
    assertNotNull("root object must exist", bob1);
    DataRecordIdentifier id1 = store
        .getDataRecordIdentifierAssociatedToObject(bob1);
    assertNotNull(BOB1_MUST_HAVE_DATA_RECORD_IDENTIFIER, id1);
    assertObjectLink(Bob1.class, id1, new DataRecordIdentifier[] {});

    Bob2 bob2 = new Bob2();
    bob1.setBob2(bob2);
    store.save(true, false);

    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);

    bob1 = (Bob1) store.readAndGetRoot();
    id1 = store.getDataRecordIdentifierAssociatedToObject(bob1);
    assertNotNull(BOB1_MUST_HAVE_DATA_RECORD_IDENTIFIER, id1);
    bob2 = bob1.getBob2();
    assertNotNull("bob1 must reference bob2", bob2);
    DataRecordIdentifier id2 = store
        .getDataRecordIdentifierAssociatedToObject(bob2);
    assertNotNull(BOB2_MUST_HAVE_DATA_RECORD_IDENTIFIER, id2);
    assertObjectLink(Bob1.class, id1, new DataRecordIdentifier[] { id2 });
    assertObjectLink(Bob2.class, id2, new DataRecordIdentifier[] {});

    bob2.setBob1(bob1);
    store.save(true, false);

    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);

    bob1 = (Bob1) store.readAndGetRoot();
    id1 = store.getDataRecordIdentifierAssociatedToObject(bob1);
    assertNotNull(BOB1_MUST_HAVE_DATA_RECORD_IDENTIFIER, id1);
    bob2 = bob1.getBob2();
    id2 = store.getDataRecordIdentifierAssociatedToObject(bob2);
    assertNotNull(BOB2_MUST_HAVE_DATA_RECORD_IDENTIFIER, id2);
    assertObjectLink(Bob1.class, id1, new DataRecordIdentifier[] { id2 });
    assertObjectLink(Bob2.class, id2, new DataRecordIdentifier[] { id1 });

    Bob3 bob3 = new Bob3();
    bob2.setBob3(bob3);
    store.save(true, false);

    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);

    bob1 = (Bob1) store.readAndGetRoot();
    id1 = store.getDataRecordIdentifierAssociatedToObject(bob1);
    assertNotNull(BOB1_MUST_HAVE_DATA_RECORD_IDENTIFIER, id1);
    bob2 = bob1.getBob2();
    id2 = store.getDataRecordIdentifierAssociatedToObject(bob2);
    assertNotNull(BOB2_MUST_HAVE_DATA_RECORD_IDENTIFIER, id2);
    bob3 = bob2.getBob3();
    final DataRecordIdentifier id3 = store
        .getDataRecordIdentifierAssociatedToObject(bob3);
View Full Code Here

TOP

Related Classes of net.sf.joafip.store.service.objectfortest.Bob1

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.