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

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


      ObjectIOClassNotFoundException, BinaryConverterException,
      ObjectIOTooBigForSerializationException {

    /* initial write */
    BobSerializable.defaultWrite = true;
    final BobSerializable bob = new BobSerializable();
    Integer firstField = Integer.valueOf(1);
    bob.setObject(firstField);// first field
    bob.setValue(1);// second field
    bob.setBoolean1(Boolean.TRUE);// third field
    final ObjectAndPersistInfo objectAndItsPersistInfo = createObjectAndItsPersistInfo(bob);
    WriteResult writeResult = write(objectAndItsPersistInfo);
    assertValueChangeForFirstWrite(writeResult);
    assertType(new int[] { HelperBinaryConversion.REFERENCE_TYPE,
        HelperBinaryConversion.INTEGER_TYPE,
        HelperBinaryConversion.BOOLEAN_TYPE }, writeResult);
    assertReferencedSons(new Class[] { Object.class },
        new Class[] { Integer.class }, new Object[] { firstField },
        writeResult);
    assertReferenceChange(objectAndItsPersistInfo, new Class[] { null },
        new Class[] { Integer.class }, writeResult);

    assertOriginalValue(new Object[] { firstField /* ,1,Boolean.TRUE */},
        objectAndItsPersistInfo);

    assertWriteInformationCleared(objectAndItsPersistInfo);

    /* second write, no state change */
    writeResult = write(objectAndItsPersistInfo);
    assertValueChangeForSameStateWrite(writeResult);
    assertWriteInformationCleared(objectAndItsPersistInfo);

    /* third write */
    firstField = Integer.valueOf(2);
    bob.setObject(firstField);// change first field
    final Boolean thirdField = Boolean.FALSE;
    bob.setBoolean1(thirdField);// change third field
    writeResult = write(objectAndItsPersistInfo);
    assertValueChangeSinceStateChange(writeResult);
    assertReferencedSons(new Class[] { Object.class /* , Boolean.class */},
        new Class[] { Integer.class /* , Boolean.class */},
        new Object[] { firstField /* , thirdField */}, writeResult);
    assertReferenceChange(objectAndItsPersistInfo, new Class[] {
        Integer.class, null }, new Class[] { null, Integer.class },
        writeResult);

    // assertOriginalValueNotDefined(objectAndItsPersistInfo);
    assertOriginalValue(new Object[] { firstField },
        objectAndItsPersistInfo);

    assertWriteInformationCleared(objectAndItsPersistInfo);

    /* fourth write */
    bob.setValue(2);// change second field
    writeResult = write(objectAndItsPersistInfo);
    assertValueChangeSinceStateChange(writeResult);
    assertReferencedSons(new Class[] { Object.class },
        new Class[] { Integer.class }, new Object[] { firstField },
        writeResult);
View Full Code Here


    filePersistence.keptInMemory("object", keptInMemoryObject);
    final IDataAccessSession dataAccessSession = filePersistence
        .createDataAccessSession();

    BobSerializable.defaultWrite = false;
    BobSerializable bobSerializable = new BobSerializable();
    bobSerializable.setObject(keptInMemoryObject);
    bobSerializable.setValue(10);
    bobSerializable.setBoolean1(Boolean.TRUE);
    dataAccessSession.open();
    dataAccessSession.setObject(KEY1, bobSerializable);
    dataAccessSession.close(EnumFilePersistenceCloseAction.SAVE);

    dataAccessSession.open();
    bobSerializable = (BobSerializable) dataAccessSession.getObject(KEY1);
    assertSame(MUST_BE_SAME_INSTANCE, keptInMemoryObject,
        bobSerializable.getObject());
  }
