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

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


      StoreTooBigForSerializationException {
    /*
     * creation of object graph with a cycle
     */
    BobContainer bobContainer = new BobContainer();
    Bob1 bob1 = new Bob1();
    bobContainer.setObject1(bob1);
    Bob2 bob2 = new Bob2();
    bob1.setBob2(bob2);
    Bob3 bob3 = new Bob3();
    bob2.setBob3(bob3);
    bob3.setBob1(bob1);
    store.setRoot(bobContainer);
    logger.debug("initial save");
    store.save(false, false);
    Map<DataRecordIdentifier, String> map = objectClassMap(new DataRecordIdentifier[] {});
    objectIoManager.clearObjectState();
    final String links1 = links(map);
    // logAllDataIdentifier();
    // objectIoManager.clearObjectState();
    // heapRecordableManager.clear();

    /*
     * assert garbage information after initial creation
     */
    String expectedLinks = sortString(
    /**/"StoreRoot4 -> BobContainer\n" +
    /**/"BobContainer -> Bob1\n" +
    /**/"Bob1 -> Bob2\n" +
    /**/"Bob2 -> Bob3\n" +
    /**/"Bob3 -> Bob1\n");

    assertEquals("not expected link", expectedLinks, links1);

    int numberToGarbage = toGarbageRecordManager.getNumberOfToGarbage();
    assertEquals("must not have object to garbage", 0, numberToGarbage);

    int numberOfGarbageCandidate = garbageCandidateRecordManager
        .getNumberOfGarbageCandidate();
    assertEquals(MUST_NOT_HAVE_OBJECT_MARKED_GARBAGE_CANDIDATE, 0,
        numberOfGarbageCandidate);

    final int initialNumberOfDataRecord = dataManager
        .getNumberOfDataRecord();

    /*
     * read, check data record identifier, detach object, save
     */
    bobContainer = (BobContainer) store.readAndGetRoot();
    final DataRecordIdentifier idBobContainer = store
        .getDataRecordIdentifierAssociatedToObject(bobContainer);
    logger.debug("id bob container " + idBobContainer);
    assertNotNull("bobContainer must have associated data record",
        idBobContainer);

    bob1 = (Bob1) bobContainer.getObject1();
    final DataRecordIdentifier idBob1 = store
        .getDataRecordIdentifierAssociatedToObject(bob1);
    logger.debug("id bob1 " + idBob1);
    assertNotNull("bob1 must have associated data record", idBob1);

    bob2 = bob1.getBob2();
    final DataRecordIdentifier idBob2 = store
        .getDataRecordIdentifierAssociatedToObject(bob2);
    logger.debug("id bob2 " + idBob2);
    assertNotNull("bob2 must have associated data record", idBob2);

View Full Code Here


    /*
     * creation of object graph:
     * BobWithSerializeMethod->Bob1->Bob2,BobWithSerializeMethod->Integer
     */
    BobWithSerializeMethod bobContainer = new BobWithSerializeMethod();
    Bob1 bob1 = new Bob1();
    bobContainer.setObject1(bob1);
    bobContainer.setNotPrimitiveValue(Integer.valueOf(10));
    Bob2 bob2 = new Bob2();
    bob1.setBob2(bob2);
    store.setRoot(bobContainer);
    store.save(false, false);
    Map<DataRecordIdentifier, String> map = objectClassMap(new DataRecordIdentifier[] {});
    objectIoManager.clearObjectState();
    final String links1 = links(map);
    // objectIoManager.clearObjectState();
    // heapRecordableManager.clear();

    logger.debug("initial save");

    /*
     * assert garbage information after initial creation:
     * BobWithSerializeMethod->Bob1->Bob2,BobWithSerializeMethod->Integer
     */
    /*
     * BobWithSerializeMethod->Integer: no data record for basic
     */
    String expectedLinks = sortString(
    /**/"StoreRoot4 -> BobWithSerializeMethod\n" +
    /**/"BobWithSerializeMethod -> Bob1\n" +
    /**/"Bob1 -> Bob2\n");

    assertEquals("not expected link", expectedLinks, links1);

    /* number of to garbage */
    int numberToGarbage = toGarbageRecordManager.getNumberOfToGarbage();
    assertEquals("must not have object to garbage", 0, numberToGarbage);

    /* number of garbage candidate */
    int numberOfGarbageCandidate = garbageCandidateRecordManager
        .getNumberOfGarbageCandidate();
    assertEquals(MUST_NOT_HAVE_OBJECT_MARKED_GARBAGE_CANDIDATE, 0,
        numberOfGarbageCandidate);

    /* number of class name definition */
    final int initialNumberOfClassDef = classNameManager
        .getNumberOfClassDef();

    /* number of to visit */
    final int numberOfToVisit = toVisitRecordManager.getNumberOfToVisit();
    assertEquals(0, numberOfToVisit);

    /* number of visited */
    int numberOfVisited = visitedRecordManager.getNumberOfVisited();
    assertEquals(0, numberOfVisited);

    /* all data record */
    final int initialNumberOfDataRecord = dataManager
        .getNumberOfDataRecord();
    /*
     * read, check data record identifier, detach object, save
     */
    bobContainer = (BobWithSerializeMethod) store.readAndGetRoot();
    // x = store.getObjectIOManager().getObjectAndPersistInfoOfObject(
    // bobContainer);
    final DataRecordIdentifier idBobContainer = store
        .getDataRecordIdentifierAssociatedToObject(bobContainer);
    logger.debug("id bob container " + idBobContainer);
    assertNotNull("bobContainer must have associated data record",
        idBobContainer);

    bob1 = (Bob1) bobContainer.getObject1();
    final DataRecordIdentifier idBob1 = store
        .getDataRecordIdentifierAssociatedToObject(bob1);
    logger.debug("id bob1 " + idBob1);
    assertNotNull("bob1 must have associated data record", idBob1);

    bob2 = bob1.getBob2();
    final DataRecordIdentifier idBob2 = store
        .getDataRecordIdentifierAssociatedToObject(bob2);
    logger.debug("id bob2 " + idBob2);
    assertNotNull("bob2 must have associated data record", idBob2);

View Full Code Here

        .createDataAccessSession();
    ArraySerializable arraySerializable;
    session.open();
    arraySerializable = new ArraySerializable();
    Bob1[] bob1s = new Bob1[1];
    bob1s[0] = new Bob1();
    bob1s[0].setVal(10);
    arraySerializable.setArray(bob1s);
    session.setObject(KEY, arraySerializable);
    session.close(EnumFilePersistenceCloseAction.SAVE);
View Full Code Here

        .createDataAccessSession();
    ArrayExternalizable arrayExternalizable;
    session.open();
    arrayExternalizable = new ArrayExternalizable();
    Bob1[] bob1s = new Bob1[1];
    bob1s[0] = new Bob1();
    bob1s[0].setVal(10);
    arrayExternalizable.setArray(bob1s);
    session.setObject(KEY, arrayExternalizable);
    session.close(EnumFilePersistenceCloseAction.SAVE);
View Full Code Here

      FilePersistenceDataCorruptedException,
      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {

    session.open();
    Bob1 bob1 = new Bob1();
    Bob2 bob2 = new Bob2();
    bob1.setBob2(bob2);
    session.setObject(BOB1, bob1);
    if (logger.debugEnabled) {
      logger.debug("initiale save");
    }
    session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
    int nbModified = filePersistence.getNumberOfModified();
    assertEquals("bad number of modified", 16, nbModified);
    int nbVisited = filePersistence.getNumberOfVisited();
    assertEquals("bad number of visited", 20, nbVisited);

    session.open();
    bob1 = (Bob1) session.getObject(BOB1);
    bob2 = bob1.getBob2();
    bob2.setVal(bob2.getVal() + 1);// modify state
    if (logger.debugEnabled) {
      logger.debug("save modification");
    }
    session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
View Full Code Here

      FilePersistenceInvalidClassException,
      FilePersistenceDataCorruptedException,
      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {
    final Bob1[] bob1s = new Bob1[1];
    bob1s[0] = new Bob1();
    bob1s[0].setVal(15);
    final Bob1 bob1 = new Bob1();
    bob1.setVal(20);
    final ForThisTest forThisTest = new ForThisTest(bob1s, bob1);
    assertEquals("bad value", 15,
        ((Bob1) forThisTest.getObject1()).getVal());
    assertEquals("bad value", 20,
        ((Bob1) forThisTest.getObject2()).getVal());
View Full Code Here

                               * garbage
                               * management
                               */);
    store.addToNotCheckMethod(Bob1.class);
    store.openAndNewAccessSession(false/* remove files */);
    store.setRoot(new Bob1());
    store.save(true, false);
    store.close();
    assertDataAndBackupAreSame();

    store = new StoreForTest(1, null,
View Full Code Here

                     * + DebugUtil.getInstance().stackTrace(
                     * ProxyManager2
                     * .loadTrace(bobContainer)));
                     */
    }
    final Bob1 bob1 = (Bob1) bobContainer.getObject1();
    assertSaved();
    assertEquals("bad value", 10, bob1.getVal());
    filePersistence.close();
  }
View Full Code Here

    builder.setCrashSafeMode(true);
    filePersistence = builder.build();
    final IDataAccessSession dataAccessSession = filePersistence
        .createDataAccessSession();
    dataAccessSession.open();
    dataAccessSession.setObject("key", new Bob1());
    dataAccessSession.close(EnumFilePersistenceCloseAction.SAVE);
    filePersistence.close();
    assertDataAndBackupAreSame();
  }
View Full Code Here

    }
  }

  private SubstitutedBob initialBob() throws FilePersistenceException {
    final BobContainer bobContainer = new BobContainer();
    final Bob1 bob1 = new Bob1();
    bob1.setVal(10);
    bobContainer.setObject1(bob1);
    final SubstitutedBob bob = new SubstitutedBob(0);
    bob.setObject1(bobContainer);
    return (SubstitutedBob) filePersistence.newProxyInstance(bob);
  }
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.