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/08/24 04:34:44 UTC
svn commit: rev 36799 - in incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src: java/org/apache/snickers/ldap/encoder/unbind test/org/apache/snickers/ldap/encoder/unbind
Author: akarasulu
Date: Mon Aug 23 19:34:44 2004
New Revision: 36799
Added:
incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/unbind/
incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/unbind/UnbindRequestEncoder.java
incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder/unbind/
incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder/unbind/UnbindRequestEncoderTest.java
Log:
Commit changes ...
o created TupleNode tree encoder for Unbind request stubs
o created Unbind stub encoder unit tests and passed test cases
Added: incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/unbind/UnbindRequestEncoder.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/unbind/UnbindRequestEncoder.java Mon Aug 23 19:34:44 2004
@@ -0,0 +1,73 @@
+/*
+ * 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.unbind;
+
+import org.apache.ldap.common.message.UnbindRequest;
+import org.apache.snickers.ber.TupleNode;
+import org.apache.snickers.ber.DefaultMutableTupleNode;
+import org.apache.snickers.ber.Tuple;
+import org.apache.snickers.ber.Length;
+import org.apache.snickers.ber.primitives.UniversalTag;
+import org.apache.snickers.ldap.encoder.EncoderUtils;
+import org.apache.snickers.ldap.LdapTag;
+
+
+/**
+ * An UnbindRequest stub to TupleNode tree encoder.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
+ * Project</a> $Rev$
+ */
+public class UnbindRequestEncoder
+{
+ /** thread safe instance of this encoder */
+ public static final UnbindRequestEncoder INSTANCE =
+ new UnbindRequestEncoder();
+
+
+ /**
+ * Encodes a UnbindRequest stub into a tree of TupleNodes.
+ *
+ * @param resp the UnbindRequest stub to encode
+ * @return the root TupleNode of the tlv tree
+ */
+ public TupleNode encode( UnbindRequest resp )
+ {
+ /// Create the top level TupleNode of the PDU
+ 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( resp.getMessageId() );
+ top.addLast( child );
+ child.setParent( top );
+
+ // Create the unbind resp sequence of TLV tuple
+ DefaultMutableTupleNode unbindResp =
+ new DefaultMutableTupleNode( new Tuple() );
+ unbindResp.getTuple().setTag( LdapTag.UNBIND_REQUEST, true );
+ unbindResp.getTuple().setLength( 0 );
+
+ top.addLast( unbindResp );
+ unbindResp.setParent( top );
+ return top;
+
+ }
+}
Added: incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder/unbind/UnbindRequestEncoderTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/test/org/apache/snickers/ldap/encoder/unbind/UnbindRequestEncoderTest.java Mon Aug 23 19:34:44 2004
@@ -0,0 +1,48 @@
+/*
+ * 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.unbind;
+
+
+import org.apache.snickers.ldap.encoder.AbstractEncoderTestCase;
+import org.apache.snickers.ber.TupleNode;
+import org.apache.snickers.ber.DefaultMutableTupleNode;
+import org.apache.ldap.common.message.UnbindRequestImpl;
+
+
+/**
+ * TestCase for the UnbindRequestEncoder class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
+ * Project</a> $Rev$
+ */
+public class UnbindRequestEncoderTest extends AbstractEncoderTestCase
+{
+ /**
+ * Tests the round trip encoding and decoding of an UnbindRequest.
+ */
+ public void testEncode()
+ {
+ UnbindRequestImpl request = new UnbindRequestImpl( 34 );
+
+ // Encode stub into tuple tree then into the accumulator
+ TupleNode node = UnbindRequestEncoder.INSTANCE.encode( request );
+ encode( ( DefaultMutableTupleNode ) node );
+
+ // Test to see if original stub equals the round trip generated stub
+ assertTrue( request.equals( decode() ) );
+ }
+}