View Full Code Here

      FilePersistenceInvalidClassException,
      FilePersistenceDataCorruptedException,
      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {
    BobSerializable.defaultWrite = true;
    BobSerializable bob = new BobSerializable();
    session.open();
    bob.setBoolean1(Boolean.TRUE);
    bob.setObject(Integer.valueOf(1));
    bob.setValue(1);
    session.setObject(KEY, bob);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    bob = (BobSerializable) session.getObject(KEY);
    assertTrue(MUST_BE_TRUE, bob.getBoolean1().booleanValue());
    assertEquals(MUST_BE_1, Integer.valueOf(1), bob.getObject());
    bob.setObject(Integer.valueOf(2));
    bob.setBoolean1(Boolean.FALSE);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    bob = (BobSerializable) session.getObject(KEY);
    assertFalse(MUST_BE_FALSE, bob.getBoolean1().booleanValue());
    assertEquals(MUST_BE_2, Integer.valueOf(2), bob.getObject());
    bob.setValue(2);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    bob = (BobSerializable) session.getObject(KEY);
    assertEquals(VALUE_MUST_BE_2, 2, bob.getValue());
    session.close(EnumFilePersistenceCloseAction.SAVE);
  }
View Full Code Here

      FilePersistenceInvalidClassException,
      FilePersistenceDataCorruptedException,
      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {
    BobSerializable.defaultWrite = false;
    BobSerializable bob = new BobSerializable();
    session.open();
    bob.setBoolean1(Boolean.TRUE);
    bob.setObject(Integer.valueOf(1));
    bob.setValue(1);
    session.setObject(KEY, bob);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    bob = (BobSerializable) session.getObject(KEY);
    assertTrue(MUST_BE_TRUE, bob.getBoolean1().booleanValue());
    assertEquals(MUST_BE_1, Integer.valueOf(1), bob.getObject());
    bob.setObject(Integer.valueOf(2));
    bob.setBoolean1(Boolean.FALSE);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    assertFalse(MUST_BE_FALSE, bob.getBoolean1().booleanValue());
    bob = (BobSerializable) session.getObject(KEY);
    assertEquals(MUST_BE_2, Integer.valueOf(2), bob.getObject());
    bob.setValue(2);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    bob = (BobSerializable) session.getObject(KEY);
    assertEquals(VALUE_MUST_BE_2, 2, bob.getValue());
    session.close(EnumFilePersistenceCloseAction.SAVE);
  }
View Full Code Here

      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {

    BobSerializable.defaultWrite = true;

    BobSerializable bob = new BobSerializable();
    session.open();
    bob.setBoolean1(Boolean.TRUE);
    bob.setObject(Integer.valueOf(1));
    bob.setValue(1);
    session.setObject(KEY, bob);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    bob = (BobSerializable) session.getObject(KEY);
    assertTrue(MUST_BE_TRUE, bob.getBoolean1().booleanValue());
    assertEquals(MUST_BE_1, Integer.valueOf(1), bob.getObject());
    bob.setObject(Integer.valueOf(2));
    bob.setBoolean1(Boolean.FALSE);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    BobSerializable.defaultWrite = false;

    session.open();
    bob = (BobSerializable) session.getObject(KEY);
    assertFalse(MUST_BE_FALSE, bob.getBoolean1().booleanValue());
    assertEquals(MUST_BE_2, Integer.valueOf(2), bob.getObject());
    bob.setValue(2);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    bob = (BobSerializable) session.getObject(KEY);
    assertEquals(VALUE_MUST_BE_2, 2, bob.getValue());
    session.close(EnumFilePersistenceCloseAction.SAVE);
  }
View Full Code Here

      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {

    BobSerializable.defaultWrite = false;

    BobSerializable bob = new BobSerializable();
    session.open();
    bob.setBoolean1(Boolean.TRUE);
    bob.setObject(Integer.valueOf(1));
    bob.setValue(1);
    session.setObject(KEY, bob);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    bob = (BobSerializable) session.getObject(KEY);
    assertTrue(MUST_BE_TRUE, bob.getBoolean1().booleanValue());
    assertEquals(MUST_BE_1, Integer.valueOf(1), bob.getObject());
    bob.setObject(Integer.valueOf(2));
    bob.setBoolean1(Boolean.FALSE);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    BobSerializable.defaultWrite = true;

    session.open();
    assertFalse(MUST_BE_FALSE, bob.getBoolean1().booleanValue());
    bob = (BobSerializable) session.getObject(KEY);
    assertEquals(MUST_BE_2, Integer.valueOf(2), bob.getObject());
    bob.setValue(2);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    bob = (BobSerializable) session.getObject(KEY);
    assertEquals(VALUE_MUST_BE_2, 2, bob.getValue());
    session.close(EnumFilePersistenceCloseAction.SAVE);
  }
View Full Code Here

TOP

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

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.