directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1201932 - in /directory/apacheds/trunk: ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/
Date Mon, 14 Nov 2011 22:14:08 GMT
Author: elecharny
Date: Mon Nov 14 22:14:08 2011
New Revision: 1201932

URL: http://svn.apache.org/viewvc?rev=1201932&view=rev
Log:
Forgt to commit a test for getRootDse

Added:
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java
Modified:
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java

Added: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java?rev=1201932&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java
(added)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/GetRootDseTest.java
Mon Nov 14 22:14:08 2011
@@ -0,0 +1,257 @@
+/*
+ *   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 org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * A class to test the GetRootDse operation with a returningAttributes parameter
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
+public class GetRootDseTest extends AbstractLdapTestUnit
+{
+    private LdapNetworkConnection connection;
+
+
+    @Before
+    public void setup() throws Exception
+    {
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+    }
+
+
+    @After
+    public void shutdown() throws Exception
+    {
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer()
);
+    }
+
+
+    /**
+     * Test a                     if ( attributeType.getUsage() != UsageEnum.USER_APPLICATIONS
)
+lookup requesting all the attributes (* and +)
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testGetRootDse() throws Exception
+    {
+        Entry rootDse = connection.getRootDse();
+        
+        assertNotNull( rootDse );
+
+        assertEquals( 1, rootDse.size() );
+        assertTrue( rootDse.containsAttribute( "objectClass" ) );
+    }
+
+
+    /**
+     * Test a                     if ( attributeType.getUsage() != UsageEnum.USER_APPLICATIONS
)
+lookup requesting all the user attributes (*)
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testGetRooDseAllUserAttributes() throws Exception
+    {
+        Entry rootDse = connection.getRootDse( "*" );
+
+        assertNotNull( rootDse );
+
+        assertEquals( 1, rootDse.size() );
+        assertTrue( rootDse.containsAttribute( "objectClass" ) );
+    }
+
+
+    /**
+     * Test a lookup requesting all the operational attributes (+)
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testGetRooDseAllOperationalAttributes() throws Exception
+    {
+        Entry rootDse = connection.getRootDse( "+" );
+
+        assertNotNull( rootDse );
+        
+        assertEquals( 10, rootDse.size() );
+        assertTrue( rootDse.containsAttribute( "entryUUID" ) );
+        assertTrue( rootDse.containsAttribute( "namingContexts" ) );
+        assertTrue( rootDse.containsAttribute( "subschemaSubentry" ) );
+        assertTrue( rootDse.containsAttribute( "supportedControl" ) );
+        assertTrue( rootDse.containsAttribute( "supportedExtension" ) );
+        assertTrue( rootDse.containsAttribute( "supportedFeatures" ) );
+        assertTrue( rootDse.containsAttribute( "supportedLDAPVersion" ) );
+        assertTrue( rootDse.containsAttribute( "supportedSASLMechanisms" ) );
+        assertTrue( rootDse.containsAttribute( "vendorName" ) );
+        assertTrue( rootDse.containsAttribute( "vendorVersion" ) );
+    }
+
+
+    /**
+     * Test a lookup requesting a few attributes (Objectclass, vendorName and vendorVersion)
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testGetRooDseSelectedAttributes() throws Exception
+    {
+        Entry rootDse = connection.getRootDse( "objectClass", "vendorName", "vendorVersion"
);
+
+        assertNotNull( rootDse );
+        
+        assertEquals( 3, rootDse.size() );
+        assertTrue( rootDse.containsAttribute( "objectClass" ) );
+        assertTrue( rootDse.containsAttribute( "vendorName" ) );
+        assertTrue( rootDse.containsAttribute( "vendorVersion" ) );
+    }
+
+
+    /**
+     * Test a lookup requesting a few operational attributes (vendorName and vendorVersion)
+     * and all user attrinutes (*)
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testGetRooDseSomeOpAttributesAllUserAttributes() throws Exception
+    {
+        Entry rootDse = connection.getRootDse( "*", "vendorName", "vendorVersion" );
+
+        assertNotNull( rootDse );
+        
+        assertEquals( 3, rootDse.size() );
+        assertTrue( rootDse.containsAttribute( "objectClass" ) );
+        assertTrue( rootDse.containsAttribute( "vendorName" ) );
+        assertTrue( rootDse.containsAttribute( "vendorVersion" ) );
+    }
+
+
+    /**
+     * Test a lookup requesting a few user attributes (objectClass)
+     * and all operational attributes (+)
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testGetRooDseSomeUserAttributesAllOpAttributes() throws Exception
+    {
+        Entry rootDse = connection.getRootDse( "+", "Objectclass" );
+
+        assertNotNull( rootDse );
+        
+        assertEquals( 11, rootDse.size() );
+        assertTrue( rootDse.containsAttribute( "objectClass" ) );
+        assertTrue( rootDse.containsAttribute( "entryUUID" ) );
+        assertTrue( rootDse.containsAttribute( "namingContexts" ) );
+        assertTrue( rootDse.containsAttribute( "subschemaSubentry" ) );
+        assertTrue( rootDse.containsAttribute( "supportedControl" ) );
+        assertTrue( rootDse.containsAttribute( "supportedExtension" ) );
+        assertTrue( rootDse.containsAttribute( "supportedFeatures" ) );
+        assertTrue( rootDse.containsAttribute( "supportedLDAPVersion" ) );
+        assertTrue( rootDse.containsAttribute( "supportedSASLMechanisms" ) );
+        assertTrue( rootDse.containsAttribute( "vendorName" ) );
+        assertTrue( rootDse.containsAttribute( "vendorVersion" ) );
+    }
+
+
+    /**
+     * Test a                     if ( attributeType.getUsage() != UsageEnum.USER_APPLICATIONS
)
+lookup requesting a all user attributes (*)
+     * and all operational attributes (+)
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testGetRooDseAllUserAttributesAllOpAttributes() throws Exception
+    {
+        Entry rootDse = connection.getRootDse( "+", "*" );
+
+        assertNotNull( rootDse );
+        
+        assertEquals( 11, rootDse.size() );
+        assertTrue( rootDse.containsAttribute( "objectClass" ) );
+        assertTrue( rootDse.containsAttribute( "entryUUID" ) );
+        assertTrue( rootDse.containsAttribute( "namingContexts" ) );
+        assertTrue( rootDse.containsAttribute( "subschemaSubentry" ) );
+        assertTrue( rootDse.containsAttribute( "supportedControl" ) );
+        assertTrue( rootDse.containsAttribute( "supportedExtension" ) );
+        assertTrue( rootDse.containsAttribute( "supportedFeatures" ) );
+        assertTrue( rootDse.containsAttribute( "supportedLDAPVersion" ) );
+        assertTrue( rootDse.containsAttribute( "supportedSASLMechanisms" ) );
+        assertTrue( rootDse.containsAttribute( "vendorName" ) );
+        assertTrue( rootDse.containsAttribute( "vendorVersion" ) );
+    }
+
+
+    /**
+     * Test a lookup requesting no attributes (1.1)
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testGetRooDseNoAttribute() throws Exception
+    {
+        Entry rootDse = connection.getRootDse( "1.1" );
+
+        assertNotNull( rootDse );
+        
+        assertEquals( 0, rootDse.size() );
+    }
+
+
+    /**
+     * Test a lookup requesting no attributes (1.1) with some attributes
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testGetRooDseNoAttributeSomeUserAttributes() throws Exception
+    {
+        Entry rootDse = connection.getRootDse( "1.1", "objectClass" );
+
+        assertNotNull( rootDse );
+        
+        assertEquals( 1, rootDse.size() );
+        assertTrue( rootDse.containsAttribute( "objectClass" ) );
+    }
+}

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java?rev=1201932&r1=1201931&r2=1201932&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
Mon Nov 14 22:14:08 2011
@@ -820,8 +820,8 @@ public abstract class AbstractBTreeParti
      */
     public EntryFilteringCursor list( ListOperationContext listContext ) throws LdapException
     {
-        return new BaseEntryFilteringCursor( 
-            new EntryCursorAdaptor<ID>( this, 
+        return new BaseEntryFilteringCursor(
+            new EntryCursorAdaptor<ID>( this,
                 list( getEntryId( listContext.getDn() ) ) ), listContext );
     }
 
@@ -870,7 +870,7 @@ public abstract class AbstractBTreeParti
         }
         catch ( LdapException le )
         {
-            // TODO: SearchEngine.cursor() should only throw LdapException, then the exception
handling here can be removed 
+            // TODO: SearchEngine.cursor() should only throw LdapException, then the exception
handling here can be removed
             throw le;
         }
         catch ( Exception e )
@@ -897,8 +897,8 @@ public abstract class AbstractBTreeParti
 
         Entry entry = lookup( id );
 
-        // Remove all the attributes if the NO_ATTRIBUTE flag is set
-        if ( lookupContext.hasNoAttribute() )
+        // Remove all the attributes if the NO_ATTRIBUTE flag is set and there is no requested
attribute
+        if ( lookupContext.hasNoAttribute() && ( ( lookupContext.getAttrsId() ==
null ) || lookupContext.getAttrsId().size() == 0 ) )
         {
             entry.clear();
 
@@ -918,7 +918,7 @@ public abstract class AbstractBTreeParti
                     AttributeType attributeType = attribute.getAttributeType();
                     String oid = attributeType.getOid();
 
-                    if ( attributeType.getUsage() != UsageEnum.USER_APPLICATIONS ) 
+                    if ( attributeType.getUsage() != UsageEnum.USER_APPLICATIONS )
                     {
                         if ( !lookupContext.getAttrsId().contains( oid ) )
                         {
@@ -936,7 +936,7 @@ public abstract class AbstractBTreeParti
                 {
                     AttributeType attributeType = attribute.getAttributeType();
 
-                    if ( attributeType.getUsage() == UsageEnum.USER_APPLICATIONS ) 
+                    if ( attributeType.getUsage() == UsageEnum.USER_APPLICATIONS )
                     {
                         entry.removeAttributes( attributeType );
                     }
@@ -950,7 +950,7 @@ public abstract class AbstractBTreeParti
                     {
                         AttributeType attributeType = attribute.getAttributeType();
 
-                        if ( attributeType.getUsage() != UsageEnum.USER_APPLICATIONS ) 
+                        if ( attributeType.getUsage() != UsageEnum.USER_APPLICATIONS )
                         {
                             entry.removeAttributes( attributeType );
                         }
@@ -1481,7 +1481,7 @@ public abstract class AbstractBTreeParti
         }
         catch ( LdapException le )
         {
-            // In case we get an LdapException, just rethrow it as is to 
+            // In case we get an LdapException, just rethrow it as is to
             // avoid having it lost
             throw le;
         }
@@ -1807,7 +1807,7 @@ public abstract class AbstractBTreeParti
 
             Entry entry = lookup( id );
             
-            return entry != null; 
+            return entry != null;
         }
         catch ( LdapException e )
         {



Mime
View raw message