You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/05/31 01:03:36 UTC

svn commit: rev 20663 - in incubator/directory/snickers/trunk/ldap-ber-provider/src: java/org/apache/snickers/ldap test/org/apache/snickers/ldap

Author: akarasulu
Date: Sun May 30 16:03:35 2004
New Revision: 20663

Added:
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestDeleteOldRdnRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestEntryRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestNewRdnRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestNewSuperiorRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/ModifyDnRequestRuleTest.java   (contents, props changed)
Modified:
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapDigesterFactory.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java
Log:
finished and tested the modifyDn request rules

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapDigesterFactory.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapDigesterFactory.java	(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapDigesterFactory.java	Sun May 30 16:03:35 2004
@@ -88,11 +88,58 @@
         addDeleteResponseRules( digester ) ;
         addExtendedRequestRules( digester ) ;
         addExtendedResponseRules( digester ) ;
+        addModifyDnRequestRules( digester ) ;
+        addModifyDnResponseRules( digester ) ;
 
         return digester ;
     }
 
 
+    /**
+     * Adds digester rules for processing LDAPv3 ModifyDn requests.
+     *
+     * @param digester the digester to add the rules to
+     */
+    private void addModifyDnRequestRules( BERDigester digester )
+    {
+        int[] pattern = new int[2] ;
+        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[1] = LdapTag.MODIFYDN_REQUEST.getPrimitiveTag() ;
+        digester.addRule( pattern, new ModifyDnRequestRule() ) ;
+
+        pattern = new int[3] ;
+        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[1] = LdapTag.MODIFYDN_REQUEST.getPrimitiveTag() ;
+        pattern[2] = UniversalTag.OCTET_STRING.getPrimitiveTag() ;
+        digester.addRule( pattern, new ModifyDnRequestEntryRule() ) ;
+
+        pattern[2] = UniversalTag.OCTET_STRING.getPrimitiveTag() ;
+        digester.addRule( pattern, new ModifyDnRequestNewRdnRule() ) ;
+
+        pattern[2] = UniversalTag.BOOLEAN.getPrimitiveTag() ;
+        digester.addRule( pattern, new ModifyDnRequestDeleteOldRdnRule() ) ;
+
+        pattern[2] = LdapTag.MODIFYDN_REQUEST_NEWSUP_TAG.getPrimitiveTag() ;
+        digester.addRule( pattern, new ModifyDnRequestNewSuperiorRule() ) ;
+    }
+
+
+    /**
+     * Adds digester rules for processing LDAPv3 ModifyDn responses.
+     *
+     * @param digester the digester to add the rules to
+     */
+    private void addModifyDnResponseRules( BERDigester digester )
+    {
+
+    }
+
+
+    /**
+     * Adds digester rules for processing LDAPv3 Extended requests.
+     *
+     * @param digester the digester to add the rules to
+     */
     private void addExtendedRequestRules( BERDigester digester )
     {
         int[] pattern = new int[2] ;
@@ -111,6 +158,11 @@
     }
 
 
