@Test
public void testNonIndexedServerEntry() throws Exception
{
PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "sn" ) );
PresenceEvaluator evaluator = new PresenceEvaluator( node, store, schemaManager );
PresenceCursor cursor = new PresenceCursor( store, evaluator );
assertEquals( node, evaluator.getExpression() );
cursor.beforeFirst();
Set<String> set = new HashSet<String>();
while ( cursor.next() )
{
assertTrue( cursor.available() );
assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getKey() );
set.add( cursor.get().getId() );
}
assertEquals( 3, set.size() );
assertTrue( set.contains( Strings.getUUID( 5L ) ) );
assertTrue( set.contains( Strings.getUUID( 6L ) ) );
assertTrue( set.contains( Strings.getUUID( 8L ) ) );
assertFalse( cursor.next() );
assertFalse( cursor.available() );
// test first()
cursor.first();
assertTrue( cursor.available() );
assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getKey() );
// test last()
cursor.last();
assertTrue( cursor.available() );
assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getKey() );
// test beforeFirst()
cursor.beforeFirst();
assertFalse( cursor.available() );
assertTrue( cursor.next() );
assertTrue( cursor.available() );
assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getKey() );
// test afterLast()
set.clear();
cursor.afterLast();
assertFalse( cursor.available() );
while ( cursor.previous() )
{
assertTrue( cursor.available() );
assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getKey() );
set.add( cursor.get().getId() );
}
assertEquals( 3, set.size() );
assertTrue( set.contains( Strings.getUUID( 5L ) ) );
assertTrue( set.contains( Strings.getUUID( 6L ) ) );
assertTrue( set.contains( Strings.getUUID( 8L ) ) );
assertFalse( cursor.previous() );
assertFalse( cursor.available() );
cursor.close();
// ----------- organizationName attribute
node = new PresenceNode( schemaManager.getAttributeType( "o" ) );
evaluator = new PresenceEvaluator( node, store, schemaManager );
cursor = new PresenceCursor( store, evaluator );
cursor.beforeFirst();
assertTrue( cursor.next() );
assertTrue( cursor.available() );