You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/01/30 14:37:47 UTC
svn commit: r1065266 - in /directory/shared/trunk/ldap/src:
main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/
main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/
test/java/org/apache/d...
Author: elecharny
Date: Sun Jan 30 13:37:47 2011
New Revision: 1065266
URL: http://svn.apache.org/viewvc?rev=1065266&view=rev
Log:
Fixed the SyncDoneValue and SyncInfoValue control tests
Modified:
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueDecorator.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValue.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueDecorator.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueGrammar.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncDoneValueControlTest.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncInfoValueControlTest.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/syncDoneValue/SyncDoneValueDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueDecorator.java?rev=1065266&r1=1065265&r2=1065266&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueDecorator.java Sun Jan 30 13:37:47 2011
@@ -184,13 +184,13 @@ public class SyncDoneValueDecorator exte
// Copy the bytes
if ( cookie != null )
{
- byte[] copy = new byte[getCookie().length];
+ byte[] copy = new byte[cookie.length];
System.arraycopy( cookie, 0, copy, 0, cookie.length );
- setCookie( copy );
+ getDecorated().setCookie( copy );
}
else
{
- setCookie( null );
+ getDecorated().setCookie( null );
}
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValue.java?rev=1065266&r1=1065265&r2=1065266&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValue.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValue.java Sun Jan 30 13:37:47 2011
@@ -20,6 +20,7 @@
package org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue;
+import java.util.ArrayList;
import java.util.List;
import org.apache.directory.shared.ldap.message.control.replication.SynchronizationInfoEnum;
@@ -42,7 +43,7 @@ public class SyncInfoValue implements IS
/** The refreshDone flag if we are dealing with refreshXXX syncInfo. Default to true */
private boolean refreshDone = true;
- /** The refreshDeletes flag if we are dealing with syncIdSet syncInfo. Defaluts to false */
+ /** The refreshDeletes flag if we are dealing with syncIdSet syncInfo. Defaults to false */
private boolean refreshDeletes = false;
/** The list of UUIDs if we are dealing with syncIdSet syncInfo */
@@ -146,6 +147,11 @@ public class SyncInfoValue implements IS
*/
public void addSyncUUID( byte[] syncUUID )
{
+ if ( syncUUIDs == null )
+ {
+ syncUUIDs = new ArrayList<byte[]>();
+ }
+
syncUUIDs.add( syncUUID );
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueDecorator.java?rev=1065266&r1=1065265&r2=1065266&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueDecorator.java Sun Jan 30 13:37:47 2011
@@ -117,7 +117,17 @@ public class SyncInfoValueDecorator exte
*/
public void setCookie( byte[] cookie )
{
- getDecorated().setCookie( cookie );
+ // Copy the bytes
+ if ( cookie != null )
+ {
+ byte[] copy = new byte[cookie.length];
+ System.arraycopy( cookie, 0, copy, 0, cookie.length );
+ getDecorated().setCookie( copy );
+ }
+ else
+ {
+ getDecorated().setCookie( null );
+ }
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueGrammar.java?rev=1065266&r1=1065265&r2=1065266&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueGrammar.java Sun Jan 30 13:37:47 2011
@@ -25,12 +25,11 @@ import org.apache.directory.shared.asn1.
import org.apache.directory.shared.asn1.ber.grammar.Grammar;
import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition;
+import org.apache.directory.shared.asn1.ber.tlv.BooleanDecoder;
import org.apache.directory.shared.asn1.ber.tlv.BooleanDecoderException;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
import org.apache.directory.shared.asn1.ber.tlv.Value;
-import org.apache.directory.shared.asn1.ber.tlv.BooleanDecoder;
import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.message.control.replication.SynchronizationInfoEnum;
import org.apache.directory.shared.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -99,8 +98,7 @@ public final class SyncInfoValueGrammar
{
public void action( SyncInfoValueContainer container )
{
- SyncInfoValueDecorator control =
- new SyncInfoValueDecorator( SynchronizationInfoEnum.NEW_COOKIE);
+ SyncInfoValueDecorator control = container.getSyncInfoValueControl();
Value value = container.getCurrentTLV().getValue();
@@ -138,11 +136,6 @@ public final class SyncInfoValueGrammar
{
public void action( SyncInfoValueContainer container )
{
- SyncInfoValueDecorator control =
- new SyncInfoValueDecorator( SynchronizationInfoEnum.REFRESH_DELETE);
-
- container.setSyncInfoValueControl( control );
-
// We can have an END transition
container.setGrammarEndAllowed( true );
}
@@ -304,10 +297,7 @@ public final class SyncInfoValueGrammar
{
public void action( SyncInfoValueContainer container )
{
- SyncInfoValueDecorator control =
- new SyncInfoValueDecorator( SynchronizationInfoEnum.REFRESH_PRESENT);
-
- container.setSyncInfoValueControl( control );
+ SyncInfoValueDecorator control = container.getSyncInfoValueControl();
// We can have an END transition
container.setGrammarEndAllowed( true );
@@ -466,17 +456,7 @@ public final class SyncInfoValueGrammar
super.transitions[SyncInfoValueStatesEnum.START_STATE.ordinal()][SyncInfoValueTags.SYNC_ID_SET_TAG.getValue()] =
new GrammarTransition( SyncInfoValueStatesEnum.START_STATE,
SyncInfoValueStatesEnum.SYNC_ID_SET_STATE,
- SyncInfoValueTags.SYNC_ID_SET_TAG.getValue(),
- new GrammarAction<SyncInfoValueContainer>( "SyncIdSet choice for SyncInfoValueControl" )
- {
- public void action( SyncInfoValueContainer container )
- {
- SyncInfoValueDecorator control =
- new SyncInfoValueDecorator( SynchronizationInfoEnum.SYNC_ID_SET);
-
- container.setSyncInfoValueControl( control );
- }
- } );
+ SyncInfoValueTags.SYNC_ID_SET_TAG.getValue(), null );
/**
@@ -686,7 +666,7 @@ public final class SyncInfoValueGrammar
{
public void action( SyncInfoValueContainer container ) throws DecoderException
{
- ISyncInfoValue control = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator control = container.getSyncInfoValueControl();
Value value = container.getCurrentTLV().getValue();
@@ -706,7 +686,7 @@ public final class SyncInfoValueGrammar
}
// Store the UUID in the UUIDs list
- control.getSyncUUIDs().add( uuid );
+ control.addSyncUUID( uuid );
// We can have an END transition
container.setGrammarEndAllowed( true );
@@ -731,7 +711,7 @@ public final class SyncInfoValueGrammar
{
public void action( SyncInfoValueContainer container ) throws DecoderException
{
- ISyncInfoValue control = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator control = container.getSyncInfoValueControl();
Value value = container.getCurrentTLV().getValue();
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=1065266&r1=1065265&r2=1065266&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 Sun Jan 30 13:37:47 2011
@@ -33,7 +33,6 @@ import org.apache.directory.junit.tools.
import org.apache.directory.shared.asn1.EncoderException;
import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.ISyncDoneValue;
import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueDecorator;
-import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueContainer;
import org.apache.directory.shared.util.Strings;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -51,7 +50,7 @@ public class SyncDoneValueControlTest
{
@Test
- public void testSyncDoneValueControl()
+ public void testSyncDoneValueControl() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 11 );
@@ -64,19 +63,10 @@ public class SyncDoneValueControlTest
bb.flip();
- SyncDoneValueContainer container = new SyncDoneValueContainer();
- SyncDoneValueDecorator decorator = container.getSyncDoneValueControl();
+ SyncDoneValueDecorator decorator = new SyncDoneValueDecorator();
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( Exception e )
- {
- fail( e.getMessage() );
- }
-
- SyncDoneValueDecorator control = container.getSyncDoneValueControl();
+ ISyncDoneValue control = (ISyncDoneValue)decorator.decode( bb.array() );
+
assertEquals( "xkcd", Strings.utf8ToString(control.getCookie()) );
assertTrue( control.isRefreshDeletes() );
@@ -99,7 +89,7 @@ public class SyncDoneValueControlTest
buffer.flip();
- bb = control.encode( ByteBuffer.allocate( control.computeLength() ) );
+ bb = ((SyncDoneValueDecorator)control).encode( ByteBuffer.allocate( ((SyncDoneValueDecorator)control).computeLength() ) );
String expected = Strings.dumpBytes(buffer.array());
String decoded = Strings.dumpBytes(bb.array());
assertEquals( expected, decoded );
@@ -112,7 +102,7 @@ public class SyncDoneValueControlTest
@Test
- public void testSyncDoneValueControlWithoutCookie()
+ public void testSyncDoneValueControlWithoutCookie() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 5 );
@@ -125,19 +115,10 @@ public class SyncDoneValueControlTest
bb.flip();
- SyncDoneValueContainer container = new SyncDoneValueContainer();
- SyncDoneValueDecorator decorator = container.getSyncDoneValueControl();
+ SyncDoneValueDecorator decorator = new SyncDoneValueDecorator();
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( Exception e )
- {
- fail( e.getMessage() );
- }
+ ISyncDoneValue control = (ISyncDoneValue)decorator.decode( bb.array() );
- SyncDoneValueDecorator control = container.getSyncDoneValueControl();
assertNull( control.getCookie() );
assertTrue( control.isRefreshDeletes() );
@@ -159,7 +140,7 @@ public class SyncDoneValueControlTest
buffer.flip();
- bb = control.encode( ByteBuffer.allocate( control.computeLength() ) );
+ bb = ((SyncDoneValueDecorator)control).encode( ByteBuffer.allocate( ((SyncDoneValueDecorator)control).computeLength() ) );
String expected = Strings.dumpBytes(buffer.array());
String decoded = Strings.dumpBytes(bb.array());
assertEquals( expected, decoded );
@@ -172,7 +153,7 @@ public class SyncDoneValueControlTest
@Test
- public void testSyncDoneValueWithSequenceOnly()
+ public void testSyncDoneValueWithSequenceOnly() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 2 );
@@ -183,26 +164,17 @@ public class SyncDoneValueControlTest
bb.flip();
- SyncDoneValueContainer container = new SyncDoneValueContainer();
- SyncDoneValueDecorator decorator = container.getSyncDoneValueControl();
+ SyncDoneValueDecorator decorator = new SyncDoneValueDecorator();
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( Exception e )
- {
- fail( "shouldn't reach this" );
- }
+ ISyncDoneValue control = (ISyncDoneValue)decorator.decode( bb.array() );
- ISyncDoneValue control = container.getSyncDoneValueControl();
assertNull( control.getCookie() );
assertFalse( control.isRefreshDeletes() );
}
@Test
- public void testSyncDoneValueControlWithEmptyCookie()
+ public void testSyncDoneValueControlWithEmptyCookie() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 7 );
@@ -215,19 +187,10 @@ public class SyncDoneValueControlTest
bb.flip();
- SyncDoneValueContainer container = new SyncDoneValueContainer();
- SyncDoneValueDecorator decorator = container.getSyncDoneValueControl();
+ SyncDoneValueDecorator decorator = new SyncDoneValueDecorator();
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( Exception e )
- {
- fail( e.getMessage() );
- }
+ ISyncDoneValue control = (ISyncDoneValue)decorator.decode( bb.array() );
- SyncDoneValueDecorator control = container.getSyncDoneValueControl();
assertEquals( "", Strings.utf8ToString(control.getCookie()) );
assertFalse( control.isRefreshDeletes() );
@@ -248,7 +211,7 @@ public class SyncDoneValueControlTest
buffer.flip();
- bb = control.encode( ByteBuffer.allocate( control.computeLength() ) );
+ bb = ((SyncDoneValueDecorator)control).encode( ByteBuffer.allocate( ((SyncDoneValueDecorator)control).computeLength() ) );
String expected = Strings.dumpBytes(buffer.array());
String decoded = Strings.dumpBytes(bb.array());
assertEquals( expected, decoded );
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncInfoValueControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncInfoValueControlTest.java?rev=1065266&r1=1065265&r2=1065266&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncInfoValueControlTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncInfoValueControlTest.java Sun Jan 30 13:37:47 2011
@@ -30,8 +30,8 @@ import org.apache.directory.junit.tools.
import org.apache.directory.junit.tools.ConcurrentJunitRunner;
import org.apache.directory.shared.asn1.DecoderException;
import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.ISyncInfoValue;
import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueDecorator;
-import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueContainer;
import org.apache.directory.shared.ldap.message.control.replication.SynchronizationInfoEnum;
import org.apache.directory.shared.util.Strings;
import org.junit.Test;
@@ -53,7 +53,7 @@ public class SyncInfoValueControlTest
* Test the decoding of a SyncInfoValue control, newCookie choice
*/
@Test
- public void testDecodeSyncInfoValueControlNewCookie()
+ public void testDecodeSyncInfoValueControlNewCookie() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x05 );
bb.put( new byte[]
@@ -63,21 +63,11 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
decorator.setType( SynchronizationInfoEnum.NEW_COOKIE );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.NEW_COOKIE, syncInfoValue.getType() );
assertEquals( "abc", Strings.utf8ToString(syncInfoValue.getCookie()) );
@@ -98,7 +88,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -112,7 +102,7 @@ public class SyncInfoValueControlTest
* Test the decoding of a SyncInfoValue control, empty newCookie choice
*/
@Test
- public void testDecodeSyncInfoValueControlEmptyNewCookie()
+ public void testDecodeSyncInfoValueControlEmptyNewCookie() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x02 );
bb.put( new byte[]
@@ -122,21 +112,11 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
decorator.setType( SynchronizationInfoEnum.NEW_COOKIE );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.NEW_COOKIE, syncInfoValue.getType() );
assertEquals( "", Strings.utf8ToString(syncInfoValue.getCookie()) );
@@ -156,7 +136,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -174,7 +154,7 @@ public class SyncInfoValueControlTest
* refreshDone = true
*/
@Test
- public void testDecodeSyncInfoValueControlRefreshDelete()
+ public void testDecodeSyncInfoValueControlRefreshDelete() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x0A );
bb.put( new byte[]
@@ -186,21 +166,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.REFRESH_DELETE );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.REFRESH_DELETE, syncInfoValue.getType() );
assertEquals( "abc", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertTrue( syncInfoValue.isRefreshDone() );
@@ -223,7 +194,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -238,7 +209,7 @@ public class SyncInfoValueControlTest
* refreshDone = false
*/
@Test
- public void testDecodeSyncInfoValueControlRefreshDeleteRefreshDoneFalse()
+ public void testDecodeSyncInfoValueControlRefreshDeleteRefreshDoneFalse() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x0A );
bb.put( new byte[]
@@ -250,21 +221,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.REFRESH_DELETE );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.REFRESH_DELETE, syncInfoValue.getType() );
assertEquals( "abc", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertFalse( syncInfoValue.isRefreshDone() );
@@ -288,7 +250,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -303,7 +265,7 @@ public class SyncInfoValueControlTest
* no refreshDone
*/
@Test
- public void testDecodeSyncInfoValueControlRefreshDeleteNoRefreshDone()
+ public void testDecodeSyncInfoValueControlRefreshDeleteNoRefreshDone() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x07 );
bb.put( new byte[]
@@ -314,21 +276,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.REFRESH_DELETE );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.REFRESH_DELETE, syncInfoValue.getType() );
assertEquals( "abc", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertTrue( syncInfoValue.isRefreshDone() );
@@ -351,7 +304,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -366,7 +319,7 @@ public class SyncInfoValueControlTest
* no cookie
*/
@Test
- public void testDecodeSyncInfoValueControlRefreshDeleteNoCookie()
+ public void testDecodeSyncInfoValueControlRefreshDeleteNoCookie() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x05 );
bb.put( new byte[]
@@ -377,21 +330,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.REFRESH_DELETE );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.REFRESH_DELETE, syncInfoValue.getType() );
assertEquals( "", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertFalse( syncInfoValue.isRefreshDone() );
@@ -414,7 +358,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -429,7 +373,7 @@ public class SyncInfoValueControlTest
* no cookie, no refreshDone
*/
@Test
- public void testDecodeSyncInfoValueControlRefreshDeleteNoCookieNoRefreshDone()
+ public void testDecodeSyncInfoValueControlRefreshDeleteNoCookieNoRefreshDone() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x02 );
bb.put( new byte[]
@@ -438,21 +382,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.REFRESH_DELETE );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.REFRESH_DELETE, syncInfoValue.getType() );
assertEquals( "", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertTrue( syncInfoValue.isRefreshDone() );
@@ -473,7 +408,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -491,7 +426,7 @@ public class SyncInfoValueControlTest
* refreshDone = true
*/
@Test
- public void testDecodeSyncInfoValueControlRefreshPresent()
+ public void testDecodeSyncInfoValueControlRefreshPresent() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x0A );
bb.put( new byte[]
@@ -503,21 +438,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.REFRESH_PRESENT );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.REFRESH_PRESENT, syncInfoValue.getType() );
assertEquals( "abc", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertTrue( syncInfoValue.isRefreshDone() );
@@ -540,7 +466,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -555,7 +481,7 @@ public class SyncInfoValueControlTest
* refreshDone = false
*/
@Test
- public void testDecodeSyncInfoValueControlRefreshPresentRefreshDoneFalse()
+ public void testDecodeSyncInfoValueControlRefreshPresentRefreshDoneFalse() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x0A );
bb.put( new byte[]
@@ -567,21 +493,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.REFRESH_PRESENT );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.REFRESH_PRESENT, syncInfoValue.getType() );
assertEquals( "abc", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertFalse( syncInfoValue.isRefreshDone() );
@@ -605,7 +522,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -620,7 +537,7 @@ public class SyncInfoValueControlTest
* no refreshDone
*/
@Test
- public void testDecodeSyncInfoValueControlRefreshPresentNoRefreshDone()
+ public void testDecodeSyncInfoValueControlRefreshPresentNoRefreshDone() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x07 );
bb.put( new byte[]
@@ -631,21 +548,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.REFRESH_PRESENT );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.REFRESH_PRESENT, syncInfoValue.getType() );
assertEquals( "abc", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertTrue( syncInfoValue.isRefreshDone() );
@@ -668,7 +576,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -683,7 +591,7 @@ public class SyncInfoValueControlTest
* no cookie
*/
@Test
- public void testDecodeSyncInfoValueControlRefreshPresentNoCookie()
+ public void testDecodeSyncInfoValueControlRefreshPresentNoCookie() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x05 );
bb.put( new byte[]
@@ -694,21 +602,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.REFRESH_PRESENT );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.REFRESH_PRESENT, syncInfoValue.getType() );
assertEquals( "", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertFalse( syncInfoValue.isRefreshDone() );
@@ -731,7 +630,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -746,7 +645,7 @@ public class SyncInfoValueControlTest
* no cookie, no refreshDone
*/
@Test
- public void testDecodeSyncInfoValueControlRefreshPresentNoCookieNoRefreshDone()
+ public void testDecodeSyncInfoValueControlRefreshPresentNoCookieNoRefreshDone() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x02 );
bb.put( new byte[]
@@ -755,21 +654,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.REFRESH_PRESENT );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.REFRESH_PRESENT, syncInfoValue.getType() );
assertEquals( "", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertTrue( syncInfoValue.isRefreshDone() );
@@ -790,7 +680,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -817,8 +707,8 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
try
@@ -849,8 +739,8 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
try
@@ -881,8 +771,8 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
try
@@ -914,8 +804,8 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
try
@@ -935,7 +825,7 @@ public class SyncInfoValueControlTest
* no refreshDeletes flag, an empty UUID set
*/
@Test
- public void testDecodeSyncInfoValueControlSyncIdSetNoCookieNoRefreshDeletesEmptySet()
+ public void testDecodeSyncInfoValueControlSyncIdSetNoCookieNoRefreshDeletesEmptySet() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x04 );
bb.put( new byte[]
@@ -946,21 +836,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
-
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
+
assertEquals( SynchronizationInfoEnum.SYNC_ID_SET, syncInfoValue.getType() );
assertEquals( "", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertFalse( syncInfoValue.isRefreshDeletes() );
@@ -984,7 +865,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -999,7 +880,7 @@ public class SyncInfoValueControlTest
* no refreshDeletes flag, a UUID set with some values
*/
@Test
- public void testDecodeSyncInfoValueControlSyncIdSetNoCookieNoRefreshDeletesUUIDsSet()
+ public void testDecodeSyncInfoValueControlSyncIdSetNoCookieNoRefreshDeletesUUIDsSet() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x3A );
bb.put( new byte[]
@@ -1019,20 +900,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
+
assertEquals( SynchronizationInfoEnum.SYNC_ID_SET, syncInfoValue.getType() );
assertEquals( "", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertFalse( syncInfoValue.isRefreshDeletes() );
@@ -1075,7 +948,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -1090,7 +963,7 @@ public class SyncInfoValueControlTest
* no refreshDeletes flag, an empty UUID set
*/
@Test
- public void testDecodeSyncInfoValueControlSyncIdSetCookieNoRefreshDeletesEmptySet()
+ public void testDecodeSyncInfoValueControlSyncIdSetCookieNoRefreshDeletesEmptySet() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x09 );
bb.put( new byte[]
@@ -1102,20 +975,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
+
assertEquals( SynchronizationInfoEnum.SYNC_ID_SET, syncInfoValue.getType() );
assertEquals( "abc", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertFalse( syncInfoValue.isRefreshDeletes() );
@@ -1140,7 +1005,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -1155,7 +1020,7 @@ public class SyncInfoValueControlTest
* no refreshDeletes flag, a UUID set with some values
*/
@Test
- public void testDecodeSyncInfoValueControlSyncIdSetCookieNoRefreshDeletesUUIDsSet()
+ public void testDecodeSyncInfoValueControlSyncIdSetCookieNoRefreshDeletesUUIDsSet() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x3F );
bb.put( new byte[]
@@ -1176,21 +1041,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
-
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
+
assertEquals( SynchronizationInfoEnum.SYNC_ID_SET, syncInfoValue.getType() );
assertEquals( "abc", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertFalse( syncInfoValue.isRefreshDeletes() );
@@ -1234,7 +1090,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -1249,7 +1105,7 @@ public class SyncInfoValueControlTest
* a refreshDeletes flag, an empty UUID set
*/
@Test
- public void testDecodeSyncInfoValueControlSyncIdSetNoCookieRefreshDeletesEmptySet()
+ public void testDecodeSyncInfoValueControlSyncIdSetNoCookieRefreshDeletesEmptySet() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x07 );
bb.put( new byte[]
@@ -1261,20 +1117,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
+
assertEquals( SynchronizationInfoEnum.SYNC_ID_SET, syncInfoValue.getType() );
assertEquals( "", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertTrue( syncInfoValue.isRefreshDeletes() );
@@ -1299,7 +1147,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -1314,7 +1162,7 @@ public class SyncInfoValueControlTest
* no refreshDeletes flag, a UUID set with some values
*/
@Test
- public void testDecodeSyncInfoValueControlSyncIdSetNoCookieRefreshDeletesUUIDsSet()
+ public void testDecodeSyncInfoValueControlSyncIdSetNoCookieRefreshDeletesUUIDsSet() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x3D );
bb.put( new byte[]
@@ -1335,20 +1183,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
- decorator.setType( SynchronizationInfoEnum.NEW_COOKIE );
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
+ decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
+
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
assertEquals( SynchronizationInfoEnum.SYNC_ID_SET, syncInfoValue.getType() );
assertEquals( "", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertTrue( syncInfoValue.isRefreshDeletes() );
@@ -1392,7 +1232,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -1407,7 +1247,7 @@ public class SyncInfoValueControlTest
* a refreshDeletes flag, an empty UUID set
*/
@Test
- public void testDecodeSyncInfoValueControlSyncIdSetCookieRefreshDeletesEmptySet()
+ public void testDecodeSyncInfoValueControlSyncIdSetCookieRefreshDeletesEmptySet() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x0C );
bb.put( new byte[]
@@ -1420,20 +1260,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
+
assertEquals( SynchronizationInfoEnum.SYNC_ID_SET, syncInfoValue.getType() );
assertEquals( "abc", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertTrue( syncInfoValue.isRefreshDeletes() );
@@ -1459,7 +1291,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -1474,7 +1306,7 @@ public class SyncInfoValueControlTest
* a refreshDeletes flag, a UUID set with some values
*/
@Test
- public void testDecodeSyncInfoValueControlSyncIdSetCookieRefreshDeletesUUIDsSet()
+ public void testDecodeSyncInfoValueControlSyncIdSetCookieRefreshDeletesUUIDsSet() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x42 );
bb.put( new byte[]
@@ -1496,21 +1328,12 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
- try
- {
- decorator.decode( bb.array() );
- }
- catch ( DecoderException de )
- {
- de.printStackTrace();
- fail( de.getMessage() );
- }
-
- SyncInfoValueDecorator syncInfoValue = container.getSyncInfoValueControl();
+ ISyncInfoValue syncInfoValue = (ISyncInfoValue)decorator.decode( bb.array() );
+
assertEquals( SynchronizationInfoEnum.SYNC_ID_SET, syncInfoValue.getType() );
assertEquals( "abc", Strings.utf8ToString(syncInfoValue.getCookie()) );
assertTrue( syncInfoValue.isRefreshDeletes() );
@@ -1555,7 +1378,7 @@ public class SyncInfoValueControlTest
} );
buffer.flip();
- ByteBuffer encoded = syncInfoValue.encode( ByteBuffer.allocate( syncInfoValue.computeLength() ) );
+ ByteBuffer encoded = ((SyncInfoValueDecorator)syncInfoValue).encode( ByteBuffer.allocate( ((SyncInfoValueDecorator)syncInfoValue).computeLength() ) );
assertEquals( Strings.dumpBytes(buffer.array()), Strings.dumpBytes(encoded.array()) );
}
catch ( EncoderException ee )
@@ -1586,8 +1409,8 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
+
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
try
@@ -1624,8 +1447,7 @@ public class SyncInfoValueControlTest
} );
bb.flip();
- SyncInfoValueContainer container = new SyncInfoValueContainer();
- SyncInfoValueDecorator decorator = container.getSyncInfoValueControl();
+ SyncInfoValueDecorator decorator = new SyncInfoValueDecorator();
decorator.setType( SynchronizationInfoEnum.SYNC_ID_SET );
try
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=1065266&r1=1065265&r2=1065266&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 Jan 30 13:37:47 2011
@@ -31,8 +31,8 @@ import org.apache.directory.junit.tools.
import org.apache.directory.junit.tools.ConcurrentJunitRunner;
import org.apache.directory.shared.asn1.DecoderException;
import org.apache.directory.shared.asn1.EncoderException;
-import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.SyncRequestValueDecorator;
import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.SyncRequestValueContainer;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.SyncRequestValueDecorator;
import org.apache.directory.shared.ldap.message.control.replication.SynchronizationModeEnum;
import org.apache.directory.shared.util.Strings;
import org.junit.Test;
@@ -66,8 +66,8 @@ public class SyncRequestValueControlTest
} );
bb.flip();
- SyncRequestValueContainer container = new SyncRequestValueContainer();
- SyncRequestValueDecorator decorator = container.getSyncRequestValueControl();
+ SyncRequestValueDecorator decorator = new SyncRequestValueDecorator();
+ SyncRequestValueContainer container = new SyncRequestValueContainer( decorator );
try
{