directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r691847 [2/2] - in /directory: apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ apacheds/trunk/core/src/main/java/org/apache/direct...
Date Thu, 04 Sep 2008 01:23:13 GMT
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java?rev=691847&r1=691846&r2=691847&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java
Wed Sep  3 18:23:12 2008
@@ -24,8 +24,6 @@
 import java.util.List;
 
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.ModificationItem;
 
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
@@ -37,6 +35,8 @@
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.ResponseCarryingException;
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequest;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.message.Message;
 import org.apache.directory.shared.ldap.message.ModifyResponseImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
@@ -120,25 +120,25 @@
         assertEquals( 1, message.getMessageId() );
         assertEquals( "cn=testModify,ou=users,ou=system", modifyRequest.getObject().toString()
);
 
-        List<ModificationItem> modifications = modifyRequest.getModifications();
+        List<Modification> modifications = modifyRequest.getModifications();
 
         assertEquals( 2, modifications.size() );
 
-        ModificationItem modification = modifications.get( 0 );
-        Attribute attributeValue =  modification.getAttribute();
-
-        assertEquals( "l", attributeValue.getID().toLowerCase() );
-
-        String attrValue = ( String ) attributeValue.get( 0 );
-        assertEquals( "Paris", attrValue );
-
-        modification = modifications.get( 1 );
-        attributeValue =  modification.getAttribute();
-
-        assertEquals( "attrs", attributeValue.getID().toLowerCase() );
-
-        attrValue = ( String ) attributeValue.get( 0 );
-        assertEquals( "test", attrValue );
+        for ( Modification modification:modifications )
+        {
+            EntryAttribute attribute =  modification.getAttribute();
+            
+            if ( "l".equalsIgnoreCase( attribute.getId() ) )
+            {
+                String attrValue = attribute.getString();
+                assertEquals( "Paris", attrValue );
+            }
+            else if ( "attrs".equalsIgnoreCase( attribute.getId() ) )
+            {
+                String attrValue = attribute.getString();
+                assertEquals( "test", attrValue );
+            }
+        }
 
         // Check the length
         assertEquals( 0x54, message.computeLength() );
@@ -288,24 +288,24 @@
         assertEquals( 21, message.getMessageId() );
         assertEquals( "cn=Tori Amos,ou=playground,dc=apache,dc=org", modifyRequest.getObject().toString()
);
 
-        List<ModificationItem> modifications = modifyRequest.getModifications();
+        List<Modification> modifications = modifyRequest.getModifications();
 
         assertEquals( 2, modifications.size() );
 
-        ModificationItem modification = modifications.get( 0 );
-        Attribute attributeValue = modification.getAttribute();
+        Modification modification = modifications.get( 0 );
+        EntryAttribute attributeValue = modification.getAttribute();
 
-        assertEquals( "telephonenumber", attributeValue.getID().toLowerCase() );
+        assertEquals( "telephonenumber", attributeValue.getId().toLowerCase() );
 
-        String attrValue = ( String ) attributeValue.get( 0 );
+        String attrValue = attributeValue.getString();
         assertEquals( "1234567890", attrValue );
 
         modification = modifications.get( 1 );
         attributeValue = modification.getAttribute();
 
-        assertEquals( "cn", attributeValue.getID().toLowerCase() );
+        assertEquals( "cn", attributeValue.getId().toLowerCase() );
 
-        attrValue = ( String ) attributeValue.get( 0 );
+        attrValue = attributeValue.getString();
         assertEquals( "XXX", attrValue );
 
         // Check the length
@@ -411,33 +411,33 @@
         assertEquals( 49, message.getMessageId() );
         assertEquals( "cn=Tori Amos,ou=playground,dc=apache,dc=org", modifyRequest.getObject().toString()
);
 
-        List<ModificationItem> modifications = modifyRequest.getModifications();
+        List<Modification> modifications = modifyRequest.getModifications();
 
         assertEquals( 3, modifications.size() );
 
-        ModificationItem modification = modifications.get( 0 );
-        Attribute attributeValue = modification.getAttribute();
+        Modification modification = modifications.get( 0 );
+        EntryAttribute attributeValue = modification.getAttribute();
 
