directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1226741 - /directory/apacheds/branches/apacheds-txns/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
Date Tue, 03 Jan 2012 11:18:52 GMT
Author: elecharny
Date: Tue Jan  3 11:18:51 2012
New Revision: 1226741

URL: http://svn.apache.org/viewvc?rev=1226741&view=rev
Log:
Fixed a failing test

Modified:
    directory/apacheds/branches/apacheds-txns/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java

Modified: directory/apacheds/branches/apacheds-txns/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java?rev=1226741&r1=1226740&r2=1226741&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
(original)
+++ directory/apacheds/branches/apacheds-txns/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
Tue Jan  3 11:18:51 2012
@@ -51,6 +51,8 @@ import javax.naming.directory.SearchResu
 import javax.naming.ldap.LdapContext;
 import javax.naming.ldap.LdapName;
 
+import netscape.ldap.LDAPException;
+
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -115,10 +117,10 @@ import org.slf4j.LoggerFactory;
                     "objectClass: top\n" +
                     "objectClass: domain\n\n"),
             indexes =
-            {
-                @CreateIndex(attribute = "objectClass"),
-                @CreateIndex(attribute = "dc"),
-                @CreateIndex(attribute = "ou")
+                {
+                    @CreateIndex(attribute = "objectClass"),
+                    @CreateIndex(attribute = "dc"),
+                    @CreateIndex(attribute = "ou")
             }),
 
         @CreatePartition(
@@ -130,13 +132,13 @@ import org.slf4j.LoggerFactory;
                     "objectClass: top\n" +
                     "objectClass: domain\n\n"),
             indexes =
-            {
-                @CreateIndex(attribute = "objectClass"),
-                @CreateIndex(attribute = "dc"),
-                @CreateIndex(attribute = "ou")
+                {
+                    @CreateIndex(attribute = "objectClass"),
+                    @CreateIndex(attribute = "dc"),
+                    @CreateIndex(attribute = "ou")
             }) })
-@CreateLdapServer( name = "ADDIT",  transports =
-    { @CreateTransport(protocol = "LDAP", port = -1 ) })
+@CreateLdapServer(name = "ADDIT", transports =
+    { @CreateTransport(protocol = "LDAP", port = -1) })
 @ApplyLdifs(
     {
         // Entry # 0
@@ -195,7 +197,7 @@ public class AddIT extends AbstractLdapT
 
         // modify object classes, add two more
         Attributes attributes = LdifUtils.createJndiAttributes( "objectClass: organizationalPerson",
-                "objectClass: inetOrgPerson" );
+            "objectClass: inetOrgPerson" );
 
         DirContext person = ( DirContext ) ctx.lookup( RDN );
         person.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, attributes );
@@ -704,16 +706,17 @@ public class AddIT extends AbstractLdapT
         addRequest.addControl( manageDSAIT );
 
         // add success
-        Entry entry = new DefaultEntry( "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system",

+        Entry entry = new DefaultEntry( "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system",
             "objectClass", "organizationalUnit",
             "ou", "UnderReferral" );
-        
+
         addRequest.setEntry( entry );
 
         AddResponse addResponse = conn.add( addRequest );
         assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode()
);
 
-        assertNull( conn.lookup( "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system",
new Control[]{ manageDSAIT } ) );
+        assertNull( conn.lookup( "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system",
new Control[]
+            { manageDSAIT } ) );
 
         conn.close();
     }
@@ -783,8 +786,8 @@ public class AddIT extends AbstractLdapT
         AddRequest addRequest = new AddRequestImpl();
 
         // referrals failure
-        Entry entry = new DefaultEntry( 
-            "ou=UnderReferral,ou=Computers,uid=akarasuluref,ou=users,ou=system", 
+        Entry entry = new DefaultEntry(
+            "ou=UnderReferral,ou=Computers,uid=akarasuluref,ou=users,ou=system",
             "objectClass", "organizationalUnit",
             "ou", "UnderReferral" );
         addRequest.setEntry( entry );
@@ -793,9 +796,12 @@ public class AddIT extends AbstractLdapT
 
         assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode()
);
 
-        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://localhost:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system"
) );
-        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://foo:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system"
) );
-        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://bar:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system"
) );
+        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls()
+            .contains( "ldap://localhost:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system"
) );
+        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls()
+            .contains( "ldap://foo:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system"
) );
+        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls()
+            .contains( "ldap://bar:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system"
) );
 
         conn.close();
     }
@@ -817,20 +823,23 @@ public class AddIT extends AbstractLdapT
         //addRequest.addControl( manageDSAIT );
 
         // referrals failure
-        Entry entry = new DefaultEntry( 
-            "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system", 
+        Entry entry = new DefaultEntry(
+            "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system",
             "objectClass", "organizationalUnit",
             "ou", "UnderReferral" );
-        
+
         addRequest.setEntry( entry );
 
         AddResponse addResponse = conn.add( addRequest );
 
         assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode()
);
 
-        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://localhost:10389/ou=UnderReferral,uid=akarasulu,ou=users,ou=system"
) );
-        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://foo:10389/ou=UnderReferral,uid=akarasulu,ou=users,ou=system"
) );
-        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://bar:10389/ou=UnderReferral,uid=akarasulu,ou=users,ou=system"
) );
+        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls()
+            .contains( "ldap://localhost:10389/ou=UnderReferral,uid=akarasulu,ou=users,ou=system"
) );
+        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls()
+            .contains( "ldap://foo:10389/ou=UnderReferral,uid=akarasulu,ou=users,ou=system"
) );
+        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls()
+            .contains( "ldap://bar:10389/ou=UnderReferral,uid=akarasulu,ou=users,ou=system"
) );
 
         conn.close();
     }
