directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r291317 - /directory/shared/ldap/trunk/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AbandonRequestTest.java
Date Sat, 24 Sep 2005 15:39:41 GMT
Author: elecharny
Date: Sat Sep 24 08:39:38 2005
New Revision: 291317

URL: http://svn.apache.org/viewcvs?rev=291317&view=rev
Log:
Added a test with a MessageId over 127.

Modified:
    directory/shared/ldap/trunk/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AbandonRequestTest.java

Modified: directory/shared/ldap/trunk/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AbandonRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AbandonRequestTest.java?rev=291317&r1=291316&r2=291317&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AbandonRequestTest.java
(original)
+++ directory/shared/ldap/trunk/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AbandonRequestTest.java
Sat Sep 24 08:39:38 2005
@@ -173,4 +173,65 @@
             Assert.fail( ee.getMessage() );
         }
     }
+
+    /**
+     * Test the decoding of a AbandonRequest with no controls
+     */
+    public void testDecodeAbandonRequestNoControlsHighMessageId()
+    {
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        ByteBuffer  stream      = ByteBuffer.allocate( 0x0A );
+        stream.put(
+            new byte[]
+            {
+                0x30, 0x08,         // LDAPMessage ::=SEQUENCE {
+                0x02, 0x03, 0x00, (byte)0x80, 0x13,  //        messageID MessageID
+                0x50, 0x01, 0x02    //        CHOICE { ..., abandonRequest AbandonRequest,...
+                                    // AbandonRequest ::= [APPLICATION 16] MessageID
+            } );
+
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
+        stream.flip();
+
+        // Allocate a LdapMessageContainer Container
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+        // Decode the PDU
+        try
+        {
+            ldapDecoder.decode( stream, ldapMessageContainer );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+            Assert.fail( de.getMessage() );
+        }
+        
+        // Check that everything is OK
+        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+        AbandonRequest abandonRequest = message.getAbandonRequest();
+
+        Assert.assertEquals( 32787, message.getMessageId() );
+        Assert.assertEquals( 2, abandonRequest.getAbandonedMessageId() );
+        
+        // Check the length
+        Assert.assertEquals(10, message.computeLength());
+        
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
+    }
+
 }



Mime
View raw message