@Test
public void testIndexedServerEntry() throws Exception
{
PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "cn" ) );
PresenceEvaluator evaluator = new PresenceEvaluator( node, store, schemaManager );
PresenceCursor cursor = new PresenceCursor( store, evaluator );
assertEquals( node, evaluator.getExpression() );
cursor.beforeFirst();
assertTrue( cursor.next() );
assertTrue( cursor.available() );
assertEquals( Strings.getUUID( 5 ), cursor.get().getId() );
assertTrue( cursor.next() );
assertTrue( cursor.available() );
assertEquals( Strings.getUUID( 6 ), cursor.get().getId() );
assertTrue( cursor.next() );
assertTrue( cursor.available() );
assertEquals( Strings.getUUID( 8 ), cursor.get().getId() );
assertTrue( cursor.next() );
assertTrue( cursor.available() );
assertEquals( Strings.getUUID( 9 ), cursor.get().getId() );
assertTrue( cursor.next() );
assertTrue( cursor.available() );
assertEquals( Strings.getUUID( 10 ), cursor.get().getId() );
assertTrue( cursor.next() );
assertTrue( cursor.available() );
assertEquals( Strings.getUUID( 11 ), cursor.get().getId() );
assertFalse( cursor.next() );
assertFalse( cursor.available() );
// test first()
cursor.first();
assertTrue( cursor.available() );
assertEquals( SchemaConstants.CN_AT_OID, cursor.get().getKey() );
// test last()
cursor.last();
assertTrue( cursor.available() );
assertEquals( SchemaConstants.CN_AT_OID, cursor.get().getKey() );
// test beforeFirst()
cursor.beforeFirst();
assertFalse( cursor.available() );
assertTrue( cursor.next() );
assertTrue( cursor.available() );
assertEquals( SchemaConstants.CN_AT_OID, cursor.get().getKey() );
// test afterLast()
cursor.afterLast();
assertFalse( cursor.available() );
assertTrue( cursor.previous() );
assertTrue( cursor.available() );
assertEquals( SchemaConstants.CN_AT_OID, cursor.get().getKey() );
// test before()
IndexEntry<String, String> entry = new IndexEntry<String, String>();
entry.setKey( SchemaConstants.CN_AT_OID );
cursor.before( entry );
assertTrue( cursor.next() );
assertTrue( cursor.available() );
assertEquals( SchemaConstants.CN_AT_OID, cursor.get().getKey() );
// test after()
entry = new IndexEntry<String, String>();
cursor.after( entry );
assertTrue( cursor.previous() );
assertTrue( cursor.available() );
assertEquals( SchemaConstants.CN_AT_OID, cursor.get().getKey() );
cursor.close();
node = new PresenceNode( schemaManager.getAttributeType( "ou" ) );
evaluator = new PresenceEvaluator( node, store, schemaManager );
cursor = new PresenceCursor( store, evaluator );
cursor.beforeFirst();
assertTrue( cursor.next() );
assertTrue( cursor.available() );