directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r178900 - /directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/AbandonRequestTest.java
Date Sat, 28 May 2005 23:09:58 GMT
Author: elecharny
Date: Sat May 28 16:09:57 2005
New Revision: 178900

URL: http://svn.apache.org/viewcvs?rev=178900&view=rev
Log:
Created a test for AbandonRequest 

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

Added: directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/AbandonRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/AbandonRequestTest.java?rev=178900&view=auto
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/AbandonRequestTest.java
(added)
+++ directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/AbandonRequestTest.java
Sat May 28 16:09:57 2005
@@ -0,0 +1,82 @@
+/*
+ *   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.AbandonRequestPOJO;
+import org.apache.asn1.ldap.pojo.LdapMessagePOJO;
+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 AbandonRequestTest extends TestCase {
+    /** Logger */
+    private static Logger log = Logger.getLogger( AbandonRequestTest.class );
+
+    static
+    {
+        PropertyConfigurator.configure( "conf/log4j.conf" );
+    }
+
+    /**
+     * Test the decoding of a AbandonRequest with no controls
+     */
+    public void testDecodeAbandonRequestNoControls()
+    {
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        ByteBuffer  stream      = ByteBuffer.allocate( 0x08 );
+        stream.put(
+            new byte[]
+            {
+                0x30, 0x06, 		// LDAPMessage ::=SEQUENCE {
+				0x02, 0x01, 0x01, 	//         messageID MessageID
+				0x50, 0x01, 0x01	//        CHOICE { ..., abandonRequest AbandonRequest,...
+									// AbandonRequest ::= [APPLICATION 16] MessageID
+									// The MessageId value is 1.
+            } );
+
+        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();
+        AbandonRequestPOJO abandonRequest = ( AbandonRequestPOJO ) ( message.getProtocolOp()
);
+
+        Assert.assertEquals( 1, abandonRequest.getMessageId() );
+    }
+}



Mime
View raw message