You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2009/02/09 18:23:47 UTC
svn commit: r742640 -
/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncDoneValueControlTest.java
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() );
+ }
+ }
+
}