public void testCount() throws Exception
{
initIndex();
assertEquals( 0, idx.count() );
ParentIdAndRdn key = new ParentIdAndRdn( Strings.getUUID( 0L ), new Rdn( "cn=key" ) );
idx.add( key, Strings.getUUID( 0L ) );
assertEquals( 1, idx.count() );
// setting a different parentId should make this key a different key
key = new ParentIdAndRdn( Strings.getUUID( 1L ), new Rdn( "cn=key" ) );
idx.add( key, Strings.getUUID( 1L ) );
assertEquals( 2, idx.count() );
//count shouldn't get affected cause of inserting the same key
try
{
// We should not be able to add a new value to an existing key
idx.add( key, Strings.getUUID( 2L ) );
fail();
}
catch ( DuplicateValueNotAllowedException dvnae )
{
// expected
}
assertEquals( 2, idx.count() );
key = new ParentIdAndRdn( Strings.getUUID( 2L ), new Rdn( "cn=key" ) );
idx.add( key, Strings.getUUID( 3L ) );
assertEquals( 3, idx.count() );
}