You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2008/08/05 07:39:37 UTC

svn commit: r682586 - in /directory/apacheds/branches/bigbang: server-integ/src/test/java/org/apache/directory/server/operations/modify/ server-unit/ server-unit/src/test/java/org/apache/directory/server/

Author: akarasulu
Date: Mon Aug  4 22:39:37 2008
New Revision: 682586

URL: http://svn.apache.org/viewvc?rev=682586&view=rev
Log:
changes to modify operations and their tests

 o moved old server-unit based tests over to server-integ and adapted them for 
   the new framework


Added:
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationITest.java
      - copied, changed from r682569, directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/IllegalModificationITest.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddTest.java
      - copied, changed from r682569, directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveTest.java
      - copied, changed from r682569, directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceITest.java
      - copied, changed from r682569, directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyReplaceITest.java
Removed:
    directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/IllegalModificationITest.java
    directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java
    directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java
    directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyReplaceITest.java
Modified:
    directory/apacheds/branches/bigbang/server-unit/pom.xml

Copied: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationITest.java (from r682569, directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/IllegalModificationITest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationITest.java?p2=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationITest.java&p1=directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/IllegalModificationITest.java&r1=682569&r2=682586&rev=682586&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/IllegalModificationITest.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationITest.java Mon Aug  4 22:39:37 2008
@@ -17,13 +17,22 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.server;
+package org.apache.directory.server.operations.modify;
 
 
-import org.apache.directory.server.unit.AbstractServerTest;
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import org.apache.directory.server.integ.SiRunner;
+import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredConnection;
+
+import org.apache.directory.server.newldap.LdapServer;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
 
 import netscape.ldap.LDAPAttribute;
-import netscape.ldap.LDAPAttributeSet;
 import netscape.ldap.LDAPConnection;
 import netscape.ldap.LDAPEntry;
 import netscape.ldap.LDAPException;
@@ -51,46 +60,28 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: $
  */
-public class IllegalModificationITest extends AbstractServerTest
-{
-    static final String DN = "cn=Kate Bush,ou=system";
-    static final String USER = "uid=admin,ou=system";
-    static final String PASSWORD = "secret";
-    static final String HOST = "localhost";
-
-    private LDAPConnection con = null;
-
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-        con = new LDAPConnection();
-        con.connect( 3, HOST, super.port, USER, PASSWORD );
-
-        // Create a person entry
-        LDAPAttributeSet attrs = new LDAPAttributeSet();
-        attrs.add( new LDAPAttribute( "sn", "Bush" ) );
-        attrs.add( new LDAPAttribute( "cn", "Kate Bush" ) );
-        LDAPAttribute oc = new LDAPAttribute( "objectClass" );
-        oc.addValue( "top" );
-        oc.addValue( "person" );
-        attrs.add( oc );
-        LDAPEntry entry = new LDAPEntry( DN, attrs );
-        con.add( entry );
-    }
-
-
-    protected void tearDown() throws Exception
-    {
-        // Remove the person entry and disconnect
-        con.delete( DN );
-        con.disconnect();
-        super.tearDown();
+@RunWith ( SiRunner.class ) 
+@CleanupLevel ( Level.SUITE )
+@ApplyLdifs( {
+    // Entry # 1
+    "dn: cn=Kate Bush,ou=system\n" +
+    "objectClass: person\n" +
+    "objectClass: top\n" +
+    "cn: Kate Bush\n" +
+    "sn: Bush\n\n" 
     }
+)
+public class IllegalModificationITest 
+{
+    private static final String DN = "cn=Kate Bush,ou=system";
 
+    public static LdapServer ldapServer;
+    
 
-    public void testIllegalModification() throws LDAPException
+    @Test
+    public void testIllegalModification() throws Exception
     {
+        LDAPConnection con = getWiredConnection( ldapServer );
         LDAPAttribute attr = new LDAPAttribute( "description" );
         LDAPModification mod = new LDAPModification( LDAPModification.ADD, attr );
 
@@ -110,8 +101,11 @@
     }
     
     
-    public void testIllegalModification2() throws LDAPException
+    @Test
+    public void testIllegalModification2() throws Exception
     {
+        LDAPConnection con = getWiredConnection( ldapServer );
+
         // first a valid attribute
         LDAPAttribute attr = new LDAPAttribute( "description", "The description" );
         LDAPModification mod = new LDAPModification( LDAPModification.ADD, attr );

Copied: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddTest.java (from r682569, directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddTest.java?p2=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddTest.java&p1=directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java&r1=682569&r2=682586&rev=682586&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddTest.java Mon Aug  4 22:39:37 2008
@@ -17,11 +17,10 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.server;
+package org.apache.directory.server.operations.modify;
 
 
 import java.util.Arrays;
-import java.util.Hashtable;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
@@ -38,30 +37,66 @@
 import javax.naming.directory.NoSuchAttributeException;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
-import javax.naming.ldap.InitialLdapContext;
-import javax.naming.ldap.LdapContext;
 
-import org.apache.directory.server.unit.AbstractServerTest;
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import org.apache.directory.server.integ.SiRunner;
+import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContext;
+
+import org.apache.directory.server.newldap.LdapServer;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 
 
 /**
- * Testcase with different modify operations on a person entry. Each includes a
+ * Test case with different modify operations on a person entry. Each includes a
  * single add op only. Created to demonstrate DIREVE-241 ("Adding an already
  * existing attribute value with a modify operation does not cause an error.").
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ModifyAddTest extends AbstractServerTest
+@RunWith ( SiRunner.class ) 
+@CleanupLevel ( Level.SUITE )
+@ApplyLdifs( {
+    // Entry # 1
+    "dn: cn=Tori Amos,ou=system\n" +
+    "objectClass: inetOrgPerson\n" +
+    "objectClass: organizationalPerson\n" +
+    "objectClass: person\n" +
+    "objectClass: top\n" +
+    "description: an American singer-songwriter\n" +
+    "cn: Tori Amos\n" +
+    "sn: Amos\n\n" + 
+    // Entry # 2
+    "dn: cn=Debbie Harry,ou=system\n" +
+    "objectClass: inetOrgPerson\n" +
+    "objectClass: organizationalPerson\n" +
+    "objectClass: person\n" +
+    "objectClass: top\n" +
+    "cn: Debbie Harry\n" +
+    "sn: Harry\n\n" 
+    }
+)
+public class ModifyAddTest 
 {
-    private LdapContext ctx = null;
+    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";
 
+    public static LdapServer ldapServer;
+    
 
     /**
      * Creation of required attributes of a person entry.
@@ -83,54 +118,13 @@
 
 
     /**
-     * Create context and a person entry.
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-
-        Hashtable<String, Object> env = new Hashtable<String, Object>();
-        env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( "java.naming.provider.url", "ldap://localhost:" + port + "/ou=system" );
-        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
-        env.put( "java.naming.security.credentials", "secret" );
-        env.put( "java.naming.security.authentication", "simple" );
-
-        ctx = new InitialLdapContext( env, null );
-        assertNotNull( ctx );
-
-        // Create Tori Amos with description
-        Attributes attributes = this.getPersonAttributes( "Amos", "Tori Amos" );
-        attributes.put( "description", "an American singer-songwriter" );
-        ctx.createSubcontext( RDN_TORI_AMOS, attributes );
-
-        // Create Debbie Harry ( I feel like being God when creating people as good looking as Blondie :)
-        attributes = getPersonAttributes( "Harry", "Debbie Harry" );
-        ctx.createSubcontext( RDN_DEBBIE_HARRY, attributes );
-
-    }
-
-
-    /**
-     * Remove person entry and close context.
-     */
-    protected void tearDown() throws Exception
-    {
-        ctx.unbind( RDN_TORI_AMOS );
-        ctx.destroySubcontext( RDN_DEBBIE_HARRY );
-        ctx.close();
-        ctx = null;
-        super.tearDown();
-    }
-
-
-    /**
      * Add a new attribute to a person entry.
-     * 
-     * @throws NamingException
      */
-    public void testAddNewAttributeValue() throws NamingException
+    @Test
+    public void testAddNewAttributeValue() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Add telephoneNumber attribute
         String newValue = "1234567890";
         Attributes attrs = new AttributesImpl( "telephoneNumber", newValue );
@@ -147,11 +141,12 @@
 
     /**
      * Add a new attribute with two values.
-     * 
-     * @throws NamingException
      */
-    public void testAddNewAttributeValues() throws NamingException
+    @Test
+    public void testAddNewAttributeValues() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Add telephoneNumber attribute
         String[] newValues =
             { "1234567890", "999999999" };
@@ -174,11 +169,12 @@
 
     /**
      * Add an additional value.
-     * 
-     * @throws NamingException
      */
-    public void testAddAdditionalAttributeValue() throws NamingException
+    @Test
+    public void testAddAdditionalAttributeValue() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // A new description attribute value
         String newValue = "A new description for this person";
         assertFalse( newValue.equals( PERSON_DESCRIPTION ) );
@@ -203,11 +199,12 @@
      * AttributeInUseException. Original LDAP Error code: 20 (Indicates that the
      * attribute value specified in a modify or add operation already exists as
      * a value for that attribute).
-     * 
-     * @throws NamingException
      */
-    public void testAddExistingAttributeValue() throws NamingException
+    @Test
+    public void testAddExistingAttributeValue() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Change description attribute
         Attributes attrs = new AttributesImpl( "description", PERSON_DESCRIPTION );
         
@@ -229,6 +226,7 @@
         assertEquals( 1, attr.size() );
     }
 
+    
     /**
      * Try to add an already existing attribute value.
      * 
@@ -238,11 +236,12 @@
      * a value for that attribute).
      * 
      * Check for bug DIR_SERVER664
-     * 
-     * @throws NamingException
      */
-    public void testAddExistingNthAttributesDirServer664() throws NamingException
+    @Test
+    public void testAddExistingNthAttributesDirServer664() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Change description attribute
         Attributes attrs = new AttributesImpl( true );
         attrs.put( new AttributeImpl( "telephoneNumber", "attr 1" ) );
@@ -282,13 +281,15 @@
         assertEquals( 1, attr.size() );
     }
 
+    
     /**
      * Check for DIR_SERVER_643
-     * 
-     * @throws NamingException
      */
-    public void testTwoDescriptionDirServer643() throws NamingException
+    @Test
+    public void testTwoDescriptionDirServer643() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Change description attribute
         Attributes attrs = new AttributesImpl( true );
         Attribute attr = new AttributeImpl( "description", "a British singer-songwriter with an expressive four-octave voice" );
@@ -312,11 +313,12 @@
      * is already present (objectclass in this case). Expected behaviour is that
      * the modify operation causes an error (error code 20, "Attribute or value
      * exists").
-     * 
-     * @throws NamingException
      */
-    public void testAddDuplicateValueToExistingAttribute() throws NamingException
+    @Test
+    public void testAddDuplicateValueToExistingAttribute() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // modify object classes, add a new value twice
         Attribute ocls = new AttributeImpl( "objectClass", "organizationalPerson" );
         ModificationItemImpl[] modItems = new ModificationItemImpl[2];
@@ -344,11 +346,12 @@
      * Try to add a duplicate attribute value to an entry, where this attribute
      * is not present. Expected behaviour is that the modify operation causes an
      * error (error code 20, "Attribute or value exists").
-     * 
-     * @throws NamingException
      */
-    public void testAddDuplicateValueToNewAttribute() throws NamingException
+    @Test
+    public void testAddDuplicateValueToNewAttribute() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // add the same description value twice
         Attribute desc = new AttributeImpl( "description", "another description value besides songwriter" );
         ModificationItemImpl[] modItems = new ModificationItemImpl[2];
@@ -371,21 +374,12 @@
 
     /**
      * Create an entry with a bad attribute : this should fail.
-     * 
-     * @throws NamingException
      */
-    public void testAddUnexistingAttribute() throws NamingException
+    @Test
+    public void testAddUnexistingAttribute() throws Exception
     {
-        Hashtable<String, Object> env = new Hashtable<String, Object>();
-        env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( "java.naming.provider.url", "ldap://localhost:" + port + "/ou=system" );
-        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
-        env.put( "java.naming.security.credentials", "secret" );
-        env.put( "java.naming.security.authentication", "simple" );
-
-        ctx = new InitialLdapContext( env, null );
-        assertNotNull( ctx );
-
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Create a third person with a voice attribute
         Attributes attributes = this.getPersonAttributes( "Jackson", "Michael Jackson" );
         attributes.put( "voice", "He is bad ..." );
@@ -406,11 +400,12 @@
 
     /**
      * Modify the entry with a bad attribute : this should fail 
-     * 
-     * @throws NamingException
      */
-    public void testSearchBadAttribute() throws NamingException
+    @Test
+    public void testSearchBadAttribute() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Add a not existing attribute
         String newValue = "unbelievable";
         Attributes attrs = new AttributesImpl( "voice", newValue );
@@ -433,11 +428,12 @@
     /**
      * Create a person entry and perform a modify op, in which
      * we modify an attribute two times.
-     * 
-     * @throws NamingException 
      */
-    public void testAttributeValueMultiMofificationDIRSERVER_636() throws NamingException {
-
+    @Test
+    public void testAttributeValueMultiMofificationDIRSERVER_636() throws Exception 
+    {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Create a person entry
         Attributes attrs = getPersonAttributes("Bush", "Kate Bush");
         String rdn = "cn=Kate Bush";
@@ -483,13 +479,15 @@
         ctx.destroySubcontext(rdn);
     }
 
+    
     /**
      * Try to add subschemaSubentry attribute to an entry
-     * 
-     * @throws NamingException 
      */
-    public void testModifyOperationalAttributeAdd() throws NamingException
+    @Test
+    public void testModifyOperationalAttributeAdd() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         ModificationItem modifyOp = new ModificationItemImpl( DirContext.ADD_ATTRIBUTE, new BasicAttribute(
             "subschemaSubentry", "cn=anotherSchema" ) );
 
@@ -516,11 +514,12 @@
      * attribute which is part of the DN. This is not allowed.
      * 
      * A JIRA has been created for this bug : DIRSERVER_687
-     * 
-     * @throws NamingException 
      */
-     public void testDNAttributeMemberMofificationDIRSERVER_687() throws NamingException {
-
+    @Test
+     public void testDNAttributeMemberMofificationDIRSERVER_687() throws Exception 
+     {
+         DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+         
         // Create a person entry
         Attributes attrs = getPersonAttributes("Bush", "Kate Bush");
         String rdn = "cn=Kate Bush";
@@ -550,15 +549,18 @@
             ctx.destroySubcontext(rdn);
         }
     }
+
     
     /**
      * Try to modify an entry adding invalid number of values for a single-valued atribute
      * 
-     * @throws NamingException 
      * @see <a href="http://issues.apache.org/jira/browse/DIRSERVER-614">DIRSERVER-614</a>
      */
-    public void testModifyAddWithInvalidNumberOfAttributeValues() throws NamingException
+    @Test
+    public void testModifyAddWithInvalidNumberOfAttributeValues() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         Attributes attrs = new AttributesImpl();
         Attribute ocls = new AttributeImpl( "objectClass" );
         ocls.add( "top" );
@@ -589,11 +591,12 @@
 
     /**
      * Add a new attribute to a person entry.
-     * 
-     * @throws NamingException
      */
-    public void testAddNewBinaryAttributeValue() throws NamingException
+    @Test
+    public void testAddNewBinaryAttributeValue() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Add a binary attribute
         byte[] newValue = new byte[]{0x00, 0x01, 0x02, 0x03};
         Attributes attrs = new AttributesImpl( "userCertificate;binary", newValue );

Copied: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveTest.java (from r682569, directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveTest.java?p2=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveTest.java&p1=directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java&r1=682569&r2=682586&rev=682586&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveTest.java Mon Aug  4 22:39:37 2008
@@ -17,13 +17,10 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.server;
+package org.apache.directory.server.operations.modify;
 
 
-import java.util.Hashtable;
-
 import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
@@ -34,29 +31,54 @@
 import javax.naming.directory.SchemaViolationException;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
-import javax.naming.ldap.InitialLdapContext;
-import javax.naming.ldap.LdapContext;
 
-import org.apache.directory.server.unit.AbstractServerTest;
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import org.apache.directory.server.integ.SiRunner;
+import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContext;
+
+import org.apache.directory.server.newldap.LdapServer;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 
 
 /**
- * Testcase with different modify operations on a person entry. Each includes a
- * single removal op only.
+ * Test case with different modify operations on a person entry. Each includes a
+ * single removal operation only.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ModifyRemoveTest extends AbstractServerTest
+@RunWith ( SiRunner.class ) 
+@CleanupLevel ( Level.SUITE )
+@ApplyLdifs( {
+    // Entry # 1
+    "dn: cn=Tori Amos,ou=system\n" +
+    "objectClass: person\n" +
+    "objectClass: top\n" +
+    "description: an American singer-songwriter\n" +
+    "cn: Tori Amos\n" +
+    "sn: Amos\n\n"
+    }
+)
+public class ModifyRemoveTest
 {
-
-    private LdapContext ctx = null;
-
+    private static final String BASE = "ou=system";
     private static final String RDN = "cn=Tori Amos";
 
+    
+    public static LdapServer ldapServer;
+    
 
     /**
      * Creation of required attributes of a person entry.
@@ -95,66 +117,17 @@
 
 
     /**
-     * Create context and a person entry.
-     */
-    public void setUp() throws Exception
-    {
-        super.setUp();
-
-        Hashtable<String,Object> env = new Hashtable<String,Object>();
-        env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( "java.naming.provider.url", "ldap://localhost:" + port + "/ou=system" );
-        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
-        env.put( "java.naming.security.credentials", "secret" );
-        env.put( "java.naming.security.authentication", "simple" );
-
-        ctx = new InitialLdapContext( env, null );
-        assertNotNull( ctx );
-
-        // Create a person with description
-        Attributes attributes = this.getPersonAttributes( "Amos", "Tori Amos" );
-        attributes.put( "description", "an American singer-songwriter" );
-        ctx.createSubcontext( RDN, attributes );
-    }
-
-
-    /**
-     * Remove person entry and close context.
-     */
-    public void tearDown() throws Exception
-    {
-        ctx.unbind( RDN );
-        ctx.close();
-        ctx = null;
-        super.tearDown();
-    }
-
-
-    /**
-     * Just a little test to check wether opening the connection and creation of
-     * the person succeeds succeeds.
-     * 
-     * @throws NamingException 
-     */
-    public void testSetUpTearDown() throws NamingException
-    {
-        assertNotNull( ctx );
-        DirContext tori = ( DirContext ) ctx.lookup( RDN );
-        assertNotNull( tori );
-    }
-
-
-    /**
      * Remove an attribute which does not exist in an attribute making sure 
      * it does not remove other values in that attribute.  Tests if the 
      * following JIRA issue is still valid:
      * 
      *    https://issues.apache.org/jira/browse/DIRSERVER-1149
-     * 
-     * @throws NamingException
      */
-    public void testRemoveAttemptWithoutChange() throws NamingException
+    @Test
+    public void testRemoveAttemptWithoutChange() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Get the attributes and check the contents
         Attributes tori = ctx.getAttributes( RDN );
         assertNotNull( tori.get( "objectClass" ) );
@@ -192,11 +165,12 @@
      * 
      * Expected result: After successful deletion, attribute is not present in
      * entry.
-     * 
-     * @throws NamingException
      */
-    public void testRemoveNotRequiredAttribute() throws NamingException
+    @Test
+    public void testRemoveNotRequiredAttribute() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Remove description Attribute
         Attribute attr = new AttributeImpl( "description" );
         Attributes attrs = new AttributesImpl();
@@ -215,11 +189,12 @@
      * 
      * Expected result: After successful deletion, both attributes ar not
      * present in entry.
-     * 
-     * @throws NamingException
      */
-    public void testRemoveTwoNotRequiredAttributes() throws NamingException
+    @Test
+    public void testRemoveTwoNotRequiredAttributes() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // add telephoneNumber to entry
         Attributes tn = new AttributesImpl( "telephoneNumber", "12345678" );
         ctx.modifyAttributes( RDN, DirContext.ADD_ATTRIBUTE, tn );
@@ -244,11 +219,12 @@
      * here.
      * 
      * Expected Result: Deletion fails with NamingException (Schema Violation).
-     * 
-     * @throws NamingException
      */
-    public void testRemoveRequiredAttribute() throws NamingException
+    @Test
+    public void testRemoveRequiredAttribute() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Remove sn attribute
         Attribute attr = new AttributeImpl( "sn" );
         Attributes attrs = new AttributesImpl();
@@ -270,11 +246,12 @@
      * Remove a required attribute from RDN.
      * 
      * Expected Result: Deletion fails with SchemaViolationException.
-     * 
-     * @throws NamingException
      */
-    public void testRemovePartOfRdn() throws NamingException
+    @Test
+    public void testRemovePartOfRdn() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Remove sn attribute
         Attribute attr = new AttributeImpl( "cn" );
         Attributes attrs = new AttributesImpl();
@@ -296,11 +273,12 @@
      * Remove a not required attribute from RDN.
      * 
      * Expected Result: Deletion fails with SchemaViolationException.
-     * 
-     * @throws NamingException
      */
-    public void testRemovePartOfRdnNotRequired() throws NamingException
+    @Test
+    public void testRemovePartOfRdnNotRequired() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Change RDN to another attribute
         String newRdn = "description=an American singer-songwriter";
         ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "false" );
@@ -332,11 +310,12 @@
      * schema.
      * 
      * Expected result: Deletion fails with NoSuchAttributeException
-     * 
-     * @throws NamingException
      */
-    public void testRemoveAttributeNotPresent() throws NamingException
+    @Test
+    public void testRemoveAttributeNotPresent() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Remove telephoneNumber Attribute
         Attribute attr = new AttributeImpl( "telephoneNumber" );
         Attributes attrs = new AttributesImpl();
@@ -358,11 +337,12 @@
      * Remove a an attribute which is not present in the schema.
      * 
      * Expected result: Deletion fails with NoSuchAttributeException
-     * 
-     * @throws NamingException
      */
-    public void testRemoveAttributeNotValid() throws NamingException
+    @Test
+    public void testRemoveAttributeNotValid() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Remove phantasy attribute
         Attribute attr = new AttributeImpl( "XXX" );
         Attributes attrs = new AttributesImpl();
@@ -386,11 +366,12 @@
 
     /**
      * Create a person entry and try to remove an attribute value
-     * 
-     * @throws NamingException 
      */
-    public void testReplaceNonExistingAttribute() throws NamingException
+    @Test
+    public void testReplaceNonExistingAttribute() throws Exception
     {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Create an entry
         Attributes attrs = getInetOrgPersonAttributes( "Bush", "Kate Bush" );
         attrs.put( "givenname", "Kate" );
@@ -406,10 +387,10 @@
         sctls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         String filter = "(cn=Kate Bush)";
         String base = "";
-        NamingEnumeration enm = ctx.search( base, filter, sctls );
+        NamingEnumeration<SearchResult> enm = ctx.search( base, filter, sctls );
         if ( enm.hasMore() )
         {
-            SearchResult sr = ( SearchResult ) enm.next();
+            SearchResult sr = enm.next();
             attrs = sr.getAttributes();
             Attribute cn = sr.getAttributes().get( "cn" );
             assertNotNull( cn );
@@ -431,12 +412,12 @@
     /**
      * Create a person entry and try to remove an attribute value from the RDN
      * by Replacement
-     * 
-     * @throws NamingException 
      */
-    public void testReplaceRdnByEmptyValueAttribute() throws NamingException
+    @Test
+    public void testReplaceRdnByEmptyValueAttribute() throws Exception
     {
-
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Create an entry
         Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
         String rdn = "cn=Kate Bush";
@@ -463,12 +444,12 @@
 
     /**
      * Create a person entry and try to remove an attribute from the RDN
-     * 
-     * @throws NamingException 
      */
-    public void testRemoveRdnAttribute() throws NamingException
+    @Test
+    public void testRemoveRdnAttribute() throws Exception
     {
-
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Create an entry
         Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
         String rdn = "cn=Kate Bush";
@@ -495,12 +476,12 @@
 
     /**
      * Create a person entry and try to remove an attribute from the RDN
-     * 
-     * @throws NamingException 
      */
-    public void testRemoveRdnAttributeValue() throws NamingException
+    @Test
+    public void testRemoveRdnAttributeValue() throws Exception
     {
-
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Create an entry
         Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
         String rdn = "cn=Kate Bush";
@@ -523,14 +504,16 @@
 
         ctx.destroySubcontext( rdn );
     }
+
     
     /**
      * Create a person entry and try to remove objectClass attribute
-     * 
-     * @throws NamingException 
      */
-    public void testDeleteOclAttrWithTopPersonOrganizationalpersonInetorgperson() throws NamingException {
-
+    @Test
+    public void testDeleteOclAttrWithTopPersonOrganizationalpersonInetorgperson() throws Exception 
+    {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Create an entry
         Attributes attrs = getInetOrgPersonAttributes("Bush", "Kate Bush");
         String rdn = "cn=Kate Bush";
@@ -554,14 +537,16 @@
         ctx.destroySubcontext(rdn);
     }
 
+    
     /**
      * Create a person entry and try to remove objectClass attribute. A variant
      * which works.
-     * 
-     * @throws NamingException 
      */
-    public void testDeleteOclAttrWithTopPersonOrganizationalpersonInetorgpersonVariant() throws NamingException {
-
+    @Test
+    public void testDeleteOclAttrWithTopPersonOrganizationalpersonInetorgpersonVariant() throws Exception 
+    {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         // Create an entry
         Attributes attrs = getInetOrgPersonAttributes("Bush", "Kate Bush");
         String rdn = "cn=Kate Bush";

Copied: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceITest.java (from r682569, directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyReplaceITest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceITest.java?p2=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceITest.java&p1=directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyReplaceITest.java&r1=682569&r2=682586&rev=682586&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyReplaceITest.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceITest.java Mon Aug  4 22:39:37 2008
@@ -17,11 +17,10 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.server;
+package org.apache.directory.server.operations.modify;
 
 
 import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
@@ -31,17 +30,33 @@
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 
-import org.apache.directory.server.unit.AbstractServerTest;
+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 static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContext;
+
+import org.apache.directory.server.newldap.LdapServer;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
 
 
 /**
  * Test case for all modify replace operations.
  * 
- * Testcase to demonstrate DIRSERVER-646 ("Replacing an unknown attribute with
+ * Demonstrates DIRSERVER-646 ("Replacing an unknown attribute with
  * no values (deletion) causes an error").
  */
-public class ModifyReplaceITest extends AbstractServerTest
+@RunWith ( SiRunner.class ) 
+@CleanupLevel ( Level.SUITE )
+public class ModifyReplaceITest 
 {
+    private static final String BASE = "ou=system";
+
+    public static LdapServer ldapServer;
+    
+    
     protected Attributes getPersonAttributes( String sn, String cn ) 
     {
         Attributes attrs = new BasicAttributes();
@@ -59,8 +74,11 @@
     /**
      * Create a person entry and try to remove a not present attribute
      */
-    public void testReplaceNotPresentAttribute() throws NamingException 
+    @Test
+    public void testReplaceNotPresentAttribute() throws Exception 
     {
+        DirContext sysRoot = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
         String rdn = "cn=Kate Bush";
         sysRoot.createSubcontext( rdn, attrs );
@@ -75,7 +93,7 @@
         String filter = "(sn=Bush)";
         String base = "";
 
-        NamingEnumeration enm = sysRoot.search( base, filter, sctls );
+        NamingEnumeration<SearchResult> enm = sysRoot.search( base, filter, sctls );
         while ( enm.hasMore() ) 
         {
             SearchResult sr = ( SearchResult ) enm.next();
@@ -92,8 +110,11 @@
     /**
      * Create a person entry and try to remove a non existing attribute
      */
-    public void testReplaceNonExistingAttribute() throws NamingException 
+    @Test
+    public void testReplaceNonExistingAttribute() throws Exception 
     {
+        DirContext sysRoot = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
         String rdn = "cn=Kate Bush";
         sysRoot.createSubcontext( rdn, attrs );
@@ -108,10 +129,10 @@
         String filter = "(sn=Bush)";
         String base = "";
 
-        NamingEnumeration enm = sysRoot.search( base, filter, sctls );
+        NamingEnumeration<SearchResult> enm = sysRoot.search( base, filter, sctls );
         while ( enm.hasMore() ) 
         {
-            SearchResult sr = ( SearchResult ) enm.next();
+            SearchResult sr = enm.next();
             attrs = sr.getAttributes();
             Attribute cn = sr.getAttributes().get( "cn" );
             assertNotNull( cn );
@@ -125,8 +146,11 @@
     /**
      * Create a person entry and try to remove a non existing attribute
      */
-    public void testReplaceNonExistingAttributeManyMods() throws NamingException 
+    @Test
+    public void testReplaceNonExistingAttributeManyMods() throws Exception 
     {
+        DirContext sysRoot = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
         Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
         String rdn = "cn=Kate Bush";
         sysRoot.createSubcontext( rdn, attrs );
@@ -143,10 +167,10 @@
         String filter = "(sn=Bush)";
         String base = "";
 
-        NamingEnumeration enm = sysRoot.search( base, filter, sctls );
+        NamingEnumeration<SearchResult> enm = sysRoot.search( base, filter, sctls );
         while ( enm.hasMore() ) 
         {
-            SearchResult sr = ( SearchResult ) enm.next();
+            SearchResult sr = enm.next();
             attrs = sr.getAttributes();
             Attribute cn = sr.getAttributes().get( "cn" );
             assertNotNull( cn );

Modified: directory/apacheds/branches/bigbang/server-unit/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/pom.xml?rev=682586&r1=682585&r2=682586&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/pom.xml (original)
+++ directory/apacheds/branches/bigbang/server-unit/pom.xml Mon Aug  4 22:39:37 2008
@@ -168,6 +168,7 @@
               <excludes>
                 <exclude>**/Abstract*</exclude>
                 <exclude>**/PersistentSearchTest*</exclude>
+                <exclude>**/SaslBindITest*</exclude>
               </excludes>
             </configuration>
           </plugin>