-        assertEquals( "description", attributeValue.getID().toLowerCase() );
+        assertEquals( "description", attributeValue.getId().toLowerCase() );
         assertEquals( 0, attributeValue.size() );
 
         modification = modifications.get( 1 );
         attributeValue = modification.getAttribute();
 
-        String attrValue = ( String ) attributeValue.get( 0 );
+        String attrValue = attributeValue.getString();
 
-        assertEquals( "telephonenumber", attributeValue.getID().toLowerCase() );
+        assertEquals( "telephonenumber", attributeValue.getId().toLowerCase() );
 
         assertEquals( "01234567890", attrValue );
 
         modification = modifications.get( 2 );
         attributeValue = modification.getAttribute();
 
-        attrValue = ( String ) attributeValue.get( 0 );
+        attrValue = attributeValue.getString();
 
-        assertEquals( "telephonenumber", attributeValue.getID().toLowerCase() );
+        assertEquals( "telephonenumber", attributeValue.getId().toLowerCase() );
 
-        attrValue = ( String ) attributeValue.get( 0 );
+        attrValue = attributeValue.getString();
         assertEquals( "01234567890", attrValue );
 
         // Check the length
@@ -542,27 +542,27 @@
         assertEquals( 1, message.getMessageId() );
         assertEquals( "cn=testModify,ou=users,ou=system", modifyRequest.getObject().toString()
);
 
-        List<ModificationItem> modifications = modifyRequest.getModifications();
+        List<Modification> modifications = modifyRequest.getModifications();
 
         assertEquals( 2, modifications.size() );
 
-        ModificationItem modification = modifications.get( 0 );
-        Attribute attributeValue = modification.getAttribute();
+        Modification modification = modifications.get( 0 );
+        EntryAttribute attributeValue = modification.getAttribute();
 
-        assertEquals( "l", attributeValue.getID().toLowerCase() );
+        assertEquals( "l", attributeValue.getId().toLowerCase() );
 
-        String attrValue = ( String ) attributeValue.get( 0 );
+        String attrValue = attributeValue.getString();
         assertEquals( "Paris", attrValue );
 
-        attrValue = ( String ) attributeValue.get( 1 );
+        attrValue = (String)attributeValue.get( 1 ).get();
         assertEquals( "London", attrValue );
 
         modification = modifications.get( 1 );
         attributeValue = modification.getAttribute();
 
-        assertEquals( "attrs", attributeValue.getID().toLowerCase() );
+        assertEquals( "attrs", attributeValue.getId().toLowerCase() );
 
-        attrValue = ( String ) attributeValue.get( 0 );
+        attrValue = attributeValue.getString();
         assertEquals( "test", attrValue );
 
         // Check the length
@@ -1073,14 +1073,14 @@
         assertEquals( 49, message.getMessageId() );
         assertEquals( "cn=testModify,ou=users,ou=system", modifyRequest.getObject().toString()
);
 
-        List<ModificationItem> modifications = modifyRequest.getModifications();
+        List<Modification> modifications = modifyRequest.getModifications();
 
         assertEquals( 1, modifications.size() );
 
-        ModificationItem modification = modifications.get( 0 );
-        Attribute attributeValue = modification.getAttribute();
+        Modification modification = modifications.get( 0 );
+        EntryAttribute attributeValue = modification.getAttribute();
 
-        assertEquals( "l", attributeValue.getID().toLowerCase() );
+        assertEquals( "l", attributeValue.getId().toLowerCase() );
         assertEquals( 0, attributeValue.size() );
 
         // Check the length
@@ -1156,14 +1156,14 @@
         assertEquals( 49, message.getMessageId() );
         assertEquals( "cn=testModify,ou=users,ou=system", modifyRequest.getObject().toString()
);
 
-        List<ModificationItem> modifications = modifyRequest.getModifications();
+        List<Modification> modifications = modifyRequest.getModifications();
 
         assertEquals( 1, modifications.size() );
 
