directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r795423 - in /directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations: ClientAddRequestTest.java ClientCompareRequestTest.java
Date Sat, 18 Jul 2009 19:32:43 GMT
Author: kayyagari
Date: Sat Jul 18 19:32:43 2009
New Revision: 795423

URL: http://svn.apache.org/viewvc?rev=795423&view=rev
Log:
o test case for compare operation
o fixed a typo in the method names of add operation test case

Added:
    directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
Modified:
    directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java

Modified: directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java?rev=795423&r1=795422&r2=795423&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
(original)
+++ directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
Sat Jul 18 19:32:43 2009
@@ -75,7 +75,7 @@
     
     
     @Test
-    public void testModify() throws Exception
+    public void testAdd() throws Exception
     {
         LdapDN dn = new LdapDN( "cn=testadd,ou=system" );
         Entry entry = new DefaultClientEntry( dn ); 
@@ -94,7 +94,7 @@
 
     
     @Test
-    public void testModifyAsync() throws Exception
+    public void testAddAsync() throws Exception
     {
         LdapDN dn = new LdapDN( "cn=testAsyncAdd,ou=system" );
         Entry entry = new DefaultClientEntry( dn ); 

Added: directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java?rev=795423&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
(added)
+++ directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
Sat Jul 18 19:32:43 2009
@@ -0,0 +1,115 @@
+/*
+ *  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;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.concurrent.Semaphore;
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import org.apache.directory.server.integ.SiRunner;
+import org.apache.directory.server.ldap.LdapServer;
+import org.apache.directory.shared.ldap.client.api.LdapConnection;
+import org.apache.directory.shared.ldap.client.api.exception.LdapException;
+import org.apache.directory.shared.ldap.client.api.listeners.CompareListener;
+import org.apache.directory.shared.ldap.client.api.messages.CompareRequest;
+import org.apache.directory.shared.ldap.client.api.messages.CompareResponse;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests the compare operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith(SiRunner.class)
+@CleanupLevel(Level.CLASS)
+public class ClientCompareRequestTest
+{
+    /** The server instance */
+    public static LdapServer ldapServer;
+
+    private LdapConnection connection;
+    
+    private CoreSession session;
+    
+    @Before
+    public void setup() throws Exception
+    {
+        connection = new LdapConnection( "localhost", ldapServer.getPort() );
+        LdapDN bindDn = new LdapDN( "uid=admin,ou=system" );
+        connection.bind( bindDn.getUpName(), "secret" );
+        
+        session = ldapServer.getDirectoryService().getSession();
+    }
+    
+    
+    @Test
+    public void testCompare() throws Exception
+    {
+        LdapDN dn = new LdapDN( "uid=admin,ou=system" );
+        
+        CompareResponse response = connection.compare( dn, SchemaConstants.UID_AT, "admin"
);
+        assertNotNull( response );
+        assertTrue( response.isTrue() );
+        
+        response = connection.compare( dn.getUpName(), SchemaConstants.USER_PASSWORD_AT,
"secret".getBytes() );
+        assertNotNull( response );
+        assertTrue( response.isTrue() );
+    }
+
+    
+    @Test
+    public void testCompareAsync() throws Exception
+    {
+        LdapDN dn = new LdapDN( "uid=admin,ou=system" );
+
+        final Semaphore lock = new Semaphore( 1 );
+        lock.acquire();
+        CompareRequest compareRequest = new CompareRequest();
+        compareRequest.setEntryDn( dn );
+        compareRequest.setAttrName( SchemaConstants.UID_AT );
+        compareRequest.setValue( "admin" );
+        
+        connection.compare( compareRequest, new CompareListener()
+        {
+            
+            public void attributeCompared( LdapConnection connection, CompareResponse response
) throws LdapException
+            {
+                assertNotNull( response );
+                assertTrue( response.isTrue() );
+                lock.release();
+            }
+        });
+
+        lock.acquire();
+        assertTrue( session.exists( dn ) );
+    }
+}



Mime
View raw message