Package net.sf.joafip.kvstore.record.entity

Examples of net.sf.joafip.kvstore.record.entity.RecordForTest


  }

  @Override
  protected void setUp() throws Exception {// NOPMD
    super.setUp();
    final RecordForTest heapHeader = new RecordForTest(heapElementManager,
        0L, RECORD_SIZE, -1);
    heapHeader.setValue(HEAP_HEADER_VALUE);
    heapElementManager.setHeapHeader(heapHeader);
  }
View Full Code Here


   */
  public void testEmptyHeap() throws HeapException {// NOPMD assertion in
    // method called

    /* new heap header creation and write with check */
    final RecordForTest heapHeader = appendHeaderInEmptyFile();

    /* check the wrote header */
    heapElementManager.startService();
    heapElementManager.openTransaction();
    getHeapHeaderAndCheckPosition(heapHeader);
 
View Full Code Here

   * @throws RBTException
   *
   */
  public void testChangeHeader() throws HeapException, RBTException {
    /* new heap header creation and write with check */
    final RecordForTest heapHeader1 = appendHeaderInEmptyFile();

    /* then read header */
    heapElementManager.startService();
    heapElementManager.openTransaction();
    final RecordForTest heapHeader2 = getHeapHeaderAndCheckPosition(heapHeader1);
    heapHeader2.setValue(HEAP_HEADER_VALUE - 1);
    /* write modifications */
    heapElementManager.closeTransaction();

    /* read the last modification */
    heapElementManager.openTransaction();
    final RecordForTest heapHeader3 = getHeapHeaderAndCheckPosition(heapHeader2);
    /* check modifications */
    assertEquals("bad value", HEAP_HEADER_VALUE - 1, heapHeader3.getValue());// NOPMD

    heapElementManager.closeTransaction();
    heapElementManager.stopService();
  }
View Full Code Here

    heapElementManager.startService();
    appendRecords();
    // check
    heapElementManager.openTransaction();
    for (int recordNumber = 0; recordNumber < 100; recordNumber++) {
      final RecordForTest heapRecord = (RecordForTest) heapElementManager
          .readHeapFileDataRecord(RECORD_SIZE * (recordNumber + 1));
      assertEquals("bad value", recordNumber, heapRecord.getValue());
    }
    heapElementManager.closeTransaction();
    heapElementManager.stopService();
  }
View Full Code Here

    heapElementManager.startService();
    appendRecords();
    // update
    heapElementManager.openTransaction();
    final int recordNumber = 50;
    RecordForTest heapRecord = new RecordForTest(heapElementManager,
        RECORD_SIZE * (recordNumber + 1), RECORD_SIZE, RECORD_SIZE
            * recordNumber);
    heapRecord.setValue(-recordNumber);
    heapElementManager.appendHeapFileRecord(heapRecord);
    heapElementManager.closeTransaction();
    // check update
    heapElementManager.openTransaction();
    heapRecord = (RecordForTest) heapElementManager
        .readHeapFileDataRecord(RECORD_SIZE * (recordNumber + 1));
    assertEquals("bad value", -recordNumber, heapRecord.getValue());
    heapElementManager.closeTransaction();
    heapElementManager.stopService();
  }
View Full Code Here

    heapElementManager.startService();
    appendRecords();
    // update
    heapElementManager.openTransaction();
    final int recordNumber = 50;
    RecordForTest heapRecord = new RecordForTest(heapElementManager,
        RECORD_SIZE * (recordNumber + 1), RECORD_SIZE, RECORD_SIZE
            * recordNumber);
    heapRecord.setValue(-recordNumber);
    heapElementManager.appendHeapFileRecord(heapRecord);
    heapElementManager.delete(RECORD_SIZE * (recordNumber + 1));
    heapElementManager.closeTransaction();
    // check update
    heapElementManager.openTransaction();
    heapRecord = (RecordForTest) heapElementManager
        .readHeapFileDataRecord(RECORD_SIZE * (recordNumber + 1));
    assertEquals("bad value", recordNumber, heapRecord.getValue());

    heapElementManager.closeTransaction();
    heapElementManager.stopService();
  }
View Full Code Here

    heapElementManager.startService();
    appendRecords();
    // update
    heapElementManager.openTransaction();
    int recordNumber = 50;
    RecordForTest heapRecord = new RecordForTest(heapElementManager,
        RECORD_SIZE * (recordNumber + 1), RECORD_SIZE, RECORD_SIZE
            * recordNumber);
    heapRecord.setValue(-recordNumber);
    heapElementManager.appendHeapFileRecord(heapRecord);
    heapElementManager.closeTransactionDiscardChange();
    // check
    heapElementManager.openTransaction();
    for (recordNumber = 0; recordNumber < 100; recordNumber++) {
      heapRecord = (RecordForTest) heapElementManager
          .readHeapFileDataRecord(RECORD_SIZE * (recordNumber + 1));
      assertEquals("bad value", recordNumber, heapRecord.getValue());
    }
    heapElementManager.closeTransaction();
    heapElementManager.stopService();
  }
View Full Code Here

   *
   */
  private RecordForTest appendHeaderInEmptyFile() throws HeapException {
    heapElementManager.startService();
    heapElementManager.openTransaction();
    final RecordForTest heapHeader1 = getHeapHeaderAndCheckPosition(null);
    assertEquals("bad value", HEAP_HEADER_VALUE, heapHeader1.getValue());
    assertFalse("created header must be saved",
        heapHeader1.isValueChangedToSave());
    heapElementManager.closeTransaction();
    heapElementManager.stopService();
    assertFalse("saving implies no more value changed",
        heapHeader1.isValueChangedToSave());
    assertFalse("just created must be false", heapHeader1.isJustCreated());
    return heapHeader1;
  }
View Full Code Here

   * @return heap header
   * @throws HeapException
   */
  private RecordForTest getHeapHeaderAndCheckPosition(
      final RecordForTest heapHeaderReference) throws HeapException {
    final RecordForTest heapHeader = (RecordForTest) heapElementManager
        .getHeapHeader();
    assertEquals("header must be at file beginning", 0,
        heapHeader.getPositionInFile());
    if (heapHeaderReference != null) {
      assertEquals("wrote and read must be equals", heapHeaderReference,
          heapHeader);
    }
    return heapHeader;
View Full Code Here

  }

  private void appendRecords() throws HeapException {
    heapElementManager.openTransaction();
    for (int recordNumber = 0; recordNumber < 100; recordNumber++) {
      @SuppressWarnings("PMD")
      final RecordForTest heapRecord = new RecordForTest(
          heapElementManager, RECORD_SIZE * (recordNumber + 1),
          RECORD_SIZE, RECORD_SIZE * recordNumber);
      heapRecord.setValue(recordNumber);
      heapElementManager.appendHeapFileRecord(heapRecord);
    }
    heapElementManager.closeTransaction();
  }
 
View Full Code Here

TOP

Related Classes of net.sf.joafip.kvstore.record.entity.RecordForTest

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.