-        ModificationItem modification = modifications.get( 0 );
-        Attribute attributeValue = modification.getAttribute();
+        Modification modification = modifications.get( 0 );
+        EntryAttribute attributeValue = modification.getAttribute();
 
-        assertEquals( "l", attributeValue.getID().toLowerCase() );
+        assertEquals( "l", attributeValue.getId().toLowerCase() );
         assertEquals( 0, attributeValue.size() );
 
         // Check the Control
@@ -1247,20 +1247,20 @@
         assertEquals( 49, message.getMessageId() );
         assertEquals( "cn=testModify,ou=users,ou=system", modifyRequest.getObject().toString()
);
 
-        List<ModificationItem> modifications = modifyRequest.getModifications();
+        List<Modification> modifications = modifyRequest.getModifications();
 
         assertEquals( 1, modifications.size() );
 
-        ModificationItem modification = modifications.get( 0 );
-        Attribute attributeValue = modification.getAttribute();
+        Modification modification = modifications.get( 0 );
+        EntryAttribute attributeValue = modification.getAttribute();
 
-        assertEquals( "l", attributeValue.getID().toLowerCase() );
+        assertEquals( "l", attributeValue.getId().toLowerCase() );
         assertEquals( 2, attributeValue.size() );
 
-        String attrValue = ( String ) attributeValue.get( 0 );
+        String attrValue = attributeValue.getString();
         assertEquals( "a", attrValue );
 
-        attrValue = ( String ) attributeValue.get( 1 );
+        attrValue = ( String ) attributeValue.get( 1 ).get();
         assertEquals( "b", attrValue );
 
         // Check the length

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyRequestImplTest.java?rev=691847&r1=691846&r2=691847&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyRequestImplTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyRequestImplTest.java
Wed Sep  3 18:23:12 2008
@@ -23,12 +23,13 @@
 import junit.framework.TestCase;
 
 import javax.naming.InvalidNameException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
 import javax.naming.ldap.Control;
 
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.client.ClientModification;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
 import org.apache.directory.shared.ldap.message.AbandonListener;
 import org.apache.directory.shared.ldap.message.MessageException;
 import org.apache.directory.shared.ldap.message.MessageTypeEnum;
@@ -73,22 +74,22 @@
             // do nothing
         }
 
-        Attribute attr = new BasicAttribute( "attr0" );
+        EntryAttribute attr = new DefaultClientAttribute( "attr0" );
         attr.add( "val0" );
         attr.add( "val1" );
         attr.add( "val2" );
-        ModificationItem item = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
+        Modification item = new ClientModification( ModificationOperation.ADD_ATTRIBUTE,
attr );
         req.addModification( item );
 
-        attr = new BasicAttribute( "attr1" );
+        attr = new DefaultClientAttribute( "attr1" );
         attr.add( "val3" );
-        item = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, attr );
+        item = new ClientModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );
         req.addModification( item );
 
-        attr = new BasicAttribute( "attr2" );
+        attr = new DefaultClientAttribute( "attr2" );
         attr.add( "val4" );
         attr.add( "val5" );
-        item = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
+        item = new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE, attr );
         req.addModification( item );
 
         return req;
@@ -154,19 +155,19 @@
     public void testNotEqualDiffModOps()
     {
         ModifyRequestImpl req0 = getRequest();
-        Attribute attr = new BasicAttribute( "attr3" );
+        EntryAttribute attr = new DefaultClientAttribute( "attr3" );
         attr.add( "val0" );
         attr.add( "val1" );
         attr.add( "val2" );
-        ModificationItem item = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
+        Modification item = new ClientModification( ModificationOperation.ADD_ATTRIBUTE,
attr );
         req0.addModification( item );
 
         ModifyRequestImpl req1 = getRequest();
-        attr = new BasicAttribute( "attr3" );
+        attr = new DefaultClientAttribute( "attr3" );
         attr.add( "val0" );
         attr.add( "val1" );
         attr.add( "val2" );
-        item = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, attr );
+        item = new ClientModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );
         req0.addModification( item );
 
         assertFalse( req0.equals( req1 ) );
