directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r802622 - in /directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify: ./ ModifyAddIT.java ModifyDelIT.java
Date Sun, 09 Aug 2009 22:57:06 GMT
Author: elecharny
Date: Sun Aug  9 22:57:06 2009
New Revision: 802622

URL: http://svn.apache.org/viewvc?rev=802622&view=rev
Log:
Added a set of test methods for the Modify operation. The Add and Remove changes have been partially added.

Added:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyAddIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyDelIT.java

Added: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyAddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyAddIT.java?rev=802622&view=auto
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyAddIT.java (added)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyAddIT.java Sun Aug  9 22:57:06 2009
@@ -0,0 +1,690 @@
+/*
+ *  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.server.core.operations.modify;
+
+
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.NoPermissionException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.NoSuchAttributeException;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.integ.CiRunner;
+import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
+import org.apache.directory.shared.ldap.constants.JndiPropertyConstants;
+import org.apache.directory.shared.ldap.exception.LdapAttributeInUseException;
+import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException;
+import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
+import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
+import org.apache.directory.shared.ldap.exception.LdapSizeLimitExceededException;
+import org.apache.directory.shared.ldap.exception.LdapTimeLimitExceededException;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+ 
+
+/**
+ * Tests the modify() methods of the provider.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 770988 $
+ */
+@RunWith ( CiRunner.class )
+@ApplyLdifs(
+    {
+        "dn: m-oid=2.2.0, ou=attributeTypes, cn=apachemeta, ou=schema\n" +
+        "objectclass: metaAttributeType\n" +
+        "objectclass: metaTop\n" +
+        "objectclass: top\n" +
+        "m-oid: 2.2.0\n" +
+        "m-name: integerAttribute\n" +
+        "m-description: the precursor for all integer attributes\n" +
+        "m-equality: integerMatch\n" +
+        "m-ordering: integerOrderingMatch\n" +
+        "m-syntax: 1.3.6.1.4.1.1466.115.121.1.27\n" +
+        "m-length: 0\n" +
+        "\n" +
+        "dn: ou=testing00,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "objectClass: extensibleObject\n" +
+        "ou: testing00\n" +
+        "integerAttribute: 0\n" +
+        "\n" +
+        "dn: ou=testing01,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "objectClass: extensibleObject\n" +
+        "ou: testing01\n" +
+        "integerAttribute: 1\n" +
+        "\n" +
+        "dn: ou=testing02,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "objectClass: extensibleObject\n" +
+        "ou: testing02\n" +
+        "integerAttribute: 2\n" +
+        "\n" +
+        "dn: ou=testing03,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "objectClass: extensibleObject\n" +
+        "ou: testing03\n" +
+        "integerAttribute: 3\n" +
+        "\n" +
+        "dn: ou=testing04,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "objectClass: extensibleObject\n" +
+        "ou: testing04\n" +
+        "integerAttribute: 4\n" +
+        "\n" +
+        "dn: ou=testing05,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "objectClass: extensibleObject\n" +
+        "ou: testing05\n" +
+        "integerAttribute: 5\n" +
+        "\n" +
+        "dn: ou=subtest,ou=testing01,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "ou: subtest\n" +
+        "\n" +
+        "dn: cn=Heather Nova, ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: person\n" +
+        "cn: Heather Nova\n" +
+        "sn: Nova\n" +
+        "telephoneNumber: 1 801 555 1212 \n" +
+        "description: an American singer-songwriter\n" +
+        "\n" +
+        "dn: cn=with-dn, ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: person\n" +
+        "objectClass: organizationalPerson\n" +
+        "objectClass: inetorgPerson\n" +
+        "cn: singer\n" +
+        "sn: manager\n" +
+        "telephoneNumber: 1 801 555 1212 \n" +
+        "manager: cn=Heather Nova, ou=system\n"
+    }
+)
+public class ModifyAddIT
+{
+    private static final String BASE = "ou=system";
+    private static final String RDN_TORI_AMOS = "cn=Tori Amos";
+    private static final String PERSON_DESCRIPTION = "an American singer-songwriter";
+    private static final String RDN_DEBBIE_HARRY = "cn=Debbie Harry";
+    private static final String RDN_HEATHER_NOVA = "cn=Heather Nova";
+    private static final String FILTER = "(objectclass=*)";
+
+    public static DirectoryService service;
+
+    
+    /**
+     * @param sysRoot the system root to add entries to
+     * @throws NamingException on errors
+     */
+    protected void createData( LdapContext sysRoot ) throws Exception
+    {
+        /*
+         * Check ou=testing00,ou=system
+         */
+        DirContext ctx = ( DirContext ) sysRoot.lookup( "ou=testing00" );
+        assertNotNull( ctx );
+        Attributes attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "testing00", attributes.get( "ou" ).get() );
+        Attribute attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+
+        /*
+         * check ou=testing01,ou=system
+         */
+        ctx = ( DirContext ) sysRoot.lookup( "ou=testing01" );
+        assertNotNull( ctx );
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "testing01", attributes.get( "ou" ).get() );
+        attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+
+        /*
+         * Check ou=testing02,ou=system
+         */
+        ctx = ( DirContext ) sysRoot.lookup( "ou=testing02" );
+        assertNotNull( ctx );
+
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "testing02", attributes.get( "ou" ).get() );
+
+        attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+
+        /*
+         * Check ou=subtest,ou=testing01,ou=system
+         */
+        ctx = ( DirContext ) sysRoot.lookup( "ou=subtest,ou=testing01" );
+        assertNotNull( ctx );
+
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "subtest", attributes.get( "ou" ).get() );
+
+        attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+
+        /*
+         *  Check entry cn=Heather Nova, ou=system
+         */
+        ctx = ( DirContext ) sysRoot.lookup( RDN_HEATHER_NOVA );
+        assertNotNull( ctx );
+
+
+        // -------------------------------------------------------------------
+        // Enable the nis schema
+        // -------------------------------------------------------------------
+
+        // check if nis is disabled
+        LdapContext schemaRoot = getSchemaContext( service );
+        Attributes nisAttrs = schemaRoot.getAttributes( "cn=nis" );
+        boolean isNisDisabled = false;
+        
+        if ( nisAttrs.get( "m-disabled" ) != null )
+        {
+            isNisDisabled = ( ( String ) nisAttrs.get( "m-disabled" ).get() ).equalsIgnoreCase( "TRUE" );
+        }
+
+        // if nis is disabled then enable it
+        if ( isNisDisabled )
+        {
+            Attribute disabled = new BasicAttribute( "m-disabled" );
+            ModificationItem[] mods = new ModificationItem[] {
+                new ModificationItem( DirContext.REMOVE_ATTRIBUTE, disabled ) };
+            schemaRoot.modifyAttributes( "cn=nis", mods );
+        }
+
+        // -------------------------------------------------------------------
+        // Add a bunch of nis groups
+        // -------------------------------------------------------------------
+        addNisPosixGroup( "testGroup0", 0 );
+        addNisPosixGroup( "testGroup1", 1 );
+        addNisPosixGroup( "testGroup2", 2 );
+        addNisPosixGroup( "testGroup4", 4 );
+        addNisPosixGroup( "testGroup5", 5 );
+    }
+
+
+    /**
+     * Create a NIS group
+     */
+    private DirContext addNisPosixGroup( String name, int gid ) throws Exception
+    {
+        Attributes attrs = new BasicAttributes( "objectClass", "top", true );
+        attrs.get( "objectClass" ).add( "posixGroup" );
+        attrs.put( "cn", name );
+        attrs.put( "gidNumber", String.valueOf( gid ) );
+        return getSystemContext( service ).createSubcontext( "cn="+name+",ou=groups", attrs );
+    }
+
+
+    //---------------------------------------------------------------------------------------------
+    // Add operation
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.1 AT does not exist.
+    //    - new valid AVA, new AT is in MAY
+    //    - new valid AVA, new AT is not in MAY => error
+    //    - new valid AVA, new AT is not in MAY, but OC contains extensibleOC
+    //    - new valid AVA, new AT is not in MAY, but OC contains extensibleOC, legal empty value
+    //    - new invalid AVA, not existing AT => error
+    //    - new invalid AVA, existing AT, two values in a single valued AT => error
+    //    - new invalid AVA, not existing AT, extensibleObject in OCs => error
+    //    - new invalid AVA (Value is invalid per syntax), AT is in MAY => error
+    //    - new invalid AVA (Value is invalid per syntax), AT is not in MAY, but OC contains extensibleOC => error
+    //    - new OperationalAttribute => error
+    //    - new OperationalAttribute, OC contains extensibleOC => error
+    //---------------------------------------------------------------------------------------------
+    /**
+     * Add a new AT with a valid Value in the entry, the AT is part of the MAY
+     */
+    @Test
+    public void testModifyAddExistingEntryNotExistingATValidAVA() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // A new description attribute value
+        String newValue = "ou=test";
+
+        Attributes attrs = new BasicAttributes( "seeAlso", newValue, true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.ADD_ATTRIBUTE, attrs );
+
+        // Verify that the attribute value has been added
+        attrs = sysRoot.getAttributes( RDN_HEATHER_NOVA );
+        Attribute attr = attrs.get( "seeAlso" );
+        assertNotNull( attr );
+        assertTrue( attr.contains( newValue ) );
+        assertEquals( 1, attr.size() );
+    }
+
+
+    /**
+     * Add a new AT with a valid Value in the entry, the AT is not part of the MAY or MUST,
+     * and the OC does not contain the extensibleObject OC
+     */
+    @Test( expected = LdapSchemaViolationException.class )
+    public void testModifyAddExistingEntryNotExistingATNotInMayValidAVA() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // A valid AT not in MUST or MAY
+        Attributes attrs = new BasicAttributes( "crossCertificatePair", "12345", true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.ADD_ATTRIBUTE, attrs );
+    }
+
+
+    /**
+     * Add a new AT with a valid Value in the entry, the AT is not part of the MAY or MUST,
+     * and the OC contains the extensibleObject OC
+     */
+    @Test
+    public void testModifyAddExistingEntryNotExistingATNotInMayExtensibleObjectOCValidAVA() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // A valid AT not in MUST or MAY, but the extensibleObject OC is present in the OCs
+        Attributes attrs = new BasicAttributes( "crossCertificatePair", "12345", true );
+
+        // Add the AVA
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
+
+        // Verify that the attribute value has been added
+        attrs = sysRoot.getAttributes( "ou=testing01" );
+        Attribute attr = attrs.get( "crossCertificatePair" );
+        assertNotNull( attr );
+        assertTrue( attr.contains( "12345".getBytes() ) );
+        assertEquals( 1, attr.size() );
+    }
+
+
+    /**
+     * Add a new AT with an empty Value in the entry, the AT is not part of the MAY or MUST,
+     * and the OC contains the extensibleObject OC
+     */
+    @Test
+    public void testModifyAddExistingEntryNotExistingAtEmptyValue() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // A valid AT not in MUST or MAY, but the extensibleObject OC is present in the OCs
+        // The value is empty
+        Attributes attrs = new BasicAttributes( "crossCertificatePair", StringTools.EMPTY_BYTES, true );
+
+        // Add the AVA
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
+
+        // Verify that the attribute value has been added
+        attrs = sysRoot.getAttributes( "ou=testing01" );
+        Attribute attr = attrs.get( "crossCertificatePair" );
+        assertNotNull( attr );
+        assertTrue( attr.contains( StringTools.EMPTY_BYTES ) );
+        assertEquals( 1, attr.size() );
+    }
+
+
+    /**
+     * Add a new single valued AT with 2 Values in the entry
+     */
+    @Test( expected = LdapInvalidAttributeValueException.class )
+    public void testModifyAddExistingEntrySingleValuedATWithTwoValues() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // 
+        Attribute attr = new BasicAttribute( "c" );
+        attr.add( "FR" );
+        attr.add( "US" );
+        Attributes attrs = new BasicAttributes( "c", true );
+        attrs.put( attr );
+
+        // Add the AVA
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
+    }
+
+    
+    /**
+     * Add a bad AT in the entry, the OC does not contain the extensibleObject OC
+     */
+    @Test( expected = NoSuchAttributeException.class )
+    public void testModifyAddExistingEntryNotExistingATInvalidAVA() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // An invalid AT
+        Attributes attrs = new BasicAttributes( "badAttr", "12345", true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.ADD_ATTRIBUTE, attrs );
+    }
+
+
+    /**
+     * Add a bad AT in the entry, the OC contains the extensibleObject OC
+     */
+    @Test( expected = NoSuchAttributeException.class )
+    public void testModifyAddExistingEntryNotExistingATInvalidAVAExtensibleObjectInOcs() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // An invalid AT
+        Attributes attrs = new BasicAttributes( "badAttr", "12345", true );
+
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
+    }
+    
+
+    /**
+     * Add a AT part of the MAY/MUST, with an invalid value
+     */
+    @Test( expected = LdapInvalidAttributeValueException.class )
+    public void testModifyAddExistingEntryExistingATInvalidValue() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // An invalid AT value
+        Attributes attrs = new BasicAttributes( "seeAlso", "AAA", true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.ADD_ATTRIBUTE, attrs );
+    }
+    
+    
+    /**
+     * Add a AT not part of the MAY/MUST, with an invalid value, in an entry with the 
+     * extensibleObject OC 
+     */
+    @Test( expected = LdapInvalidAttributeValueException.class )
+    public void testModifyAddExistingEntryExistingATInvalidValueExtensibleObjectInOcs() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // An invalid AT value
+        Attributes attrs = new BasicAttributes( "mobile", "AAA", true );
+
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
+    }
+    
+    
+    /**
+     * Add an operational AT in an entry with no extensibleObject OC
+     */
+    @Test( expected = NoPermissionException.class )
+    public void testModifyAddExistingEntryOperationalAttribute() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // An operationalAttribute
+        Attributes attrs = new BasicAttributes( "subschemaSubentry", "cn=anotherSchema", true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.ADD_ATTRIBUTE, attrs );
+    }
+    
+    
+    /**
+     * Add an operational AT in an entry the extensibleObject OC
+     */
+    @Test( expected = NoPermissionException.class )
+    public void testModifyAddExistingEntryOperationalAttributeExtensibleObjectInOcs() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // An operational attribute
+        Attributes attrs = new BasicAttributes( "subschemaSubentry", "cn=anotherSchema", true );
+
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
+    }
+    
+    
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.2 AT exists.
+    //---------------------------------------------------------------------------------------------
+    /**
+     * Add a new AT with a valid Value in the entry, the AT is part of the MAY
+     */
+    @Test
+    public void testModifyAddExistingEntryExistingATValidAVA() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // A new description attribute value
+        String newValue = "test";
+
+        Attributes attrs = new BasicAttributes( "description", newValue, true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.ADD_ATTRIBUTE, attrs );
+
+        // Verify that the attribute value has been added
+        attrs = sysRoot.getAttributes( RDN_HEATHER_NOVA );
+        Attribute attr = attrs.get( "description" );
+        assertNotNull( attr );
+        assertTrue( attr.contains( newValue ) );
+        assertTrue( attr.contains( PERSON_DESCRIPTION ) );
+        assertEquals( 2, attr.size() );
+    }
+
+    
+    /**
+     * Add a new AT with a valid Value in the entry, the AT is part of the MAY,
+     * the value already exists
+     */
+    @Test( expected = LdapAttributeInUseException.class )
+    public void testModifyAddExistingEntryExistingATExistingValue() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        Attributes attrs = new BasicAttributes( "description", PERSON_DESCRIPTION, true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.ADD_ATTRIBUTE, attrs );
+    }
+    
+    
+    /**
+     * Add an empty value in an existing AT in the entry, the AT is not part of the MAY or MUST,
+     * and the OC contains the extensibleObject OC
+     */
+    @Test
+    public void testModifyAddExistingEntryExistingAtEmptyValue() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        Attributes attrs = new BasicAttributes( "crossCertificatePair", "12345".getBytes(), true );
+        
+        // Add the first AVA
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
+
+        attrs = new BasicAttributes( "crossCertificatePair", StringTools.EMPTY_BYTES, true );
+        
+        // Add the second AVA
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
+
+        // Verify that the attribute value has been added
+        attrs = sysRoot.getAttributes( "ou=testing01" );
+        Attribute attr = attrs.get( "crossCertificatePair" );
+        assertNotNull( attr );
+        assertTrue( attr.contains( "12345".getBytes() ) );
+        assertTrue( attr.contains( StringTools.EMPTY_BYTES ) );
+        assertEquals( 2, attr.size() );
+    }
+    
+    
+    /**
+     * Add a new value in a single valued AT
+     */
+    @Test( expected = LdapInvalidAttributeValueException.class )
+    public void testModifyAddExistingEntryExistingSingleValuedAT() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // The initial value
+        Attributes attrs = new BasicAttributes( "c", "FR", true );
+
+        // Add the AVA
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
+        
+        // Add another value
+        Attributes attrs2 = new BasicAttributes( "c", "US", true );
+
+        // Add the AVA
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs2 );
+    }
+    
+    
+    /**
+     * Add the existing value in a single valued AT
+     */
+    @Test( expected = LdapAttributeInUseException.class )
+    public void testModifyAddExistingEntryExistingSingleValuedATExistingValue() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // The initial value
+        Attributes attrs = new BasicAttributes( "c", "FR", true );
+
+        // Add the AVA
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
+        
+        // Add another value
+        Attributes attrs2 = new BasicAttributes( "c", "FR", true );
+
+        // Add the AVA
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs2 );
+    }
+    
+    
+    /**
+     * Add an invalue in a existing AT
+     */
+    @Test( expected = LdapInvalidAttributeValueException.class )
+    public void testModifyAddExistingEntryExistingATBadValue() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // The added value
+        Attributes attrs = new BasicAttributes( "telephoneNumber", "BAD", true );
+
+        // Add the AVA
+        sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
+    }
+    
+    
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.3 Entry is an alias
+    //---------------------------------------------------------------------------------------------
+    
+    
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.4 Entry is a referral.
+    //---------------------------------------------------------------------------------------------
+    
+    
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.2 Entry is a schema element.
+    //---------------------------------------------------------------------------------------------
+    
+    
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.2 The added AT is ObjectClass.
+    //---------------------------------------------------------------------------------------------
+    
+    
+    //---------------------------------------------------------------------------------------------
+    // 2 Entry does not exist
+    //---------------------------------------------------------------------------------------------
+    /**
+     * Add an AT in an entry which does not exist
+     */
+    @Test( expected = LdapNameNotFoundException.class )
+    public void testModifyAddNotExistingEntry() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // An operational attribute
+        Attributes attrs = new BasicAttributes( "cn", "test", true );
+
+        sysRoot.modifyAttributes( "ou=absent", DirContext.ADD_ATTRIBUTE, attrs );
+    }
+}

