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/10/02 01:07:49 UTC
svn commit: r451836 [10/11] - in /directory/branches/shared/0.9.5/ldap/src:
main/java/org/apache/directory/shared/ldap/codec/
main/java/org/apache/directory/shared/ldap/codec/abandon/
main/java/org/apache/directory/shared/ldap/codec/actions/ main/java/...
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/Message.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/Message.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/Message.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/Message.java Sun Oct 1 16:07:44 2006
@@ -49,15 +49,13 @@
*/
Map getControls();
-
+
/**
* Adds a control to this Message.
*
- * @param control
- * the control to add.
- * @throws MessageException
- * if controls cannot be added to this Message or the control is
- * not known etc.
+ * @param control the control to add.
+ * @throws MessageException if controls cannot be added to this
+ * Message or the control is not known etc.
*/
void add( Control control ) throws MessageException;
@@ -65,11 +63,9 @@
/**
* Deletes a control removing it from this Message.
*
- * @param control
- * the control to remove.
- * @throws MessageException
- * if controls cannot be added to this Message or the control is
- * not known etc.
+ * @param control the control to remove.
+ * @throws MessageException if controls cannot be added to this
+ * Message or the control is not known etc.
*/
void remove( Control control ) throws MessageException;
@@ -95,8 +91,7 @@
* without firing LockExceptions even when this Lockable is in the locked
* state.
*
- * @param key
- * the key used to access a message parameter.
+ * @param key the key used to access a message parameter.
* @return the transient message parameter value.
*/
Object get( Object key );
@@ -107,10 +102,8 @@
* down so modifications can occur without firing LockExceptions even when
* this Lockable is in the locked state.
*
- * @param key
- * the parameter key
- * @param value
- * the parameter value
+ * @param key the parameter key
+ * @param value the parameter value
* @return the old value or null
*/
Object put( Object key, Object value );
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java Sun Oct 1 16:07:44 2006
@@ -984,7 +984,7 @@
return this;
}
- for ( int ii = name.size() - 1; ii >= 0; ii-- )
+ for ( int ii = 0; ii < name.size(); ii++ )
{
Rdn rdn = new Rdn( name.get( ii ) );
rdns.add( size() - posn, rdn );
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java Sun Oct 1 16:07:44 2006
@@ -2817,4 +2817,28 @@
return advanceBy;
}
+
+ /**
+ * Thansform an array of ASCII bytes to a string. the byte array should contains
+ * only values in [0, 127].
+ *
+ * @param bytes The byte array to transform
+ * @return The resulting string
+ */
+ public static String asciiBytesToString( byte[] bytes )
+ {
+ if ( (bytes == null) || (bytes.length == 0 ) )
+ {
+ return "";
+ }
+
+ char[] result = new char[bytes.length];
+
+ for ( int i = 0; i < bytes.length; i++ )
+ {
+ result[i] = (char)bytes[i];
+ }
+
+ return new String( result );
+ }
}
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java Sun Oct 1 16:07:44 2006
@@ -32,7 +32,6 @@
import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
import org.apache.directory.shared.ldap.codec.bind.BindRequest;
import org.apache.directory.shared.ldap.codec.bind.SimpleAuthentication;
-import org.apache.directory.shared.ldap.codec.del.DelRequest;
import org.apache.directory.shared.ldap.util.StringTools;
import java.nio.ByteBuffer;
@@ -305,19 +304,20 @@
ByteBuffer stream = ByteBuffer.allocate( 0x35 );
stream.put( new byte[]
- { 0x30, 0x33, // LDAPMessage ::=SEQUENCE {
- // Length should be 0x01...
- 0x02, 0x02, 0x01, // messageID MessageID
- 0x60, 0x2E, // CHOICE { ..., bindRequest BindRequest, ...
- // BindRequest ::= APPLICATION[0] SEQUENCE {
- 0x02, 0x01, 0x03, // version INTEGER (1..127),
- 0x04, 0x1F, // name LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', ( byte ) 0x80, 0x08, // authentication
- // AuthenticationChoice
- // AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING,
- // ...
- 'p', 'a', 's', 's', 'w', 'o', 'r' } );
+ {
+ 0x30, 0x33, // LDAPMessage ::=SEQUENCE {
+ // Length should be 0x01...
+ 0x02, 0x02, 0x01, // messageID MessageID
+ 0x60, 0x2E, // CHOICE { ..., bindRequest BindRequest, ...
+ // BindRequest ::= APPLICATION[0] SEQUENCE {
+ 0x02, 0x01, 0x03, // version INTEGER (1..127),
+ 0x04, 0x1F, // name LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ ( byte ) 0x80, 0x08, // authentication AuthenticationChoice
+ // AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING,
+ // ...
+ 'p', 'a', 's', 's', 'w', 'o', 'r' } );
stream.flip();
@@ -331,7 +331,7 @@
}
catch ( DecoderException de )
{
- assertEquals( "Universal tag 14 is reserved", de.getMessage() );
+ assertEquals( "Bad transition !", de.getMessage() );
return;
}
catch ( NamingException ne )
@@ -394,17 +394,20 @@
}
/**
- * Test the decoding of a splitted length
+ * Test the decoding of a splitted Length.
+ *
+ * The length is 3 bytes long, but the PDU has been splitted
+ * just after the first byte
*/
- public void testDecodeSplittedLength() throws NamingException
+ public void testDecodeSplittedLength()
{
- Asn1Decoder ldapDecoder = new LdapDecoder();
- ByteBuffer stream = ByteBuffer.allocate( 0x03 );
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+ ByteBuffer stream = ByteBuffer.allocate( 3 );
stream.put( new byte[]
- {
- 0x30, (byte)0x82, 0x01 // LDAPMessage ::= SEQUENCE {
+ {
+ 0x30, (byte)0x82, 0x01,// LDAPMessage ::=SEQUENCE {
} );
stream.flip();
@@ -412,7 +415,7 @@
// Allocate a LdapMessage Container
IAsn1Container ldapMessageContainer = new LdapMessageContainer();
- // Decode a DelRequest PDU
+ // Decode a BindRequest PDU first block of data
try
{
ldapDecoder.decode( stream, ldapMessageContainer );
@@ -422,29 +425,24 @@
de.printStackTrace();
fail( de.getMessage() );
}
+ catch ( NamingException ne )
+ {
+ ne.printStackTrace();
+ fail( ne.getMessage() );
+ }
assertEquals( TLVStateEnum.LENGTH_STATE_PENDING, ldapMessageContainer.getState() );
- stream = ByteBuffer.allocate( 0x101 );
-
+ // Second block of data
+ stream = ByteBuffer.allocate( 1 );
stream.put( new byte[]
- {
- 0x00, // LDAPMessage ::= SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- // CHOICE { ..., delRequest DelRequest, ...
- // DelRequest ::= [APPLICATION 10] LDAPDN;
- 0x4A, (byte)0x81, (byte)0xFA,
- 'c', 'n', '=',
+ {
+ (byte)0x80 // End of the length
} );
- for ( int i = 0; i < 0xFA - 3; i++ )
- {
- stream.put( (byte)'a' );
- }
-
stream.flip();
- // Decode a DelRequest PDU
+ // Decode a BindRequest PDU second block of data
try
{
ldapDecoder.decode( stream, ldapMessageContainer );
@@ -454,15 +452,15 @@
de.printStackTrace();
fail( de.getMessage() );
}
+ catch ( NamingException ne )
+ {
+ ne.printStackTrace();
+ fail( ne.getMessage() );
+ }
- // Check the decoded DelRequest PDU
- LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
- DelRequest delRequest = message.getDelRequest();
-
- assertEquals( 1, message.getMessageId() );
- assertEquals( "cn=aaaaaaaaaaaaaaaaa", delRequest.getEntry().toString().substring( 0, 20 ) );
+ assertEquals( TLVStateEnum.LENGTH_STATE_END, ldapMessageContainer.getState() );
- // Check the length
- assertEquals( 0x104, message.computeLength() );
+ // Check the decoded length
+ assertEquals( 384, ldapMessageContainer.getCurrentTLV().getLength() );
}
}
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindRequestTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindRequestTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindRequestTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindRequestTest.java Sun Oct 1 16:07:44 2006
@@ -54,31 +54,32 @@
* Test the decoding of a BindRequest with Simple authentication and no
* controls
*/
- public void testDecodeBindRequestSimpleNoControls()
+ /* Not used in unit tests
+ public void testDecodeBindRequestSimpleNoControlsPerf()
{
Asn1Decoder ldapDecoder = new LdapDecoder();
ByteBuffer stream = ByteBuffer.allocate( 0x52 );
stream.put( new byte[]
- {
- 0x30, 0x50, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x60, 0x2E, // CHOICE { ..., bindRequest BindRequest, ...
- // BindRequest ::= APPLICATION[0] SEQUENCE {
- 0x02, 0x01, 0x03, // version INTEGER (1..127),
- 0x04, 0x1F, // name LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
- ( byte ) 0x80, 0x08, // authentication AuthenticationChoice
- // AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING,
- // ...
- 'p', 'a', 's', 's', 'w', 'o', 'r', 'd',
- ( byte ) 0xA0, 0x1B, // A control
- 0x30, 0x19,
- 0x04, 0x17,
- 0x32, 0x2E, 0x31, 0x36, 0x2E, 0x38, 0x34, 0x30, 0x2E, 0x31, 0x2E, 0x31, 0x31, 0x33, 0x37, 0x33,
- 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32
- } );
+ {
+ 0x30, 0x50, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x60, 0x2E, // CHOICE { ..., bindRequest BindRequest, ...
+ // BindRequest ::= APPLICATION[0] SEQUENCE {
+ 0x02, 0x01, 0x03, // version INTEGER (1..127),
+ 0x04, 0x1F, // name LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ ( byte ) 0x80, 0x08, // authentication AuthenticationChoice
+ // AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING,
+ // ...
+ 'p', 'a', 's', 's', 'w', 'o', 'r', 'd',
+ ( byte ) 0xA0, 0x1B, // A control
+ 0x30, 0x19,
+ 0x04, 0x17,
+ 0x32, 0x2E, 0x31, 0x36, 0x2E, 0x38, 0x34, 0x30, 0x2E, 0x31, 0x2E, 0x31, 0x31, 0x33, 0x37, 0x33,
+ 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32
+ } );
String decodedPdu = StringTools.dumpBytes( stream.array() );
stream.flip();
@@ -89,6 +90,16 @@
// Decode the BindRequest PDU
try
{
+ long t0 = System.currentTimeMillis();
+ for ( int i = 0; i < 10000; i++ )
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ ( ( LdapMessageContainer ) ldapMessageContainer).clean();
+ stream.flip();
+ }
+ long t1 = System.currentTimeMillis();
+ System.out.println( "Delta = " + ( t1 - t0 ) );
+
ldapDecoder.decode( stream, ldapMessageContainer );
}
catch ( DecoderException de )
@@ -140,7 +151,7 @@
fail( ee.getMessage() );
}
}
-
+ */
/**
* Test the decoding of a BindRequest with Simple authentication and
@@ -306,8 +317,7 @@
}
catch ( DecoderException de )
{
- assertEquals( "Cannot pop the grammar BIND_REQUEST_GRAMMAR for state BIND_REQUEST_NAME_TAG", de
- .getMessage() );
+ assertEquals( "Bad transition !", de.getMessage() );
return;
}
catch ( NamingException ne )
@@ -1328,4 +1338,51 @@
fail( ee.getMessage() );
}
}
+
+ /**
+ * Test the decoding of a BindRequest with Simple authentication and no
+ * controls
+ */
+ /* No used by unit tests
+ public void testPerf() throws Exception
+ {
+ LdapDN name = new LdapDN( "uid=akarasulu,dc=example,dc=com" );
+ long t0 = System.currentTimeMillis();
+
+ for ( int i = 0; i< 10000; i++)
+ {
+ // Check the decoded BindRequest
+ LdapMessage message = new LdapMessage();
+ message.setMessageId( 1 );
+
+ BindRequest br = new BindRequest();
+ br.setMessageId( 1 );
+ br.setName( name );
+
+ Control control = new Control();
+ control.setControlType( "2.16.840.1.113730.3.4.2" );
+
+ LdapAuthentication authentication = new SimpleAuthentication();
+ ((SimpleAuthentication)authentication).setSimple( StringTools.getBytesUtf8( "password" ) );
+
+ br.addControl( control );
+ br.setAuthentication( authentication );
+ message.setProtocolOP( br );
+
+ // Check the encoding
+ try
+ {
+ message.encode( null );
+ }
+ catch ( EncoderException ee )
+ {
+ ee.printStackTrace();
+ fail( ee.getMessage() );
+ }
+ }
+
+ long t1 = System.currentTimeMillis();
+ System.out.println( "Delta = " + (t1 - t0));
+ }
+ */
}
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java Sun Oct 1 16:07:44 2006
@@ -131,25 +131,32 @@
ByteBuffer stream = ByteBuffer.allocate( 0x41 );
stream.put( new byte[]
- { 0x30, 0x3F, // LDAPMessage ::= SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- // CHOICE { ..., extendedResp ExtendedResponse, ...
- 0x78, 0x1D, // ExtendedResponse ::= [APPLICATION 23] SEQUENCE {
- // COMPONENTS OF LDAPResult,
- 0x0A, 0x01, 0x00, // LDAPResult ::= SEQUENCE {
- // resultCode ENUMERATED {
- // success (0), ...
- // },
- 0x04, 0x00, // matchedDN LDAPDN,
- 0x04, 0x00, // errorMessage LDAPString,
- // referral [3] Referral OPTIONAL }
- // responseName [10] LDAPOID OPTIONAL,
- ( byte ) 0x8A, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
- // response [11] OCTET STRING OPTIONAL }
- ( byte ) 0x8B, 0x05, 'v', 'a', 'l', 'u', 'e', ( byte ) 0xA0, 0x1B, // A
- // control
- 0x30, 0x19, 0x04, 0x17, 0x32, 0x2E, 0x31, 0x36, 0x2E, 0x38, 0x34, 0x30, 0x2E, 0x31, 0x2E, 0x31, 0x31,
- 0x33, 0x37, 0x33, 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 } );
+ {
+ 0x30, 0x3F, // LDAPMessage ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ // CHOICE {
+ // ...,
+ // extendedResp ExtendedResponse,
+ // ...
+ 0x78, 0x1D, // ExtendedResponse ::= [APPLICATION 23] SEQUENCE {
+ // COMPONENTS OF LDAPResult,
+ 0x0A, 0x01, 0x00, // LDAPResult ::= SEQUENCE {
+ // resultCode ENUMERATED {
+ // success (0), ...
+ // },
+ 0x04, 0x00, // matchedDN LDAPDN,
+ 0x04, 0x00, // errorMessage LDAPString,
+ // referral [3] Referral OPTIONAL }
+ ( byte ) 0x8A, 0x0D, // responseName [10] LDAPOID OPTIONAL,
+ '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+ ( byte ) 0x8B, 0x05, // response [11] OCTET STRING OPTIONAL }
+ 'v', 'a', 'l', 'u', 'e',
+ ( byte ) 0xA0, 0x1B, // A control
+ 0x30, 0x19,
+ 0x04, 0x17,
+ '2', '.', '1', '6', '.', '8', '4', '0', '.', '1', '.', '1',
+ '1', '3', '7', '3', '0', '.', '3', '.', '4', '.', '2'
+ } );
String decodedPdu = StringTools.dumpBytes( stream.array() );
stream.flip();
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectTest.java Sun Oct 1 16:07:44 2006
@@ -274,15 +274,17 @@
Asn1Decoder decoder = new GracefulDisconnectDecoder();
ByteBuffer stream = ByteBuffer.allocate( 0x6A );
stream.put( new byte[]
- { 0x30, 0x68, // GracefulDisconnec ::= SEQUENCE {
- 0x30, 0x66, // replicatedContexts Referral OPTIONAL
- 0x04, 0x1F, 'l', 'd', 'a', 'p', ':', '/', '/', 'd', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y', '.', 'a',
- 'p', 'a', 'c', 'h', 'e', '.', 'o', 'r', 'g', ':', '8', '0', '/', 0x04, 0x43, 'l', 'd', 'a', 'p', ':',
- '/', '/', 'l', 'd', 'a', 'p', '.', 'n', 'e', 't', 's', 'c', 'a', 'p', 'e', '.', 'c', 'o', 'm', '/',
- 'o', '=', 'B', 'a', 'b', 's', 'c', 'o', ',', 'c', '=', 'U', 'S', '?', '?', '?', '(', 'i', 'n', 't',
- '=', '%', '5', 'c', '0', '0', '%', '5', 'c', '0', '0', '%', '5', 'c', '0', '0', '%', '5', 'c', '0',
- '4', ')'
- // }
+ {
+ 0x30, 0x68, // GracefulDisconnec ::= SEQUENCE {
+ 0x30, 0x66, // replicatedContexts Referral OPTIONAL
+ 0x04, 0x1F,
+ 'l', 'd', 'a', 'p', ':', '/', '/', 'd', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y', '.', 'a',
+ 'p', 'a', 'c', 'h', 'e', '.', 'o', 'r', 'g', ':', '8', '0', '/',
+ 0x04, 0x43,
+ 'l', 'd', 'a', 'p', ':', '/', '/', 'l', 'd', 'a', 'p', '.', 'n', 'e', 't', 's', 'c', 'a',
+ 'p', 'e', '.', 'c', 'o', 'm', '/', 'o', '=', 'B', 'a', 'b', 's', 'c', 'o', ',', 'c', '=',
+ 'U', 'S', '?', '?', '?', '(', 'i', 'n', 't', '=', '%', '5', 'c', '0', '0', '%', '5', 'c',
+ '0', '0', '%', '5', 'c', '0', '0', '%', '5', 'c', '0', '4', ')'
} );
String decodedPdu = StringTools.dumpBytes( stream.array() );
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java Sun Oct 1 16:07:44 2006
@@ -372,7 +372,7 @@
0x30, 0x0F, // type : description
0x04, 0x0B,
0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E,
- 0x31, 0x00, // Vals = null
+ 0x31, 0x00, // Vals = null
0x30, 0x25, // Modification
0x0A, 0x01, 0x00, // Operation : Add
0x30, 0x20, // type : telephoneNumber
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java Sun Oct 1 16:07:44 2006
@@ -659,18 +659,19 @@
{
0x30, 0x43,
0x02, 0x01, 0x04, // messageID
- 0x63, 0x3E, 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
- 0x0A, 0x01, 0x01,
- 0x0A, 0x01, 0x03,
- 0x02, 0x01, 0x00,
- 0x02, 0x01, 0x00,
- 0x01, 0x01, ( byte ) 0xFF,
- ( byte ) 0xA9, 0x06,
- ( byte ) 0x83, 0x04, 't', 'e', 's', 't',
- 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
- 0x04, 0x00
+ 0x63, 0x3E, 0x04,
+ 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01,
+ 0x0A, 0x01, 0x03,
+ 0x02, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x01, 0x01, ( byte ) 0xFF,
+ ( byte ) 0xA9, 0x06,
+ ( byte ) 0x83, 0x04, 't', 'e', 's', 't',
+ 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+ 0x04, 0x00
};
Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -689,8 +690,7 @@
}
catch ( DecoderException de )
{
- assertTrue( true );
- return;
+ fail( de.getMessage() );
}
catch ( NamingException ne )
{
@@ -698,6 +698,33 @@
fail( ne.getMessage() );
}
- fail( "We should not reach this point" );
+ LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+ SearchRequest sr = message.getSearchRequest();
+
+ assertEquals( 4, message.getMessageId() );
+ assertEquals( "uid=akarasulu,dc=example,dc=com", sr.getBaseObject().toString() );
+ assertEquals( LdapConstants.SCOPE_SINGLE_LEVEL, sr.getScope() );
+ assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
+ assertEquals( 0, sr.getSizeLimit() );
+ assertEquals( 0, sr.getTimeLimit() );
+ assertEquals( true, sr.isTypesOnly() );
+
+ // Extended
+ ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) sr.getFilter();
+ assertNotNull( extensibleMatchFilter );
+
+ assertNull( extensibleMatchFilter.getMatchingRule() );
+ assertNull( extensibleMatchFilter.getType() );
+ assertEquals( "test", extensibleMatchFilter.getMatchValue() );
+ assertFalse( extensibleMatchFilter.isDnAttributes() );
+
+ Attributes attributes = sr.getAttributes();
+
+ assertEquals( 1, attributes.size() );
+
+ for ( int i = 0; i < attributes.size(); i++ )
+ {
+ assertNull( attributes.get( "" ) );
+ }
}
}
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java Sun Oct 1 16:07:44 2006
@@ -39,7 +39,6 @@
import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
import org.apache.directory.shared.ldap.codec.search.SearchRequest;
import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
-import org.apache.directory.shared.ldap.codec.util.LdapString;
import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
import org.apache.directory.shared.ldap.schema.OidNormalizer;
import org.apache.directory.shared.ldap.util.StringTools;
@@ -81,27 +80,27 @@
ByteBuffer stream = ByteBuffer.allocate( 0x64 );
stream.put( new byte[]
- { 0x30, 0x62, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x63, 0x5D, // CHOICE { ..., searchRequest SearchRequest, ...
- // SearchRequest ::= APPLICATION[3] SEQUENCE {
- 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, // scope
- // ENUMERATED
- // {
- // baseObject (0),
- // singleLevel (1),
- // wholeSubtree (2) },
- 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
- // neverDerefAliases (0),
- // derefInSearching (1),
- // derefFindingBaseObj (2),
- // derefAlways (3) },
- // sizeLimit INTEGER (0 .. maxInt), (1000)
- 0x02, 0x02, 0x03, ( byte ) 0xE8,
- // timeLimit INTEGER (0 .. maxInt), (1000)
- 0x02, 0x02, 0x03, ( byte ) 0xE8, 0x01, 0x01, ( byte ) 0xFF, // typesOnly
+ {
+ 0x30, 0x62, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x63, 0x5D, // CHOICE { ...,
+ // searchRequest SearchRequest, ...
+ // SearchRequest ::= APPLICATION[3] SEQUENCE {
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01, // scope ENUMERATED {
+ // baseObject (0),
+ // singleLevel (1),
+ // wholeSubtree (2) },
+ 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
+ // neverDerefAliases (0),
+ // derefInSearching (1),
+ // derefFindingBaseObj (2),
+ // derefAlways (3) },
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // sizeLimit INTEGER (0 .. maxInt), (1000)
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // timeLimit INTEGER (0 .. maxInt), (1000)
+ 0x01, 0x01, ( byte ) 0xFF, // typesOnly
// BOOLEAN,
// (TRUE)
// filter Filter,
@@ -109,15 +108,17 @@
// substrings [4] SubstringFilter
// }
// SubstringFilter ::= SEQUENCE {
- 0x04, 0x0B, // type AttributeDescription,
- 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's', 0x30, 0x03, ( byte ) 0x80, 0x01, 't', //
+ 0x04, 0x0B, // type AttributeDescription,
+ 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ 0x30, 0x03,
+ ( byte ) 0x80, 0x01, 't', //
0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF
// AttributeDescription
- 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription
+ 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription
// ::= LDAPString
- 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription
+ 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription
// ::= LDAPString
- 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::=
+ 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::=
// LDAPString
} );
@@ -408,7 +409,7 @@
assertEquals( "objectclass", substringFilter.getType().toString() );
assertEquals( null, substringFilter.getInitialSubstrings() );
- assertEquals( "t", ( ( LdapString ) substringFilter.getAnySubstrings().get( 0 ) ).toString() );
+ assertEquals( "t", ( ( String ) substringFilter.getAnySubstrings().get( 0 ) ) );
assertEquals( null, substringFilter.getFinalSubstrings() );
// The attributes
@@ -530,7 +531,7 @@
assertEquals( "objectclass", substringFilter.getType().toString() );
assertEquals( null, substringFilter.getInitialSubstrings() );
- assertEquals( "t", ( ( LdapString ) substringFilter.getAnySubstrings().get( 0 ) ).toString() );
+ assertEquals( "t", ( ( String ) substringFilter.getAnySubstrings().get( 0 ) ) );
assertEquals( "t", substringFilter.getFinalSubstrings().toString() );
// The attributes
@@ -653,7 +654,7 @@
assertEquals( "objectclass", substringFilter.getType().toString() );
assertEquals( "t", substringFilter.getInitialSubstrings().toString() );
- assertEquals( "t", ( ( LdapString ) substringFilter.getAnySubstrings().get( 0 ) ).toString() );
+ assertEquals( "t", ( ( String ) substringFilter.getAnySubstrings().get( 0 ) ) );
assertEquals( "t", substringFilter.getFinalSubstrings().toString() );
// The attributes
@@ -775,7 +776,7 @@
assertEquals( "objectclass", substringFilter.getType().toString() );
assertEquals( "t", substringFilter.getInitialSubstrings().toString() );
- assertEquals( "t", ( ( LdapString ) substringFilter.getAnySubstrings().get( 0 ) ).toString() );
+ assertEquals( "t", ( ( String ) substringFilter.getAnySubstrings().get( 0 ) ) );
// The attributes
Attributes attributes = sr.getAttributes();
@@ -817,46 +818,40 @@
ByteBuffer stream = ByteBuffer.allocate( 0x6A );
stream.put( new byte[]
- { 0x30, 0x68, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x63, 0x63, // CHOICE { ..., searchRequest SearchRequest, ...
- // SearchRequest ::= APPLICATION[3] SEQUENCE {
- 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, // scope
- // ENUMERATED
- // {
- // baseObject (0),
- // singleLevel (1),
- // wholeSubtree (2) },
- 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
- // neverDerefAliases (0),
- // derefInSearching (1),
- // derefFindingBaseObj (2),
- // derefAlways (3) },
- // sizeLimit INTEGER (0 .. maxInt), (1000)
- 0x02, 0x02, 0x03, ( byte ) 0xE8,
- // timeLimit INTEGER (0 .. maxInt), (1000)
- 0x02, 0x02, 0x03, ( byte ) 0xE8, 0x01, 0x01, ( byte ) 0xFF, // typesOnly
- // BOOLEAN,
- // (TRUE)
- // filter Filter,
- ( byte ) 0xA4, 0x18, // Filter ::= CHOICE {
- // substrings [4] SubstringFilter
- // }
- // SubstringFilter ::= SEQUENCE {
- 0x04, 0x0B, // type AttributeDescription,
- 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's', 0x30, 0x09, ( byte ) 0x81, 0x01, 't', //
- ( byte ) 0x81, 0x01, 't', //
- ( byte ) 0x82, 0x01, 't', //
- 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF
- // AttributeDescription
- 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription
- // ::= LDAPString
- 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription
- // ::= LDAPString
- 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::=
- // LDAPString
+ {
+ 0x30, 0x68, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x63, 0x63, // CHOICE { ..., searchRequest SearchRequest, ...
+ // SearchRequest ::= APPLICATION[3] SEQUENCE {
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01, // scope ENUMERATED {
+ // baseObject (0),
+ // singleLevel (1),
+ // wholeSubtree (2) },
+ 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
+ // neverDerefAliases (0),
+ // derefInSearching (1),
+ // derefFindingBaseObj (2),
+ // derefAlways (3) },
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // sizeLimit INTEGER (0 .. maxInt), (1000)
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // timeLimit INTEGER (0 .. maxInt), (1000)
+ 0x01, 0x01, ( byte ) 0xFF, // typesOnly BOOLEAN, (TRUE)
+ // filter Filter,
+ ( byte ) 0xA4, 0x18, // Filter ::= CHOICE {
+ // substrings [4] SubstringFilter }
+ // SubstringFilter ::= SEQUENCE {
+ 0x04, 0x0B, // type AttributeDescription,
+ 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ 0x30, 0x09,
+ ( byte ) 0x81, 0x01, 't',
+ ( byte ) 0x81, 0x01, 't',
+ ( byte ) 0x82, 0x01, 't',
+ 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+ 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::= LDAPString
} );
String decodedPdu = StringTools.dumpBytes( stream.array() );
@@ -897,8 +892,8 @@
assertEquals( "objectclass", substringFilter.getType().toString() );
assertEquals( null, substringFilter.getInitialSubstrings() );
- assertEquals( "t", ( ( LdapString ) substringFilter.getAnySubstrings().get( 0 ) ).toString() );
- assertEquals( "t", ( ( LdapString ) substringFilter.getAnySubstrings().get( 1 ) ).toString() );
+ assertEquals( "t", ( ( String ) substringFilter.getAnySubstrings().get( 0 ) ) );
+ assertEquals( "t", ( ( String ) substringFilter.getAnySubstrings().get( 1 ) ) );
assertEquals( "t", substringFilter.getFinalSubstrings().toString() );
// The attributes
@@ -1020,7 +1015,7 @@
assertEquals( "objectclass", substringFilter.getType().toString() );
assertEquals( "t", substringFilter.getInitialSubstrings().toString() );
- assertEquals( "*", ( ( LdapString ) substringFilter.getAnySubstrings().get( 0 ) ).toString() );
+ assertEquals( "*", ( ( String ) substringFilter.getAnySubstrings().get( 0 ) ) );
// The attributes
Attributes attributes = sr.getAttributes();
@@ -1140,11 +1135,11 @@
SubstringFilter substringFilter = ( SubstringFilter ) sr.getFilter();
assertNotNull( substringFilter );
- assertEquals( "objectclass", substringFilter.getType().getString() );
+ assertEquals( "objectclass", substringFilter.getType() );
assertEquals( null, substringFilter.getInitialSubstrings() );
- assertEquals( "t", ( ( LdapString ) substringFilter.getAnySubstrings().get( 0 ) ).getString() );
- assertEquals( "t", ( ( LdapString ) substringFilter.getAnySubstrings().get( 1 ) ).getString() );
- assertEquals( "t", ( ( LdapString ) substringFilter.getAnySubstrings().get( 2 ) ).getString() );
+ assertEquals( "t", ( ( String ) substringFilter.getAnySubstrings().get( 0 ) ) );
+ assertEquals( "t", ( ( String ) substringFilter.getAnySubstrings().get( 1 ) ) );
+ assertEquals( "t", ( ( String ) substringFilter.getAnySubstrings().get( 2 ) ) );
assertEquals( null, substringFilter.getFinalSubstrings() );
// The attributes
@@ -1264,7 +1259,7 @@
SubstringFilter substringFilter = ( SubstringFilter ) sr.getFilter();
assertNotNull( substringFilter );
- assertEquals( "objectclass", substringFilter.getType().getString() );
+ assertEquals( "objectclass", substringFilter.getType() );
assertEquals( null, substringFilter.getInitialSubstrings() );
assertEquals( 0, substringFilter.getAnySubstrings().size() );
assertEquals( "Amos", substringFilter.getFinalSubstrings().toString() );
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java Sun Oct 1 16:07:44 2006
@@ -258,67 +258,55 @@
ByteBuffer stream = ByteBuffer.allocate( 0x90 );
stream.put( new byte[]
- { 0x30, ( byte ) 0x81, ( byte ) 0x8D, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x63, ( byte ) 0x81, ( byte ) 0x87, // CHOICE { ...,
- // searchRequest
- // SearchRequest, ...
- // SearchRequest ::= APPLICATION[3] SEQUENCE {
- 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, // scope
- // ENUMERATED
- // {
- // baseObject (0),
- // singleLevel (1),
- // wholeSubtree (2) },
- 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
- // neverDerefAliases (0),
- // derefInSearching (1),
- // derefFindingBaseObj (2),
- // derefAlways (3) },
- // sizeLimit INTEGER (0 .. maxInt), (1000)
- 0x02, 0x02, 0x03, ( byte ) 0xE8,
- // timeLimit INTEGER (0 .. maxInt), (1000)
- 0x02, 0x02, 0x03, ( byte ) 0xE8, 0x01, 0x01, ( byte ) 0xFF, // typesOnly
- // BOOLEAN,
- // (TRUE)
- // filter Filter,
- ( byte ) 0xA0, 0x3C, // Filter ::= CHOICE {
- // and [0] SET OF Filter,
- ( byte ) 0xA1, 0x24, // or [1] SET of Filter,
- ( byte ) 0xA8, 0x12, // approxMatch [8]
- // AttributeValueAssertion,
- // AttributeValueAssertion ::= SEQUENCE {
- // attributeDesc AttributeDescription (LDAPString),
- 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
- // assertionValue AssertionValue (OCTET STRING) }
- 0x04, 0x03, 't', 'o', 'p', ( byte ) 0xA6, 0x0E, // lessOrEqual
- // [3]
- // AttributeValueAssertion,
- // AttributeValueAssertion ::= SEQUENCE {
- 0x04, 0x02, 'o', 'u', // attributeDesc AttributeDescription
- // (LDAPString),
- // assertionValue AssertionValue (OCTET STRING) }
- 0x04, 0x08, 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ( byte ) 0xA2, 0x14, // not
- // [2]
- // Filter,
- ( byte ) 0xA5, 0x12, // greaterOrEqual [5]
- // AttributeValueAssertion,
- // AttributeValueAssertion ::= SEQUENCE {
- // attributeDesc AttributeDescription (LDAPString),
- 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
- // assertionValue AssertionValue (OCTET STRING) }
- 0x04, 0x03, 't', 't', 't',
- // attributes AttributeDescriptionList }
- 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF
- // AttributeDescription
- 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription
- // ::= LDAPString
- 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription
- // ::= LDAPString
- 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::=
- // LDAPString
+ {
+ 0x30, ( byte ) 0x81, ( byte ) 0x8D, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x63, ( byte ) 0x81, ( byte ) 0x87, // CHOICE { ...,
+ // searchRequest SearchRequest, ...
+ // SearchRequest ::= APPLICATION[3] SEQUENCE {
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01, // scope ENUMERATED {
+ // baseObject (0),
+ // singleLevel (1),
+ // wholeSubtree (2) },
+ 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
+ // neverDerefAliases (0),
+ // derefInSearching (1),
+ // derefFindingBaseObj (2),
+ // derefAlways (3) },
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // sizeLimit INTEGER (0 .. maxInt), (1000)
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // timeLimit INTEGER (0 .. maxInt), (1000)
+ 0x01, 0x01, ( byte ) 0xFF, // typesOnly BOOLEAN, (TRUE)
+ // filter Filter,
+ ( byte ) 0xA0, 0x3C, // Filter ::= CHOICE {
+ // and [0] SET OF Filter,
+ ( byte ) 0xA1, 0x24, // or [1] SET of Filter,
+ ( byte ) 0xA8, 0x12, // approxMatch [8]
+ // AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ 0x04, 0x0B, // attributeDesc AttributeDescription (LDAPString),
+ 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ 0x04, 0x03, // attributeDesc AttributeDescription (LDAPString),
+ 't', 'o', 'p',
+ ( byte ) 0xA6, 0x0E, // lessOrEqual [3] AttributeValueAssertion,
+ 0x04, 0x02, // AttributeValueAssertion ::= SEQUENCE {
+ 'o', 'u', // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x08, // assertionValue AssertionValue (OCTET STRING) }
+ 'c', 'o', 'n', 't', 'a', 'c', 't', 's',
+ ( byte ) 0xA2, 0x14, // not [2] Filter,
+ ( byte ) 0xA5, 0x12, // greaterOrEqual [5] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ 0x04, 0x0B, // attributeDesc AttributeDescription (LDAPString),
+ 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ 0x04, 0x03, 't', 't', 't', // assertionValue AssertionValue (OCTET STRING) }
+ // attributes AttributeDescriptionList }
+ 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF
+ // AttributeDescription
+ 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::= LDAPString
} );
String decodedPdu = StringTools.dumpBytes( stream.array() );
@@ -864,29 +852,35 @@
public void testDecodeSearchRequestWithControls()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x7f, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x33, 0x04, 0x13, 0x64, 0x63, 0x3d, 0x6d, 0x79, 0x2d, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2c,
- 0x64, 0x63, 0x3d, 0x63, 0x6f, 0x6d, // baseObject:
- // dc=my-domain,dc=com
- 0x0a, 0x01, 0x02, // scope: subtree
- 0x0a, 0x01, 0x03, // derefAliases: derefAlways
- 0x02, 0x01, 0x00, // sizeLimit: 0
- 0x02, 0x01, 0x00, // timeLimit: 0
- 0x01, 0x01, 0x00, // typesOnly: false
- ( byte ) 0x87, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x43, 0x6c, 0x61, 0x73, 0x73, // filter:
- // (objectClass=*)
- 0x30, 0x00, ( byte ) 0xa0, 0x45, // controls
- 0x30, 0x28, 0x04, 0x16, 0x31, 0x2e, 0x32, 0x2e, 0x38, 0x34, 0x30, 0x2e, 0x31, 0x31, 0x33, 0x35, 0x35,
- 0x36, 0x2e, 0x31, 0x2e, 0x34, 0x2e, 0x33, 0x31, 0x39, // control
- // oid:
- // 1.2.840.113556.1.4.319
- 0x01, 0x01, ( byte ) 0xff, // criticality: false
- 0x04, 0x0b, 0x30, 0x09, 0x02, 0x01, 0x02, 0x04, 0x04, 0x47, 0x00, 0x00, 0x00, // value:
- // pageSize=2
- 0x30, 0x19, 0x04, 0x17, 0x32, 0x2e, 0x31, 0x36, 0x2e, 0x38, 0x34, 0x30, 0x2e, 0x31, 0x2e, 0x31, 0x31,
- 0x33, 0x37, 0x33, 0x30, 0x2e, 0x33, 0x2e, 0x34, 0x2e, 0x32 // control
- // oid:
- // 2.16.840.1.113730.3.4.2
+ {
+ 0x30, 0x7f,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x33,
+ 0x04, 0x13, // baseObject
+ 'd', 'c', '=', 'm', 'y', '-', 'd', 'o', 'm', 'a', 'i',
+ 'n', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0a, 0x01, 0x02, // scope: subtree
+ 0x0a, 0x01, 0x03, // derefAliases: derefAlways
+ 0x02, 0x01, 0x00, // sizeLimit: 0
+ 0x02, 0x01, 0x00, // timeLimit: 0
+ 0x01, 0x01, 0x00, // typesOnly: false
+ ( byte ) 0x87, 0x0b, // Present filter: (objectClass=*)
+ 'o', 'b', 'j', 'e', 'c', 't', 'C', 'l', 'a', 's', 's',
+ 0x30, 0x00, // Attributes = '*'
+ ( byte ) 0xa0, 0x45, // controls
+ 0x30, 0x28,
+ 0x04, 0x16, // control
+ '1', '.', '2', '.', '8', '4', '0', '.', '1', '1', '3',
+ '5', '5', '6', '.', '1', '.', '4', '.', '3', '1', '9',
+ 0x01, 0x01, ( byte ) 0xff, // criticality: false
+ 0x04, 0x0b,
+ 0x30, 0x09,
+ 0x02, 0x01, 0x02,
+ 0x04, 0x04, 0x47, 0x00, 0x00, 0x00, // value: pageSize=2
+ 0x30, 0x19,
+ 0x04, 0x17, // control
+ '2', '.', '1', '6', '.', '8', '4', '0', '.', '1', '.', '1',
+ '1', '3', '7', '3', '0', '.', '3', '.', '4', '.', '2',
};
Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -937,7 +931,7 @@
assertEquals( false, sr.isTypesOnly() );
assertTrue( sr.getFilter() instanceof PresentFilter );
- assertEquals( "objectClass", ( ( PresentFilter ) sr.getFilter() ).getAttributeDescription().getString() );
+ assertEquals( "objectClass", ( ( PresentFilter ) sr.getFilter() ).getAttributeDescription() );
// Check the encoding
try
@@ -1127,22 +1121,29 @@
public void testDecodeSearchRequestSubEntryControl()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x5D, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x33, 0x04, 0x13, 0x64, 0x63, 0x3d, 0x6d, 0x79, 0x2d, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2c,
- 0x64, 0x63, 0x3d, 0x63, 0x6f, 0x6d, // baseObject:
- // dc=my-domain,dc=com
- 0x0a, 0x01, 0x02, // scope: subtree
- 0x0a, 0x01, 0x03, // derefAliases: derefAlways
- 0x02, 0x01, 0x00, // sizeLimit: 0
- 0x02, 0x01, 0x00, // timeLimit: 0
- 0x01, 0x01, 0x00, // typesOnly: false
- ( byte ) 0x87, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x43, 0x6c, 0x61, 0x73, 0x73, // filter:
- // (objectClass=*)
- 0x30, 0x00, ( byte ) 0xa0, 0x23, // controls
- 0x30, 0x21, 0x04, 0x17, '1', '.', '3', '.', '6', '.', '1', '.', '4', '.', '1', '.', '4', '2', '0', '3',
- '.', '1', '.', '1', '0', '.', '1', // SubEntry OID
- 0x01, 0x01, ( byte ) 0xFF, // criticality: true
- 0x04, 0x03, 0x01, 0x01, ( byte ) 0xFF // SubEntry visibility
+ {
+ 0x30, 0x5D,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x33,
+ 0x04, 0x13, // baseObject: dc=my-domain,dc=com
+ 'd', 'c', '=', 'm', 'y', '-', 'd', 'o', 'm', 'a',
+ 'i', 'n', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0a, 0x01, 0x02, // scope: subtree
+ 0x0a, 0x01, 0x03, // derefAliases: derefAlways
+ 0x02, 0x01, 0x00, // sizeLimit: 0
+ 0x02, 0x01, 0x00, // timeLimit: 0
+ 0x01, 0x01, 0x00, // typesOnly: false
+ ( byte ) 0x87, 0x0b, // filter: (objectClass=*)
+ 'o', 'b', 'j', 'e', 'c', 't', 'C', 'l', 'a', 's', 's',
+ 0x30, 0x00,
+ ( byte ) 0xa0, 0x23, // controls
+ 0x30, 0x21,
+ 0x04, 0x17,
+ '1', '.', '3', '.', '6', '.', '1', '.', '4', '.', '1', '.', '4', '2', '0', '3',
+ '.', '1', '.', '1', '0', '.', '1', // SubEntry OID
+ 0x01, 0x01, ( byte ) 0xFF, // criticality: true
+ 0x04, 0x03,
+ 0x01, 0x01, ( byte ) 0xFF // SubEntry visibility
};
Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1189,7 +1190,7 @@
assertEquals( false, sr.isTypesOnly() );
assertTrue( sr.getFilter() instanceof PresentFilter );
- assertEquals( "objectClass", ( ( PresentFilter ) sr.getFilter() ).getAttributeDescription().getString() );
+ assertEquals( "objectClass", ( ( PresentFilter ) sr.getFilter() ).getAttributeDescription() );
// Check the encoding
try
@@ -2888,7 +2889,7 @@
SubstringFilter substringFilter = ( SubstringFilter ) andFilters.get( 0 );
assertNotNull( substringFilter );
- assertEquals( "pgpuserid", substringFilter.getType().getString() );
+ assertEquals( "pgpuserid", substringFilter.getType() );
assertEquals( "vgjokjev@netcetera.com.mk", substringFilter.getInitialSubstrings().toString() );
assertEquals( 0, substringFilter.getAnySubstrings().size() );
assertEquals( null, substringFilter.getFinalSubstrings() );
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java Sun Oct 1 16:07:44 2006
@@ -619,19 +619,25 @@
ByteBuffer stream = ByteBuffer.allocate( 0x45 );
stream.put( new byte[]
- { 0x30, 0x43, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x64, 0x21, // CHOICE { ..., searchResEntry SearchResultEntry,
- // ...
- // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
- // objectName LDAPDN,
- 0x04, 0x1B, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't',
- 'e', 'k', ',', 'd', 'c', '=', 'c', 'o', 'm',
- // attributes PartialAttributeList }
- // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
- 0x30, 0x02, 0x30, 0x00, ( byte ) 0xA0, 0x1B, // A control
- 0x30, 0x19, 0x04, 0x17, 0x32, 0x2E, 0x31, 0x36, 0x2E, 0x38, 0x34, 0x30, 0x2E, 0x31, 0x2E, 0x31, 0x31,
- 0x33, 0x37, 0x33, 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 } );
+ {
+ 0x30, 0x43, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x64, 0x21, // CHOICE { ..., searchResEntry SearchResultEntry,
+ // ...
+ // SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
+ // objectName LDAPDN,
+ 0x04, 0x1B,
+ 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=',
+ 'i', 'k', 't', 'e', 'k', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ // attributes PartialAttributeList }
+ // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
+ 0x30, 0x02,
+ 0x30, 0x00,
+ ( byte ) 0xA0, 0x1B, // A control
+ 0x30, 0x19,
+ 0x04, 0x17,
+ '2', '.', '1', '6', '.', '8', '4', '0', '.', '1', '.', '1',
+ '1', '3', '7', '3', '0', '.', '3', '.', '4', '.', '2' } );
stream.flip();
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlTest.java Sun Oct 1 16:07:44 2006
@@ -52,15 +52,13 @@
Asn1Decoder decoder = new EntryChangeControlDecoder();
ByteBuffer bb = ByteBuffer.allocate( 0x0D );
bb.put( new byte[]
- { 0x30, 0x0B, // EntryChangeNotification ::= SEQUENCE {
- 0x0A, 0x01, 0x08, // changeType ENUMERATED {
- // modDN (8)
- // }
- 0x04, 0x03, 'a', '=', 'b', // previousDN LDAPDN OPTIONAL, --
- // modifyDN ops. only
- 0x02, 0x01, 0x10 // changeNumber INTEGER OPTIONAL -- if
- // supported
- // }
+ {
+ 0x30, 0x0B, // EntryChangeNotification ::= SEQUENCE {
+ 0x0A, 0x01, 0x08, // changeType ENUMERATED {
+ // modDN (8)
+ // }
+ 0x04, 0x03, 'a', '=', 'b', // previousDN LDAPDN OPTIONAL, -- modifyDN ops. only
+ 0x02, 0x01, 0x10 // changeNumber INTEGER OPTIONAL } -- if supported
} );
bb.flip();
@@ -90,13 +88,13 @@
Asn1Decoder decoder = new EntryChangeControlDecoder();
ByteBuffer bb = ByteBuffer.allocate( 0x08 );
bb.put( new byte[]
- { 0x30, 0x06, // EntryChangeNotification ::= SEQUENCE {
- 0x0A, 0x01, 0x01, // changeType ENUMERATED {
- // Add (1)
- // }
- 0x02, 0x01, 0x10 // changeNumber INTEGER OPTIONAL -- if
- // supported
- // }
+ {
+ 0x30, 0x06, // EntryChangeNotification ::= SEQUENCE {
+ 0x0A, 0x01, 0x01, // changeType ENUMERATED {
+ // Add (1)
+ // }
+ 0x02, 0x01, 0x10 // changeNumber INTEGER OPTIONAL -- if supported
+ // }
} );
bb.flip();
@@ -127,15 +125,15 @@
Asn1Decoder decoder = new EntryChangeControlDecoder();
ByteBuffer bb = ByteBuffer.allocate( 0x0D );
bb.put( new byte[]
- { 0x30, 0x0B, // EntryChangeNotification ::= SEQUENCE {
- 0x0A, 0x01, 0x01, // changeType ENUMERATED {
- // ADD (1)
- // }
- 0x04, 0x03, 'a', '=', 'b', // previousDN LDAPDN OPTIONAL, --
- // modifyDN ops. only
- 0x02, 0x01, 0x10 // changeNumber INTEGER OPTIONAL -- if
- // supported
- // }
+ {
+ 0x30, 0x0B, // EntryChangeNotification ::= SEQUENCE {
+ 0x0A, 0x01, 0x01, // changeType ENUMERATED {
+ // ADD (1)
+ // }
+ 0x04, 0x03, 'a', '=', 'b', // previousDN LDAPDN OPTIONAL, --
+ // modifyDN ops. only
+ 0x02, 0x01, 0x10 // changeNumber INTEGER OPTIONAL -- if supported
+ // }
} );
bb.flip();
@@ -164,11 +162,12 @@
Asn1Decoder decoder = new EntryChangeControlDecoder();
ByteBuffer bb = ByteBuffer.allocate( 0x05 );
bb.put( new byte[]
- { 0x30, 0x03, // EntryChangeNotification ::= SEQUENCE {
- 0x0A, 0x01, 0x01, // changeType ENUMERATED {
- // ADD (1)
- // }
- // }
+ {
+ 0x30, 0x03, // EntryChangeNotification ::= SEQUENCE {
+ 0x0A, 0x01, 0x01, // changeType ENUMERATED {
+ // ADD (1)
+ // }
+ // }
} );
bb.flip();
@@ -200,11 +199,12 @@
Asn1Decoder decoder = new EntryChangeControlDecoder();
ByteBuffer bb = ByteBuffer.allocate( 0x05 );
bb.put( new byte[]
- { 0x30, 0x03, // EntryChangeNotification ::= SEQUENCE {
- 0x0A, 0x01, 0x03, // changeType ENUMERATED {
- // BAD Change Type
- // }
- // }
+ {
+ 0x30, 0x03, // EntryChangeNotification ::= SEQUENCE {
+ 0x0A, 0x01, 0x03, // changeType ENUMERATED {
+ // BAD Change Type
+ // }
+ // }
} );
bb.flip();
@@ -232,14 +232,13 @@
{
ByteBuffer bb = ByteBuffer.allocate( 0x0D );
bb.put( new byte[]
- { 0x30, 0x0B, // EntryChangeNotification ::= SEQUENCE {
- 0x0A, 0x01, 0x08, // changeType ENUMERATED {
- // modDN (8)
- // }
- 0x04, 0x03, 'a', '=', 'b', // previousDN LDAPDN OPTIONAL, --
- // modifyDN ops. only
- 0x02, 0x01, 0x10 // changeNumber INTEGER OPTIONAL -- if
- // supported
+ {
+ 0x30, 0x0B, // EntryChangeNotification ::= SEQUENCE {
+ 0x0A, 0x01, 0x08, // changeType ENUMERATED {
+ // modDN (8)
+ // }
+ 0x04, 0x03, 'a', '=', 'b', // previousDN LDAPDN OPTIONAL, -- modifyDN ops. only
+ 0x02, 0x01, 0x10 // changeNumber INTEGER OPTIONAL -- if supported
} );
String expected = StringTools.dumpBytes( bb.array() );
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.java Sun Oct 1 16:07:44 2006
@@ -43,18 +43,44 @@
public class PSearchControlTest extends TestCase
{
/**
- * Test the decoding of a PSearchControl
+ * Test encoding of a PSearchControl.
*/
- public void testDecodeModifyDNRequestSuccess() throws NamingException
+ public void testEncodePSearchControl() throws Exception
+ {
+ ByteBuffer bb = ByteBuffer.allocate( 0x0b );
+ bb.put( new byte[]
+ {
+ 0x30, 0x09, // PersistentSearch ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // changeTypes INTEGER,
+ 0x01, 0x01, 0x00, // changesOnly BOOLEAN,
+ 0x01, 0x01, 0x00 // returnECs BOOLEAN
+ } );
+
+ String expected = StringTools.dumpBytes( bb.array() );
+ bb.flip();
+
+ PSearchControl ctrl = new PSearchControl();
+ ctrl.setChangesOnly( false );
+ ctrl.setReturnECs( false );
+ ctrl.setChangeTypes( 1 );
+ bb = ctrl.encode( null );
+ String decoded = StringTools.dumpBytes( bb.array() );
+ assertEquals( expected, decoded );
+ }
+
+ /**
+ * Test the decoding of a PSearchControl with combined changes types
+ */
+ public void testDecodeModifyDNRequestSuccessChangeTypesAddModDN() throws NamingException
{
Asn1Decoder decoder = new PSearchControlDecoder();
ByteBuffer bb = ByteBuffer.allocate( 0x0b );
bb.put( new byte[]
- { 0x30, 0x09, // PersistentSearch ::= SEQUENCE {
- 0x02, 0x01, 0x01, // changeTypes INTEGER,
- 0x01, 0x01, 0x00, // changesOnly BOOLEAN,
- 0x01, 0x01, 0x00 // returnECs BOOLEAN
- // }
+ {
+ 0x30, 0x09, // PersistentSearch ::= SEQUENCE {
+ 0x02, 0x01, 0x09, // changeTypes INTEGER,
+ 0x01, 0x01, 0x00, // changesOnly BOOLEAN,
+ 0x01, 0x01, 0x00 // returnECs BOOLEAN
} );
bb.flip();
@@ -65,40 +91,178 @@
}
catch ( DecoderException de )
{
- de.printStackTrace();
Assert.fail( de.getMessage() );
}
PSearchControl control = container.getPSearchControl();
- assertEquals( 1, control.getChangeTypes() );
+ int changeTypes = control.getChangeTypes();
+ assertEquals( PSearchControl.CHANGE_TYPE_ADD, changeTypes & PSearchControl.CHANGE_TYPE_ADD );
+ assertEquals( PSearchControl.CHANGE_TYPE_MODDN, changeTypes & PSearchControl.CHANGE_TYPE_MODDN );
assertEquals( false, control.isChangesOnly() );
assertEquals( false, control.isReturnECs() );
}
+ /**
+ * Test the decoding of a PSearchControl with a changes types which
+ * value is 0
+ */
+ public void testDecodeModifyDNRequestSuccessChangeTypes0() throws NamingException
+ {
+ Asn1Decoder decoder = new PSearchControlDecoder();
+ ByteBuffer bb = ByteBuffer.allocate( 0x0b );
+ bb.put( new byte[]
+ {
+ 0x30, 0x09, // PersistentSearch ::= SEQUENCE {
+ 0x02, 0x01, 0x00, // changeTypes INTEGER,
+ 0x01, 0x01, 0x00, // changesOnly BOOLEAN,
+ 0x01, 0x01, 0x00 // returnECs BOOLEAN
+ } );
+ bb.flip();
+
+ PSearchControlContainer container = new PSearchControlContainer();
+ try
+ {
+ decoder.decode( bb, container );
+ fail( "We should never reach this point" );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( true );
+ }
+ }
/**
- * Test encoding of a PSearchControl.
+ * Test the decoding of a PSearchControl with a changes types which
+ * value is above 15
*/
- public void testEncodePSearchControl() throws Exception
+ public void testDecodeModifyDNRequestSuccessChangeTypes22() throws NamingException
{
+ Asn1Decoder decoder = new PSearchControlDecoder();
ByteBuffer bb = ByteBuffer.allocate( 0x0b );
bb.put( new byte[]
- { 0x30, 0x09, // PersistentSearch ::= SEQUENCE {
- 0x02, 0x01, 0x01, // changeTypes INTEGER,
- 0x01, 0x01, 0x00, // changesOnly BOOLEAN,
- 0x01, 0x01, 0x00 // returnECs BOOLEAN
- // }
+ {
+ 0x30, 0x09, // PersistentSearch ::= SEQUENCE {
+ 0x02, 0x01, 0x22, // changeTypes INTEGER,
+ 0x01, 0x01, 0x00, // changesOnly BOOLEAN,
+ 0x01, 0x01, 0x00 // returnECs BOOLEAN
} );
+ bb.flip();
- String expected = StringTools.dumpBytes( bb.array() );
+ PSearchControlContainer container = new PSearchControlContainer();
+ try
+ {
+ decoder.decode( bb, container );
+ fail( "We should never reach this point" );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( true );
+ }
+ }
+
+ /**
+ * Test the decoding of a PSearchControl with a null sequence
+ */
+ public void testDecodeModifyDNRequestSuccessNullSequence() throws NamingException
+ {
+ Asn1Decoder decoder = new PSearchControlDecoder();
+ ByteBuffer bb = ByteBuffer.allocate( 0x02 );
+ bb.put( new byte[]
+ {
+ 0x30, 0x00, // PersistentSearch ::= SEQUENCE {
+ } );
bb.flip();
- PSearchControl ctrl = new PSearchControl();
- ctrl.setChangesOnly( false );
- ctrl.setReturnECs( false );
- ctrl.setChangeTypes( 1 );
- bb = ctrl.encode( null );
- String decoded = StringTools.dumpBytes( bb.array() );
- assertEquals( expected, decoded );
+ PSearchControlContainer container = new PSearchControlContainer();
+ try
+ {
+ decoder.decode( bb, container );
+ fail( "We should never reach this point" );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( true );
+ }
+ }
+
+ /**
+ * Test the decoding of a PSearchControl without changeTypes
+ */
+ public void testDecodeModifyDNRequestSuccessWithoutChangeTypes() throws NamingException
+ {
+ Asn1Decoder decoder = new PSearchControlDecoder();
+ ByteBuffer bb = ByteBuffer.allocate( 0x08 );
+ bb.put( new byte[]
+ {
+ 0x30, 0x06, // PersistentSearch ::= SEQUENCE {
+ 0x01, 0x01, 0x00, // changesOnly BOOLEAN,
+ 0x01, 0x01, 0x00 // returnECs BOOLEAN
+ } );
+ bb.flip();
+
+ PSearchControlContainer container = new PSearchControlContainer();
+ try
+ {
+ decoder.decode( bb, container );
+ fail( "We should never reach this point" );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( true );
+ }
+ }
+
+ /**
+ * Test the decoding of a PSearchControl without changeOnly
+ */
+ public void testDecodeModifyDNRequestSuccessWithoutChangesOnly() throws NamingException
+ {
+ Asn1Decoder decoder = new PSearchControlDecoder();
+ ByteBuffer bb = ByteBuffer.allocate( 0x08 );
+ bb.put( new byte[]
+ {
+ 0x30, 0x06, // PersistentSearch ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // changeTypes INTEGER,
+ 0x01, 0x01, 0x00 // returnECs BOOLEAN
+ } );
+ bb.flip();
+
+ PSearchControlContainer container = new PSearchControlContainer();
+ try
+ {
+ decoder.decode( bb, container );
+ fail( "We should never reach this point" );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( true );
+ }
+ }
+
+ /**
+ * Test the decoding of a PSearchControl without returnECs
+ */
+ public void testDecodeModifyDNRequestSuccessWithoutReturnECs() throws NamingException
+ {
+ Asn1Decoder decoder = new PSearchControlDecoder();
+ ByteBuffer bb = ByteBuffer.allocate( 0x08 );
+ bb.put( new byte[]
+ {
+ 0x30, 0x06, // PersistentSearch ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // changeTypes INTEGER,
+ 0x01, 0x01, 0x00, // changesOnly BOOLEAN,
+ } );
+ bb.flip();
+
+ PSearchControlContainer container = new PSearchControlContainer();
+ try
+ {
+ decoder.decode( bb, container );
+ fail( "We should never reach this point" );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( true );
+ }
}
}
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java Sun Oct 1 16:07:44 2006
@@ -80,16 +80,16 @@
fail( ne.getMessage() );
}
- LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+ LdapMessage ldapMessage = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
- assertEquals( 1, message.getMessageId() );
+ assertEquals( 1, ldapMessage.getMessageId() );
// Check the length
- assertEquals( 7, message.computeLength() );
+ assertEquals( 7, ldapMessage.computeLength() );
try
{
- ByteBuffer bb = message.encode( null );
+ ByteBuffer bb = ldapMessage.encode( null );
String encodedPdu = StringTools.dumpBytes( bb.array() );
@@ -145,25 +145,25 @@
fail( ne.getMessage() );
}
- LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+ LdapMessage ldapMessage = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
- assertEquals( 1, message.getMessageId() );
+ assertEquals( 1, ldapMessage.getMessageId() );
// Check the Control
- List controls = message.getControls();
+ List controls = ldapMessage.getControls();
assertEquals( 1, controls.size() );
- Control control = message.getControls( 0 );
+ Control control = ldapMessage.getControls( 0 );
assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() );
assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) );
// Check the length
- assertEquals( 0x24, message.computeLength() );
+ assertEquals( 0x24, ldapMessage.computeLength() );
try
{
- ByteBuffer bb = message.encode( null );
+ ByteBuffer bb = ldapMessage.encode( null );
String encodedPdu = StringTools.dumpBytes( bb.array() );
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java Sun Oct 1 16:07:44 2006
@@ -1423,53 +1423,4 @@
assertTrue( true );
}
}
-
- public void testLdifReaderDirServer() throws NamingException, Exception
- {
- String ldif =
- "# -------------------------------------------------------------------\n" +
- "#\n" +
- "# Licensed to the Apache Software Foundation (ASF) under one\n" +
- "# or more contributor license agreements. See the NOTICE file\n" +
- "# distributed with this work for additional information\n" +
- "# regarding copyright ownership. The ASF licenses this file\n" +
- "# to you under the Apache License, Version 2.0 (the\n" +
- "# \"License\"); you may not use this file except in compliance\n" +
- "# with the License. You may obtain a copy of the License at\n" +
- "# \n" +
- "# http://www.apache.org/licenses/LICENSE-2.0\n" +
- "# \n" +
- "# Unless required by applicable law or agreed to in writing,\n" +
- "# software distributed under the License is distributed on an\n" +
- "# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n" +
- "# KIND, either express or implied. See the License for the\n" +
- "# specific language governing permissions and limitations\n" +
- "# under the License. \n" +
- "# \n" +
- "#\n" +
- "# EXAMPLE.COM is freely and reserved for testing according to this RFC:\n" +
- "#\n" +
- "# http://www.rfc-editor.org/rfc/rfc2606.txt\n" +
- "#\n" +
- "# -------------------------------------------------------------------\n" +
- "\n" +
- "dn: ou=Users, dc=example, dc=com\n" +
- "objectclass: top\n" +
- "objectclass: organizationalunit\n" +
- "ou: Users";
-
- LdifReader reader = new LdifReader();
-
- List entries = reader.parseLdif( ldif );
- Entry entry = (Entry) entries.get( 0 );
-
- assertEquals( "ou=Users, dc=example, dc=com", entry.getDn() );
-
- Attribute attr = entry.get( "objectclass" );
- assertTrue( attr.contains( "top" ) );
- assertTrue( attr.contains( "organizationalunit" ) );
-
- attr = entry.get( "ou" );
- assertTrue( attr.contains( "Users" ) );
- }
}