directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r725712 [9/9] - in /directory: apacheds/trunk/ apacheds/trunk/all/ apacheds/trunk/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/ apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltr...
Date Thu, 11 Dec 2008 15:32:12 GMT
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindResponseTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindResponseTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindResponseTest.java Thu Dec 11 07:32:04 2008
@@ -21,6 +21,7 @@
 
 
 import java.nio.ByteBuffer;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
@@ -32,7 +33,9 @@
 import org.apache.directory.shared.ldap.codec.LdapMessage;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.bind.BindResponse;
+import org.apache.directory.shared.ldap.codec.search.controls.PagedSearchControlCodec;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.control.PagedSearchControl;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 import junit.framework.TestCase;
@@ -124,26 +127,32 @@
         ByteBuffer stream = ByteBuffer.allocate( 0x3C );
 
         stream.put( new byte[]
-            { 0x30, 0x3A, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x61, 0x07, // CHOICE { ..., bindResponse BindResponse, ...
-                // BindResponse ::= APPLICATION[1] SEQUENCE {
-                // COMPONENTS OF LDAPResult,
-                0x0A, 0x01, 0x00, // LDAPResult ::= SEQUENCE {
-                // resultCode ENUMERATED {
-                // success (0), ...
-                // },
-                0x04, 0x00, // matchedDN LDAPDN,
-                0x04, 0x00, // errorMessage LDAPString,
-                // referral [3] Referral OPTIONAL }
-                // serverSaslCreds [7] OCTET STRING OPTIONAL }
-                ( byte ) 0xa0, 0x2C, // controls
-                0x30, 0x2A, 0x04, 0x16, 0x31, 0x2e, 0x32, 0x2e, 0x38, 0x34, 0x30, 0x2e, 0x31, 0x31, 0x33, 0x35, 0x35,
-                0x36, 0x2e, 0x31, 0x2e, 0x34, 0x2e, 0x33, 0x31, 0x39, // control
-                                                                        // oid:
-                                                                        // 1.2.840.113556.1.4.319
-                0x01, 0x01, ( byte ) 0xff, // criticality: false
-                0x04, 0x0D, 0x30, 0x0B, 0x0A, 0x01, 0x08, 0x04, 0x03, 'a', '=', 'b', 0x02, 0x01, 0x10 } );
+            { 
+              0x30, 0x3A,                      // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01, 0x01,              // messageID MessageID
+                0x61, 0x07,                    // CHOICE { ..., bindResponse BindResponse, ...
+                                               // BindResponse ::= APPLICATION[1] SEQUENCE {
+                                               // COMPONENTS OF LDAPResult,
+                  0x0A, 0x01, 0x00,            // LDAPResult ::= SEQUENCE {
+                                               // resultCode ENUMERATED {
+                                               // success (0), ...
+                                               // },
+                  0x04, 0x00,                  // matchedDN LDAPDN,
+                  0x04, 0x00,                  // errorMessage LDAPString,
+                                               // referral [3] Referral OPTIONAL }
+                                               // serverSaslCreds [7] OCTET STRING OPTIONAL }
+                  ( byte ) 0xa0, 0x2C,         // controls
+                    0x30, 0x2A,                // The PagedSearchControl
+                      0x04, 0x16,              // Oid : 1.2.840.113556.1.4.319
+                        0x31, 0x2e, 0x32, 0x2e, 0x38, 0x34, 0x30, 0x2e, 
+                        0x31, 0x31, 0x33, 0x35, 0x35, 0x36, 0x2e, 0x31, 
+                        0x2e, 0x34, 0x2e, 0x33, 0x31, 0x39, // control
+                    0x01, 0x01, ( byte ) 0xff, // criticality: false
+                    0x04, 0x0D,
+                      0x30, 0x0B,
+                        0x02, 0x01, 0x05,      // Size = 5, cookie = "abcdef" 
+                        0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f'
+              } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -181,8 +190,12 @@
 
         Control control = message.getControls( 0 );
         assertEquals( "1.2.840.113556.1.4.319", control.getControlType() );
-        assertEquals( "0x30 0x0B 0x0A 0x01 0x08 0x04 0x03 0x61 0x3D 0x62 0x02 0x01 0x10 ", StringTools
-            .dumpBytes( ( byte[] ) control.getControlValue() ) );
+        assertTrue( control.getControlValue() instanceof PagedSearchControlCodec );
+        
+        PagedSearchControlCodec pagedSearchControl = (PagedSearchControlCodec)control.getControlValue();
+        
+        assertEquals( 5, pagedSearchControl.getSize() );
+        assertTrue( Arrays.equals( "abcdef".getBytes(), pagedSearchControl.getCookie() ) );
 
         // Check the encoding
         try

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectTest.java Thu Dec 11 07:32:04 2008
@@ -45,7 +45,7 @@
     /**
      * Test the decoding of a GracefulDisconnect
      */
