You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/01/17 20:36:41 UTC
svn commit: r369891 - in /directory/trunks/common/ldap/src:
main/java/org/apache/ldap/common/codec/unbind/UnBindRequestGrammar.java
test/java/org/apache/ldap/common/codec/unbind/UnBindRequestTest.java
Author: elecharny
Date: Tue Jan 17 11:36:34 2006
New Revision: 369891
URL: http://svn.apache.org/viewcvs?rev=369891&view=rev
Log:
- Added some tests case
- Removed useless Assert prefix
- Modified logs
Modified:
directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/unbind/UnBindRequestGrammar.java
directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/unbind/UnBindRequestTest.java
Modified: directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/unbind/UnBindRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/unbind/UnBindRequestGrammar.java?rev=369891&r1=369890&r2=369891&view=diff
==============================================================================
--- directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/unbind/UnBindRequestGrammar.java (original)
+++ directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/unbind/UnBindRequestGrammar.java Tue Jan 17 11:36:34 2006
@@ -110,7 +110,7 @@
// If the length is not null, this is an error.
if ( expectedLength != 0 )
{
- log.error( "The length of a UnBindRequest must be null, the actual value is " + expectedLength );
+ log.error( "The length of a UnBindRequest must be null, the actual value is {}", new Integer( expectedLength ) );
throw new DecoderException( "The length of a UnBindRequest must be null" );
}
Modified: directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/unbind/UnBindRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/unbind/UnBindRequestTest.java?rev=369891&r1=369890&r2=369891&view=diff
==============================================================================
--- directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/unbind/UnBindRequestTest.java (original)
+++ directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/unbind/UnBindRequestTest.java Tue Jan 17 11:36:34 2006
@@ -27,7 +27,6 @@
import org.apache.ldap.common.codec.LdapMessageContainer;
import org.apache.ldap.common.util.StringTools;
-import junit.framework.Assert;
import junit.framework.TestCase;
/**
@@ -64,15 +63,15 @@
catch ( DecoderException de )
{
de.printStackTrace();
- Assert.fail( de.getMessage() );
+ fail( de.getMessage() );
}
LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
- Assert.assertEquals( 1, message.getMessageId() );
+ assertEquals( 1, message.getMessageId() );
// Check the length
- Assert.assertEquals(7, message.computeLength());
+ assertEquals(7, message.computeLength());
try
{
@@ -80,12 +79,50 @@
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 UnBindRequest with a not null body
+ */
+ public void testDecodeUnBindRequestNotNull()
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x09 );
+ stream.put(
+ new byte[]
+ {
+ 0x30, 0x07, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x42, 0x02, // CHOICE { ..., unbindRequest UnbindRequest,...
+ 0x04, 0x00 // UnbindRequest ::= [APPLICATION 2] NULL
+
+ } );
+
+ stream.flip();
+
+ // Allocate a LdapMessage Container
+ IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+ // Decode a UnbindRequest message
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ System.out.println( de.getMessage() );
+ assertTrue( true );
+ return;
+ }
+
+ fail( "We should not reach this point" );
}
}