directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 37055 - in incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src: java/org/apache/snickers/ldap/encoder/delete test/org/apache/snickers/ldap/encoder/delete
Date Thu, 26 Aug 2004 05:03:15 GMT
Author: akarasulu
Date: Wed Aug 25 22:03:13 2004
New Revision: 37055

Added:
   incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/delete/
   incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/delete/DeleteRequestEncoder.java
   incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder/delete/
   incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder/delete/DeleteRequestEncoderTest.java
Log:
Commit changes ...

 o added delete request encoder impl which is complete
 o added and passed DeleteRequest encoder test case
 


Added: incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/delete/DeleteRequestEncoder.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/delete/DeleteRequestEncoder.java
Wed Aug 25 22:03:13 2004
@@ -0,0 +1,72 @@
+/*
+ *   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.encoder.delete;
+
+
+import org.apache.ldap.common.message.DeleteRequest;
+
+import org.apache.snickers.ber.Tuple;
+import org.apache.snickers.ber.Length;
+import org.apache.snickers.ber.TupleNode;
+import org.apache.snickers.ber.DefaultMutableTupleNode;
+import org.apache.snickers.ber.primitives.UniversalTag;
+
+import org.apache.snickers.ldap.LdapTag;
+import org.apache.snickers.ldap.encoder.EncoderUtils;
+
+
+/**
+ * A DeleteRequest stub to TupleNode encoder.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
+ *         Project</a> $Rev$
+ */
+public class DeleteRequestEncoder
+{
+    /** thread safe instance of the DeleteRequest stub encoder */
+    public static final DeleteRequestEncoder INSTANCE =
+            new DeleteRequestEncoder();
+
+    /**
+     * Encodes a DeleteRequest stub into a TupleNode representing a tlv tree
+     * for the PDU.
+     *
+     * @param request the DeleteRequest stub to encode
+     * @return the encoded root TupleNode for the tlv tree
+     */
+    public TupleNode encode( DeleteRequest request )
+    {
+        /// Create the top level BindRequest PDU node
+        DefaultMutableTupleNode top =
+                new DefaultMutableTupleNode( new Tuple() );
+        top.getTuple().setTag( UniversalTag.SEQUENCE_SEQUENCE_OF, false );
+        top.getTuple().setLength( Length.INDEFINATE );
+
+        // Create and add the message id to response PDU
+        DefaultMutableTupleNode child = ( DefaultMutableTupleNode )
+                EncoderUtils.encode( request.getMessageId() );
+        top.addLast( child );
+        child.setParent( top );
+
+        DefaultMutableTupleNode delreq = ( DefaultMutableTupleNode )
+                EncoderUtils.encode( LdapTag.DEL_REQUEST, request.getName() );
+        top.addLast( delreq );
+        delreq.setParent( top );
+
+        return top;
+    }
+}

Added: incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder/delete/DeleteRequestEncoderTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder/delete/DeleteRequestEncoderTest.java
Wed Aug 25 22:03:13 2004
@@ -0,0 +1,47 @@
+/*
+ *   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.encoder.delete;
+
+import org.apache.snickers.ldap.encoder.AbstractEncoderTestCase;
+import org.apache.snickers.ldap.encoder.bind.BindRequestEncoder;
+import org.apache.snickers.ber.TupleNode;
+import org.apache.snickers.ber.DefaultMutableTupleNode;
+import org.apache.ldap.common.message.BindRequestImpl;
+import org.apache.ldap.common.message.DeleteRequestImpl;
+
+/**
+ * Document me.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
+ *         Project</a> $Rev$
+ */
+public class DeleteRequestEncoderTest extends AbstractEncoderTestCase
+{
+
+    public void testEncode()
+    {
+        DeleteRequestImpl req = new DeleteRequestImpl( 12 );
+        req.setName( "uid=akarasulu,dc=apache,dc=org" );
+
+        // Encode stub into tuple tree then into the accumulator
+        TupleNode node = DeleteRequestEncoder.INSTANCE.encode( req );
+        encode( ( DefaultMutableTupleNode ) node );
+
+        // Test to see if original stub equals the round trip generated stub
+        assertTrue( req.equals( decode() ) );
+    }
+}

Mime
View raw message