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

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


      FilePersistenceDataCorruptedException,
      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {
    // add a first object
    session.open();
    Bob1 bob1 = new Bob1();
    bob1.setVal(0);
    session.setObject("0", bob1);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    // try to save a new object with a not storable ( this is to cause a
    // save error )
    session.open();
    bob1 = new Bob1();
    bob1.setVal(1);
    session.setObject("1", bob1);
    session.setObject(NOT_STORABLE_KEY, new ANotStorableClass());
    try {
      session.close(EnumFilePersistenceCloseAction.SAVE);
      fail("save must fail"); // NOPMD
    } catch (final FilePersistenceException exception) { // NOPMD
    }

    /* check storage state */
    createFilePersistence();
    session.open();
    bob1 = (Bob1) session.getObject("0");
    assertNotNull("must exist for key '0'", bob1);
    assertEquals("bad state", 0, bob1.getVal());
    bob1 = (Bob1) session.getObject("1");
    assertNull("must not have object for key '1'", bob1);
    assertNull("must not have object for key 'notStorable'",
        session.getObject(NOT_STORABLE_KEY));
    session.close(EnumFilePersistenceCloseAction.SAVE);
View Full Code Here


      FilePersistenceTooBigForSerializationException {
    final IExclusiveDataAccessSession aloneSession = filePersistence
        .createExclusiveDataAccessSession();
    // add a first object
    aloneSession.open();
    Bob1 bob1 = new Bob1();
    bob1.setVal(0);
    aloneSession.setObject("0", bob1);
    aloneSession.save();

    // try to save a new object with a not storable ( this is to cause a
    // save error )
    bob1 = new Bob1();
    bob1.setVal(1);
    aloneSession.setObject("1", bob1);
    aloneSession.setObject(NOT_STORABLE_KEY, new ANotStorableClass());
    try {
      aloneSession.close();
      fail("save must fail"); // NOPMD
    } catch (final FilePersistenceException exception) { // NOPMD
      // expected exception
    }

    createFilePersistence();

    session.open();
    bob1 = (Bob1) session.getObject("0");
    assertNotNull("must exist for key '0'", bob1);
    assertEquals("bad state", 0, bob1.getVal());
    bob1 = (Bob1) session.getObject("1");
    assertNull("must not have object for key '1'", bob1);
    assertNull("must not have object for key 'notStorable'",
        session.getObject(NOT_STORABLE_KEY));
    session.close(EnumFilePersistenceCloseAction.SAVE);
View Full Code Here

  public OGraphTest(final String name) throws TestException {
    super(name);
  }

  public void test1() throws GraphException {
    final Bob1 root = new Bob1();
    final Bob1 bob1a = new Bob1();
    root.setBob1(bob1a);
    final Bob1 bob1b = new Bob1();
    bob1a.setBob1(bob1b);
    bob1b.setBob1(root);
    final Bob2 bob2 = new Bob2();
    root.setBob2(bob2);
    bob1a.setBob2(bob2);
    final ObjectGraphCreator creator = ObjectGraphCreator.getInstance();
    final ObjectGraph graph = creator.create(root);
View Full Code Here

  }

  public void test2() throws GraphException {
    final BobContainer bobContainer = new BobContainer();
    bobContainer.setObject1(bobContainer);
    final Bob1 bob1 = new Bob1();
    bobContainer.setObject2(bob1);
    final ObjectGraphCreator creator = ObjectGraphCreator.getInstance();
    final ObjectGraph graph = creator.create(bobContainer);
    assertEquals(
        BAD_PATH,
View Full Code Here

  }

  public void test3() throws GraphException {
    final BobContainer bobContainer = new BobContainer();
    bobContainer.setObject1(bobContainer);
    final Bob1 bob1 = new Bob1();
    bobContainer.setObject2(bob1);
    final ObjectGraphCreator creator = ObjectGraphCreator.getInstance();
    final ObjectGraph graph = creator.create(bobContainer);
    assertEquals(
        BAD_PATH,
View Full Code Here

      FilePersistenceClassNotFoundException,
      FilePersistenceInvalidClassException,
      FilePersistenceDataCorruptedException,
      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {
    IBob bob1 = new Bob1();
    bob1.setVal(10);
    session.open();
    session.setObject(BOB1, bob1);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    bob1 = (IBob) session.getObject(BOB1);
    assertTrue("must be Bob1Substitute instance",
        bob1 instanceof Bob1Substitute);
    assertEquals("bad value", 10, bob1.getVal());
    session.close(EnumFilePersistenceCloseAction.DO_NOT_SAVE);
  }
View Full Code Here

      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {
    final IDataAccessSession session = filePersistence
        .createDataAccessSession();

    final Bob1 bob1 = new Bob1();
    final Bob2 bob2 = new Bob2();
    bob2.setVal(0);
    bob1.setBob2(bob2);
    final Bob3 bob3 = new Bob3();
    bob3.setVal(0);
    bob1.setBob3(bob3);
    bob1.setVal(0);

    session.open();
    session.setObject(KEY, bob1);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    Bob1 bob1Read = (Bob1) session.getObject(KEY);
    assertEquals("bad state for val", 0, bob1Read.getVal());
    assertEquals("read must be equals to saved", bob1, bob1Read);
    bob1Read.setVal(1);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    bob1Read = (Bob1) session.getObject(KEY);
    assertEquals("bad state for val", 1, bob1Read.getVal());
    assertFalse("read must not be equals to modified",
        bob1.equals(bob1Read));
    bob1Read.setVal(2);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    bob1Read = (Bob1) session.getObject(KEY);
    assertEquals("bad state for val", 2, bob1Read.getVal());
    final Bob2 bob2Bis = new Bob2();
    bob2.setVal(1);
    bob1Read.setBob2(bob2Bis);
    final Bob3 bob3Bis = new Bob3();
    bob3.setVal(1);
    bob1Read.setBob3(bob3Bis);
    session.close(EnumFilePersistenceCloseAction.SAVE);

    final Bob1 bob1Bis = new Bob1();
    bob1Bis.setVal(2);
    bob1Bis.setBob2(bob2Bis);
    bob1Bis.setBob3(bob3Bis);

    session.open();
    bob1Read = (Bob1) session.getObject(KEY);
    assertEquals("bad state", bob1Bis, bob1Read);
    session.close(EnumFilePersistenceCloseAction.SAVE);
View Full Code Here

    addBob1();

    final IDataAccessSession session = filePersistence
        .createDataAccessSession();
    session.open();
    final Bob1 bob1 = (Bob1) session.getObject(BOB1);
    assertNotNull("must found an object", bob1);
    assertEquals("value must be 0", 0, bob1.getVal());
    session.close(EnumFilePersistenceCloseAction.DO_NOT_SAVE);

    assertNotUsed();
  }
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.