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 17:01:17 UTC
svn commit: r369824 - in
/directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/del:
DelRequestTest.java DelResponseTest.java
Author: elecharny
Date: Tue Jan 17 08:01:11 2006
New Revision: 369824
URL: http://svn.apache.org/viewcvs?rev=369824&view=rev
Log:
- Added some tests case
- Removed useless Assert prefix
Modified:
directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/del/DelRequestTest.java
directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/del/DelResponseTest.java
Modified: directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/del/DelRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/del/DelRequestTest.java?rev=369824&r1=369823&r2=369824&view=diff
==============================================================================
--- directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/del/DelRequestTest.java (original)
+++ directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/del/DelRequestTest.java Tue Jan 17 08:01:11 2006
@@ -30,7 +30,6 @@
import org.apache.ldap.common.codec.del.DelRequest;
import org.apache.ldap.common.util.StringTools;
-import junit.framework.Assert;
import junit.framework.TestCase;
/**
@@ -74,18 +73,18 @@
catch ( DecoderException de )
{
de.printStackTrace();
- Assert.fail( de.getMessage() );
+ fail( de.getMessage() );
}
// Check the decoded DelRequest PDU
LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
DelRequest delRequest = message.getDelRequest();
- Assert.assertEquals( 1, message.getMessageId() );
- Assert.assertEquals( "cn=testModify,ou=users,ou=system", delRequest.getEntry() );
+ assertEquals( 1, message.getMessageId() );
+ assertEquals( "cn=testModify,ou=users,ou=system", delRequest.getEntry() );
// Check the length
- Assert.assertEquals(0x27, message.computeLength());
+ assertEquals(0x27, message.computeLength());
// Check the encoding
try
@@ -94,17 +93,17 @@
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 aempty DelRequest
+ * Test the decoding of an empty DelRequest
*/
public void testDecodeDelRequestEmpty() throws NamingException
{
@@ -133,11 +132,11 @@
try
{
ldapDecoder.decode( stream, ldapMessageContainer );
- Assert.fail("We should never reach this point !!!");
+ fail("We should never reach this point !!!");
}
catch ( DecoderException de )
{
- Assert.assertTrue( true );
+ assertTrue( true );
}
}
}
Modified: directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/del/DelResponseTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/del/DelResponseTest.java?rev=369824&r1=369823&r2=369824&view=diff
==============================================================================
--- directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/del/DelResponseTest.java (original)
+++ directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/del/DelResponseTest.java Tue Jan 17 08:01:11 2006
@@ -28,7 +28,6 @@
import org.apache.ldap.common.codec.del.DelResponse;
import org.apache.ldap.common.util.StringTools;
-import junit.framework.Assert;
import junit.framework.TestCase;
/**
@@ -79,20 +78,20 @@
catch ( DecoderException de )
{
de.printStackTrace();
- Assert.fail( de.getMessage() );
+ fail( de.getMessage() );
}
// Check the decoded DelResponse PDU
LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
DelResponse delResponse = message.getDelResponse();
- Assert.assertEquals( 1, message.getMessageId() );
- Assert.assertEquals( 33, delResponse.getLdapResult().getResultCode() );
- Assert.assertEquals( "uid=akarasulu,dc=example,dc=com", delResponse.getLdapResult().getMatchedDN() );
- Assert.assertEquals( "", delResponse.getLdapResult().getErrorMessage() );
+ assertEquals( 1, message.getMessageId() );
+ assertEquals( 33, delResponse.getLdapResult().getResultCode() );
+ assertEquals( "uid=akarasulu,dc=example,dc=com", delResponse.getLdapResult().getMatchedDN() );
+ assertEquals( "", delResponse.getLdapResult().getErrorMessage() );
// Check the length
- Assert.assertEquals(0x2D, message.computeLength());
+ assertEquals(0x2D, message.computeLength());
// Check the encoding
try
@@ -101,12 +100,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 DelResponse with no LdapResult
+ */
+ public void testDecodeDelResponseEmptyResult()
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x07 );
+
+ stream.put(
+ new byte[]
+ {
+ 0x30, 0x05, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x6B, 0x00, // CHOICE { ..., delResponse DelResponse, ...
+ } );
+
+ stream.flip();
+
+ // Allocate a LdapMessage Container
+ IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+ // Decode a DelResponse message
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ System.out.println( de.getMessage() );
+ assertTrue( true );
+ return;
+ }
+
+ fail( "We should not reach this point" );
}
}