Ejemplo n.º 1
0
 /**
  * Test the whether setting of one set of values does not affect another set of values
  *
  * @throws Exception
  */
 public void testAllOperationsValidatingResult1() {
   DiskId did = getDiskId();
   for (int i = -16777215; i < 16777215; i++) {
     boolean boolValuePerIteration = false;
     did.setOplogId(i);
     // set true for even, set false for odd
     switch ((i % 3)) {
       case 0:
         boolValuePerIteration = true;
         break;
       case 1:
       case 2:
         boolValuePerIteration = false;
         break;
     }
     byte userbits = 0;
     switch (i % 4) {
       case 0:
         break;
       case 1:
         did.setUserBits(EntryBits.setSerialized(userbits, boolValuePerIteration));
         break;
       case 2:
         did.setUserBits(EntryBits.setInvalid(userbits, boolValuePerIteration));
         break;
       case 3:
         did.setUserBits(EntryBits.setLocalInvalid(userbits, boolValuePerIteration));
         break;
     }
     assertEquals(did.getOplogId(), i);
     byte userBits2 = did.getUserBits();
     switch (i % 4) {
       case 0:
         break;
       case 1:
         assertEquals(EntryBits.isSerialized(userBits2), boolValuePerIteration);
         break;
       case 2:
         assertEquals(EntryBits.isInvalid(userBits2), boolValuePerIteration);
         break;
       case 3:
         assertEquals(EntryBits.isLocalInvalid(userBits2), boolValuePerIteration);
         break;
     }
   }
 }
Ejemplo n.º 2
0
  /**
   * Test the getUserbits returns what has been set
   *
   * @throws Exception
   */
  public void testGetSetUserBits() throws Exception {
    DiskId did = getDiskId();
    byte userBits = 0;
    userBits = EntryBits.setSerialized(userBits, true);
    did.setUserBits(userBits);
    assertEquals(userBits, did.getUserBits());
    userBits = EntryBits.setInvalid(userBits, true);
    did.setUserBits(userBits);
    assertEquals(userBits, did.getUserBits());
    userBits = EntryBits.setLocalInvalid(userBits, true);
    did.setUserBits(userBits);
    assertEquals(userBits, did.getUserBits());
    assertTrue(EntryBits.isSerialized(userBits));
    assertTrue(EntryBits.isInvalid(userBits));
    assertTrue(EntryBits.isLocalInvalid(userBits));
    userBits = EntryBits.setSerialized(userBits, false);
    did.setUserBits(userBits);
    assertEquals(userBits, did.getUserBits());
    userBits = EntryBits.setInvalid(userBits, false);
    did.setUserBits(userBits);
    assertEquals(userBits, did.getUserBits());
    userBits = EntryBits.setLocalInvalid(userBits, false);
    did.setUserBits(userBits);
    assertFalse(EntryBits.isSerialized(userBits));
    assertFalse(EntryBits.isInvalid(userBits));
    assertFalse(EntryBits.isLocalInvalid(userBits));

    userBits = 0x0;
    userBits = EntryBits.setSerialized(userBits, true);
    did.setUserBits(userBits);
    assertTrue(EntryBits.isSerialized(userBits));
    assertFalse(EntryBits.isInvalid(userBits));
    assertFalse(EntryBits.isLocalInvalid(userBits));

    userBits = 0x0;
    userBits = EntryBits.setInvalid(userBits, true);
    did.setUserBits(userBits);
    assertFalse(EntryBits.isSerialized(userBits));
    assertTrue(EntryBits.isInvalid(userBits));
    assertFalse(EntryBits.isLocalInvalid(userBits));

    userBits = 0x0;
    userBits = EntryBits.setLocalInvalid(userBits, true);
    did.setUserBits(userBits);
    assertFalse(EntryBits.isSerialized(userBits));
    assertFalse(EntryBits.isInvalid(userBits));
    assertTrue(EntryBits.isLocalInvalid(userBits));

    userBits = 0x0;
    userBits = EntryBits.setTombstone(userBits, true);
    userBits = EntryBits.setWithVersions(userBits, true);
    did.setUserBits(userBits);
    assertFalse(EntryBits.isLocalInvalid(userBits));
    assertFalse(EntryBits.isSerialized(userBits));
    assertFalse(EntryBits.isInvalid(userBits));
    assertTrue(EntryBits.isTombstone(userBits));
    assertTrue(EntryBits.isWithVersions(userBits));
  }