RuleEntry { static void deleteAidHash(byte[] buf, short aidOfs, byte aidLen, short hashOfs, byte hashLen) { RuleEntry re = searchAidHash(buf, aidOfs, aidLen, hashOfs, hashLen); while (re != null) { JCSystem.beginTransaction(); re.remove(); re.recycle(); JCSystem.commitTransaction(); re = searchAidHash(buf, aidOfs, aidLen, hashOfs, hashLen); } } 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 deleteAidHashTest() throws NoSuchFieldException, IllegalAccessException { assertEquals("init length", 0, getLength()); addItem(AID_BASIC, HASH_BASIC, RULE_BASIC); assertEquals("length after addition", 1, getLength()); deleteAidHash(TestUtils.concatByteArray(AID_BASIC, HASH_BASIC), (short) 0, (byte) AID_BASIC.length, (short) AID_BASIC.length, (byte) HASH_BASIC.length); assertEquals("length after deletion", 0, getLength()); }
@Test public void deleteAidHashWrongHashTest() throws NoSuchFieldException, IllegalAccessException { assertEquals("init length", 0, getLength()); addItem(AID_BASIC, HASH_BASIC, RULE_BASIC); assertEquals("length after addition", 1, getLength()); deleteAidHash(TestUtils.concatByteArray(AID_BASIC, HASH_BASIC1), (short) 0, (byte) AID_BASIC.length, (short) AID_BASIC.length, (byte) HASH_BASIC1.length); assertEquals("length after deletion", 1, getLength()); }
@Test public void deleteAidHashMultipleTest() 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()); deleteAidHash(TestUtils.concatByteArray(AID_BASIC, HASH_BASIC), (short) 0, (byte) AID_BASIC.length, (short) AID_BASIC.length, (byte) HASH_BASIC.length); deleteAidHash(TestUtils.concatByteArray(AID_BASIC1, HASH_BASIC1), (short) 0, (byte) AID_BASIC1.length, (short) AID_BASIC1.length, (byte) HASH_BASIC1.length); deleteAidHash(TestUtils.concatByteArray(AID_BASIC2, HASH_BASIC2), (short) 0, (byte) AID_BASIC2.length, (short) AID_BASIC2.length, (byte) HASH_BASIC2.length); deleteAidHash(TestUtils.concatByteArray(AID_BASIC3, HASH_BASIC3), (short) 0, (byte) AID_BASIC3.length, (short) AID_BASIC3.length, (byte) HASH_BASIC3.length); assertEquals("length after deletion", 0, getLength()); }
@Test public void deleteAidHashMultipleNonEmptyTest() throws NoSuchFieldException, IllegalAccessException { addItem(AID_BASIC1, HASH_BASIC, RULE_BASIC); addItem(AID_BASIC, HASH_BASIC, RULE_BASIC1); addItem(AID_BASIC, HASH_BASIC, RULE_BASIC); deleteAidHash(TestUtils.concatByteArray(AID_BASIC, HASH_BASIC), (short) 0, (byte) AID_BASIC.length, (short) AID_BASIC.length, (byte) HASH_BASIC.length); assertEquals("length after deletion", 1, getLength()); }
@Test public void deleteAidHashMultipleSameTest() throws NoSuchFieldException, IllegalAccessException { addItem(AID_BASIC, HASH_BASIC, RULE_BASIC); addItem(AID_BASIC, HASH_BASIC, RULE_BASIC1); addItem(AID_BASIC, HASH_BASIC, RULE_BASIC2); addItem(AID_BASIC, HASH_BASIC, RULE_BASIC3); assertEquals("init length", 4, getLength()); deleteAidHash(TestUtils.concatByteArray(AID_BASIC, HASH_BASIC), (short) 0, (byte) AID_BASIC.length, (short) AID_BASIC.length, (byte) HASH_BASIC.length); assertEquals("length after deletion", 0, getLength()); }