directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r742092 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/ test/java/org/apache/directory/shared/ldap/codec/controls/replication/
Date Sun, 08 Feb 2009 13:25:09 GMT
Author: elecharny
Date: Sun Feb  8 13:25:09 2009
New Revision: 742092

URL: http://svn.apache.org/viewvc?rev=742092&view=rev
Log:
Fixed bugs in the encoding method

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlCodec.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncRequestValueControlTest.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlCodec.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlCodec.java?rev=742092&r1=742091&r2=742092&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlCodec.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlCodec.java
Sun Feb  8 13:25:09 2009
@@ -145,8 +145,12 @@
         bb.put( UniversalTag.SEQUENCE_TAG );
         bb.put( TLV.getBytes( syncRequestValueLength ) );
 
-        Value.encode( bb, mode.getValue() );
-        
+        // The mode
+        bb.put(  UniversalTag.ENUMERATED_TAG );
+        bb.put( (byte)0x01 );
+        bb.put( Value.getBytes( mode.getValue() ) );
+
+        // The cookie
         if ( cookie != null )
         {
             Value.encode( bb, cookie );

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncRequestValueControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncRequestValueControlTest.java?rev=742092&r1=742091&r2=742092&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncRequestValueControlTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncRequestValueControlTest.java
Sun Feb  8 13:25:09 2009
@@ -20,9 +20,11 @@
 package org.apache.directory.shared.ldap.codec.controls.replication;
 
 import java.nio.ByteBuffer;
+import java.util.Arrays;
 
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.SyncRequestValueControlCodec;
 import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.SyncRequestValueControlContainer;
 import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.SyncRequestValueControlDecoder;
@@ -62,6 +64,7 @@
         bb.flip();
 
         SyncRequestValueControlContainer container = new SyncRequestValueControlContainer();
+        
         try
         {
             decoder.decode( bb, container );
@@ -76,6 +79,19 @@
         assertEquals( SynchronizationModeEnum.REFRESH_ONLY, syncRequestValue.getMode() );
         assertEquals( "abc", StringTools.utf8ToString( syncRequestValue.getCookie() ) );
         assertEquals( false, syncRequestValue.isReloadHint() );
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer encoded = syncRequestValue.encode( null );
+            encoded.flip();
+            bb.flip();
+            assertTrue( Arrays.equals( bb.array(), encoded.array() ) );
+        }
+        catch ( EncoderException ee )
+        {
+            fail();
+        }
     }
 
 
@@ -99,6 +115,7 @@
         bb.flip();
 
         SyncRequestValueControlContainer container = new SyncRequestValueControlContainer();
+       
         try
         {
             decoder.decode( bb, container );
@@ -113,6 +130,19 @@
         assertEquals( SynchronizationModeEnum.REFRESH_AND_PERSIST, syncRequestValue.getMode()
);
         assertEquals( "abc", StringTools.utf8ToString( syncRequestValue.getCookie() ) );
         assertEquals( false, syncRequestValue.isReloadHint() );
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer encoded = syncRequestValue.encode( null );
+            encoded.flip();
+            bb.flip();
+            assertTrue( Arrays.equals( bb.array(), encoded.array() ) );
+        }
+        catch ( EncoderException ee )
+        {
+            fail();
+        }
     }
 
 
@@ -135,6 +165,7 @@
         bb.flip();
 
         SyncRequestValueControlContainer container = new SyncRequestValueControlContainer();
+        
         try
         {
             decoder.decode( bb, container );
@@ -149,6 +180,19 @@
         assertEquals( SynchronizationModeEnum.REFRESH_AND_PERSIST, syncRequestValue.getMode()
);
         assertNull( syncRequestValue.getCookie() );
         assertEquals( false, syncRequestValue.isReloadHint() );
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer encoded = syncRequestValue.encode( null );
+            encoded.flip();
+            bb.flip();
+            assertTrue( Arrays.equals( bb.array(), encoded.array() ) );
+        }
+        catch ( EncoderException ee )
+        {
+            fail();
+        }
     }
 
 