@@ -886,7 +895,7 @@ public class AddIT extends AbstractLdapT
         attrs.put( "cn", "Jim, Bean" );
 
         DirContext jimBeanCtx = ctx.createSubcontext( "cn=\"Jim, Bean\"", attrs );
-        
+
         assertNotNull( jimBeanCtx );
     }
 
@@ -980,7 +989,7 @@ public class AddIT extends AbstractLdapT
      * Create an entry a Rdn which is not present in the entry,
      * with another attribute's value, and on a SingleValued attribute
      */
-    @Test
+    @Test(expected = InvalidAttributeValueException.class)
     public void testAddEntryDifferentRDNSingleValuedInEntry() throws Exception
     {
         DirContext ctx = ( DirContext ) getWiredContext( getLdapServer() ).lookup( BASE );
@@ -994,27 +1003,7 @@ public class AddIT extends AbstractLdapT
         person.put( "sn", "Michael Jackson" );
         person.put( "cn", "Jackson" );
 
-        DirContext michaelCtx = ctx.createSubcontext( "displayName=test", person );
-
-        assertNotNull( michaelCtx );
-
-        DirContext jackson = ( DirContext ) ctx.lookup( "displayName=test" );
-        person = jackson.getAttributes( "" );
-        javax.naming.directory.Attribute newOcls = person.get( "objectClass" );
-
-        String[] expectedOcls =
-            { "top", "person", "organizationalPerson", "inetOrgPerson" };
-
-        for ( String name : expectedOcls )
-        {
-            assertTrue( "object class " + name + " is present", newOcls.contains( name )
);
-        }
-
-        // Check that the displayName attribute has been replaced
-        javax.naming.directory.Attribute displayName = person.get( "displayName" );
-
-        assertEquals( 1, displayName.size() );
-        assertTrue( displayName.contains( "test" ) );
+        ctx.createSubcontext( "displayName=test", person );
     }
 
 
@@ -1329,10 +1318,10 @@ public class AddIT extends AbstractLdapT
      * @throws NamingException 
      */
     @Test
-    @CreateDS( 
+    @CreateDS(
         enableChangeLog = false,
-        name = "DSAlias" )
-    @CreateLdapServer( name = "DSAlias", transports =
+        name = "DSAlias")
+    @CreateLdapServer(name = "DSAlias", transports =
         { @CreateTransport(protocol = "LDAP", port = -1) })
     public void test_DIRSERVER_1357() throws Exception
     {
@@ -1367,6 +1356,7 @@ public class AddIT extends AbstractLdapT
         ctx.destroySubcontext( "cn=alias,ou=engineering" );
     }
 
+
     /**
      * Adding an entry with a non existing attribute type.
      * 
@@ -1389,9 +1379,9 @@ public class AddIT extends AbstractLdapT
         try
         {
             connection.add( personEntry );
-            fail("should throw LdapNoSuchAttributeException");
+            fail( "should throw LdapNoSuchAttributeException" );
         }
-        catch( LdapNoSuchAttributeException e )
+        catch ( LdapNoSuchAttributeException e )
         {
             //expected exception
         }
@@ -1408,7 +1398,7 @@ public class AddIT extends AbstractLdapT
      * 
      * @throws Exception 
      */
-    @Test( expected = LdapOperationException.class )
+    @Test(expected = LdapOperationException.class)
     public void testAddEntryNonExistingOC() throws Exception
     {
         LdapConnection connection = getAdminConnection( getLdapServer() );
@@ -1430,41 +1420,41 @@ public class AddIT extends AbstractLdapT
      * 
      * @throws Exception 
      */
-    @Test( expected = LdapException.class )
+    @Test(expected = LdapException.class)
     public void testAddEntry100KData() throws Exception
     {
         LdapConnection connection = getAdminConnection( getLdapServer() );
 
-        int size = 100*1024;
+        int size = 100 * 1024;
         byte[] dataBytes = new byte[size];
-        
-        for ( int i = 0; i < size; i++)
+
+        for ( int i = 0; i < size; i++ )
         {
             dataBytes[i] = 'A';
         }
-        
+
         String data = Strings.utf8ToString( dataBytes );
 
         Dn dn = new Dn( "cn=Kate Bush," + BASE );
-        
+
         Entry personEntry = new DefaultEntry( "cn=Kate Bush," + BASE,
-        "objectClass: top",
-        "objectClass: person",
-        "cn: Kate Bush",
-        "sn: Bush",
-        "description", data );
+            "objectClass: top",
+            "objectClass: person",
+            "cn: Kate Bush",
+            "sn: Bush",
+            "description", data );
 
         connection.add( personEntry );
-        
+
         // Check that the entry has been stored 
         Entry entry = connection.lookup( dn, "description", "cn", "sn" );
-        
+
         String description = entry.get( "description" ).getString();
-        
+
         assertNotNull( description );
         assertTrue( description.startsWith( "AAA" ) );
         assertEquals( size, description.length() );
-        
+
         for ( int i = 0; i < size; i++ )
         {
             assertEquals( 'A', description.charAt( i ) );



Mime
View raw message