Package net.sf.joafip.entity

Examples of net.sf.joafip.entity.Item


      FilePersistenceTooBigForSerializationException {
    final IDataAccessSession session1 = filePersistence
        .createDataAccessSession();
    final IDataAccessSession session2 = filePersistence
        .createDataAccessSession();
    final Item item1 = new Item();
    final Item item2 = new Item();
    session1.open();
    session2.open();
    session1.setObject("item1", item1);
    session2.setObject("item2", item2);
    ended = false;
View Full Code Here


      FilePersistenceClassNotFoundException,
      FilePersistenceInvalidClassException,
      FilePersistenceDataCorruptedException,
      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {
    final Item item1 = new Item();
    final Item item2 = new Item();
    session1.open();
    session2.open();
    session1.setObject("item1", item1);
    session2.setObject("item2", item2);
    session2.addListener(new IFilePersistenceCloseActionListener() {
View Full Code Here

  public void testAddRemoveWithSession() throws Throwable {
    final IDataAccessSession session = filePersistence
        .createDataAccessSession();
    for (int index = 0; index < 5; index++) {
      final Item item = new Item();// NOPMD
      item.setValue(EMPTY_STRING + index);// NOPMD
      logger.info("item to add " + item);
      session.open();
      session.setObject(ITEM + index, item);
      session.close(EnumFilePersistenceCloseAction.SAVE);
      logger.info("item added " + item);
    }

    for (int index = 0; index < 5; index++) {
      session.open();
      final Item item = (Item) session.getObject(ITEM + index);
      assertNotNull("item " + index + " not found", item);
      final Item itemCopy = new Item(item);// NOPMD new in loop
      logger.info("item read " + itemCopy);
      session.close(EnumFilePersistenceCloseAction.SAVE);
      assertEquals("bad value", EMPTY_STRING + index, itemCopy.getValue());// NOPMD
      session.open();
      final Item removedItem = (Item) session.removeObject(ITEM + index);
      logger.info("item deleted " + removedItem);
      assertEquals("bad item", itemCopy, removedItem);
      session.close(EnumFilePersistenceCloseAction.SAVE);
    }
  }
View Full Code Here

    final TransactionForTest transaction = new TransactionForTest(session);
    for (int index = 0; index < 10; index++) {
      addItem(transaction, index);
    }
    for (int index = 0; index < 10; index++) {
      final Item item = getItem(transaction, index);
      assertEquals("bad value", EMPTY_STRING + index, item.getValue());// NOPMD
      assertEquals("bad item", item, removeItem(transaction, index));
    }
  }
View Full Code Here

      @Override
      public void run() {
        for (int index = 0; inThreadThrowable == null && index < 5; index++) {
          try {
            final Item item = getItem(transaction, index);
            if (!(EMPTY_STRING + index).equals(item.getValue())) {// NOPMD
              inThreadThrowable = new Exception(// NOPMD
                  "bad value " + index + " expected "
                      + item.getValue());
            }
            removeItem(transaction, index);
          } catch (final Throwable throwable) {// NOPMD
            inThreadThrowable = throwable;
          }
View Full Code Here

      FilePersistenceClassNotFoundException,
      FilePersistenceInvalidClassException,
      FilePersistenceDataCorruptedException,
      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {
    final Item item = new Item();
    item.setValue(EMPTY_STRING + itemNumber);// NOPMD
    logger.info("item to add " + item);
    transaction.join();
    transaction.setObject(ITEM + itemNumber, item);
    transaction.quit();
    logger.info("item added " + item);
View Full Code Here

      FilePersistenceDataCorruptedException,
      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {
    logger.info("get item " + itemNumber);
    transaction.join();
    final Item item = (Item) transaction.getObject(ITEM + itemNumber);
    final Item detachedItem = item.clone();
    transaction.quit();
    logger.info("item read " + detachedItem);
    return detachedItem;
  }
View Full Code Here

      FilePersistenceDataCorruptedException,
      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {
    logger.info("remove item " + itemNumber);
    transaction.join();
    final Item item = (Item) transaction.removeObject(ITEM + itemNumber);
    final Item detachedItem = item.clone();
    transaction.quit();
    logger.info("item removed " + detachedItem);
    return detachedItem;
  }
View Full Code Here

    threadStopped = false;
    final Thread thread = new Thread(new Runnable() {
      @Override
      public void run() {
        for (int index = 0; inThreadThrowable == null && index < 5; index++) {
          final Item item = new Item();
          item.setValue(EMPTY_STRING + index);// NOPMD
          try {
            session.setObject(ITEM + index, item);
          } catch (final Throwable throwable) {// NOPMD
            inThreadThrowable = throwable;
          }
        }
        synchronized (mutex) {
          threadStopped = true;
          mutex.notifyAll();// NOPMD
        }
      }
    });
    thread.start();
    for (int index = 5; inThreadThrowable == null && index < 10; index++) {
      final Item item = new Item();// NOPMD
      item.setValue(EMPTY_STRING + index);// NOPMD
      session.setObject(ITEM + index, item);
    }
    synchronized (mutex) {
      while (!threadStopped) {
        mutex.wait();
      }
    }
    if (inThreadThrowable != null) {
      throw inThreadThrowable;
    }
    session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);

    session.open();
    for (int index = 0; index < 10; index++) {
      final Item item = (Item) session.getObject(ITEM + index);
      assertNotNull("must have an object " + index, item);
      assertEquals("not expected value for item", EMPTY_STRING + index,
          item.getValue());
    }
    session.close(EnumFilePersistenceCloseAction.DO_NOT_SAVE);
  }
View Full Code Here

TOP

Related Classes of net.sf.joafip.entity.Item

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.