directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r905623 - /directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
Date Tue, 02 Feb 2010 13:20:14 GMT
Author: kayyagari
Date: Tue Feb  2 13:20:12 2010
New Revision: 905623

URL: http://svn.apache.org/viewvc?rev=905623&view=rev
Log:
o extracted the bind DN as a constant
o added a test to demonstrate the search problem while searching based on entryUUID AT

Modified:
    directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java

Modified: directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java?rev=905623&r1=905622&r2=905623&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
(original)
+++ directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
Tue Feb  2 13:20:12 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.client.api;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -37,9 +38,14 @@
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.cursor.Cursor;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -59,6 +65,8 @@
 public class LdapConnectionTest extends AbstractLdapTestUnit
 {
     
+    private static final String ADMIN_DN = "uid=admin,ou=system";
+
     private LdapConnection connection;
     
     
@@ -66,7 +74,7 @@
     public void bindConnection() throws Exception
     {
         connection = new LdapConnection( "localhost", ldapServer.getPort() );
-        connection.bind( "uid=admin,ou=system", "secret" );
+        connection.bind( ADMIN_DN, "secret" );
     }
     
     
@@ -88,7 +96,7 @@
         LdapConnection connection = new LdapConnection( "localhost", ldapServer.getPort()
);
         try
         {
-            BindResponse bindResponse = connection.bind( "uid=admin,ou=system", "secret"
);
+            BindResponse bindResponse = connection.bind( ADMIN_DN, "secret" );
             
             assertNotNull( bindResponse );
             
@@ -128,15 +136,36 @@
     @Test
     public void testLookup() throws Exception
     {
-        SearchResponse resp = connection.lookup( "uid=admin,ou=system" );
+        SearchResponse resp = connection.lookup( ADMIN_DN );
         assertNotNull( resp );
         
         Entry entry = ( ( SearchResultEntry ) resp ).getEntry();
         assertNull( entry.get( SchemaConstants.ENTRY_UUID_AT ) );
 
         // perform lookup with operational attributes
-        resp = connection.lookup( "uid=admin,ou=system", "+", "*" );
+        resp = connection.lookup( ADMIN_DN, "+", "*" );
         entry = ( ( SearchResultEntry ) resp ).getEntry();
         assertNotNull( entry.get( SchemaConstants.ENTRY_UUID_AT ) );
     }
+    
+
+    @Ignore( "failing to lookup an existing entry based on the entryUUID AT" )
+    @Test
+    public void searchByEntryUuid() throws Exception
+    {
+        SearchResponse resp = connection.lookup( ADMIN_DN, "+" );
+        Entry entry = ( ( SearchResultEntry ) resp ).getEntry();
+        
+        String uuid = entry.get( SchemaConstants.ENTRY_UUID_AT ).getString();
+        
+        EqualityNode<String> filter = new EqualityNode<String>( SchemaConstants.ENTRY_UUID_AT,
new ClientStringValue( uuid ) );
+        
+        Cursor<SearchResponse> cursor = connection.search( ADMIN_DN, filter.toString(),
SearchScope.SUBTREE, "+" );
+        cursor.next();
+
+        Entry readEntry = ( ( SearchResultEntry ) cursor.get() ).getEntry();
+        assertEquals( uuid, readEntry.get( SchemaConstants.ENTRY_UUID_AT ).getString() );
+        
+        cursor.close();
+    }
 }



Mime
View raw message