directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r742640 - /directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncDoneValueControlTest.java
Date Mon, 09 Feb 2009 17:23:47 GMT
Author: kayyagari
Date: Mon Feb  9 17:23:44 2009
New Revision: 742640

URL: http://svn.apache.org/viewvc?rev=742640&view=rev
Log:
added two more tests

Modified:
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncDoneValueControlTest.java

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncDoneValueControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncDoneValueControlTest.java?rev=742640&r1=742639&r2=742640&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncDoneValueControlTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncDoneValueControlTest.java
Mon Feb  9 17:23:44 2009
@@ -139,4 +139,82 @@
         }
     }
 
+    
+    @Test
+    public void testSyncDoneValueWithSequenceOnly()
+    {
+        Asn1Decoder decoder = new SyncDoneValueControlDecoder();
+        ByteBuffer bb = ByteBuffer.allocate( 2 );
+
+        bb.put( new byte[]
+            { 
+              0x30, 0x00 
+            } );
+
+        bb.flip();
+
+        SyncDoneValueControlContainer container = new SyncDoneValueControlContainer();
+
+        try
+        {
+            decoder.decode( bb, container );
+            fail( "shouldn't reach this" );
+        }
+        catch ( Exception e )
+        {
+            assertTrue( true );
+        }
+
+    }
+
+    
+    @Test
+    public void testSyncDoneValueControlWithEmptyCookie()
+    {
+        Asn1Decoder decoder = new SyncDoneValueControlDecoder();
+        ByteBuffer bb = ByteBuffer.allocate( 7 );
+
+        bb.put( new byte[]
+            { 
+              0x30, 0x05, 
+              0x04, 0x00,      // empty cookie
+              0x01, 0x01, 0x00 // refreshDeletes flag FALSE
+            } );
+
+        bb.flip();
+
+        SyncDoneValueControlContainer container = new SyncDoneValueControlContainer();
+
+        try
+        {
+            decoder.decode( bb, container );
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        SyncDoneValueControlCodec control = container.getSyncDoneValueControl();
+        assertEquals( "", StringTools.utf8ToString( control.getCookie() ) );
+        assertFalse( control.isRefreshDeletes() );
+
+        // test encoding
+        try
+        {
+            ByteBuffer encodedBuf = control.encode( null );
+            encodedBuf.flip();
+            bb.flip();
+            
+            decoder.decode( encodedBuf, container );
+            SyncDoneValueControlCodec redecoded = container.getSyncDoneValueControl();
+            
+            assertEquals( control.isRefreshDeletes(), redecoded.isRefreshDeletes() );
+            assertTrue( Arrays.equals( control.getCookie(), redecoded.getCookie() ) );
+        }
+        catch( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+    }
+
 }



Mime
View raw message