directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 20680 - in incubator/directory/snickers/trunk: ber-codec/src/java/org/apache/snickers/ber/digester/rules ldap-ber-provider/src/java/org/apache/snickers/ldap ldap-ber-provider/src/test/org/apache/snickers/ldap
Date Mon, 31 May 2004 04:48:01 GMT
Author: akarasulu
Date: Sun May 30 21:48:01 2004
New Revision: 20680

Added:
   incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/digester/rules/Octets2StringRule.java
  (contents, props changed)
   incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/digester/rules/PopOnFinish.java
  (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/AddAttributeValueRule.java
  (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/AddRequestEntryDnRule.java
  (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/AddRequestRule.java
  (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/AttributesRule.java
  (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/AddRequestTest.java
  (contents, props changed)
Modified:
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapDigesterFactory.java
Log:
finished and tested the add request rules

Added: incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/digester/rules/Octets2StringRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/digester/rules/Octets2StringRule.java
Sun May 30 21:48:01 2004
@@ -0,0 +1,57 @@
+/*
+ *   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.ber.digester.rules ;
+
+
+import java.nio.ByteBuffer ;
+
+
+/**
+ * Rule that collects octets and leaves octets as a string on the stack.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class Octets2StringRule extends PrimitiveOctetStringRule
+{
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#finish()
+     */
+    public void finish()
+    {
+        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 ) ;
+        }
+
+        getDigester().push( new String( octets ) ) ;
+    }
+}

Added: incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/digester/rules/PopOnFinish.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/digester/rules/PopOnFinish.java
Sun May 30 21:48:01 2004
@@ -0,0 +1,40 @@
+/*
+ *   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.ber.digester.rules;
+
+
+import org.apache.snickers.ber.digester.AbstractRule;
+
+
+/**
+ * Document this class.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class PopOnFinish extends AbstractRule
+{
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#finish()
+     */
+    public void finish()
+    {
+        super.finish() ;
+        getDigester().pop() ;
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/AddAttributeValueRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/AddAttributeValueRule.java
Sun May 30 21:48:01 2004
@@ -0,0 +1,90 @@
+/*
+ *   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 javax.naming.directory.Attributes ;
+
+import org.apache.snickers.ber.primitives.UniversalTag ;
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule ;
+
+
+/**
+ * A BERDigester rule to set the OID of the ExtendedRequest's OID field.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ * Project</a>
+ * @version $Rev$
+ */
+public class AddAttributeValueRule extends PrimitiveOctetStringRule
+{
+    public AddAttributeValueRule()
+    {
+        super( UniversalTag.OCTET_STRING ) ;
+    }
+
+    
+    /**
+     * 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 ( isConstructed() )
+        {
+            return ;
+        }
+
+        // drain the accumulator
+        ByteBuffer buf = ( ByteBuffer ) getAccumulator().drain( 0 ) ;
+
+        // peek at the id string underneath which we use to set attributes with
+        String id = ( String ) getDigester().peek() ;
+
+        // peek at the Attributes object underneath which we add values to
+        Attributes attrs = ( Attributes ) getDigester().peek( 1 ) ;
+
+        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 ) ;
+        }
+
+        // Add the attribute
+        attrs.put( id, new String( octets ) ) ;
+
+        // clean up
+        setConstructed( false ) ;
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/AddRequestEntryDnRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/AddRequestEntryDnRule.java
Sun May 30 21:48:01 2004
@@ -0,0 +1,81 @@
+/*
+ *   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.AddRequest ;
+
+import org.apache.snickers.ber.primitives.UniversalTag ;
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule ;
+
+
+/**
+ * A BERDigester rule to set the dn of the entry added with a AddRequest.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ * Project</a>
+ * @version $Rev$
+ */
+public class AddRequestEntryDnRule extends PrimitiveOctetStringRule
+{
+    public AddRequestEntryDnRule()
+    {
+        super( UniversalTag.OCTET_STRING ) ;
+    }
+
+    
+    /**
+     * 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() ;
+
+        // pop the ByteBuffer the super method pushed
+        ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
+        // peek at the AddRequest underneath whose octets we set
+        AddRequest req = ( AddRequest ) 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.setName( new String( octets ) ) ;
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/AddRequestRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/AddRequestRule.java
Sun May 30 21:48:01 2004
@@ -0,0 +1,63 @@
+/*
+ *   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.AddRequestImpl ;
+
+import org.apache.snickers.ber.TypeClass ;
+import org.apache.snickers.ber.digester.AbstractRule ;
+
+
+/**
+ * A rule that creates an AddRequest and populates it.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ * Project</a>
+ * @version $Rev$
+ */
+public class AddRequestRule extends AbstractRule
+{
+    /* (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 ) ;
+
+        LdapTag tag = LdapTag.getLdapTagById( id ) ;
+
+        if ( LdapTag.ADD_REQUEST != tag )
+        {
+            throw new IllegalArgumentException( "Expected a ADD_REQUEST tag "
+                + "id but got a " + tag ) ;
+        }
+
+        AddRequestImpl req = new AddRequestImpl( getDigester().popInt() ) ;
+        getDigester().push( req ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.digester.Rule#finish()
+     */
+    public void finish()
+    {
+        super.finish() ;
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/AttributesRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/AttributesRule.java
Sun May 30 21:48:01 2004
@@ -0,0 +1,93 @@
+/*
+ *   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.TagEnum ;
+import org.apache.snickers.ber.TypeClass ;
+import org.apache.snickers.ber.digester.AbstractRule ;
+import org.apache.snickers.ber.primitives.UniversalTag ;
+
+import org.apache.ldap.common.message.AddRequestImpl ;
+import org.apache.ldap.common.message.LockableAttributesImpl ;
+
+
+/**
+ * Document this class.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class AttributesRule extends AbstractRule
+{
+    /** the tag this rule expects to encounter */
+    private final TagEnum expected ;
+
+
+    /**
+     * Creates a new AttributesRule using an expected tag to enforce.
+     *
+     * @param expected the tag the rule must encounter to fire properly
+     */
+    public AttributesRule( TagEnum expected )
+    {
+        this.expected = expected ;
+    }
+
+
+    /**
+     * Creates a new AttributesRule that expects a SEQUENCE tag.
+     */
+    public AttributesRule()
+    {
+        this.expected = UniversalTag.SEQUENCE_SEQUENCE_OF ;
+    }
+
+
+    /* (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 )
+    {
+        super.tag( id, isPrimitive, typeClass ) ;
+
+        if ( id != expected.getTagId() )
+        {
+            throw new IllegalArgumentException( "expected tag with id "
+                    + expected.getTagId() + " for " + expected
+                    + " but got " + id + "instead" ) ;
+        }
+
+        AddRequestImpl req = ( AddRequestImpl ) getDigester().peek() ;
+        LockableAttributesImpl attrs = new LockableAttributesImpl( req ) ;
+        req.setEntry( attrs ) ;
+        getDigester().push( attrs ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#finish()
+     */
+    public void finish()
+    {
+        super.finish() ;
+
+        getDigester().pop() ;
+    }
+}

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 21:48:01 2004
@@ -21,6 +21,8 @@
 import org.apache.snickers.ber.primitives.UniversalTag ;
 import org.apache.snickers.ber.digester.rules.PrimitiveIntDecodeRule ;
 import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule ;
+import org.apache.snickers.ber.digester.rules.Octets2StringRule;
+import org.apache.snickers.ber.digester.rules.PopOnFinish;
 
 
 /**
@@ -80,6 +82,7 @@
         addMessageIdRules( digester ) ;
         addAbandonRequestRules( digester ) ;
         addAddResponseRules( digester ) ;
+        addAddRequestRules( digester ) ;
         addUnbindRequestRules( digester ) ;
         addBindRequestRules( digester ) ;
         addBindResponseRules( digester ) ;
@@ -96,6 +99,53 @@
         addSearchResponseReferenceRules( digester ) ;
 
         return digester ;
+    }
+
+
+    private void addAddRequestRules( BERDigester digester )
+    {
+        int[] pattern = new int[2] ;
+
+        // set pattern and addRule for the AddRequest
+        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[1] = LdapTag.ADD_REQUEST.getPrimitiveTag() ;
+        digester.addRule( pattern, new AddRequestRule() ) ;
+
+        // setup pattern to set the dn of the entry added
+        pattern = new int[3] ;
+        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[1] = LdapTag.ADD_REQUEST.getPrimitiveTag() ;
+        pattern[2] = UniversalTag.OCTET_STRING.getPrimitiveTag() ;
+        digester.addRule( pattern, new AddRequestEntryDnRule() ) ;
+
+        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[1] = LdapTag.ADD_REQUEST.getPrimitiveTag() ;
+        pattern[2] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        digester.addRule( pattern, new AttributesRule() ) ;
+
+        pattern = new int[4] ;
+        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[1] = LdapTag.ADD_REQUEST.getPrimitiveTag() ;
+        pattern[2] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[3] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        digester.addRule( pattern, new PopOnFinish() ) ;
+
+        pattern = new int[5] ;
+        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[1] = LdapTag.ADD_REQUEST.getPrimitiveTag() ;
+        pattern[2] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[3] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[4] = UniversalTag.OCTET_STRING.getPrimitiveTag() ;
+        digester.addRule( pattern, new Octets2StringRule() ) ;
+
+        pattern = new int[6] ;
+        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[1] = LdapTag.ADD_REQUEST.getPrimitiveTag() ;
+        pattern[2] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[3] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[4] = UniversalTag.SET_SET_OF.getPrimitiveTag() ;
+        pattern[5] = UniversalTag.OCTET_STRING.getPrimitiveTag() ;
+        digester.addRule( pattern, new AddAttributeValueRule() ) ;
     }
 
 

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/AddRequestTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/AddRequestTest.java
Sun May 30 21:48:01 2004
@@ -0,0 +1,78 @@
+/*
+ *   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.util.HashSet;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.Attribute;
+import javax.naming.NamingEnumeration;
+
+import org.apache.ldap.common.message.*;
+import org.apache.snickers.ldap.testutils.RuleTestCase ;
+import org.apache.snickers.ldap.testutils.TestUtils;
+
+
+/**
+ * Tests the capability to end to end decode a BindRequest.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ * Project</a>
+ * @version $Rev$
+ */
+public class AddRequestTest extends RuleTestCase
+{
+    /**
+     * Tests a simple bind request decode.
+     */
+    public void testAddRequest() throws Exception
+    {
+        AddRequestImpl req = new AddRequestImpl( 33 ) ;
+        req.setName( "dc=example,dc=com" ) ;
+        LockableAttributesImpl attrs = new LockableAttributesImpl( req ) ;
+        attrs.put( "objectClass", "top" ) ;
+        attrs.put( "objectClass", "dcObject" ) ;
+        attrs.put( "dc", "dc=example" ) ;
+        req.setEntry( attrs ) ;
+        System.out.println( "Generated AddRequest for test:" ) ;
+        System.out.println( TestUtils.printTupleTree( req ) ) ;
+
+        AddRequest decoded = ( AddRequest )
+                snickersDecode( snaccEncode( req ) ) ;
+        assertNotNull( decoded ) ;
+        assertEquals( req.getName(), decoded.getName() ) ;
+        Attributes decodedAttrs = decoded.getEntry() ;
+        assertEquals( 2, decodedAttrs.size() ) ;
+        Attribute attr = decodedAttrs.get( "dc" ) ;
+        assertNotNull( attr ); ;
+        assertEquals( 1, attr.size() ) ;
+        assertEquals( "dc=example", attr.get() ) ;
+        attr = decodedAttrs.get( "objectClass" ) ;
+        assertEquals( 2, attr.size() ) ;
+
+        NamingEnumeration list = attr.getAll() ;
+        HashSet map = new HashSet() ;
+
+        while( list.hasMore() )
+        {
+            map.add( list.next() ) ;
+        }
+
+        assertTrue( map.contains( "top" ) ) ;
+        assertTrue( map.contains( "dcObject" ) ) ;
+    }
+}
\ No newline at end of file

Mime
View raw message