@@ -180,11 +181,11 @@
     public void testNotEqualDiffModCount()
     {
         ModifyRequestImpl req0 = getRequest();
-        Attribute attr = new BasicAttribute( "attr3" );
+        EntryAttribute attr = new DefaultClientAttribute( "attr3" );
         attr.add( "val0" );
         attr.add( "val1" );
         attr.add( "val2" );
-        ModificationItem item = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
+        Modification item = new ClientModification( ModificationOperation.ADD_ATTRIBUTE,
attr );
         req0.addModification( item );
 
         ModifyRequestImpl req1 = getRequest();
@@ -200,19 +201,19 @@
     public void testNotEqualDiffModIds()
     {
         ModifyRequestImpl req0 = getRequest();
-        Attribute attr = new BasicAttribute( "attr3" );
+        EntryAttribute attr = new DefaultClientAttribute( "attr3" );
         attr.add( "val0" );
         attr.add( "val1" );
         attr.add( "val2" );
-        ModificationItem item = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
+        Modification item = new ClientModification( ModificationOperation.ADD_ATTRIBUTE,
attr );
         req0.addModification( item );
 
         ModifyRequestImpl req1 = getRequest();
-        attr = new BasicAttribute( "attr4" );
+        attr = new DefaultClientAttribute( "attr4" );
         attr.add( "val0" );
         attr.add( "val1" );
         attr.add( "val2" );
-        item = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
+        item = new ClientModification( ModificationOperation.ADD_ATTRIBUTE, attr );
         req0.addModification( item );
 
         assertFalse( req0.equals( req1 ) );
@@ -226,20 +227,20 @@
     public void testNotEqualDiffModValues()
     {
         ModifyRequestImpl req0 = getRequest();
-        Attribute attr = new BasicAttribute( "attr3" );
+        EntryAttribute attr = new DefaultClientAttribute( "attr3" );
         attr.add( "val0" );
         attr.add( "val1" );
         attr.add( "val2" );
-        ModificationItem item = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
+        Modification item = new ClientModification( ModificationOperation.ADD_ATTRIBUTE,
attr );
         req0.addModification( item );
 
         ModifyRequestImpl req1 = getRequest();
-        attr = new BasicAttribute( "attr3" );
+        attr = new DefaultClientAttribute( "attr3" );
         attr.add( "val0" );
         attr.add( "val1" );
         attr.add( "val2" );
         attr.add( "val3" );
-        item = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
+        item = new ClientModification( ModificationOperation.ADD_ATTRIBUTE, attr );
         req0.addModification( item );
 
         assertFalse( req0.equals( req1 ) );
@@ -254,37 +255,37 @@
     {
         ModifyRequest req0 = new ModifyRequest()
         {
-            public Collection<ModificationItem> getModificationItems()
+            public Collection<Modification> getModificationItems()
             {
-                List<ModificationItem> list = new ArrayList<ModificationItem>();
-                Attribute attr = new BasicAttribute( "attr0" );
+                List<Modification> list = new ArrayList<Modification>();
+                EntryAttribute attr = new DefaultClientAttribute( "attr0" );
                 attr.add( "val0" );
                 attr.add( "val1" );
                 attr.add( "val2" );
-                ModificationItem item = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr
);
+                Modification item = new ClientModification( ModificationOperation.ADD_ATTRIBUTE,
attr );
                 list.add( item );
 
-                attr = new BasicAttribute( "attr1" );
+                attr = new DefaultClientAttribute( "attr1" );
                 attr.add( "val3" );
-                item = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, attr );
+                item = new ClientModification( ModificationOperation.REMOVE_ATTRIBUTE, attr
);
                 list.add( item );
 
-                attr = new BasicAttribute( "attr2" );
+                attr = new DefaultClientAttribute( "attr2" );
                 attr.add( "val4" );
                 attr.add( "val5" );
-                item = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
+                item = new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE, attr
);
                 list.add( item );
 
                 return list;
             }
 
 
-            public void addModification( ModificationItem mod )
+            public void addModification( Modification mod )
             {
             }
 
 
-            public void removeModification( ModificationItem mod )
+            public void removeModification( Modification mod )
             {
             }
 



Mime
View raw message