directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r742144 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/ main/java/org/apache/directory/shared/ldap/message/control/replication/ test/java/org/apache/directory/shar...
Date Sun, 08 Feb 2009 19:29:25 GMT
Author: kayyagari
Date: Sun Feb  8 19:29:24 2009
New Revision: 742144

URL: http://svn.apache.org/viewvc?rev=742144&view=rev
Log:
code for syncStateValue codec

Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlCodec.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlDecoder.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/control/replication/SyncStateTypeEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/control/replication/SyncStateValueControl.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncStateValueControlTest.java

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlCodec.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlCodec.java?rev=742144&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlCodec.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlCodec.java
Sun Feb  8 19:29:24 2009
@@ -0,0 +1,187 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
+import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.ldap.message.control.replication.SyncStateTypeEnum;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * A syncStateValue object, as defined in RFC 4533
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev:$, $Date: 
+ */
+public class SyncStateValueControlCodec extends AbstractAsn1Object
+{
+    /** The syncStateEnum type */
+    private SyncStateTypeEnum syncStateType;
+
+    /** The Sync cookie */
+    private byte[] cookie;
+
+    /** The entryUUID */
+    private byte[] entryUUID;
+
+    /** global length for the control */
+    private int syncStateValueLength;
+
+
+    /**
+     * @return the cookie
+     */
+    public byte[] getCookie()
+    {
+        return cookie;
+    }
+
+
+    /**
+     * @param cookie the cookie to set
+     */
+    public void setCookie( byte[] cookie )
+    {
+        this.cookie = cookie;
+    }
+
+
+    /**
+     * @return the syncState's type
+     */
+    public SyncStateTypeEnum getSyncStateType()
+    {
+        return syncStateType;
+    }
+
+
+    /**
+     * set the syncState's type
+     * 
+     * @param syncStateType the syncState's type
+     */
+    public void setSyncStateType( SyncStateTypeEnum syncStateType )
+    {
+        this.syncStateType = syncStateType;
+    }
+
+
+    /**
+     * @return the entryUUID
+     */
+    public byte[] getEntryUUID()
+    {
+        return entryUUID;
+    }
+
+
+    /**
+     * set the entryUUID
+     * 
+     * @param entryUUID the entryUUID
+     */
+    public void setEntryUUID( byte[] entryUUID )
+    {
+        this.entryUUID = entryUUID;
+    }
+
+
+    /**
+     * Compute the SyncStateValue length.
+     * 
+     * SyncStateValue :
+     * 0x30 L1
+     *  | 
+     *  +--> 0x0A 0x01 [0x00|0x01|0x02|0x03] (type)
+     * [+--> 0x04 L2 abcd...                 (entryUUID)
+     * [+--> 0x04 L3 abcd...                 (cookie)
+     *   
+     */
+    public int computeLength()
+    {
+        // The sync state type length
+        syncStateValueLength = 1 + 1 + 1;
+
+        syncStateValueLength += 1 + TLV.getNbBytes( entryUUID.length ) + entryUUID.length;
+
+        // The cookie length, if we have a cookie
+        if ( cookie != null )
+        {
+            syncStateValueLength += 1 + TLV.getNbBytes( cookie.length ) + cookie.length;
+        }
+
+        return 1 + TLV.getNbBytes( syncStateValueLength ) + syncStateValueLength;
+    }
+
+
+    /**
+     * Encode the SyncStateValue control
+     * 
+     * @param buffer The encoded sink
+     * @return A ByteBuffer that contains the encoded PDU
+     * @throws EncoderException If anything goes wrong.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        // Allocate the bytes buffer.
+        ByteBuffer bb = ByteBuffer.allocate( computeLength() );
+        bb.put( UniversalTag.SEQUENCE_TAG );
+        bb.put( TLV.getBytes( syncStateValueLength ) );
+
+        // The mode
+        bb.put( UniversalTag.ENUMERATED_TAG );
+        bb.put( ( byte ) 0x01 );
+        bb.put( Value.getBytes( syncStateType.getValue() ) );
+
+        // the entryUUID
+        Value.encode( bb, entryUUID );
+
+        // The cookie
+        if ( cookie != null )
+        {
+            Value.encode( bb, cookie );
+        }
+
+        return bb;
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "    SyncStateValue control :\n" );
+        sb.append( "        syncStateType     : '" ).append( syncStateType ).append( "'\n"
);
+        sb.append( "        entryUUID         : '" ).append( StringTools.dumpBytes( entryUUID
) ).append( "'\n" );
+        sb.append( "        cookie            : '" ).append( StringTools.dumpBytes( cookie
) ).append( "'\n" );
+
+        return sb.toString();
+    }
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlContainer.java?rev=742144&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlContainer.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlContainer.java
Sun Feb  8 19:29:24 2009
@@ -0,0 +1,79 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue;
+
+
+import org.apache.directory.shared.asn1.ber.AbstractContainer;
+
+
+/**
+ * A container for the SyncStateValue control
+ *  
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 741888 $, $Date: 2009-02-07 13:57:03 +0100 (Sat, 07 Feb 2009) $, 
+ */
+public class SyncStateValueControlContainer extends AbstractContainer
+{
+    /** SyncStateValueControl */
+    private SyncStateValueControlCodec control;
+
+
+    /**
+     * Creates a new SyncStateValueControlContainer object. We will store one grammar,
+     * it's enough ...
+     */
+    public SyncStateValueControlContainer()
+    {
+        super();
+        stateStack = new int[1];
+        grammar = SyncStateValueControlGrammar.getInstance();
+        states = SyncStateValueControlStatesEnum.getInstance();
+    }
+
+
+    /**
+     * @return Returns the syncStateValue control.
+     */
+    public SyncStateValueControlCodec getSyncStateValueControl()
+    {
+        return control;
+    }
+
+
+    /**
+     * Set a SyncStateValueControl Object into the container. It will be completed by
+     * the ldapDecoder.
+     * 
+     * @param control the SyncStateValueControl to set.
+     */
+    public void setSyncStateValueControl( SyncStateValueControlCodec control )
+    {
+        this.control = control;
+    }
+
+    /**
+     * Clean the container
+     */
+    public void clean()
+    {
+        super.clean();
+        control = null;
+    }
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlDecoder.java?rev=742144&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlDecoder.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlDecoder.java
Sun Feb  8 19:29:24 2009
@@ -0,0 +1,70 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.ber.Asn1Decoder;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.ControlDecoder;
+import org.apache.directory.shared.ldap.message.control.replication.SyncStateValueControl;
+
+
+/**
+ * A decoder for SyncStateValueControl.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 741888 $, $Date: 2009-02-07 13:57:03 +0100 (Sat, 07 Feb 2009) $, 
+ */
+public class SyncStateValueControlDecoder extends Asn1Decoder implements ControlDecoder
+{
+    /** An instance of this decoder */
+    private static final Asn1Decoder decoder = new Asn1Decoder();
+
+    /**
+     * Return the syncStateValue OID
+     * 
+     * @see org.apache.directory.shared.ldap.codec.ControlDecoder#getControlType()
+     */
+    public String getControlType()
+    {
+        return SyncStateValueControl.CONTROL_OID;
+    }
+
+    /**
+     * Decode the syncStateValue control
+     * 
+     * @param controlBytes The bytes array which contains the encoded syncStateValue
+     * 
+     * @return A valid SyncStateValueControl object
+     * 
+     * @throws DecoderException If the decoding found an error
+     * @throws NamingException It will never be throw by this method
+     */
+    public Asn1Object decode( byte[] controlBytes ) throws DecoderException
+    {
+        ByteBuffer bb = ByteBuffer.wrap( controlBytes );
+        SyncStateValueControlContainer container = new SyncStateValueControlContainer();
+        decoder.decode( bb, container );
+        return container.getSyncStateValueControl();
+    }
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlGrammar.java?rev=742144&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlGrammar.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlGrammar.java
Sun Feb  8 19:29:24 2009
@@ -0,0 +1,230 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.AbstractGrammar;
+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.grammar.IGrammar;
+import org.apache.directory.shared.asn1.ber.grammar.IStates;
+import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.util.BooleanDecoder;
+import org.apache.directory.shared.asn1.util.BooleanDecoderException;
+import org.apache.directory.shared.asn1.util.IntegerDecoder;
+import org.apache.directory.shared.asn1.util.IntegerDecoderException;
+import org.apache.directory.shared.ldap.message.control.replication.SyncStateTypeEnum;
+import org.apache.directory.shared.ldap.message.control.replication.SynchronizationModeEnum;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the SyncStateValueControl. All the actions are declared in
+ * this class. As it is a singleton, these declaration are only done once.
+ * 
+ * The decoded grammar is the following :
+ * 
+ *  syncStateValue ::= SEQUENCE {
+ *       state ENUMERATED {
+ *            present (0),
+ *            add (1),
+ *            modify (2),
+ *            delete (3)
+ *       },
+ *       entryUUID syncUUID,
+ *       cookie    syncCookie OPTIONAL
+ *  }
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 741888 $, $Date: 2009-02-07 13:57:03 +0100 (Sat, 07 Feb 2009) $, 
+ */
+public class SyncStateValueControlGrammar extends AbstractGrammar
+{
+    /** The logger */
+    static final Logger LOG = LoggerFactory.getLogger( SyncStateValueControlGrammar.class
);
+
+    /** Speedup for logs */
+    static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+    /** The instance of grammar. SyncStateValueControlGrammar is a singleton */
+    private static IGrammar instance = new SyncStateValueControlGrammar();
+
+
+    /**
+     * Creates a new SyncStateValueControlGrammar object.
+     */
+    private SyncStateValueControlGrammar()
+    {
+        name = SyncStateValueControlGrammar.class.getName();
+        statesEnum = SyncStateValueControlStatesEnum.getInstance();
+
+        // Create the transitions table
+        super.transitions = new GrammarTransition[SyncStateValueControlStatesEnum.LAST_SYNC_STATE_VALUE_STATE][256];
+
+        /** 
+         * Transition from initial state to SyncStateValue sequence
+         * SyncRequestValue ::= SEQUENCE OF {
+         *     ...
+         *     
+         * Initialize the syncStateValue object
+         */
+        super.transitions[IStates.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
+            IStates.INIT_GRAMMAR_STATE, SyncStateValueControlStatesEnum.SYNC_STATE_VALUE_SEQUENCE_STATE,
+            UniversalTag.SEQUENCE_TAG, new GrammarAction( "Init SyncStateValueControl" )
+            {
+                public void action( IAsn1Container container )
+                {
+                    SyncStateValueControlContainer syncStateValueContainer = ( SyncStateValueControlContainer
) container;
+                    SyncStateValueControlCodec control = new SyncStateValueControlCodec();
+                    syncStateValueContainer.setSyncStateValueControl( control );
+                }
+            } );
+
+        /** 
+         * Transition from SyncStateValue sequence to state type enum
+         * SyncRequestValue ::= SEQUENCE OF {
+         *       state ENUMERATED {
+         *            present (0),
+         *            add (1),
+         *            modify (2),
+         *            delete (3)
+         *       },
+         *     ...
+         *     
+         * Stores the sync state type value
+         */
+        super.transitions[SyncStateValueControlStatesEnum.SYNC_STATE_VALUE_SEQUENCE_STATE][UniversalTag.ENUMERATED_TAG]
= new GrammarTransition(
+            SyncStateValueControlStatesEnum.SYNC_STATE_VALUE_SEQUENCE_STATE,
+            SyncStateValueControlStatesEnum.SYNC_TYPE_STATE, UniversalTag.ENUMERATED_TAG,
new GrammarAction(
+                "Set SyncStateValueControl state type" )
+            {
+                public void action( IAsn1Container container ) throws DecoderException
+                {
+                    SyncStateValueControlContainer syncStateValueContainer = ( SyncStateValueControlContainer
) container;
+                    Value value = syncStateValueContainer.getCurrentTLV().getValue();
+
+                    try
+                    {
+                        // Check that the value is into the allowed interval
+                        int syncStateType = IntegerDecoder.parse( value, SyncStateTypeEnum.PRESENT.getValue(),
+                            SyncStateTypeEnum.DELETE.getValue() );
+
+                        SyncStateTypeEnum syncStateTypeEnum = SyncStateTypeEnum.getSyncStateType(
syncStateType );
+
+                        if ( IS_DEBUG )
+                        {
+                            LOG.debug( "SyncStateType = {}", syncStateTypeEnum );
+                        }
+
+                        syncStateValueContainer.getSyncStateValueControl().setSyncStateType(
syncStateTypeEnum );
+
+                        // move on to the entryUUID transistion
+                        syncStateValueContainer.grammarEndAllowed( false );
+                    }
+                    catch ( IntegerDecoderException e )
+                    {
+                        String msg = "failed to decode the mode for SyncStateValueControl";
+                        LOG.error( msg, e );
+                        throw new DecoderException( msg );
+                    }
+                }
+            } );
+
+        /** 
+         * Transition from sync state tpe to entryUUID
+         * SyncStateValue ::= SEQUENCE OF {
+         *     ...
+         *     entryUUID     syncUUID
+         *     ...
+         *     
+         * Stores the entryUUID
+         */
+        super.transitions[SyncStateValueControlStatesEnum.SYNC_TYPE_STATE][UniversalTag.OCTET_STRING_TAG]
= new GrammarTransition(
+            SyncStateValueControlStatesEnum.SYNC_TYPE_STATE, SyncStateValueControlStatesEnum.SYNC_UUID_STATE,
+            UniversalTag.OCTET_STRING_TAG, new GrammarAction( "Set SyncStateValueControl
entryUUID" )
+            {
+                public void action( IAsn1Container container ) throws DecoderException
+                {
+                    SyncStateValueControlContainer syncStateValueContainer = ( SyncStateValueControlContainer
) container;
+                    Value value = syncStateValueContainer.getCurrentTLV().getValue();
+
+                    byte[] entryUUID = value.getData();
+
+                    if ( IS_DEBUG )
+                    {
+                        LOG.debug( "entryUUID = {}", StringTools.dumpBytes( entryUUID ) );
+                    }
+
+                    syncStateValueContainer.getSyncStateValueControl().setEntryUUID( entryUUID
);
+
+                    // We can have an END transition
+                    syncStateValueContainer.grammarEndAllowed( true );
+                }
+            } );
+
+        /** 
+         * Transition from entryUUID to cookie
+         * SyncRequestValue ::= SEQUENCE OF {
+         *     ...
+         *     cookie    syncCookie OPTIONAL
+         * }
+         *     
+         * Stores the reloadHint flag
+         */
+        super.transitions[SyncStateValueControlStatesEnum.SYNC_UUID_STATE][UniversalTag.OCTET_STRING_TAG]
= new GrammarTransition(
+            SyncStateValueControlStatesEnum.SYNC_UUID_STATE, SyncStateValueControlStatesEnum.COOKIE_STATE,
+            UniversalTag.OCTET_STRING_TAG, new GrammarAction( "Set SyncStateValueControl
cookie value" )
+            {
+                public void action( IAsn1Container container ) throws DecoderException
+                {
+                    SyncStateValueControlContainer syncStateValueContainer = ( SyncStateValueControlContainer
) container;
+                    Value value = syncStateValueContainer.getCurrentTLV().getValue();
+
+                    byte[] cookie = value.getData();
+
+                    if ( IS_DEBUG )
+                    {
+                        LOG.debug( "cookie = {}", cookie );
+                    }
+
+                    syncStateValueContainer.getSyncStateValueControl().setCookie( cookie
);
+
+                    // terminal state
+                    syncStateValueContainer.grammarEndAllowed( true );
+                }
+            } );
+    }
+
+
+    /**
+     * This class is a singleton.
+     * 
+     * @return An instance on this grammar
+     */
+    public static IGrammar getInstance()
+    {
+        return instance;
+    }
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlStatesEnum.java?rev=742144&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlStatesEnum.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlStatesEnum.java
Sun Feb  8 19:29:24 2009
@@ -0,0 +1,141 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue;
+
+
+import org.apache.directory.shared.asn1.ber.grammar.IGrammar;
+import org.apache.directory.shared.asn1.ber.grammar.IStates;
+
+
+/**
+ * This class store the SyncStateValueControl's grammar constants. It is also used for
+ * debugging purposes.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 741888 $, $Date: 2009-02-07 13:57:03 +0100 (Sat, 07 Feb 2009) $, 
+ */
+public class SyncStateValueControlStatesEnum implements IStates
+{
+    // ~ Static fields/initializers
+    // -----------------------------------------------------------------
+
+    // =========================================================================
+    // SyncStateValue control grammar states
+    // =========================================================================
+    /** Initial state */
+    public static final int START_STATE = 0;
+
+    /** Sequence Value */
+    public static final int SYNC_STATE_VALUE_SEQUENCE_STATE = 1;
+
+    /** sync state type Value */
+    public static final int SYNC_TYPE_STATE = 2;
+    
+    /** syncUUID Value */
+    public static final int SYNC_UUID_STATE = 3;
+
+    /** cookie Value */
+    public static final int COOKIE_STATE = 4;
+
+    /** terminal state */
+    public static final int LAST_SYNC_STATE_VALUE_STATE = 5;
+
+    // =========================================================================
+    // States debug strings
+    // =========================================================================
+    /** A string representation of all the states */
+    private static String[] syncStatetValueString = new String[]
+        { 
+        "START_STATE", 
+        "SYNC_STATE_VALUE_SEQUENCE_STATE", 
+        "SYNC_TYPE_STATE",
+        "SYNC_UUID_STATE", 
+        "COOKIE_STATE" 
+        };
+
+    /** The instance */
+    private static SyncStateValueControlStatesEnum instance = new SyncStateValueControlStatesEnum();
+
+
+    // ~ Constructors
+    // -------------------------------------------------------------------------------
+
+    /**
+     * This is a private constructor. This class is a singleton
+     */
+    private SyncStateValueControlStatesEnum()
+    {
+    }
+
+
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+
+    /**
+     * Get an instance of this class
+     * 
+     * @return An instance on this class
+     */
+    public static IStates getInstance()
+    {
+        return instance;
+    }
+
+
+    /**
+     * Get the grammar name
+     * 
+     * @param grammar The grammar code
+     * @return The grammar name
+     */
+    public String getGrammarName( int grammar )
+    {
+        return "SYNC_REQUEST_VALUE_GRAMMAR";
+    }
+
+
+    /**
+     * Get the grammar name
+     * 
+     * @param grammar The grammar class
+     * @return The grammar name
+     */
+    public String getGrammarName( IGrammar grammar )
+    {
+        if ( grammar instanceof SyncStateValueControlGrammar )
+        {
+            return "SYNC_STATE_VALUE_GRAMMAR";
+        }
+
+        return "UNKNOWN GRAMMAR";
+    }
+
+
+    /**
+     * Get the string representing the state
+     * 
+     * @param state The state number
+     * @return The String representing the state
+     */
+    public String getState( int state )
+    {
+        return ( ( state == GRAMMAR_END ) ? "SYNC_STATE_VALUE_END_STATE" : syncStatetValueString[state]
);
+    }
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/control/replication/SyncStateTypeEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/control/replication/SyncStateTypeEnum.java?rev=742144&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/control/replication/SyncStateTypeEnum.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/control/replication/SyncStateTypeEnum.java
Sun Feb  8 19:29:24 2009
@@ -0,0 +1,94 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.message.control.replication;
+
+
+/**
+ * 
+ * This class describes the four types of states part of the syncStateValue as described
in rfc4533.
+ * 
+ *  state ENUMERATED {
+ *            present (0),
+ *            add (1),
+ *            modify (2),
+ *            delete (3)
+ *   }
+ *   
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public enum SyncStateTypeEnum
+{
+    PRESENT(0), ADD(1), MODIFY(2), DELETE(3);
+
+    /** the internal value */
+    private int value;
+
+
+    /**
+     * Private constructor so no other instances can be created other than the
+     * public static constants in this class.
+     * 
+     * @param value the integer value of the enumeration.
+     */
+    private SyncStateTypeEnum( int value )
+    {
+        this.value = value;
+    }
+
+
+    /**
+     * @return The value associated with the current element.
+     */
+    public int getValue()
+    {
+        return value;
+    }
+
+
+    /**
+     * Get the {@link SyncStateTypeEnum} instance from an integer value.
+     * 
+     * @param value The value we want the enum element from
+     * @return The enum element associated with this integer
+     */
+    public static SyncStateTypeEnum getSyncStateType( int value )
+    {
+        if ( value == PRESENT.value )
+        {
+            return PRESENT;
+        }
+        else if ( value == ADD.value )
+        {
+            return ADD;
+        }
+        else if ( value == MODIFY.value )
+        {
+            return MODIFY;
+        }
+        else if ( value == DELETE.value )
+        {
+            return DELETE;
+        }
+
+        throw new IllegalArgumentException( "Unknown SyncStateTypeEnum value " + value );
+    }
+
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/control/replication/SyncStateValueControl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/control/replication/SyncStateValueControl.java?rev=742144&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/control/replication/SyncStateValueControl.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/control/replication/SyncStateValueControl.java
Sun Feb  8 19:29:24 2009
@@ -0,0 +1,149 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.message.control.replication;
+
+import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue.SyncStateValueControlCodec;
+import org.apache.directory.shared.ldap.message.control.AbstractMutableControlImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class implements the SyncStateValue Control, as described by RFC 4533.
+ * The structure for this control is :
+ * 
+ *  syncStateValue ::= SEQUENCE {
+ *       state ENUMERATED {
+ *            present (0),
+ *            add (1),
+ *            modify (2),
+ *            delete (3)
+ *       },
+ *       entryUUID syncUUID,
+ *       cookie    syncCookie OPTIONAL
+ *  }
+ * 
+ * This control OID is 1.3.6.1.4.1.4203.1.9.1.2
+ * 
+ * @see <a href="http://www.faqs.org/rfcs/rfc4533.html">RFC 4533</a>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: $
+ *
+ */
+public class SyncStateValueControl extends AbstractMutableControlImpl
+{
+    /** As this class is serializable, defined its serialVersionUID */ 
+    private static final long serialVersionUID = 1L;
+
+    /** The Logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( SyncStateValueControl.class
);
+
+    /** This control OID */
+    public static final String CONTROL_OID = "1.3.6.1.4.1.4203.1.9.1.2";
+
+    /** The synchronization state type */
+    private SyncStateTypeEnum syncStateType;
+    
+    /** the entryUUID */
+    private byte[] entryUUID;
+    
+    /** The cookie */
+    private byte[] cookie;
+    
+
+    /**
+     * @return the syncState's type
+     */
+    public SyncStateTypeEnum getSyncStateType()
+    {
+        return syncStateType;
+    }
+
+
+    /**
+     * set the syncState's type
+     * 
+     * @param syncStateType the syncState's type
+     */
+    public void setSyncStateType( SyncStateTypeEnum syncStateType )
+    {
+        this.syncStateType = syncStateType;
+    }
+
+
+    /**
+     * @return the entryUUID
+     */
+    public byte[] getEntryUUID()
+    {
+        return entryUUID;
+    }
+
+
+    /**
+     * set the entryUUID
+     * 
+     * @param entryUUID the entryUUID
+     */
+    public void setEntryUUID( byte[] entryUUID )
+    {
+        this.entryUUID = entryUUID;
+    }
+
+
+    /**
+     * @return the cookie
+     */
+    public byte[] getCookie()
+    {
+        return cookie;
+    }
+
+    
+    /**
+     * @param syncCookie the syncCookie to set
+     */
+    public void setCookie( byte[] cookie )
+    {
+        this.cookie = cookie;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public byte[] getEncodedValue()
+    {
+        SyncStateValueControlCodec syncStateValueCtlCodec = new SyncStateValueControlCodec();
+        syncStateValueCtlCodec.setSyncStateType( syncStateType );
+        syncStateValueCtlCodec.setEntryUUID( entryUUID );
+        syncStateValueCtlCodec.setCookie( cookie );
+
+        try
+        {
+            return syncStateValueCtlCodec.encode( null ).array();
+        }
+        catch ( EncoderException e )
+        {
+            LOG.error( "Failed to encode syncStateValue control", e );
+            throw new IllegalStateException( "Failed to encode control with encoder.", e
);
+        }
+    }
+}

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncStateValueControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncStateValueControlTest.java?rev=742144&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncStateValueControlTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncStateValueControlTest.java
Sun Feb  8 19:29:24 2009
@@ -0,0 +1,284 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.codec.controls.replication;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+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.syncStateValue.SyncStateValueControlCodec;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue.SyncStateValueControlContainer;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue.SyncStateValueControlDecoder;
+import org.apache.directory.shared.ldap.message.control.replication.SyncStateTypeEnum;
+import org.apache.directory.shared.ldap.message.control.replication.SynchronizationModeEnum;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.Test;
+
+
+/**
+ * Test the SyncStateControlValue codec
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SyncStateValueControlTest
+{
+    /**
+     * Test the decoding of a SyncStateValue control with a refreshOnly mode
+     */
+    @Test
+    public void testDecodeSyncStateValueControlWithStateType()
+    {
+        Asn1Decoder decoder = new SyncStateValueControlDecoder();
+        ByteBuffer bb = ByteBuffer.allocate( 16 );
+        bb.put( new byte[]
+            { 0x30, ( byte ) 14,               // SyncStateValue ::= SEQUENCE {
+                0x0A, 0x01, 0x00,              //     state ENUMERATED {
+                                               //         present (0)
+                                               //     }
+                0x04, 0x03, 'a', 'b', 'c',     //     entryUUID syncUUID OPTIONAL,
+                0x04, 0x04, 'x', 'k', 'c', 'd' //     cookie syncCookie OPTIONAL,
+            } );
+        bb.flip();
+
+        SyncStateValueControlContainer container = new SyncStateValueControlContainer();
+
+        try
+        {
+            decoder.decode( bb, container );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+            fail( de.getMessage() );
+        }
+
+        SyncStateValueControlCodec SyncStateValue = container.getSyncStateValueControl();
+        assertEquals( SyncStateTypeEnum.PRESENT, SyncStateValue.getSyncStateType() );
+        assertEquals( "abc", StringTools.utf8ToString( SyncStateValue.getEntryUUID() ) );
+        assertEquals( "xkcd", StringTools.utf8ToString( SyncStateValue.getCookie() ) );
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer encoded = SyncStateValue.encode( null );
+            encoded.flip();
+            bb.flip();
+            assertTrue( Arrays.equals( bb.array(), encoded.array() ) );
+        }
+        catch ( EncoderException ee )
+        {
+            fail( ee.getMessage() );
+        }
+    }
+
+
+    /**
+     * Test the decoding of a SyncStateValue control with no cookie
+     */
+    @Test
+    public void testDecodeSyncStateValueControlNoCookie()
+    {
+        Asn1Decoder decoder = new SyncStateValueControlDecoder();
+        ByteBuffer bb = ByteBuffer.allocate( 10 );
+        bb.put( new byte[]
+            { 0x30, 0x08,                 // SyncStateValue ::= SEQUENCE {
+                0x0A, 0x01, 0x01,         //     state ENUMERATED {
+                                          //         add (1)
+                                          //     }
+                0x04, 0x03, 'a', 'b', 'c' //     entryUUID syncUUID OPTIONAL
+            } );
+        bb.flip();
+
+        SyncStateValueControlContainer container = new SyncStateValueControlContainer();
+
+        try
+        {
+            decoder.decode( bb, container );
+        }
+        catch ( DecoderException de )
+        {
+            fail( de.getMessage() );
+        }
+
+        SyncStateValueControlCodec SyncStateValue = container.getSyncStateValueControl();
+        assertEquals( SyncStateTypeEnum.ADD, SyncStateValue.getSyncStateType() );
+        assertEquals( "abc", StringTools.utf8ToString( SyncStateValue.getEntryUUID() ) );
+        assertNull( SyncStateValue.getCookie() );
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer encoded = SyncStateValue.encode( null );
+            encoded.flip();
+            bb.flip();
+            assertTrue( Arrays.equals( bb.array(), encoded.array() ) );
+        }
+        catch ( EncoderException ee )
+        {
+            fail( ee.getMessage() );
+        }
+    }
+
+
+    /**
+     * Test the decoding of a SyncStateValue control with an empty cookie
+     */
+    @Test
+    public void testDecodeSyncStateValueControlEmptyCookie()
+    {
+        Asn1Decoder decoder = new SyncStateValueControlDecoder();
+        ByteBuffer bb = ByteBuffer.allocate( 0x12 );
+        bb.put( new byte[]
+            { 0x30, 0x10,                  // SyncStateValue ::= SEQUENCE {
+                0x0A, 0x01, 0x02,          //     state ENUMERATED {
+                                           //         modify (2)
+                                           //     }
+                0x04, 0x03, 'a', 'b', 'c', //     entryUUID syncUUID OPTIONAL
+                0x04, 0x00                 //     cookie syncCookie OPTIONAL,
+            } );
+        bb.flip();
+
+        SyncStateValueControlContainer container = new SyncStateValueControlContainer();
+        try
+        {
+            decoder.decode( bb, container );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+            fail( de.getMessage() );
+        }
+
+        SyncStateValueControlCodec syncStateValue = container.getSyncStateValueControl();
+        assertEquals( SyncStateTypeEnum.MODIFY, syncStateValue.getSyncStateType() );
+        assertEquals( "abc", StringTools.utf8ToString( syncStateValue.getEntryUUID() ) );
+        assertEquals( "", StringTools.utf8ToString( syncStateValue.getCookie() ) );
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer encoded = syncStateValue.encode( null );
+            encoded.flip();
+            bb.flip();
+            SyncStateValueControlCodec redecoded = container.getSyncStateValueControl();
+
+            assertEquals( syncStateValue.getSyncStateType(), redecoded.getSyncStateType()
);
+            assertTrue( Arrays.equals( syncStateValue.getCookie(), redecoded.getCookie()
) );
+            assertEquals( syncStateValue.getEntryUUID(), redecoded.getEntryUUID() );
+        }
+        catch ( EncoderException ee )
+        {
+            fail( ee.getMessage() );
+        }
+    }
+
+
+    /**
+     * Test the decoding of a SyncStateValue control with an empty sequence
+     */
+    @Test
+    public void testDecodeSyncStateValueControlEmptySequence()
+    {
+        Asn1Decoder decoder = new SyncStateValueControlDecoder();
+        ByteBuffer bb = ByteBuffer.allocate( 0x02 );
+        bb.put( new byte[]
+            { 0x30, 0x00 // SyncStateValue ::= SEQUENCE {
+            } );
+        bb.flip();
+
+        SyncStateValueControlContainer container = new SyncStateValueControlContainer();
+
+        try
+        {
+            decoder.decode( bb, container );
+            fail( "we should not get there" );
+        }
+        catch ( DecoderException de )
+        {
+            assertTrue( true );
+        }
+    }
+
+
+    /**
+     * Test the decoding of a SyncStateValue control with no syncState
+     */
+    @Test
+    public void testDecodeSyncStateValueControlNoSyancState()
+    {
+        Asn1Decoder decoder = new SyncStateValueControlDecoder();
+        ByteBuffer bb = ByteBuffer.allocate( 0x07 );
+        bb.put( new byte[]
+            { 0x30, 0x05,                 // SyncStateValue ::= SEQUENCE {
+                0x04, 0x03, 'a', 'b', 'c' //     cookie syncCookie OPTIONAL,
+            } );
+        bb.flip();
+
+        SyncStateValueControlContainer container = new SyncStateValueControlContainer();
+
+        try
+        {
+            decoder.decode( bb, container );
+            fail( "we should not get there" );
+        }
+        catch ( DecoderException de )
+        {
+            assertTrue( true );
+        }
+    }
+
+
+    /**
+     * Test the decoding of a SyncStateValue control with no syncUUID
+     */
+    @Test
+    public void testDecodeSyncStateValueControlNoSyncUUID()
+    {
+        Asn1Decoder decoder = new SyncStateValueControlDecoder();
+        ByteBuffer bb = ByteBuffer.allocate( 0x05 );
+        bb.put( new byte[]
+            { 0x30, 0x03,                  // SyncStateValue ::= SEQUENCE {
+                0x0A, 0x01, 0x02,          //     state ENUMERATED {
+                                           //         modify (2)
+                                           //     }
+            } );
+        bb.flip();
+
+        SyncStateValueControlContainer container = new SyncStateValueControlContainer();
+
+        try
+        {
+            decoder.decode( bb, container );
+            fail( "we should not get there" );
+        }
+        catch ( DecoderException de )
+        {
+            assertTrue( true );
+        }
+    }
+}



Mime
View raw message