directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r369775 - in /directory/trunks/common/ldap/src: main/java/org/apache/ldap/common/codec/bind/BindResponseGrammar.java test/java/org/apache/ldap/common/codec/bind/BindResponseTest.java
Date Tue, 17 Jan 2006 13:55:09 GMT
Author: elecharny
Date: Tue Jan 17 05:55:01 2006
New Revision: 369775

URL: http://svn.apache.org/viewcvs?rev=369775&view=rev
Log:
- Added a new test for empty ldapResult
- modified logs

Modified:
    directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/bind/BindResponseGrammar.java
    directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/bind/BindResponseTest.java

Modified: directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/bind/BindResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/bind/BindResponseGrammar.java?rev=369775&r1=369774&r2=369775&view=diff
==============================================================================
--- directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/bind/BindResponseGrammar.java
(original)
+++ directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/bind/BindResponseGrammar.java
Tue Jan 17 05:55:01 2006
@@ -168,7 +168,7 @@
                         
                         if ( log.isDebugEnabled() )
                         {
-                            log.debug( "The SASL credentials value is : " + bindResponseMessage.getServerSaslCreds().toString()
);
+                            log.debug( "The SASL credentials value is : {}", bindResponseMessage.getServerSaslCreds().toString()
);
                         }
                         
                         return;

Modified: directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/bind/BindResponseTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/bind/BindResponseTest.java?rev=369775&r1=369774&r2=369775&view=diff
==============================================================================
--- directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/bind/BindResponseTest.java
(original)
+++ directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/bind/BindResponseTest.java
Tue Jan 17 05:55:01 2006
@@ -28,7 +28,6 @@
 import org.apache.ldap.common.codec.bind.BindResponse;
 import org.apache.ldap.common.util.StringTools;
 
-import junit.framework.Assert;
 import junit.framework.TestCase;
 
 /**
@@ -76,20 +75,20 @@
         catch ( DecoderException de )
         {
             de.printStackTrace();
-            Assert.fail( de.getMessage() );
+            fail( de.getMessage() );
         }
     	
         // Check the decoded BindResponse
         LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
         BindResponse br      = message.getBindResponse();
 
-        Assert.assertEquals( 1, message.getMessageId() );
-        Assert.assertEquals( 0, br.getLdapResult().getResultCode() );
-        Assert.assertEquals( "", br.getLdapResult().getMatchedDN() );
-        Assert.assertEquals( "", br.getLdapResult().getErrorMessage() );
+        assertEquals( 1, message.getMessageId() );
+        assertEquals( 0, br.getLdapResult().getResultCode() );
+        assertEquals( "", br.getLdapResult().getMatchedDN() );
+        assertEquals( "", br.getLdapResult().getErrorMessage() );
 
         // Check the length
-        Assert.assertEquals(0x0E, message.computeLength());
+        assertEquals(0x0E, message.computeLength());
 
         // Check the encoding
         try
@@ -98,12 +97,12 @@
             
             String encodedPdu = StringTools.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            assertEquals(encodedPdu, decodedPdu );
         }
         catch ( EncoderException ee )
         {
             ee.printStackTrace();
-            Assert.fail( ee.getMessage() );
+            fail( ee.getMessage() );
         }
     }
 
@@ -157,20 +156,20 @@
         catch ( DecoderException de )
         {
             de.printStackTrace();
-            Assert.fail( de.getMessage() );
+            fail( de.getMessage() );
         }
     	
         // Check the decoded BindResponse
         LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
         BindResponse br      = message.getBindResponse();
 
-        Assert.assertEquals( 1, message.getMessageId() );
-        Assert.assertEquals( 0, br.getLdapResult().getResultCode() );
-        Assert.assertEquals( "", br.getLdapResult().getMatchedDN() );
-        Assert.assertEquals( "", br.getLdapResult().getErrorMessage() );
+        assertEquals( 1, message.getMessageId() );
+        assertEquals( 0, br.getLdapResult().getResultCode() );
+        assertEquals( "", br.getLdapResult().getMatchedDN() );
+        assertEquals( "", br.getLdapResult().getErrorMessage() );
 
         // Check the length
-        Assert.assertEquals(0x3C, message.computeLength());
+        assertEquals(0x3C, message.computeLength());
 
         // Check the encoding
         try
@@ -179,12 +178,12 @@
             
             String encodedPdu = StringTools.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            assertEquals(encodedPdu, decodedPdu );
         }
         catch ( EncoderException ee )
         {
             ee.printStackTrace();
-            Assert.fail( ee.getMessage() );
+            fail( ee.getMessage() );
         }
     }
 
@@ -229,21 +228,21 @@
         catch ( DecoderException de )
         {
             de.printStackTrace();
-            Assert.fail( de.getMessage() );
+            fail( de.getMessage() );
         }
     	
         // Check the decoded BindResponse
         LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
         BindResponse br      = message.getBindResponse();
 
-        Assert.assertEquals( 1, message.getMessageId() );
-        Assert.assertEquals( 0, br.getLdapResult().getResultCode() );
-        Assert.assertEquals( "", br.getLdapResult().getMatchedDN() );
-        Assert.assertEquals( "", br.getLdapResult().getErrorMessage() );
-        Assert.assertEquals( "AB", StringTools.utf8ToString( br.getServerSaslCreds() ) );
+        assertEquals( 1, message.getMessageId() );
+        assertEquals( 0, br.getLdapResult().getResultCode() );
+        assertEquals( "", br.getLdapResult().getMatchedDN() );
+        assertEquals( "", br.getLdapResult().getErrorMessage() );
+        assertEquals( "AB", StringTools.utf8ToString( br.getServerSaslCreds() ) );
 
         // Check the length
-        Assert.assertEquals(0x12, message.computeLength());
+        assertEquals(0x12, message.computeLength());
 
         // Check the encoding
         try
@@ -252,12 +251,49 @@
             
             String encodedPdu = StringTools.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            assertEquals(encodedPdu, decodedPdu );
         }
         catch ( EncoderException ee )
         {
             ee.printStackTrace();
-            Assert.fail( ee.getMessage() );
+            fail( ee.getMessage() );
         }
+    }
+
+    /**
+     * Test the decoding of a BindResponse with no LdapResult
+     */
+    public void testDecodeAddResponseEmptyResult()
+    {
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        ByteBuffer  stream      = ByteBuffer.allocate( 0x07 );
+        
+        stream.put(
+            new byte[]
+            {
+                    0x30, 0x05, 		// LDAPMessage ::=SEQUENCE {
+      				  0x02, 0x01, 0x01, //         messageID MessageID
+    				  0x61, 0x00, 		//        CHOICE { ..., bindResponse BindResponse, ...
+            } );
+
+        stream.flip();
+
+        // Allocate a LdapMessage Container
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+        // Decode a BindResponse message
+        try
+        {
+            ldapDecoder.decode( stream, ldapMessageContainer );
+        }
+        catch ( DecoderException de )
+        {
+        	System.out.println( de.getMessage() );
+            assertTrue( true );
+            return;
+        }
+    	
+        fail( "We should not reach this point" );
     }
 }



Mime
View raw message