RuleEntry { static void deleteAid(byte[] buf, short ofs, byte len) { RuleEntry re = searchAid(buf, ofs, len); while (re != null) { JCSystem.beginTransaction(); re.remove(); re.recycle(); JCSystem.commitTransaction(); re = searchAid(buf, ofs, len); } } private  RuleEntry(); static RuleEntry getFirst(); byte getAidLength(); byte getHashLength(); byte getRuleLength(); RuleEntry getNext(); void setAid(byte[] buf, short ofs, byte len); void setHash(byte[] buf, short ofs, byte len); void setRule(byte[] buf, short ofs, byte len);  }
@Test public void checkRecycledItem() throws NoSuchFieldException, IllegalAccessException { assertNull("no item to recycle", getDeleted()); addItem(AID_BASIC, HASH_BASIC, RULE_BASIC); deleteAid(AID_BASIC); assertNotNull("1 item to recycle", getDeleted()); }
@Test public void interTwinedAddDelete() throws NoSuchFieldException, IllegalAccessException { for (int i = 0; i < 10; i++) { assertEquals("init length, iteration n°" + i, 0, getLength()); addItem(AID_BASIC, HASH_BASIC, RULE_BASIC); assertEquals("length after addition, iteration n°" + i, 1, getLength()); deleteAid(AID_BASIC); assertEquals("length after deletion, iteration n°" + i, 0, getLength()); } }
@Test public void deleteAidTest() throws NoSuchFieldException, IllegalAccessException { assertEquals("init length", 0, getLength()); addItem(AID_BASIC, HASH_BASIC, RULE_BASIC); assertEquals("length after addition", 1, getLength()); deleteAid(AID_BASIC); assertEquals("length after deletion", 0, getLength()); }
@Test public void deleteAidMultipleTest() throws NoSuchFieldException, IllegalAccessException { addItem(AID_BASIC, HASH_BASIC, RULE_BASIC); addItem(AID_BASIC1, HASH_BASIC1, RULE_BASIC1); addItem(AID_BASIC2, HASH_BASIC2, RULE_BASIC2); addItem(AID_BASIC3, HASH_BASIC3, RULE_BASIC3); assertEquals("init length", 4, getLength()); deleteAid(AID_BASIC); deleteAid(AID_BASIC1); deleteAid(AID_BASIC2); deleteAid(AID_BASIC3); assertEquals("length after deletion", 0, getLength()); }
@Test public void deleteAidMultipleNonEmptyTest() throws NoSuchFieldException, IllegalAccessException { addItem(AID_BASIC1, HASH_BASIC, RULE_BASIC); addItem(AID_BASIC, HASH_BASIC1, RULE_BASIC1); addItem(AID_BASIC, HASH_BASIC, RULE_BASIC); deleteAid(AID_BASIC); assertEquals("length after deletion", 1, getLength()); }
@Test public void deleteAidMultipleSameTest() throws NoSuchFieldException, IllegalAccessException { addItem(AID_BASIC, HASH_BASIC, RULE_BASIC); addItem(AID_BASIC, HASH_BASIC1, RULE_BASIC1); addItem(AID_BASIC, HASH_BASIC2, RULE_BASIC2); addItem(AID_BASIC, HASH_BASIC3, RULE_BASIC3); assertEquals("init length", 4, getLength()); deleteAid(AID_BASIC); assertEquals("length after deletion", 0, getLength()); }