+    /**
+     * Adds digester rules for processing LDAPv3 Extended responses.
+     *
+     * @param digester the digester to add the rules to
+     */
     private void addExtendedResponseRules( BERDigester digester )
     {
         int[] pattern = new int[2] ;

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java	(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java	Sun May 30 16:03:35 2004
@@ -209,9 +209,13 @@
     public static final ContextSpecificTag SERVER_SASL_CREDS_TAG =
             new ContextSpecificTag( 7, true ) ;
 
+    /** Context specific tag used for CONTEXT_SPECIFIC 0 */
+    public static final ContextSpecificTag CONTEXT_SPECIFIC_TAG_0 =
+            new ContextSpecificTag( 0, false ) ;
+
     /** Context specific tag used for ExtendedRequest requestName */
     public static final ContextSpecificTag EXTENDED_REQUEST_NAME_TAG =
-            new ContextSpecificTag( 0, false ) ;
+            CONTEXT_SPECIFIC_TAG_0 ;
 
     /** Context specific tag used for ExtendedRequest request value */
     public static final ContextSpecificTag EXTENDED_REQUEST_VALUE_TAG =
@@ -225,6 +229,9 @@
     public static final ContextSpecificTag EXTENDED_RESPONSE_VALUE_TAG =
             new ContextSpecificTag( 11, false ) ;
 
+    /** Context specific tag used for ModifyDn request new superior dn */
+    public static final ContextSpecificTag MODIFYDN_REQUEST_NEWSUP_TAG =
+            CONTEXT_SPECIFIC_TAG_0 ;
 
 
 

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestDeleteOldRdnRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestDeleteOldRdnRule.java	Sun May 30 16:03:35 2004
@@ -0,0 +1,80 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.snickers.ldap ;
+
+
+import java.nio.ByteBuffer ;
+
+import org.apache.ldap.common.message.ModifyDnRequest ;
+import org.apache.snickers.ber.primitives.UniversalTag ;
+import org.apache.snickers.ber.digester.rules.PrimitiveBooleanRule ;
+import org.apache.snickers.ber.TypeClass;
+
+
+/**
+ * A BERDigester rule to set the ModifyDnRequest's deleteOldRdn field.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ * Project</a>
+ * @version $Rev$
+ */
+public class ModifyDnRequestDeleteOldRdnRule extends PrimitiveBooleanRule
+{
+    public ModifyDnRequestDeleteOldRdnRule()
+    {
+        super( UniversalTag.BOOLEAN ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.digester.Rule#tag(int, boolean,
+     * org.apache.snickers.ber.TypeClass)
+     */
+    public void tag( int id, boolean isPrimitive, TypeClass typeClass )
+    {
+        super.tag( id, isPrimitive, typeClass ) ;
+    }
+
+
+    /**
+     * Allows the super method to push a ByteBuffer onto the top of the stack
+     * which contains the drained contents of the superclass' ByteAccumulator.
+     * This ByteBuffer is popped first then used to populate the credentials.
+     * There is no need to copy this buffer since it will not be used again
+     * by the ByteAccumulator of the superclass so we should be able to use
+     * the byte[] based backing store if one is present.  However it might
+     * have to be copied even then.  Situations requiring a copy are when the
+     * buffer has a limit less than the capacity or when there is no
+     * accessible array to the buffer.
+     *
+     * @see org.apache.snickers.ber.digester.Rule#finish()
+     */
+    public void finish()
+    {
+        // pushes a ByteBuffer onto the stack
+        super.finish() ;
+
+        // @todo find a way to get this boolean without a push and a pop
+        // pop the boolean that the super method pushed
+        boolean deleteOldRdn = getDigester().popBoolean() ;
+
+        // peek at the ModifyDnRequest underneath whose octets we set
+        ModifyDnRequest req = ( ModifyDnRequest ) getDigester().peek() ;
+
+        req.setDeleteOldRdn( deleteOldRdn ) ;
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestEntryRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestEntryRule.java	Sun May 30 16:03:35 2004
@@ -0,0 +1,137 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.snickers.ldap ;
+
+
+import java.nio.ByteBuffer ;
+
+import org.apache.ldap.common.message.ModifyDnRequest ;
+import org.apache.snickers.ber.primitives.UniversalTag ;
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule ;
+import org.apache.snickers.ber.TypeClass ;
+
+
+/**
+ * A BERDigester rule to set a DN for the ModifyDnRequest's entry field.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ * Project</a>
+ * @version $Rev$
+ */
+public class ModifyDnRequestEntryRule extends PrimitiveOctetStringRule
+{
+    private boolean byPass = false ;
+    // the current ModifyDnRequest underneath whose octets we set
+    private ModifyDnRequest req = null ;
+
+
+
+    public ModifyDnRequestEntryRule()
+    {
+        super( UniversalTag.OCTET_STRING ) ;
+    }
+
+
+    public void tag( int id, boolean isPrimitive, TypeClass typeClass )
+    {
+        // peek at the ModifyDnRequest underneath whose octets we set
+        req = ( ModifyDnRequest ) getDigester().peek() ;
+
+        if ( req.getName() != null )
+        {
+            byPass = true ;
+            return ;
+        }
+
+        super.tag( id, isPrimitive, typeClass ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#length(int)
+     */
+    public void length( int length )
+    {
+        if ( byPass )
+        {
+            return ;
+        }
+
+        super.length( length ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#value(java.nio.ByteBuffer)
+     */
+    public void value( ByteBuffer buf )
+    {
+        if ( byPass )
+        {
+            return ;
+        }
+
+        super.value( buf ) ;
+    }
+
+
+    /**
+     * Allows the super method to push a ByteBuffer onto the top of the stack
+     * which contains the drained contents of the superclass' ByteAccumulator.
+     * This ByteBuffer is popped first then used to populate the credentials.
+     * There is no need to copy this buffer since it will not be used again
+     * by the ByteAccumulator of the superclass so we should be able to use
+     * the byte[] based backing store if one is present.  However it might
+     * have to be copied even then.  Situations requiring a copy are when the
+     * buffer has a limit less than the capacity or when there is no
+     * accessible array to the buffer.
+     *
+     * @see org.apache.snickers.ber.digester.Rule#finish()
+     */
+    public void finish()
+    {
+        if ( byPass )
+        {
+            req = null ;
+            byPass = false ;
+            return ;
+        }
+
+        // pushes a ByteBuffer onto the stack
+        super.finish() ;
+
+        // pop the ByteBuffer the super method pushed
+        ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
+
+        byte[] octets = null ;
+        if ( buf.limit() == buf.capacity() && buf.hasArray() )
+        {
+            // use the backing store
+            octets = buf.array() ;
+        }
+        else
+        {
+            // copy because we don't have accessible array or data < array
+            octets = new byte[buf.remaining()] ;
+            buf.get( octets ) ;
+        }
+
+        req.setName( new String( octets ) ) ;
+        byPass = false ;
+        req = null ;
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestNewRdnRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestNewRdnRule.java	Sun May 30 16:03:35 2004
@@ -0,0 +1,140 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.snickers.ldap ;
+
+
+import java.nio.ByteBuffer ;
+
+import org.apache.ldap.common.message.ModifyDnRequest ;
+import org.apache.snickers.ber.primitives.UniversalTag ;
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule ;
+import org.apache.snickers.ber.TypeClass;
+
+
+/**
+ * A BERDigester rule to set the new RDN for the ModifyDnRequest's newRdn
+ * field.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ * Project</a>
+ * @version $Rev$
+ */
+public class ModifyDnRequestNewRdnRule extends PrimitiveOctetStringRule
+{
+    private boolean byPass = false ;
+    // the current ModifyDnRequest underneath whose octets we set
+    private ModifyDnRequest req = null ;
+
+
+
+    public ModifyDnRequestNewRdnRule()
+    {
+        super( UniversalTag.OCTET_STRING ) ;
+    }
+
+    
+    public void tag( int id, boolean isPrimitive, TypeClass typeClass )
+    {
+        // peek at the ModifyDnRequest underneath whose octets we set
+        req = ( ModifyDnRequest ) getDigester().peek() ;
+
+        // byPass this rule firing if the newRdn has already been set or
+        // if the name has not yet been set - because then the data is the name
+        if ( req.getNewRdn() != null || req.getName() == null )
+        {
+            byPass = true ;
+            return ;
+        }
+
+        super.tag( id, isPrimitive, typeClass ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#length(int)
+     */
+    public void length( int length )
+    {
+        if ( byPass )
+        {
+            return ;
+        }
+
+        super.length( length ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#value(java.nio.ByteBuffer)
+     */
+    public void value( ByteBuffer buf )
+    {
+        if ( byPass )
+        {
+            return ;
+        }
+
+        super.value( buf ) ;
+    }
+
+
+    /**
+     * Allows the super method to push a ByteBuffer onto the top of the stack
+     * which contains the drained contents of the superclass' ByteAccumulator.
+     * This ByteBuffer is popped first then used to populate the credentials.
+     * There is no need to copy this buffer since it will not be used again
+     * by the ByteAccumulator of the superclass so we should be able to use
+     * the byte[] based backing store if one is present.  However it might
+     * have to be copied even then.  Situations requiring a copy are when the
+     * buffer has a limit less than the capacity or when there is no
+     * accessible array to the buffer.
+     *
+     * @see org.apache.snickers.ber.digester.Rule#finish()
+     */
+    public void finish()
+    {
+        if ( byPass )
+        {
+            req = null ;
+            byPass = false ;
+            return ;
+        }
+
+        // pushes a ByteBuffer onto the stack
+        super.finish() ;
+
+        // pop the ByteBuffer the super method pushed
+        ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
+
+        byte[] octets = null ;
+        if ( buf.limit() == buf.capacity() && buf.hasArray() )
+        {
+            // use the backing store
+            octets = buf.array() ;
+        }
+        else
+        {
+            // copy because we don't have accessible array or data < array
+            octets = new byte[buf.remaining()] ;
+            buf.get( octets ) ;
+        }
+
+        req.setNewRdn( new String( octets ) ) ;
+        byPass = false ;
+        req = null ;
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestNewSuperiorRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestNewSuperiorRule.java	Sun May 30 16:03:35 2004
@@ -0,0 +1,95 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.snickers.ldap ;
+
+
+import java.nio.ByteBuffer ;
+
+import org.apache.ldap.common.message.ModifyDnRequest ;
+import org.apache.snickers.ber.primitives.UniversalTag ;
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule ;
+import org.apache.snickers.ber.TypeClass;
+
+
+/**
+ * A BERDigester rule to set the new RDN for the ModifyDnRequest's
+ * optional newSuperior field.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ * Project</a>
+ * @version $Rev$
+ */
+public class ModifyDnRequestNewSuperiorRule extends PrimitiveOctetStringRule
+{
+    public ModifyDnRequestNewSuperiorRule()
+    {
+        super( LdapTag.MODIFYDN_REQUEST_NEWSUP_TAG ) ;
+    }
+
+
+    public void tag( int id, boolean isPrimitive, TypeClass typeClass )
+    {
+        super.tag( id, isPrimitive, typeClass ) ;
+    }
+
+
+    /**
+     * Allows the super method to push a ByteBuffer onto the top of the stack
+     * which contains the drained contents of the superclass' ByteAccumulator.
+     * This ByteBuffer is popped first then used to populate the credentials.
+     * There is no need to copy this buffer since it will not be used again
+     * by the ByteAccumulator of the superclass so we should be able to use
+     * the byte[] based backing store if one is present.  However it might
+     * have to be copied even then.  Situations requiring a copy are when the
+     * buffer has a limit less than the capacity or when there is no
+     * accessible array to the buffer.
+     *
+     * @see org.apache.snickers.ber.digester.Rule#finish()
+     */
+    public void finish()
+    {
+        // pushes a ByteBuffer onto the stack
+        super.finish() ;
+        ByteBuffer buf = null ;
+
+        if ( ! ( getDigester().peek() instanceof ByteBuffer ) )
+        {
+            return ;
+        }
+
+        // pop the ByteBuffer the super method pushed
+        buf = ( ByteBuffer ) getDigester().pop() ;
+
+        // peek at the ModifyDnRequest underneath whose octets we set
+        ModifyDnRequest req = ( ModifyDnRequest ) getDigester().peek() ;
+
+        byte[] octets = null ;
+        if ( buf.limit() == buf.capacity() && buf.hasArray() )
+        {
+            // use the backing store
+            octets = buf.array() ;
+        }
+        else
+        {
+            // copy because we don't have accessible array or data < array
+            octets = new byte[buf.remaining()] ;
+            buf.get( octets ) ;
+        }
+
+        req.setNewSuperior( new String( octets ) ) ;
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/ModifyDnRequestRule.java	Sun May 30 16:03:35 2004
@@ -0,0 +1,62 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.snickers.ldap ;
+
+
+import org.apache.snickers.ber.TypeClass ;
+import org.apache.snickers.ber.digester.AbstractRule ;
+import org.apache.ldap.common.message.ModifyDnRequestImpl ;
+
+
+/**
+ * Digester rule that instantiates ModifyDnRequest objects and pushes them onto
+ * the object stack to be populated.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class ModifyDnRequestRule extends AbstractRule
+{
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#tag(int, boolean,
+     * org.apache.snickers.ber.TypeClass)
+     */
+    public void tag( int id, boolean isPrimitive, TypeClass typeClass )
+    {
+        LdapTag tag = LdapTag.getLdapTagById( id ) ;
+
+        if ( LdapTag.MODIFYDN_REQUEST != tag )
+        {
+            throw new IllegalArgumentException( "Expected a ModifyDnRequest tag"
+                + " id but got a " + tag ) ;
+        }
+
+        ModifyDnRequestImpl req = new
+                ModifyDnRequestImpl( getDigester().popInt() ) ;
+        getDigester().push( req ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#finish()
+     */
+    public void finish()
+    {
+        getDigester().pop() ;
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/ModifyDnRequestRuleTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/ModifyDnRequestRuleTest.java	Sun May 30 16:03:35 2004
@@ -0,0 +1,55 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.snickers.ldap ;
+
+
+import org.apache.ldap.common.message.* ;
+import org.apache.snickers.ldap.testutils.TestUtils ;
+import org.apache.snickers.ldap.testutils.RuleTestCase ;
+import org.apache.commons.lang.ArrayUtils;
+
+
+/**
+ * Document this class.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class ModifyDnRequestRuleTest extends RuleTestCase
+{
+    public void testModifyDnRequest() throws Exception
+    {
+        // build the PDU
+        ModifyDnRequestImpl req = new ModifyDnRequestImpl( 7 ) ;
+        req.setDeleteOldRdn( true ) ;
+        req.setName( "uid=asulu,dc=example,dc=com" ) ;
+        req.setNewRdn( "uid=akarasulu" ) ;
+        req.setNewSuperior( "dc=bogus,dc=com" ) ;
+        System.out.println( "Generated ModifyDnRequest for test:" ) ;
+        System.out.println( TestUtils.printTupleTree( req ) ) ;
+
+        ModifyDnRequest decoded = ( ModifyDnRequest )
+                snickersDecode( snaccEncode( req ) ) ;
+        assertEquals( req.getMessageId(), decoded.getMessageId() ) ;
+        assertEquals( req.getDeleteOldRdn(), decoded.getDeleteOldRdn() ) ;
+
+        assertEquals( req.getName(), decoded.getName() ) ;
+        assertEquals( req.getNewRdn(), decoded.getNewRdn() ) ;
+        assertEquals( req.getNewSuperior(), decoded.getNewSuperior() ) ;
+    }
+}