package data.io.ldap; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import data.MVDataEntry; public class LDAPDataReaderTest { LDAPConnectionWrapper builder; @Before public void setup() { builder = new LDAPConnectionWrapper("localhost", 389, "uid=ldapadmin,ou=specialUsers,dc=univ-jfc,dc=fr", "secret"); } /* @Test public void testLookAhead1() { _testLookAhead(1); } */ @Test public void testLookAhead16() { _testLookAhead(16); } @Test public void testLookAhead32() { _testLookAhead(32); } @Test public void testLookAhead64() { _testLookAhead(64); } @Test public void testLookAhead128() { _testLookAhead(128); } @Test public void testLookAhead192() { _testLookAhead(192); } @Test public void testLookAhead256() { _testLookAhead(256); } @Test public void testLookAhead512() { _testLookAhead(512); } @Test public void testLookAhead1024() { _testLookAhead(1024); } private void _testLookAhead(int lookAheadAmount) { System.out.println("_testLookAhead("+lookAheadAmount+")"); LDAPFlatDataReader reader = builder.newFlatReader("ldap_test", "ou=people,dc=univ-jfc,dc=fr", "uid", lookAheadAmount); int resultCount = 0; String previousKey=null; for ( MVDataEntry entry : reader ) { //System.out.println(entry); if ( previousKey != null ) assertTrue(entry.getKey().compareTo(previousKey) > 0); resultCount++; previousKey=entry.getKey(); } System.out.println(resultCount); assertTrue(resultCount>0); // Second time with a second iterator (must give the same results) int newResultCount = 0; previousKey=null; for ( MVDataEntry entry : reader ) { //System.out.println(entry); if ( previousKey != null ) assertTrue(entry.getKey().compareTo(previousKey) > 0); newResultCount++; previousKey=entry.getKey(); } System.out.println(newResultCount); assertTrue(newResultCount == resultCount); } }