directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r923665 - /directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
Date Tue, 16 Mar 2010 10:20:34 GMT
Author: elecharny
Date: Tue Mar 16 10:20:34 2010
New Revision: 923665

URL: http://svn.apache.org/viewvc?rev=923665&view=rev
Log:
Added a test for searches with returning attributes

Added:
    directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java

Added: directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java?rev=923665&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
(added)
+++ directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
Tue Mar 16 10:20:34 2010
@@ -0,0 +1,134 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.shared.client.api.operations.search;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.future.SearchFuture;
+import org.apache.directory.ldap.client.api.message.SearchRequest;
+import org.apache.directory.ldap.client.api.message.SearchResponse;
+import org.apache.directory.ldap.client.api.message.SearchResultDone;
+import org.apache.directory.ldap.client.api.message.SearchResultEntry;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.annotations.ApplyLdifs;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.cursor.Cursor;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.name.DN;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * TODO ClientSearchRequestTest.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer(
+    transports = 
+        {
+          @CreateTransport(protocol = "LDAP"), 
+          @CreateTransport(protocol = "LDAPS") 
+        })
+@ApplyLdifs({
+    "dn: cn=user1,ou=users,ou=system",
+    "objectClass: person",
+    "objectClass: top",
+    "sn: user1 sn",
+    "cn: user1",
+    
+    // alias to the above entry
+    "dn: cn=user1-alias,ou=users,ou=system",
+    "objectClass: alias",
+    "objectClass: top",
+    "objectClass: extensibleObject",
+    "aliasedObjectName: cn=user1,ou=users,ou=system",
+    "cn: user1-alias"
+})
+public class SearchRequestReturningAttributesTest extends AbstractLdapTestUnit
+{
+    private LdapConnection connection;
+
+    @Before
+    public void setup() throws Exception
+    {
+        connection = new LdapConnection( "localhost", ldapServer.getPort() );
+        DN bindDn = new DN( "uid=admin,ou=system" );
+        connection.bind( bindDn.getName(), "secret" );
+    }
+
+
+    /**
+     * Close the LdapConnection
+     */
+    @After
+    public void shutdown()
+    {
+        try
+        {
+            if ( connection != null )
+            {
+                connection.close();
+            }
+        }
+        catch ( Exception ioe )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * Test a search requesting all the attributes (* and +)
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testSearchAll() throws Exception
+    {
+        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system",
"(objectclass=*)", SearchScope.OBJECT, "*",
+            "+" );
+        int count = 0;
+        
+        while ( cursor.next() )
+        {
+            SearchResponse response = cursor.get();
+            assertNotNull( response );
+            count++;
+        }
+
+        assertEquals( 1, count );
+    }
+}



Mime
View raw message