-	@Test
+    @Test
     public void testDecodeGracefulDisconnectSuccess()
     {
         Asn1Decoder decoder = new GracefulDisconnectDecoder();
@@ -110,7 +110,7 @@
     /**
      * Test the decoding of a GracefulDisconnect with a timeOffline only
      */
-	@Test
+    @Test
     public void testDecodeGracefulDisconnectTimeOffline()
     {
         Asn1Decoder decoder = new GracefulDisconnectDecoder();
@@ -163,7 +163,7 @@
     /**
      * Test the decoding of a GracefulDisconnect with a delay only
      */
-	@Test
+    @Test
     public void testDecodeGracefulDisconnectDelay()
     {
         Asn1Decoder decoder = new GracefulDisconnectDecoder();
@@ -217,7 +217,7 @@
     /**
      * Test the decoding of a GracefulDisconnect with a timeOffline and a delay
      */
-	@Test
+    @Test
     public void testDecodeGracefulDisconnectTimeOfflineDelay()
     {
         Asn1Decoder decoder = new GracefulDisconnectDecoder();
@@ -272,7 +272,7 @@
     /**
      * Test the decoding of a GracefulDisconnect with replicatedContexts only
      */
-	@Test
+    @Test
     public void testDecodeGracefulDisconnectReplicatedContextsOnly()
     {
         Asn1Decoder decoder = new GracefulDisconnectDecoder();
@@ -337,7 +337,7 @@
     /**
      * Test the decoding of a empty GracefulDisconnect
      */
-	@Test
+    @Test
     public void testDecodeGracefulDisconnectEmpty()
     {
         Asn1Decoder decoder = new GracefulDisconnectDecoder();
@@ -391,7 +391,7 @@
     /**
      * Test the decoding of a GracefulDisconnect with a timeOffline off limit
      */
-	@Test
+    @Test
     public void testDecodeGracefulDisconnectTimeOfflineOffLimit()
     {
         Asn1Decoder decoder = new GracefulDisconnectDecoder();
@@ -422,7 +422,7 @@
     /**
      * Test the decoding of a GracefulDisconnect with a delay off limit
      */
-	@Test
+    @Test
     public void testDecodeGracefulDisconnectDelayOffLimit()
     {
         Asn1Decoder decoder = new GracefulDisconnectDecoder();
@@ -456,7 +456,7 @@
     /**
      * Test the decoding of a GracefulDisconnect with an empty TimeOffline
      */
-	@Test
+    @Test
     public void testDecodeGracefulDisconnectTimeOfflineEmpty()
     {
         Asn1Decoder decoder = new GracefulDisconnectDecoder();
@@ -486,7 +486,7 @@
     /**
      * Test the decoding of a GracefulDisconnect with an empty delay
      */
-	@Test
+    @Test
     public void testDecodeGracefulDisconnectDelayEmpty()
     {
         Asn1Decoder decoder = new GracefulDisconnectDecoder();
@@ -517,7 +517,7 @@
      * Test the decoding of a GracefulDisconnect with an empty replicated
      * contexts
      */
-	@Test
+    @Test
     public void testDecodeGracefulDisconnectReplicatedContextsEmpty()
     {
         Asn1Decoder decoder = new GracefulDisconnectDecoder();
@@ -548,7 +548,7 @@
      * Test the decoding of a GracefulDisconnect with an invalid replicated
      * context
      */
-	@Test
+    @Test
     public void testDecodeGracefulDisconnectReplicatedContextsInvalid()
     {
         Asn1Decoder decoder = new GracefulDisconnectDecoder();

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownTest.java Thu Dec 11 07:32:04 2008
@@ -45,7 +45,7 @@
     /**
      * Test the decoding of a GracefulShutdown
      */
-	@Test
+    @Test
     public void testDecodeGracefulShutdownSuccess()
     {
         Asn1Decoder decoder = new LdapDecoder();
@@ -100,7 +100,7 @@
     /**
      * Test the decoding of a GracefulShutdown with a timeOffline only
      */
-	@Test
+    @Test
     public void testDecodeGracefulShutdownTimeOffline()
     {
         Asn1Decoder decoder = new LdapDecoder();
@@ -152,7 +152,7 @@
     /**
      * Test the decoding of a GracefulShutdown with a delay only
      */
-	@Test
+    @Test
     public void testDecodeGracefulShutdownDelay()
     {
         Asn1Decoder decoder = new LdapDecoder();
@@ -205,7 +205,7 @@
     /**
      * Test the decoding of a empty GracefulShutdown
      */
-	@Test
+    @Test
     public void testDecodeGracefulShutdownEmpty()
     {
         Asn1Decoder decoder = new LdapDecoder();
@@ -256,7 +256,7 @@
     /**
      * Test the decoding of a GracefulShutdown with a delay above 128
      */
-	@Test
+    @Test
     public void testDecodeGracefulShutdownDelayHigh()
     {
         Asn1Decoder decoder = new LdapDecoder();
@@ -310,7 +310,7 @@
     /**
      * Test the decoding of a GracefulShutdown with a delay equals 32767
      */
-	@Test
+    @Test
     public void testDecodeGracefulShutdownDelay32767()
     {
         Asn1Decoder decoder = new LdapDecoder();
@@ -364,7 +364,7 @@
     /**
      * Test the decoding of a GracefulShutdown with a delay above 32768
      */
-	@Test
+    @Test
     public void testDecodeGracefulShutdownDelay32768()
     {
         Asn1Decoder decoder = new LdapDecoder();
@@ -422,7 +422,7 @@
     /**
      * Test the decoding of a GracefulShutdown with a timeOffline off limit
      */
-	@Test
+    @Test
     public void testDecodeGracefulShutdownTimeOfflineOffLimit()
     {
         Asn1Decoder decoder = new LdapDecoder();
@@ -453,7 +453,7 @@
     /**
      * Test the decoding of a GracefulShutdown with a delay off limit
      */
-	@Test
+    @Test
     public void testDecodeGracefulShutdownDelayOffLimit()
     {
         Asn1Decoder decoder = new LdapDecoder();
@@ -487,7 +487,7 @@
     /**
      * Test the decoding of a GracefulShutdown with an empty TimeOffline
      */
-	@Test
+    @Test
     public void testDecodeGracefulShutdownTimeOfflineEmpty()
     {
         Asn1Decoder decoder = new LdapDecoder();
@@ -517,7 +517,7 @@
     /**
      * Test the decoding of a GracefulShutdown with an empty delay
      */
-	@Test
+    @Test
     public void testDecodeGracefulShutdownDelayEmpty()
     {
         Asn1Decoder decoder = new LdapDecoder();

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java Thu Dec 11 07:32:04 2008
@@ -54,8 +54,12 @@
 import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.OidNormalizer;
 import org.apache.directory.shared.ldap.util.StringTools;
-
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 
 /**
@@ -63,14 +67,13 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class SearchRequestTest extends TestCase
+public class SearchRequestTest
 {
     static Map<String, OidNormalizer> oids = new HashMap<String, OidNormalizer>(); 
 
-    protected void setUp() throws Exception
+    @Before
+    public void setUp() throws Exception
     {
-        super.setUp();
-
         oids.put( "dc", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
         oids.put( "domaincomponent", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
         oids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
@@ -86,6 +89,7 @@
      * Test the decoding of a SearchRequest with no controls. The search filter
      * is : (&(|(objectclass=top)(ou=contacts))(!(objectclass=ttt)))
      */
+    @Test
     public void testDecodeSearchRequestGlobalNoControls()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -251,6 +255,7 @@
      * types of filter : >=, <=, ~= The search filter is :
      * (&(|(objectclass~=top)(ou<=contacts))(!(objectclass>=ttt)))
      */
+    @Test
     public void testDecodeSearchRequestCompareFiltersNoControls()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -419,6 +424,7 @@
      * filter : =* The search filter is :
      * (&(|(objectclass=*)(ou=*))(!(objectclass>=ttt)))
      */
+    @Test
     public void testDecodeSearchRequestPresentNoControls()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -585,6 +591,7 @@
      * Test the decoding of a SearchRequest with no attributes. The search
      * filter is : (objectclass=*)
      */
+    @Test
     public void testDecodeSearchRequestNoAttributes()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -684,6 +691,7 @@
      * Test the decoding of a SearchRequest with an empty attribute. The search
      * filter is : (objectclass=*)
      */
+    @Test
     public void testDecodeSearchRequestOneEmptyAttribute()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -766,6 +774,7 @@
      * Test the decoding of a SearchRequest with a star and an attribute. The search
      * filter is : (objectclass=*)
      */
+    @Test
     public void testDecodeSearchRequestWithStarAndAttr()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -859,6 +868,7 @@
     /**
      * Tests an search request decode with a simple equality match filter.
      */
+    @Test
     public void testDecodeSearchRequestOrFilters()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1011,6 +1021,7 @@
     /**
      * Test the decoding of a SearchRequest with controls.
      */
+    @Test
     public void testDecodeSearchRequestWithControls()
     {
         byte[] asn1BER = new byte[]
@@ -1112,6 +1123,7 @@
      * attributes. The search filter is :
      * (&(|(objectclass=top)(2.5.4.11=contacts))(!(organizationalUnitName=ttt)))
      */
+    @Test
     public void testDecodeSearchRequestGlobalNoControlsOidAndAlias()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1274,6 +1286,7 @@
     /**
      * Test the decoding of a SearchRequest with SubEntry control.
      */
+    @Test
     public void testDecodeSearchRequestSubEntryControl()
     {
         byte[] asn1BER = new byte[]
@@ -1364,6 +1377,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty body
      */
+    @Test
     public void testDecodeSearchRequestEmptyBody()
     {
         byte[] asn1BER = new byte[]
@@ -1397,6 +1411,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty baseDN and nothing more
      */
+    @Test
     public void testDecodeSearchRequestBaseDnOnly()
     {
         byte[] asn1BER = new byte[]
@@ -1434,6 +1449,7 @@
      * Test the decoding of a SearchRequest with no controls. The search filter
      * is : (&(|(objectclass=top)(ou=contacts))(!(objectclass=ttt)))
      */
+    @Test
     public void testDecodeSearchRequestEmptyBaseDnNoControls()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1594,6 +1610,7 @@
     /**
      * Test the decoding of a SearchRequest with a bad objectBase
      */
+    @Test
     public void testDecodeSearchRequestGlobalBadObjectBase()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1676,6 +1693,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty scope
      */
+    @Test
     public void testDecodeSearchRequestEmptyScope()
     {
         byte[] asn1BER = new byte[]
@@ -1715,6 +1733,7 @@
     /**
      * Test the decoding of a SearchRequest with a bad scope
      */
+    @Test
     public void testDecodeSearchRequestGlobalBadScope()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1794,6 +1813,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty derefAlias
      */
+    @Test
     public void testDecodeSearchRequestEmptyDerefAlias()
     {
         byte[] asn1BER = new byte[]
@@ -1828,6 +1848,7 @@
     /**
      * Test the decoding of a SearchRequest with a bad derefAlias
      */
+    @Test
     public void testDecodeSearchRequestGlobalBadDerefAlias()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1908,6 +1929,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty size limit
      */
+    @Test
     public void testDecodeSearchRequestEmptySizeLimit()
     {
         byte[] asn1BER = new byte[]
@@ -1942,6 +1964,7 @@
     /**
      * Test the decoding of a SearchRequest with a bad sizeLimit
      */
+    @Test
     public void testDecodeSearchRequestGlobalBadSizeLimit()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -2021,6 +2044,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty time limit
      */
+    @Test
     public void testDecodeSearchRequestEmptyTimeLimit()
     {
         byte[] asn1BER = new byte[]
@@ -2056,6 +2080,7 @@
     /**
      * Test the decoding of a SearchRequest with a bad timeLimit
      */
+    @Test
     public void testDecodeSearchRequestGlobalBadTimeLimit()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -2135,6 +2160,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty filter
      */
+    @Test
     public void testDecodeSearchRequestEmptyTypeOnly()
     {
         byte[] asn1BER = new byte[]
@@ -2178,6 +2204,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty filter
      */
+    @Test
     public void testDecodeSearchRequestEmptyFilter()
     {
         byte[] asn1BER = new byte[]
@@ -2214,6 +2241,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty Present filter
      */
+    @Test
     public void testDecodeSearchRequestEmptyPresentFilter()
     {
         byte[] asn1BER = new byte[]
@@ -2260,6 +2288,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty equalityMatch filter
      */
+    @Test
     public void testDecodeSearchRequestEmptyEqualityMatchFilter()
     {
         byte[] asn1BER = new byte[]
@@ -2296,6 +2325,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty greaterOrEqual filter
      */
+    @Test
     public void testDecodeSearchRequestEmptyGreaterOrEqualFilter()
     {
         byte[] asn1BER = new byte[]
@@ -2332,6 +2362,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty lessOrEqual filter
      */
+    @Test
     public void testDecodeSearchRequestEmptyLessOrEqualFilter()
     {
         byte[] asn1BER = new byte[]
@@ -2368,6 +2399,7 @@
     /**
      * Test the decoding of a SearchRequest with an approxMatch filter
      */
+    @Test
     public void testDecodeSearchRequestEmptyApproxMatchFilter()
     {
         byte[] asn1BER = new byte[]
@@ -2405,6 +2437,7 @@
      * Test the decoding of a SearchRequest with a greaterOrEqual filter and an
      * empty attributeDesc
      */
+    @Test
     public void testDecodeSearchRequestEmptyGreaterOrEqualEmptyAttrDesc()
     {
         byte[] asn1BER = new byte[]
@@ -2451,6 +2484,7 @@
      * Test the decoding of a SearchRequest with a greaterOrEqual filter and an
      * empty attributeValue, and an empty attribute List
      */
+    @Test
     public void testDecodeSearchRequestEmptyGreaterOrEqualEmptyAttrValue()
     {
         byte[] asn1BER = new byte[]
@@ -2545,6 +2579,7 @@
      * Test the decoding of a SearchRequest with a greaterOrEqual filter and an
      * empty attributeValue, and an '*' attribute List
      */
+    @Test
     public void testDecodeSearchRequestEmptyGreaterOrEqualEmptyAttrValueStar()
     {
         byte[] asn1BER = new byte[]
@@ -2628,6 +2663,7 @@
      * Test the decoding of a SearchRequest with a greaterOrEqual filter and an
      * empty attributeValue, and an empty attribute List
      */
+    @Test
     public void testDecodeSearchRequestEmptyGreaterOrEqualEmptyAttrValueEmpty()
     {
         byte[] asn1BER = new byte[]
@@ -2703,6 +2739,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty And filter
      */
+    @Test
     public void testDecodeSearchRequestEmptyAndFilter()
     {
         byte[] asn1BER = new byte[]
@@ -2744,6 +2781,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty Or filter
      */
+    @Test
     public void testDecodeSearchRequestEmptyOrFilter()
     {
         byte[] asn1BER = new byte[]
@@ -2785,6 +2823,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty Not filter
      */
+    @Test
     public void testDecodeSearchRequestEmptyNotFilter()
     {
         byte[] asn1BER = new byte[]
@@ -2827,6 +2866,7 @@
      * Test the decoding of a SearchRequest with a Not filter and an empty And
      * filter
      */
+    @Test
     public void testDecodeSearchRequestNotFilterEmptyAndFilter()
     {
         byte[] asn1BER = new byte[]
@@ -2866,6 +2906,7 @@
      * Test the decoding of a SearchRequest with a greaterOrEqual filter and an
      * empty attributeValue, and an '*' attribute List
      */
+    @Test
     public void testDecodeSearchRequestDIRSERVER_651()
     {
         byte[] asn1BER = new byte[]
@@ -2976,6 +3017,7 @@
      * Test the decoding of a SearchRequest
      * (a=b)
      */
+    @Test
     public void testDecodeSearchRequestEq()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -3076,6 +3118,7 @@
      * Test the decoding of a SearchRequest
      * (&(a=b))
      */
+    @Test
     public void testDecodeSearchRequestAndEq()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -3184,6 +3227,7 @@
      * Test the decoding of a SearchRequest
      * (&(a=b)(c=d))
      */
+    @Test
     public void testDecodeSearchRequestAndEqEq()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -3307,6 +3351,7 @@
      * Test the decoding of a SearchRequest
      * (&(&(a=b))
      */
+    @Test
     public void testDecodeSearchRequestAndAndEq()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -3421,6 +3466,7 @@
      * Test the decoding of a SearchRequest
      * (&(&(a=b)(c=d))
      */
+    @Test
     public void testDecodeSearchRequestAndAndEqEq()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -3551,6 +3597,7 @@
      * Test the decoding of a SearchRequest
      * (&(&(a=b))(c=d))
      */
+    @Test
     public void testDecodeSearchRequestAnd_AndEq_Eq()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -3676,10 +3723,12 @@
         }
     }
 
+
     /**
      * Test the decoding of a SearchRequest
      * (&(&(a=b)(c=d))(e=f))
      */
+    @Test
     public void testDecodeSearchRequestAnd_AndEqEq_Eq()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -3819,10 +3868,159 @@
         }
     }
 
+
+
+
+    /**
+     * Test the decoding of a SearchRequest
+     * (&(a=b)(|(a=b)(c=d)))
+     */
+    @Test
+    public void testDecodeSearchRequestAndEq_OrEqEq()
+    {
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x39 );
+        stream.put( new byte[]
+            { 
+                0x30, 0x37,                 // LDAPMessage ::=SEQUENCE {
+                  0x02, 0x01, 0x01,         // messageID MessageID
+                  0x63, 0x32,               // CHOICE { ...,
+                                            // searchRequest SearchRequest, ...
+                                            // SearchRequest ::= APPLICATION[3] SEQUENCE {
+                    0x04, 0x03,             // baseObject LDAPDN,
+                      'a', '=', 'b', 
+                    0x0A, 0x01, 0x01,       // scope ENUMERATED {
+                                            //      baseObject (0),
+                                            //      singleLevel (1),
+                                            //      wholeSubtree (2) },
+                    0x0A, 0x01, 0x03,       // derefAliases ENUMERATED {
+                                            //      neverDerefAliases (0),
+                                            //      derefInSearching (1),
+                                            //      derefFindingBaseObj (2),
+                                            //      derefAlways (3) },
+                    0x02, 0x01, 0x00,       // sizeLimit INTEGER (0 .. maxInt), (0)
+                    0x02, 0x01, 0x00,       // timeLimit INTEGER (0 .. maxInt), (1000) 
+                    0x01, 0x01, ( byte ) 0xFF,// typesOnly BOOLEAN, (TRUE)
+                                            // filter Filter,
+                    ( byte ) 0xA0, 0x1A,    // Filter ::= CHOICE { and             [0] SET OF Filter,
+                      ( byte ) 0xA3, 0x06,  //      equalityMatch [3] AttributeValueAssertion,
+                                            // AttributeValueAssertion ::= SEQUENCE {
+                        0x04, 0x01, 'a',  //      attributeDesc AttributeDescription (LDAPString),
+                        0x04, 0x01, 'b',  //      assertionValue AssertionValue (OCTET STRING) } 
+                      ( byte ) 0xA1, 0x10,  // Filter ::= CHOICE { or             [1] SET OF Filter,
+                        ( byte ) 0xA3, 0x06,//      equalityMatch [3] AttributeValueAssertion,
+                                            // AttributeValueAssertion ::= SEQUENCE {
+                          0x04, 0x01, 'c',  //      attributeDesc AttributeDescription (LDAPString),
+                          0x04, 0x01, 'd',  //      assertionValue AssertionValue (OCTET STRING) } 
+                        ( byte ) 0xA3, 0x06,//      equalityMatch [3] AttributeValueAssertion,
+                                            //      equalityMatch [3] AttributeValueAssertion,
+                                            // AttributeValueAssertion ::= SEQUENCE {
+                          0x04, 0x01, 'e',  //      attributeDesc AttributeDescription (LDAPString),
+                          0x04, 0x01, 'f',  //      assertionValue AssertionValue (OCTET STRING) } 
+                    0x30, 0x00,             // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+            } );
+
+        String decodedPdu = StringTools.dumpBytes( stream.array() );
+        stream.flip();
+
+        // Allocate a BindRequest Container
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+        try
+        {
+            ldapDecoder.decode( stream, ldapMessageContainer );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+            fail( de.getMessage() );
+        }
+
+        assertEquals( TLVStateEnum.PDU_DECODED, ldapMessageContainer.getState() );
+        
+        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+        SearchRequest sr = message.getSearchRequest();
+
+        assertEquals( 1, message.getMessageId() );
+        assertEquals( "a=b", sr.getBaseObject().toString() );
+        assertEquals( SearchScope.ONELEVEL, sr.getScope() );
+        assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
+        assertEquals( 0, sr.getSizeLimit() );
+        assertEquals( 0, sr.getTimeLimit() );
+        assertEquals( true, sr.isTypesOnly() );
+
+        // (&(...
+        AndFilter andFilter = ( AndFilter ) sr.getFilter();
+        assertNotNull( andFilter );
+
+        List<Filter> andFilters = andFilter.getAndFilter();
+        assertEquals( 2, andFilters.size() );
+        
+        // (&(a=b)..
+        AttributeValueAssertionFilter equalityMatch = ( AttributeValueAssertionFilter ) andFilters.get( 0 );
+        assertNotNull( equalityMatch );
+
+        AttributeValueAssertion assertion = equalityMatch.getAssertion();
+        assertNotNull( assertion );
+
+        assertEquals( "a", assertion.getAttributeDesc() );
+        assertEquals( "b", assertion.getAssertionValue().get() );
+
+        // (&(a=b)(|(...
+        OrFilter orFilter = ( OrFilter ) andFilters.get( 1 );
+        assertNotNull( orFilter );
+
+        List<Filter> orFilters = orFilter.getOrFilter();
+        assertEquals( 2, orFilters.size() );
+
+        // (&(a=b)(|(c=d)...
+        equalityMatch = ( AttributeValueAssertionFilter ) orFilters.get( 0 );
+        assertNotNull( equalityMatch );
+
+        assertion = equalityMatch.getAssertion();
+        assertNotNull( assertion );
+
+        assertEquals( "c", assertion.getAttributeDesc() );
+        assertEquals( "d", assertion.getAssertionValue().get() );
+
+        // (&(a=b)(|(c=d)(e=f)))
+        equalityMatch = ( AttributeValueAssertionFilter ) orFilters.get( 1 );
+        assertNotNull( equalityMatch );
+
+        assertion = equalityMatch.getAssertion();
+        assertNotNull( assertion );
+
+        assertEquals( "e", assertion.getAttributeDesc() );
+        assertEquals( "f", assertion.getAssertionValue().get() );
+        
+        List<EntryAttribute> attributes = sr.getAttributes();
+        assertEquals( 0, attributes.size() );
+
+        // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+
+            String encodedPdu = StringTools.dumpBytes( bb.array() );
+
+            assertEquals( encodedPdu.substring( 0, 0x39 ), decodedPdu.substring( 0, 0x39 ) );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            fail( ee.getMessage() );
+        }
+    }
+    
+    
     /**
      * Test the decoding of a SearchRequest
      * (&(&(a=b))(&(c=d)))
      */
+    @Test
     public void testDecodeSearchRequestAnd_AndEq_AndEq()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -3960,6 +4158,7 @@
      * Test the decoding of a SearchRequest
      * (&(&(a=b)(c=d))(&(e=f)))
      */
+    @Test
     public void testDecodeSearchRequestAnd_AndEqEq_AndEq()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -4111,6 +4310,7 @@
      * Test the decoding of a SearchRequest
      * (&(|(abcdef=*)(ghijkl=*))(!(e>=f)))
      */
+    @Test
     public void testDecodeSearchRequestAnd_OrPrPr_NotGEq()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -4248,6 +4448,7 @@
      * Test the decoding of a SearchRequest
      * for rootDSE
      */
+    @Test
     public void testDecodeSearchRequestRootDSE()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -4309,6 +4510,7 @@
      * Test the decoding of a SearchRequest with special length (long form)
      * for rootDSE
      */
+    @Test
     public void testDecodeSearchRequestDIRSERVER_810()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -4404,6 +4606,7 @@
      * Test the decoding of a SearchRequest with a complex filter :
      * (&(objectClass=person)(|(cn=Tori*)(sn=Jagger)))
      */
+    @Test
     public void testDecodeSearchRequestComplexFilter()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserTest.java Thu Dec 11 07:32:04 2008
@@ -684,6 +684,55 @@
     }
 
 
+    /**
+     * Test that filters like (&(a=b)(|(c=d)(e=f))) are correctly parsed
+     */
+    @Test
+    public void testAndEqOr_EqEq()
+    {
+        try
+        {
+            BranchNode node = ( BranchNode ) FilterParser.parse("(&(objectClass=nisNetgroup)(|(nisNetGroupTriple=a*a)(nisNetGroupTriple=\\28*,acc1,*\\29)))");
+            assertEquals( 2, node.getChildren().size() );
+            
+            assertTrue( node instanceof AndNode );
+            
+            // Check the (a=b) part
+            ExprNode aEqb = node.getFirstChild();
+            assertTrue( aEqb instanceof EqualityNode );
+            assertEquals( "objectClass", ((EqualityNode<?>)aEqb).getAttribute() );
+            assertEquals( "nisNetgroup", ((EqualityNode<?>)aEqb).getValue().get() );
+            
+            // Check the or node
+            ExprNode orNode = node.getChildren().get( 1 );
+            assertTrue( orNode instanceof OrNode );
+            
+            assertEquals( 2, ((OrNode)orNode).getChildren().size() );
+            
+            ExprNode leftNode = ((OrNode)orNode).getChildren().get( 0 );
+            
+            assertTrue( leftNode instanceof SubstringNode );
+            assertEquals( "nisNetGroupTriple", ((SubstringNode)leftNode).getAttribute() );
+            assertEquals( "a", ((SubstringNode)leftNode).getInitial() );
+            assertEquals( 0, ((SubstringNode)leftNode).getAny().size() );
+            assertEquals( "a", ((SubstringNode)leftNode).getFinal() );
+            
+            ExprNode rightNode = ((OrNode)orNode).getChildren().get( 1 );
+            
+            assertTrue( rightNode instanceof SubstringNode );
+            assertEquals( "nisNetGroupTriple", ((SubstringNode)rightNode).getAttribute() );
+            assertEquals( "\\28", ((SubstringNode)rightNode).getInitial() );
+            assertEquals( 1, ((SubstringNode)rightNode).getAny().size() );
+            assertEquals( ",acc1,", ((SubstringNode)rightNode).getAny().get( 0 ) );
+            assertEquals( "\\29", ((SubstringNode)rightNode).getFinal() );
+        }
+        catch ( ParseException pe )
+        {
+            assertTrue( true );
+        }
+    }
+    
+    
     /*
     @Test
     public void testPerf() throws ParseException

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java Thu Dec 11 07:32:04 2008
@@ -21,9 +21,6 @@
 
 import org.apache.directory.shared.ldap.entry.Entry;
 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.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -35,7 +32,7 @@
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
-import org.junit.Ignore;
+
 import org.junit.Test;
 
 import javax.naming.NamingException;
@@ -44,8 +41,6 @@
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.BasicAttributes;
 
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
 
@@ -58,21 +53,7 @@
 {
     private String testString = "this is a test";
     
-    /**
-     * Helper method to build a basic entry used by the Modify tests
-     */
-    private Entry buildEntry()
-    {
-        Entry entry = new DefaultClientEntry();
-        entry.put( "objectclass", "top", "person" );
-        entry.put( "cn", "test" );
-        entry.put( "sn", "joe doe" );
-        entry.put( "l", "USA" );
-        
-        return entry;
-    }
 
-    
     /**
      * Tests the method IsLdifSafe with a null String
      */
@@ -105,7 +86,7 @@
         assertFalse( LdifUtils.isLDIFSafe( c + testString ) );
     }
     
-
+    
     /**
      * Tests the method IsLdifSafe with a String starting with the
      * char LF (ASCII code 10)
@@ -417,139 +398,6 @@
 
     
     /**
-     * Test a AddRequest reverse
-     *
-     * @throws NamingException
-     */
-    @Test
-    public void testReverseAdd() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "dc=apache, dc=com" );
-        LdifEntry reversed = LdifUtils.reverseAdd( dn );
-        
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Delete, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-    }
-
-
-    /**
-     * Test a AddRequest reverse where the DN is to be base64 encoded 
-     *
-     * @throws NamingException
-     */
-    @Test
-    public void testReverseAddBase64DN() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "dc=Emmanuel L\u00c9charny" );
-        LdifEntry reversed = LdifUtils.reverseAdd( dn );
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Delete, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-    }
-
-
-    /**
-     * Test a DelRequest reverse
-     *
-     * @throws NamingException
-     */
-    @Test
-    public void testReverseDel() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "dc=apache, dc=com" );
-        
-        Entry deletedEntry = new DefaultClientEntry( dn );
-        
-        EntryAttribute oc = new DefaultClientAttribute( "objectClass" );
-        oc.add( "top", "person" );
-        
-        deletedEntry.put( oc );
-        
-        deletedEntry.put( "cn", "test" );
-        deletedEntry.put( "sn", "apache" );
-        deletedEntry.put( "dc", "apache" );
-        
-        LdifEntry reversed = LdifUtils.reverseDel( dn, deletedEntry );
-        
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Add, reversed.getChangeType() );
-        assertNotNull( reversed.getEntry() );
-        assertEquals( deletedEntry, reversed.getEntry() );
-    }
-    
-    
-    /**
-     * Check that the correct reverse LDIF is produced for a modifyDn
-     * operation that just renames the person without preserving the
-     * old rdn.
-     *
-     * @throws NamingException on error
-     */
-    @Test
-    public void testReverseModifyDNDeleteOldRdnNoSuperior() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "cn=john doe, dc=example, dc=com" );
-
-        Attributes attrs = new BasicAttributes( "objectClass", "person", true );
-        attrs.get( "objectClass" ).add( "uidObject" );
-        attrs.put( "cn", "john doe" );
-        attrs.put( "sn", "doe" );
-        attrs.put( "uid", "jdoe" );
-
-        List<LdifEntry> reverseds = LdifUtils.reverseModifyRdn( attrs, null, dn, new Rdn( "cn=jack doe" ) );
-
-        assertNotNull( reverseds );
-        assertEquals( 1, reverseds.size() );
-        
-        LdifEntry reversed = reverseds.get( 0 );
-        assertEquals( "cn=jack doe, dc=example, dc=com", reversed.getDn().getUpName() );
-        assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
-        assertTrue( reversed.isDeleteOldRdn() );
-        assertEquals( "cn=john doe", reversed.getNewRdn() );
-        assertNull( reversed.getNewSuperior() );
-        assertNull( reversed.getEntry() );
-    }
-
-
-    /**
-     * Check that the correct reverse LDIF is produced for a modifyDn
-     * operation that just renames the person while preserving the
-     * old rdn.
-     *
-     * @throws NamingException on error
-     */
-    @Test
-    public void testReverseModifyDNNoSuperior() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "cn=john doe, dc=example, dc=com" );
-
-        Attributes attrs = new BasicAttributes( "objectClass", "person", true );
-        attrs.get( "objectClass" ).add( "uidObject" );
-        attrs.put( "cn", "john doe" );
-        attrs.put( "cn", "jack doe" );
-        attrs.put( "sn", "doe" );
-        attrs.put( "uid", "jdoe" );
-
-        List<LdifEntry> reverseds = LdifUtils.reverseModifyRdn( attrs, null, dn, new Rdn( "cn=jack doe" ) );
-
-        assertNotNull( reverseds );
-        assertEquals( 1, reverseds.size() );
-        
-        LdifEntry reversed = reverseds.get( 0 );
-        assertEquals( "cn=jack doe, dc=example, dc=com", reversed.getDn().getUpName() );
-        assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
-        assertFalse( reversed.isDeleteOldRdn() );
-        assertEquals( "cn=john doe", reversed.getNewRdn() );
-        assertNull( reversed.getNewSuperior() );
-        assertNull( reversed.getEntry() );
-    }
-
-
-    /**
      * Check that the correct reverse LDIF is produced for a modifyDn
      * operation that moves and renames the entry while preserving the
      * old rdn.
@@ -562,20 +410,13 @@
         LdapDN dn = new LdapDN( "cn=john doe, dc=example, dc=com" );
         LdapDN newSuperior = new LdapDN( "ou=system" );
 
-        Attributes attrs = new BasicAttributes( "objectClass", "person", true );
-        attrs.get( "objectClass" ).add( "uidObject" );
-                
-        Attribute attr = new BasicAttribute( "cn" );
-        
-        attr.add( "john doe" );
-        attr.add( "jack doe" );
-        
-        attrs.put( attr );
-        
-        attrs.put( "sn", "doe" );
-        attrs.put( "uid", "jdoe" );
+        Entry entry = new DefaultClientEntry( dn );
+        entry.add( "objectClass", "person", "uidObject" );
+        entry.add( "cn", "john doe", "jack doe" );
+        entry.add( "sn", "doe" );
+        entry.add( "uid", "jdoe" );
 
-        List<LdifEntry> reverseds = LdifUtils.reverseModifyRdn( attrs, newSuperior, dn, new Rdn( "cn=jack doe" ) );
+        List<LdifEntry> reverseds = LdifRevertor.reverseMoveAndRename( entry, newSuperior, new Rdn( "cn=jack doe" ), false );
 
         assertNotNull( reverseds );
         assertEquals( 1, reverseds.size() );
@@ -591,39 +432,6 @@
 
 
     /**
-     * Test a reversed move ModifyDN no rdn changes
-     *
-     * @throws NamingException on error
-     */
-    @Test
-    public void testReverseModifyDNMove() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "cn=john doe, dc=example, dc=com" );
-        LdapDN newSuperior = new LdapDN( "ou=system" );
-
-        Attributes attrs = new BasicAttributes( "objectClass", "person", true );
-        attrs.get( "objectClass" ).add( "uidObject" );
-        attrs.put( "cn", "john doe" );
-        attrs.put( "cn", "jack doe" );
-        attrs.put( "sn", "doe" );
-        attrs.put( "uid", "jdoe" );
-
-        List<LdifEntry> reverseds = LdifUtils.reverseModifyRdn( attrs, newSuperior, dn, null );
-
-        assertNotNull( reverseds );
-        assertEquals( 1, reverseds.size() );
-        
-        LdifEntry reversed = reverseds.get( 0 );
-        assertEquals( "cn=john doe,ou=system", reversed.getDn().getUpName() );
-        assertEquals( ChangeType.ModDn, reversed.getChangeType() );
-        assertFalse( reversed.isDeleteOldRdn() );
-        assertNull( reversed.getNewRdn() );
-        assertEquals( "dc=example, dc=com", StringTools.trim( reversed.getNewSuperior() ) );
-        assertNull( reversed.getEntry() );
-    }
-
-
-    /**
      * Test a reversed ModifyDN with a deleteOldRdn, rdn change, and a superior
      *
      * @throws NamingException on error
@@ -634,13 +442,13 @@
         LdapDN dn = new LdapDN( "cn=john doe, dc=example, dc=com" );
         LdapDN newSuperior = new LdapDN( "ou=system" );
 
-        Attributes attrs = new BasicAttributes( "objectClass", "person", true );
-        attrs.get( "objectClass" ).add( "uidObject" );
-        attrs.put( "cn", "john doe" );
-        attrs.put( "sn", "doe" );
-        attrs.put( "uid", "jdoe" );
+        Entry entry = new DefaultClientEntry( dn );
+        entry.add( "objectClass", "person", "uidObject" );
+        entry.add( "cn", "john doe" );
+        entry.add( "sn", "doe" );
+        entry.add( "uid", "jdoe" );
 
-        List<LdifEntry> reverseds = LdifUtils.reverseModifyRdn( attrs, newSuperior, dn, new Rdn( "cn=jack doe" ) );
+        List<LdifEntry> reverseds = LdifRevertor.reverseMoveAndRename( entry, newSuperior, new Rdn( "cn=jack doe" ), false );
 
         assertNotNull( reverseds );
         assertEquals( 1, reverseds.size() );
@@ -653,527 +461,4 @@
         assertEquals( "dc=example, dc=com", StringTools.trim( reversed.getNewSuperior() ) );
         assertNull( reversed.getEntry() );
     }
-
-    
-    /**
-     * Test a reversed Modify adding a new attribute value
-     * in an exiting attribute
-     */
-    @Test
-    public void testReverseModifyAddNewOuValue() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-
-        EntryAttribute ou = new DefaultClientAttribute( "ou" );
-        ou.add( "apache" );
-        ou.add( "acme corp" );
-        modifiedEntry.put( ou );
-        
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        Modification mod = new ClientModification(
-            ModificationOperation.ADD_ATTRIBUTE, 
-            new DefaultClientAttribute( "ou", "BigCompany inc." ) );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( "ou", attr.getId() );
-        assertEquals( "BigCompany inc.", attr.getString() );
-    }
-
-
-    /**
-     * Test a reversed Modify adding a new attribute
-     */
-    @Test
-    public void testReverseModifyAddNewOu() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-        
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        Modification mod = new ClientModification(
-            ModificationOperation.ADD_ATTRIBUTE, 
-            new DefaultClientAttribute( "ou", "BigCompany inc." ) );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-
-        assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( "ou", attr.getId() );
-        assertEquals( "BigCompany inc.", attr.getString() );
-    }
-
-   
-    /**
-     * Test a reversed Modify adding a existing attribute value
-     */
-    @Test
-    @Ignore ( "This is just not a valid test since it leaves us with no reverse LDIF" )
-    public void testReverseModifyAddExistingCnValue() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        Modification mod = new ClientModification(
-            ModificationOperation.ADD_ATTRIBUTE,
-            new DefaultClientAttribute( "cn", "test" ) );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-        assertNull( reversed );
-    }
-
-    
-    /**
-     * Test a reversed Modify adding a existing value from an existing attribute
-     */
-    @Test
-    public void testReverseModifyDelExistingOuValue() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-        
-        EntryAttribute ou = new DefaultClientAttribute( "ou" );
-        ou.add( "apache", "acme corp" );
-        modifiedEntry.put( ou );
-
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-
-        Modification mod = new ClientModification( 
-            ModificationOperation.REMOVE_ATTRIBUTE, 
-            new DefaultClientAttribute( "ou", "acme corp" ) );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-
-        assertEquals( "ou", attr.getId() );
-        assertEquals( "acme corp", attr.getString() );
-    }
-
-
-    /**
-     * Test a reversed Modify deleting an existing attribute
-     */
-    @Test
-    public void testReverseModifyDeleteOU() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-        
-        EntryAttribute ou = new DefaultClientAttribute( "ou" );
-        ou.add( "apache", "acme corp" );
-        modifiedEntry.put( ou );
-
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-
-        Modification mod = new ClientModification(
-            ModificationOperation.REMOVE_ATTRIBUTE, 
-            new DefaultClientAttribute( "ou" ) );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( "ou", attr.getId() );
-        
-        assertEquals( ou, attr );
-    }
-
-   
-    /**
-     * Test a reversed Modify deleting all values of an existing attribute
-     */
-    @Test
-    public void testReverseModifyDelExistingOuWithAllValues() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-
-        EntryAttribute ou = new DefaultClientAttribute( "ou", "apache", "acme corp" );
-        modifiedEntry.put( ou );
-        
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        
-        Modification mod = new ClientModification(
-            ModificationOperation.REMOVE_ATTRIBUTE, ou );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn, 
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( "ou", attr.getId() );
-        
-        assertEquals( ou, attr );
-    }
-
-    
-    /**
-     * Test a reversed Modify replacing existing values with new values
-     */
-    @Test
-    public void testReverseModifyReplaceExistingOuValues() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-        
-        EntryAttribute ou = new DefaultClientAttribute( "ou" );
-        ou.add( "apache", "acme corp" );
-        modifiedEntry.put( ou );
-
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-
-        EntryAttribute ouModified = new DefaultClientAttribute( "ou" );
-        ouModified.add( "directory" );
-        ouModified.add( "BigCompany inc." );
-        
-        Modification mod = new ClientModification(
-            ModificationOperation.REPLACE_ATTRIBUTE, ouModified );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( ou, attr );
-    }
-
-
-    /**
-     * Test a reversed Modify replace by injecting a new attribute
-     */
-    @Test
-    public void testReverseModifyReplaceNewAttribute() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-        
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        
-        EntryAttribute newOu = new DefaultClientAttribute( "ou" );
-        newOu.add( "apache" );
-        newOu.add( "acme corp" );
-
-        
-        Modification mod = new ClientModification(
-            ModificationOperation.REPLACE_ATTRIBUTE, newOu );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( "ou", attr.getId() );
-        
-        assertNull( attr.get() );
-    }
-
-   
-    /**
-     * Test a reversed Modify replace by removing an attribute
-     */
-    @Test
-    public void testReverseModifyReplaceExistingOuWithNothing() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-
-        EntryAttribute ou = new DefaultClientAttribute( "ou" );
-        ou.add( "apache" );
-        ou.add( "acme corp" );
-        modifiedEntry.put( ou );
-        
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        
-        Modification mod = new ClientModification( 
-            ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute( "ou" ) );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( "ou", attr.getId() );
-        
-        assertEquals( ou, attr );
-    }
-    
-    
-    /**
-     * Test a multiple modifications reverse.
-     * 
-     * On the following entry :
-     *  dn: cn=test, ou=system
-     *  objectclass: top
-     *  objectclass: person
-     *  cn: test
-     *  sn: joe doe
-     *  l: USA
-     *  ou: apache
-     *  ou: acme corp
-     * 
-     * We will :
-     *  - add an 'ou' value 'BigCompany inc.'
-     *  - delete the 'l' attribute
-     *  - add the 'l=FR' attribute
-     *  - replace the 'l=FR' by a 'l=USA' attribute
-     *  - replace the 'ou' attribute with 'apache' value.
-     *  
-     * The modify ldif will be :
-     * 
-     *  dn: cn=test, ou=system
-     *  changetype: modify
-     *  add: ou
-     *  ou: BigCompany inc.
-     *  -
-     *  delete: l
-     *  -
-     *  add: l
-     *  l: FR
-     *  -
-     *  replace: l
-     *  l: USA
-     *  -
-     *  replace: ou
-     *  ou: apache
-     *  -
-     *  
-     * At the end, the entry will looks like :
-     *  dn: cn=test, ou=system
-     *  objectclass: top
-     *  objectclass: person
-     *  cn: test
-     *  sn: joe doe
-     *  l: USA
-     *  ou: apache
-     *  
-     * and the reversed LDIF will be :
-     * 
-     *  dn: cn=test, ou=system
-     *  changetype: modify
-     *  replace: ou
-     *  ou: apache
-     *  ou: acme corp
-     *  -
-     *  replace: l
-     *  l: USA
-     *  -
-     *  delete: l
-     *  l: FR
-     *  -
-     *  add: l
-     *  l: USA
-     *  -
-     *  delete: ou 
-     *  ou: BigCompany inc.
-     *  -
-     * 
-     */
-    @Test
-    public void testReverseMultipleModifications() throws NamingException
-    {
-        String initialEntryLdif = 
-                "dn: cn=test, ou=system\n" + 
-                "objectclass: top\n" + 
-                "objectclass: person\n" + 
-                "cn: test\n" + 
-                "sn: joe doe\n" + 
-                "l: USA\n" + 
-                "ou: apache\n" + 
-                "ou: acme corp\n"; 
-        
-        LdifReader reader = new LdifReader();
-        List<LdifEntry> entries = reader.parseLdif( initialEntryLdif );
-        
-        LdifEntry initialEntry = entries.get( 0 );
- 
-        // We will :
-        //   - add an 'ou' value 'BigCompany inc.'
-        //   - delete the 'l' attribute
-        //   - add the 'l=FR' attribute
-        //   - replace the 'l=FR' by a 'l=USA' attribute
-        //   - replace the 'ou' attribute with 'apache' value.
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        
-        List<Modification> modifications = new ArrayList<Modification>();
-
-        // First, inject the 'ou'
-        
-        Modification mod = new ClientModification( 
-            ModificationOperation.ADD_ATTRIBUTE, new DefaultClientAttribute( "ou", "BigCompany inc." ) );
-        modifications.add( mod );
-
-        // Remove the 'l'
-        mod = new ClientModification(
-            ModificationOperation.REMOVE_ATTRIBUTE, new DefaultClientAttribute( "l" ) );
-        modifications.add( mod );
-        
-        // Add 'l=FR'
-        mod = new ClientModification( 
-            ModificationOperation.ADD_ATTRIBUTE, new DefaultClientAttribute( "l", "FR" ) );
-        modifications.add( mod );
-
-        // Replace it with 'l=USA'
-        mod = new ClientModification( 
-            ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute( "l", "USA" ) );
-        modifications.add( mod );
-
-        // Replace the ou value
-        mod = new ClientModification( 
-            ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute( "ou", "apache" ) );
-        modifications.add( mod );
-        
-        LdifEntry reversedEntry = LdifUtils.reverseModify( dn, modifications, initialEntry.getEntry() );
-
-        String expectedEntryLdif = 
-            "dn: cn=test, ou=system\n" +
-            "changetype: modify\n" +
-            "replace: ou\n" +
-            "ou: apache\n" +
-            "ou: acme corp\n" +
-            "-\n" +
-            "replace: l\n" +
-            "l: USA\n" +
-            "-\n" +
-            "delete: l\n" +
-            "l: FR\n" +
-            "-\n" +
-            "add: l\n" +
-            "l: USA\n" +
-            "-\n" +
-            "delete: ou\n" + 
-            "ou: BigCompany inc.\n" +
-            "-\n\n";
-    
-        reader = new LdifReader();
-        entries = reader.parseLdif( expectedEntryLdif );
-    
-        LdifEntry expectedEntry = entries.get( 0 );
-        
-        assertEquals( expectedEntry, reversedEntry );
-    }
 }

Modified: directory/shared/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/shared/trunk/pom.xml?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/shared/trunk/pom.xml (original)
+++ directory/shared/trunk/pom.xml Thu Dec 11 07:32:04 2008
@@ -98,7 +98,7 @@
       <dependency>
         <groupId>org.apache.mina</groupId>
         <artifactId>mina-core</artifactId>
-        <version>1.1.7</version>
+        <version>2.0.0-M4-SNAPSHOT</version>
       </dependency>
     </dependencies>
   </dependencyManagement>



Mime
View raw message