@@ -172,6 +216,7 @@
         bb.flip();
 
         SyncRequestValueControlContainer container = new SyncRequestValueControlContainer();
+        
         try
         {
             decoder.decode( bb, container );
@@ -186,6 +231,19 @@
         assertEquals( SynchronizationModeEnum.REFRESH_AND_PERSIST, syncRequestValue.getMode()
);
         assertNull( syncRequestValue.getCookie() );
         assertEquals( true, syncRequestValue.isReloadHint() );
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer encoded = syncRequestValue.encode( null );
+            encoded.flip();
+            bb.flip();
+            assertTrue( Arrays.equals( bb.array(), encoded.array() ) );
+        }
+        catch ( EncoderException ee )
+        {
+            fail();
+        }
     }
 
 
@@ -208,6 +266,7 @@
         bb.flip();
 
         SyncRequestValueControlContainer container = new SyncRequestValueControlContainer();
+        
         try
         {
             decoder.decode( bb, container );
@@ -222,6 +281,23 @@
         assertEquals( SynchronizationModeEnum.REFRESH_AND_PERSIST, syncRequestValue.getMode()
);
         assertNull( syncRequestValue.getCookie() );
         assertEquals( false, syncRequestValue.isReloadHint() );
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer encoded = syncRequestValue.encode( null );
+            encoded.flip();
+            bb.flip();
+            SyncRequestValueControlCodec redecoded = container.getSyncRequestValueControl();
+            
+            assertEquals( syncRequestValue.getMode(), redecoded.getMode() );
+            assertTrue( Arrays.equals( syncRequestValue.getCookie(), redecoded.getCookie()
) );
+            assertEquals( syncRequestValue.isReloadHint(), redecoded.isReloadHint() );
+        }
+        catch ( EncoderException ee )
+        {
+            fail();
+        }
     }
 
 
@@ -244,6 +320,7 @@
         bb.flip();
 
         SyncRequestValueControlContainer container = new SyncRequestValueControlContainer();
+        
         try
         {
             decoder.decode( bb, container );
@@ -258,6 +335,23 @@
         assertEquals( SynchronizationModeEnum.REFRESH_AND_PERSIST, syncRequestValue.getMode()
);
         assertEquals( "abc", StringTools.utf8ToString( syncRequestValue.getCookie() ) );
         assertEquals( false, syncRequestValue.isReloadHint() );
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer encoded = syncRequestValue.encode( null );
+            encoded.flip();
+            bb.flip();
+            SyncRequestValueControlCodec redecoded = container.getSyncRequestValueControl();
+            
+            assertEquals( syncRequestValue.getMode(), redecoded.getMode() );
+            assertTrue( Arrays.equals( syncRequestValue.getCookie(), redecoded.getCookie()
) );
+            assertEquals( syncRequestValue.isReloadHint(), redecoded.isReloadHint() );
+        }
+        catch ( EncoderException ee )
+        {
+            fail();
+        }
     }
 
 
@@ -294,6 +388,23 @@
         assertEquals( SynchronizationModeEnum.REFRESH_AND_PERSIST, syncRequestValue.getMode()
);
         assertEquals( "", StringTools.utf8ToString( syncRequestValue.getCookie() ) );
         assertEquals( false, syncRequestValue.isReloadHint() );
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer encoded = syncRequestValue.encode( null );
+            encoded.flip();
+            bb.flip();
+            SyncRequestValueControlCodec redecoded = container.getSyncRequestValueControl();
+            
+            assertEquals( syncRequestValue.getMode(), redecoded.getMode() );
+            assertTrue( Arrays.equals( syncRequestValue.getCookie(), redecoded.getCookie()
) );
+            assertEquals( syncRequestValue.isReloadHint(), redecoded.isReloadHint() );
+        }
+        catch ( EncoderException ee )
+        {
+            fail();
+        }
     }
 
 



Mime
View raw message