directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r178109 - /directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/UnBindRequestTest.java
Date Tue, 24 May 2005 06:39:25 GMT
Author: elecharny
Date: Mon May 23 23:39:25 2005
New Revision: 178109

URL: http://svn.apache.org/viewcvs?rev=178109&view=rev
Log:
Added a test for UnbindRequest

Added:
    directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/UnBindRequestTest.java

Added: directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/UnBindRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/UnBindRequestTest.java?rev=178109&view=auto
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/UnBindRequestTest.java
(added)
+++ directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/UnBindRequestTest.java
Mon May 23 23:39:25 2005
@@ -0,0 +1,81 @@
+/*
+ *   Copyright 2005 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.asn1.ldap.codec;
+
+import java.nio.ByteBuffer;
+
+import org.apache.asn1.DecoderException;
+import org.apache.asn1.ber.Asn1Decoder;
+import org.apache.asn1.ber.containers.IAsn1Container;
+import org.apache.asn1.ldap.pojo.LdapMessagePOJO;
+import org.apache.asn1.ldap.pojo.UnBindRequestPOJO;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class UnBindRequestTest extends TestCase {
+    /** Logger */
+    private static Logger log = Logger.getLogger( UnBindRequestTest.class );
+
+    static
+    {
+        PropertyConfigurator.configure( "conf/log4j.conf" );
+    }
+
+    /**
+     * Test the decoding of a UnBindRequest with no controls
+     */
+    public void testDecodeUnBindRequestNoControls()
+    {
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        ByteBuffer  stream      = ByteBuffer.allocate( 0x07 );
+        stream.put(
+            new byte[]
+            {
+                0x30, 0x05, 		// LDAPMessage ::=SEQUENCE {
+				0x02, 0x01, 0x01, 	//         messageID MessageID
+				0x42, 0x00, 		//        CHOICE { ..., unbindRequest UnbindRequest,...
+									// UnbindRequest ::= [APPLICATION 2] NULL
+            } );
+
+        stream.flip();
+
+        // Allocate a BindRequest Container
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+        try
+        {
+            ldapDecoder.decode( stream, ldapMessageContainer );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+            Assert.fail( de.getMessage() );
+        }
+    	
+        LdapMessagePOJO message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+        UnBindRequestPOJO br      = ( UnBindRequestPOJO ) ( message.getProtocolOp() );
+
+        Assert.assertEquals( 1, message.getMessageId() );
+    }
+}



Mime
View raw message