Added: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyDelIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyDelIT.java?rev=802622&view=auto
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyDelIT.java (added)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyDelIT.java Sun Aug  9 22:57:06 2009
@@ -0,0 +1,565 @@
+/*
+ *  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.server.core.operations.modify;
+
+
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+import javax.naming.NamingException;
+import javax.naming.NoPermissionException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.NoSuchAttributeException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.integ.CiRunner;
+import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
+import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException;
+import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
+import org.apache.directory.shared.ldap.exception.LdapNoSuchAttributeException;
+import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+ 
+
+/**
+ * Tests the modify() methods of the provider.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 770988 $
+ */
+@RunWith ( CiRunner.class )
+@ApplyLdifs(
+    {
+        "dn: m-oid=2.2.0, ou=attributeTypes, cn=apachemeta, ou=schema\n" +
+        "objectclass: metaAttributeType\n" +
+        "objectclass: metaTop\n" +
+        "objectclass: top\n" +
+        "m-oid: 2.2.0\n" +
+        "m-name: integerAttribute\n" +
+        "m-description: the precursor for all integer attributes\n" +
+        "m-equality: integerMatch\n" +
+        "m-ordering: integerOrderingMatch\n" +
+        "m-syntax: 1.3.6.1.4.1.1466.115.121.1.27\n" +
+        "m-length: 0\n" +
+        "\n" +
+        "dn: ou=testing00,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "objectClass: extensibleObject\n" +
+        "ou: testing00\n" +
+        "integerAttribute: 0\n" +
+        "\n" +
+        "dn: ou=testing01,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "objectClass: extensibleObject\n" +
+        "ou: testing01\n" +
+        "integerAttribute: 1\n" +
+        "\n" +
+        "dn: ou=testing02,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "objectClass: extensibleObject\n" +
+        "ou: testing02\n" +
+        "integerAttribute: 2\n" +
+        "c: FR\n" +
+        "\n" +
+        "dn: ou=testing03,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "objectClass: extensibleObject\n" +
+        "ou: testing03\n" +
+        "integerAttribute: 3\n" +
+        "\n" +
+        "dn: ou=testing04,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "objectClass: extensibleObject\n" +
+        "ou: testing04\n" +
+        "integerAttribute: 4\n" +
+        "\n" +
+        "dn: ou=testing05,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "objectClass: extensibleObject\n" +
+        "ou: testing05\n" +
+        "integerAttribute: 5\n" +
+        "\n" +
+        "dn: ou=subtest,ou=testing01,ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: organizationalUnit\n" +
+        "ou: subtest\n" +
+        "\n" +
+        "dn: cn=Heather Nova, ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: person\n" +
+        "cn: Heather Nova\n" +
+        "sn: Nova\n" +
+        "telephoneNumber: 1 801 555 1212 \n" +
+        "description: an American singer-songwriter\n" +
+        "\n" +
+        "dn: cn=Kim Wilde, ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: person\n" +
+        "cn: Kim Wilde\n" +
+        "sn: Wilde\n" +
+        "telephoneNumber: 1 801 555 1212 \n" +
+        "description: an American singer-songwriter\n" +
+        "description: She has blond hair\n" +
+        "\n" +
+        "dn: cn=with-dn, ou=system\n" +
+        "objectClass: top\n" +
+        "objectClass: person\n" +
+        "objectClass: organizationalPerson\n" +
+        "objectClass: inetorgPerson\n" +
+        "cn: singer\n" +
+        "sn: manager\n" +
+        "telephoneNumber: 1 801 555 1212 \n" +
+        "manager: cn=Heather Nova, ou=system\n"
+    }
+)
+public class ModifyDelIT
+{
+    private static final String RDN_HEATHER_NOVA = "cn=Heather Nova";
+    private static final String RDN_KIM_WILDE = "cn=kim wilde";
+
+    public static DirectoryService service;
+
+    
+    /**
+     * @param sysRoot the system root to add entries to
+     * @throws NamingException on errors
+     */
+    protected void createData( LdapContext sysRoot ) throws Exception
+    {
+        /*
+         * Check ou=testing00,ou=system
+         */
+        DirContext ctx = ( DirContext ) sysRoot.lookup( "ou=testing00" );
+        assertNotNull( ctx );
+        Attributes attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "testing00", attributes.get( "ou" ).get() );
+        Attribute attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+
+        /*
+         * check ou=testing01,ou=system
+         */
+        ctx = ( DirContext ) sysRoot.lookup( "ou=testing01" );
+        assertNotNull( ctx );
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "testing01", attributes.get( "ou" ).get() );
+        attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+
+        /*
+         * Check ou=testing02,ou=system
+         */
+        ctx = ( DirContext ) sysRoot.lookup( "ou=testing02" );
+        assertNotNull( ctx );
+
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "testing02", attributes.get( "ou" ).get() );
+
+        attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+
+        /*
+         * Check ou=subtest,ou=testing01,ou=system
+         */
+        ctx = ( DirContext ) sysRoot.lookup( "ou=subtest,ou=testing01" );
+        assertNotNull( ctx );
+
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "subtest", attributes.get( "ou" ).get() );
+
+        attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+
+        /*
+         *  Check entry cn=Heather Nova, ou=system
+         */
+        ctx = ( DirContext ) sysRoot.lookup( RDN_HEATHER_NOVA );
+        assertNotNull( ctx );
+
+
+        // -------------------------------------------------------------------
+        // Enable the nis schema
+        // -------------------------------------------------------------------
+
+        // check if nis is disabled
+        LdapContext schemaRoot = getSchemaContext( service );
+        Attributes nisAttrs = schemaRoot.getAttributes( "cn=nis" );
+        boolean isNisDisabled = false;
+        
+        if ( nisAttrs.get( "m-disabled" ) != null )
+        {
+            isNisDisabled = ( ( String ) nisAttrs.get( "m-disabled" ).get() ).equalsIgnoreCase( "TRUE" );
+        }
+
+        // if nis is disabled then enable it
+        if ( isNisDisabled )
+        {
+            Attribute disabled = new BasicAttribute( "m-disabled" );
+            ModificationItem[] mods = new ModificationItem[] {
+                new ModificationItem( DirContext.REMOVE_ATTRIBUTE, disabled ) };
+            schemaRoot.modifyAttributes( "cn=nis", mods );
+        }
+
+        // -------------------------------------------------------------------
+        // Add a bunch of nis groups
+        // -------------------------------------------------------------------
+        addNisPosixGroup( "testGroup0", 0 );
+        addNisPosixGroup( "testGroup1", 1 );
+        addNisPosixGroup( "testGroup2", 2 );
+        addNisPosixGroup( "testGroup4", 4 );
+        addNisPosixGroup( "testGroup5", 5 );
+        
+        // Create a test account
+        Attributes test = new BasicAttributes( true );
+        Attribute oc = new BasicAttribute( "ObjectClass" );
+        oc.add( "top" );
+        oc.add( "account" );
+        oc.add( "posixAccount" );
+        test.put( oc );
+        
+        test.put( "cn", "test" );
+        test.put( "uid", "1" );
+        test.put( "uidNumber", "1" );
+        test.put( "gidNumber", "1" );
+        test.put( "homeDirectory", "/" );
+        test.put( "description", "A test account" );
+        
+        getSystemContext( service ).createSubcontext( "cn=test", test );
+        
+    }
+
+
+    /**
+     * Create a NIS group
+     */
+    private DirContext addNisPosixGroup( String name, int gid ) throws Exception
+    {
+        Attributes attrs = new BasicAttributes( "objectClass", "top", true );
+        attrs.get( "objectClass" ).add( "posixGroup" );
+        attrs.put( "cn", name );
+        attrs.put( "gidNumber", String.valueOf( gid ) );
+        return getSystemContext( service ).createSubcontext( "cn="+name+",ou=groups", attrs );
+    }
+
+
+    //---------------------------------------------------------------------------------------------
+    // Del operation
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.1 AT exists
+    //   - The Value exists, it's not part of the RDN, the AT is not singleValued
+    //   - The Value exists, it's not part of the RDN, the AT is singleValued, the AT is not in MUST
+    //   - The Value exists, it's not part of the RDN, the AT is singleValued, the AT is in MUST => error
+    //   - The Value exists, it's part of the RDN => error
+    //   - The Value does not exists => error
+    //   - Delete all the values, AT is not in MUST => AT must be removed
+    //   - Delete all the values, AT is in MUST => error
+    //---------------------------------------------------------------------------------------------
+    /**
+     * Delete a value from an existing AT. There are more than one value
+     */
+    @Test
+    public void testModifyDelExistingEntryExistingATNotInRdnNotSV() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // A new description attribute value
+        String deletedValue = "she has blond hair";
+
+        Attributes attrs = new BasicAttributes( "description", deletedValue, true );
+
+        sysRoot.modifyAttributes( RDN_KIM_WILDE, DirContext.REMOVE_ATTRIBUTE, attrs );
+
+        // Verify that the attribute value has been removed
+        attrs = sysRoot.getAttributes( RDN_KIM_WILDE );
+        Attribute attr = attrs.get( "description" );
+        assertNotNull( attr );
+        assertTrue( attr.contains( "an American singer-songwriter" ) );
+        assertFalse( attr.contains( deletedValue ) );
+        assertEquals( 1, attr.size() );
+    }
+
+
+    /**
+     * Delete all the values from an existing AT not in MUST
+     */
+    @Test
+    public void testModifyDelExistingEntryExistingATNotInRdnNotInMustNotSVAllValues() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // A new description attribute value
+        String deletedValue = "she has blond hair";
+
+        Attributes attrs = new BasicAttributes( "description", true );
+        Attribute descr = new BasicAttribute( "description" );
+        descr.add( "an American singer-songwriter" );
+        descr.add( "she has blond hair" );
+        attrs.put( descr );
+        
+        sysRoot.modifyAttributes( RDN_KIM_WILDE, DirContext.REMOVE_ATTRIBUTE, attrs );
+
+        // Verify that the attribute value has been removed
+        attrs = sysRoot.getAttributes( RDN_KIM_WILDE );
+        Attribute attr = attrs.get( "description" );
+        assertNull( attr );
+    }
+    
+    
+    /**
+     * Delete all the values from an existing AT in MUST
+     */
+    @Test( expected = LdapSchemaViolationException.class )
+    public void testModifyDelExistingEntryExistingATNotInRdnNotSVAllValues() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        Attributes sn = new BasicAttributes( "sn", "Wilde", true );
+        
+        sysRoot.modifyAttributes( RDN_KIM_WILDE, DirContext.REMOVE_ATTRIBUTE, sn );
+    }
+
+    
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.2 AT does not exists.
+    //---------------------------------------------------------------------------------------------
+    /**
+     * Remove a non existing AT from an entry, the AT is part of MAY/MUST
+     */
+    @Test( expected = LdapNoSuchAttributeException.class )
+    public void testModifyDelExistingEntryNonExistingATInMay() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // A non existing AT 
+        Attributes attrs = new BasicAttributes( "seeAlso", "cn=test", true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.REMOVE_ATTRIBUTE, attrs );
+    }
+    
+    
+    /**
+     * Remove a non existing AT from an entry, the AT is notpart of MAY/MUST
+     */
+    @Test( expected = LdapNoSuchAttributeException.class )
+    public void testModifyDelExistingEntryNonExistingATNotInMayMust() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // A non existing AT 
+        Attributes attrs = new BasicAttributes( "c", "FR", true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.REMOVE_ATTRIBUTE, attrs );
+    }
+    
+    
+    /**
+     * Delete a value from an existing SingleValued AT, not in MUST, not in Rdn
+     */
+    @Test
+    public void testModifyDelExistingEntryExistingATNotInRdnSV() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        Attributes attrs = new BasicAttributes( "c", "FR", true );
+
+        sysRoot.modifyAttributes( "ou=testing02", DirContext.REMOVE_ATTRIBUTE, attrs );
+
+        // Verify that the attribute value has been removed
+        attrs = sysRoot.getAttributes( "ou=testing02" );
+        Attribute country = attrs.get( "c" );
+        assertNull( country );
+    }
+    
+    
+    /**
+     * Delete a value from an existing SingleValued AT, in MUST, not in Rdn
+     */
+    @Test( expected = LdapSchemaViolationException.class )
+    public void testModifyDelExistingEntryExistingATNotInRdnSVInMust() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        Attributes attrs = new BasicAttributes( "uidNumber", "1", true );
+
+        sysRoot.modifyAttributes( "cn=test", DirContext.REMOVE_ATTRIBUTE, attrs );
+    }
+    
+    
+    /**
+     * Delete a value part of the Rdn
+     */
+    @Test( expected = LdapSchemaViolationException.class )
+    public void testModifyDelExistingEntryExistingATPartOfRdn() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        Attributes attrs = new BasicAttributes( "cn", "test", true );
+
+        sysRoot.modifyAttributes( "cn=test", DirContext.REMOVE_ATTRIBUTE, attrs );
+    }
+    
+    
+    /**
+     * Delete an existing AT not part of the RDN, not in MUST
+     */
+    @Test
+    public void testModifyDelExistingEntryExistingATNoInRdnNotInMust() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        Attributes attrs = new BasicAttributes( "description", null, true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.REMOVE_ATTRIBUTE, attrs );
+        
+        // Verify that the attribute has been removed
+        attrs = sysRoot.getAttributes( RDN_HEATHER_NOVA );
+        Attribute descr = attrs.get( "description" );
+        assertNull( descr );
+    }
+    
+    
+    /**
+     * Delete an existing AT not part of the RDN, but in MUST
+     */
+    @Test( expected = LdapSchemaViolationException.class )
+    public void testModifyDelExistingEntryExistingATNoInRdnInMust() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        Attributes attrs = new BasicAttributes( "sn", null, true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.REMOVE_ATTRIBUTE, attrs );
+    }
+    
+    
+    /**
+     * Delete an existing AT part of the RDN
+     */
+    @Test( expected = LdapSchemaViolationException.class )
+    public void testModifyDelExistingEntryExistingATInRdn() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        Attributes attrs = new BasicAttributes( "cn", null, true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.REMOVE_ATTRIBUTE, attrs );
+    }
+    
+    
+    /**
+     * Delete a value not present in an existing AT
+     */
+    @Test
+    public void testModifyDelExistingEntryValueNotPresentInExistingAT() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        Attributes attrs = new BasicAttributes( "description", "Not present", true );
+
+        sysRoot.modifyAttributes( RDN_HEATHER_NOVA, DirContext.REMOVE_ATTRIBUTE, attrs );
+    }
+
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.3 Entry is an alias
+    //---------------------------------------------------------------------------------------------
+    
+    
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.4 Entry is a referral.
+    //---------------------------------------------------------------------------------------------
+    
+    
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.2 Entry is a schema element.
+    //---------------------------------------------------------------------------------------------
+    
+    
+    //---------------------------------------------------------------------------------------------
+    // 1 Entry exists
+    //  1.2 The added AT is ObjectClass.
+    //---------------------------------------------------------------------------------------------
+    
+    
+    //---------------------------------------------------------------------------------------------
+    // 2 Entry does not exist
+    //---------------------------------------------------------------------------------------------
+    /**
+     * Del an AT in an entry which does not exist
+     */
+    @Test( expected = LdapNameNotFoundException.class )
+    public void testModifyDelNotExistingEntry() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        createData( sysRoot );
+
+        // An operational attribute
+        Attributes attrs = new BasicAttributes( "cn", "test", true );
+
+        sysRoot.modifyAttributes( "ou=absent", DirContext.REMOVE_ATTRIBUTE, attrs );
+    }
+}



Mime
View raw message