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 2012/01/24 18:27:12 UTC
svn commit: r1235364 [11/27] - in /directory/shared/trunk:
asn1/api/src/main/java/org/apache/directory/shared/asn1/util/
asn1/api/src/test/java/org/apache/directory/shared/asn1/util/
asn1/ber/src/main/java/org/apache/directory/shared/asn1/actions/ asn1...
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java Tue Jan 24 17:27:00 2012
@@ -109,7 +109,7 @@ public abstract class ConnectorFilter ex
if ( ( filterSet != null ) && ( filterSet.size() != 0 ) )
{
- for ( Filter filter:filterSet )
+ for ( Filter filter : filterSet )
{
connectorFilterLength += filter.computeLength();
}
@@ -138,7 +138,7 @@ public abstract class ConnectorFilter ex
// encode each filter
if ( ( filterSet != null ) && ( filterSet.size() != 0 ) )
{
- for ( Filter filter:filterSet )
+ for ( Filter filter : filterSet )
{
filter.encode( buffer );
}
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java Tue Jan 24 17:27:00 2012
@@ -46,13 +46,13 @@ public class ExtensibleMatchFilter exten
/** Matching rule */
private String matchingRule;
-
+
/** Matching rule bytes */
private byte[] matchingRuleBytes;
/** Matching rule type */
private String type;
-
+
private byte[] typeBytes;
/** Matching rule value */
@@ -64,6 +64,7 @@ public class ExtensibleMatchFilter exten
/** The extensible match length */
private int extensibleMatchLength;
+
// ~ Constructors
// -------------------------------------------------------------------------------
/**
@@ -74,8 +75,8 @@ public class ExtensibleMatchFilter exten
{
super( tlvId );
}
-
-
+
+
/**
* Creates a new ExtensibleMatchFilter object. The dnAttributes flag
* defaults to false.
@@ -213,13 +214,13 @@ public class ExtensibleMatchFilter exten
{
if ( matchingRule != null )
{
- matchingRuleBytes = Strings.getBytesUtf8(matchingRule);
+ matchingRuleBytes = Strings.getBytesUtf8( matchingRule );
extensibleMatchLength = 1 + TLV.getNbBytes( matchingRuleBytes.length ) + matchingRuleBytes.length;
}
if ( type != null )
{
- typeBytes = Strings.getBytesUtf8(type);
+ typeBytes = Strings.getBytesUtf8( type );
extensibleMatchLength += 1 + TLV.getNbBytes( typeBytes.length ) + typeBytes.length;
}
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/NotFilter.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/NotFilter.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/NotFilter.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/NotFilter.java Tue Jan 24 17:27:00 2012
@@ -47,7 +47,8 @@ public class NotFilter extends Connector
{
super( tlvId );
}
-
+
+
/**
* The constructor.
*/
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/OrFilter.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/OrFilter.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/OrFilter.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/OrFilter.java Tue Jan 24 17:27:00 2012
@@ -48,8 +48,8 @@ public class OrFilter extends ConnectorF
{
super( tlvId );
}
-
-
+
+
/**
* The constructor. We wont initialize the ArrayList as they may not be
* used.
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/PresentFilter.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/PresentFilter.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/PresentFilter.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/PresentFilter.java Tue Jan 24 17:27:00 2012
@@ -103,7 +103,7 @@ public class PresentFilter extends Filte
*/
public int computeLength()
{
- attributeDescriptionBytes = Strings.getBytesUtf8(attributeDescription);
+ attributeDescriptionBytes = Strings.getBytesUtf8( attributeDescription );
return 1 + TLV.getNbBytes( attributeDescriptionBytes.length ) + attributeDescriptionBytes.length;
}
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java Tue Jan 24 17:27:00 2012
@@ -57,7 +57,7 @@ public class SubstringFilter extends Fil
/** The substring filter type (an attributeDescription) */
private String type;
-
+
/** The type length */
private int typeLength;
@@ -94,8 +94,8 @@ public class SubstringFilter extends Fil
{
super( tlvId );
}
-
-
+
+
/**
* The constructor. We will create the 'any' subsring arraylist with only
* one element.
@@ -233,30 +233,30 @@ public class SubstringFilter extends Fil
public int computeLength()
{
// The type
- typeLength = Strings.getBytesUtf8(type).length;
-
+ typeLength = Strings.getBytesUtf8( type ).length;
+
substringsFilterLength = 1 + TLV.getNbBytes( typeLength ) + typeLength;
substringsFilterSequenceLength = 0;
if ( initialSubstrings != null )
{
- int initialLength = Strings.getBytesUtf8(initialSubstrings).length;
+ int initialLength = Strings.getBytesUtf8( initialSubstrings ).length;
substringsFilterSequenceLength += 1 + TLV.getNbBytes( initialLength )
+ initialLength;
}
if ( anySubstrings != null )
{
- for ( String any:anySubstrings )
+ for ( String any : anySubstrings )
{
- int anyLength = Strings.getBytesUtf8(any).length;
+ int anyLength = Strings.getBytesUtf8( any ).length;
substringsFilterSequenceLength += 1 + TLV.getNbBytes( anyLength ) + anyLength;
}
}
if ( finalSubstrings != null )
{
- int finalLength = Strings.getBytesUtf8(finalSubstrings).length;
+ int finalLength = Strings.getBytesUtf8( finalSubstrings ).length;
substringsFilterSequenceLength += 1 + TLV.getNbBytes( finalLength )
+ finalLength;
}
@@ -317,7 +317,7 @@ public class SubstringFilter extends Fil
// The initial substring
if ( initialSubstrings != null )
{
- byte[] initialBytes = Strings.getBytesUtf8(initialSubstrings);
+ byte[] initialBytes = Strings.getBytesUtf8( initialSubstrings );
buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_INITIAL_TAG );
buffer.put( TLV.getBytes( initialBytes.length ) );
buffer.put( initialBytes );
@@ -326,9 +326,9 @@ public class SubstringFilter extends Fil
// The any substrings
if ( anySubstrings != null )
{
- for ( String any:anySubstrings )
+ for ( String any : anySubstrings )
{
- byte[] anyBytes = Strings.getBytesUtf8(any);
+ byte[] anyBytes = Strings.getBytesUtf8( any );
buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_ANY_TAG );
buffer.put( TLV.getBytes( anyBytes.length ) );
buffer.put( anyBytes );
@@ -338,7 +338,7 @@ public class SubstringFilter extends Fil
// The final substring
if ( finalSubstrings != null )
{
- byte[] finalBytes = Strings.getBytesUtf8(finalSubstrings);
+ byte[] finalBytes = Strings.getBytesUtf8( finalSubstrings );
buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_FINAL_TAG );
buffer.put( TLV.getBytes( finalBytes.length ) );
buffer.put( finalBytes );
@@ -372,7 +372,7 @@ public class SubstringFilter extends Fil
if ( anySubstrings != null )
{
- for ( String any:anySubstrings )
+ for ( String any : anySubstrings )
{
sb.append( any ).append( '*' );
}
Modified: directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java Tue Jan 24 17:27:00 2012
@@ -65,32 +65,118 @@ public class LdapControlTest extends Abs
ByteBuffer stream = ByteBuffer.allocate( 0x64 );
stream.put( new byte[]
{ 0x30, 0x62, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x03, // messageID MessageID
- 0x50, 0x01, 0x02, // CHOICE { ..., abandonRequest
+ 0x02,
+ 0x01,
+ 0x03, // messageID MessageID
+ 0x50,
+ 0x01,
+ 0x02, // CHOICE { ..., abandonRequest
// AbandonRequest,...
- ( byte ) 0xA0, 0x5A, // controls [0] Controls OPTIONAL }
- 0x30, 0x1A, // Control ::= SEQUENCE {
+ ( byte ) 0xA0,
+ 0x5A, // controls [0] Controls OPTIONAL }
+ 0x30,
+ 0x1A, // Control ::= SEQUENCE {
// controlType LDAPOID,
- 0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '1',
+ 0x04,
+ 0x0D,
+ '1',
+ '.',
+ '3',
+ '.',
+ '6',
+ '.',
+ '1',
+ '.',
+ '5',
+ '.',
+ '5',
+ '.',
+ '1',
// criticality BOOLEAN DEFAULT FALSE,
- 0x01, 0x01, ( byte ) 0xFF,
+ 0x01,
+ 0x01,
+ ( byte ) 0xFF,
// controlValue OCTET STRING OPTIONAL }
- 0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f', 0x30, 0x17, // Control ::= SEQUENCE {
+ 0x04,
+ 0x06,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 0x30,
+ 0x17, // Control ::= SEQUENCE {
// controlType LDAPOID,
- 0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+ 0x04,
+ 0x0D,
+ '1',
+ '.',
+ '3',
+ '.',
+ '6',
+ '.',
+ '1',
+ '.',
+ '5',
+ '.',
+ '5',
+ '.',
+ '2',
// controlValue OCTET STRING OPTIONAL }
- 0x04, 0x06, 'g', 'h', 'i', 'j', 'k', 'l', 0x30, 0x12, // Control ::= SEQUENCE {
+ 0x04,
+ 0x06,
+ 'g',
+ 'h',
+ 'i',
+ 'j',
+ 'k',
+ 'l',
+ 0x30,
+ 0x12, // Control ::= SEQUENCE {
// controlType LDAPOID,
- 0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '3',
+ 0x04,
+ 0x0D,
+ '1',
+ '.',
+ '3',
+ '.',
+ '6',
+ '.',
+ '1',
+ '.',
+ '5',
+ '.',
+ '5',
+ '.',
+ '3',
// criticality BOOLEAN DEFAULT FALSE}
- 0x01, 0x01, ( byte ) 0xFF, 0x30, 0x0F, // Control ::= SEQUENCE {
+ 0x01,
+ 0x01,
+ ( byte ) 0xFF,
+ 0x30,
+ 0x0F, // Control ::= SEQUENCE {
// controlType LDAPOID}
- 0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '4' } );
+ 0x04,
+ 0x0D,
+ '1',
+ '.',
+ '3',
+ '.',
+ '6',
+ '.',
+ '1',
+ '.',
+ '5',
+ '.',
+ '5',
+ '.',
+ '4' } );
stream.flip();
// Allocate a LdapMessageContainer Container
- LdapMessageContainer<AbandonRequestDecorator> ldapMessageContainer =
+ LdapMessageContainer<AbandonRequestDecorator> ldapMessageContainer =
new LdapMessageContainer<AbandonRequestDecorator>( codec );
// Decode the PDU
@@ -119,27 +205,28 @@ public class LdapControlTest extends Abs
assertEquals( 4, controls.size() );
- CodecControl<Control> control = (org.apache.directory.shared.ldap.codec.api.CodecControl<Control> ) controls.get( "1.3.6.1.5.5.1" );
+ CodecControl<Control> control = ( org.apache.directory.shared.ldap.codec.api.CodecControl<Control> ) controls
+ .get( "1.3.6.1.5.5.1" );
assertEquals( "1.3.6.1.5.5.1", control.getOid() );
assertEquals( "0x61 0x62 0x63 0x64 0x65 0x66 ", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
assertTrue( control.isCritical() );
internalAbandonRequest.addControl( control );
- control = (org.apache.directory.shared.ldap.codec.api.CodecControl<Control> ) controls.get( "1.3.6.1.5.5.2" );
+ control = ( org.apache.directory.shared.ldap.codec.api.CodecControl<Control> ) controls.get( "1.3.6.1.5.5.2" );
assertEquals( "1.3.6.1.5.5.2", control.getOid() );
- assertEquals( "0x67 0x68 0x69 0x6A 0x6B 0x6C ", Strings.dumpBytes((byte[]) control.getValue()) );
+ assertEquals( "0x67 0x68 0x69 0x6A 0x6B 0x6C ", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
assertFalse( control.isCritical() );
internalAbandonRequest.addControl( control );
- control = (org.apache.directory.shared.ldap.codec.api.CodecControl<Control> ) controls.get( "1.3.6.1.5.5.3" );
+ control = ( org.apache.directory.shared.ldap.codec.api.CodecControl<Control> ) controls.get( "1.3.6.1.5.5.3" );
assertEquals( "1.3.6.1.5.5.3", control.getOid() );
- assertEquals( "", Strings.dumpBytes((byte[]) control.getValue()) );
+ assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
assertTrue( control.isCritical() );
internalAbandonRequest.addControl( control );
- control = (org.apache.directory.shared.ldap.codec.api.CodecControl<Control> ) controls.get( "1.3.6.1.5.5.4" );
+ control = ( org.apache.directory.shared.ldap.codec.api.CodecControl<Control> ) controls.get( "1.3.6.1.5.5.4" );
assertEquals( "1.3.6.1.5.5.4", control.getOid() );
- assertEquals( "", Strings.dumpBytes((byte[]) control.getValue()) );
+ assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
assertFalse( control.isCritical() );
internalAbandonRequest.addControl( control );
@@ -186,22 +273,38 @@ public class LdapControlTest extends Abs
ByteBuffer stream = ByteBuffer.allocate( 0x19 );
stream.put( new byte[]
{ 0x30, 0x17, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x03, // messageID MessageID
- 0x50, 0x01, 0x02, // CHOICE { ..., abandonRequest
+ 0x02,
+ 0x01,
+ 0x03, // messageID MessageID
+ 0x50,
+ 0x01,
+ 0x02, // CHOICE { ..., abandonRequest
// AbandonRequest,...
- ( byte ) 0xA0, 0x0F, // controls [0] Controls OPTIONAL }
- 0x30, 0x0D, // Control ::= SEQUENCE {
+ ( byte ) 0xA0,
+ 0x0F, // controls [0] Controls OPTIONAL }
+ 0x30,
+ 0x0D, // Control ::= SEQUENCE {
// controlType LDAPOID,
- 0x04, 0x00,
+ 0x04,
+ 0x00,
// criticality BOOLEAN DEFAULT FALSE,
- 0x01, 0x01, ( byte ) 0xFF,
+ 0x01,
+ 0x01,
+ ( byte ) 0xFF,
// controlValue OCTET STRING OPTIONAL }
- 0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f', } );
+ 0x04,
+ 0x06,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f', } );
stream.flip();
// Allocate a LdapMessageContainer Container
- Asn1Container ldapMessageContainer =
+ Asn1Container ldapMessageContainer =
new LdapMessageContainer<MessageDecorator<? extends Message>>( codec );
// Decode the PDU
@@ -230,22 +333,45 @@ public class LdapControlTest extends Abs
ByteBuffer stream = ByteBuffer.allocate( 0x20 );
stream.put( new byte[]
{ 0x30, 0x1E, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x03, // messageID MessageID
- 0x50, 0x01, 0x02, // CHOICE { ..., abandonRequest
+ 0x02,
+ 0x01,
+ 0x03, // messageID MessageID
+ 0x50,
+ 0x01,
+ 0x02, // CHOICE { ..., abandonRequest
// AbandonRequest,...
- ( byte ) 0xA0, 0x16, // controls [0] Controls OPTIONAL }
- 0x30, 0x14, // Control ::= SEQUENCE {
+ ( byte ) 0xA0,
+ 0x16, // controls [0] Controls OPTIONAL }
+ 0x30,
+ 0x14, // Control ::= SEQUENCE {
// controlType LDAPOID,
- 0x04, 0x07, 'b', 'a', 'd', ' ', 'o', 'i', 'd',
+ 0x04,
+ 0x07,
+ 'b',
+ 'a',
+ 'd',
+ ' ',
+ 'o',
+ 'i',
+ 'd',
// criticality BOOLEAN DEFAULT FALSE,
- 0x01, 0x01, ( byte ) 0xFF,
+ 0x01,
+ 0x01,
+ ( byte ) 0xFF,
// controlValue OCTET STRING OPTIONAL }
- 0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f', } );
+ 0x04,
+ 0x06,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f', } );
stream.flip();
// Allocate a LdapMessageContainer Container
- Asn1Container ldapMessageContainer =
+ Asn1Container ldapMessageContainer =
new LdapMessageContainer<MessageDecorator<? extends Message>>( codec );
// Decode the PDU
@@ -274,22 +400,50 @@ public class LdapControlTest extends Abs
ByteBuffer stream = ByteBuffer.allocate( 0x25 );
stream.put( new byte[]
{ 0x30, 0x23, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x03, // messageID MessageID
- 0x50, 0x01, 0x02, // CHOICE { ..., abandonRequest
+ 0x02,
+ 0x01,
+ 0x03, // messageID MessageID
+ 0x50,
+ 0x01,
+ 0x02, // CHOICE { ..., abandonRequest
// AbandonRequest,...
- ( byte ) 0xA0, 0x1B, // controls [0] Controls OPTIONAL }
- 0x30, 0x19, // Control ::= SEQUENCE {
+ ( byte ) 0xA0,
+ 0x1B, // controls [0] Controls OPTIONAL }
+ 0x30,
+ 0x19, // Control ::= SEQUENCE {
// controlType LDAPOID,
- 0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '1',
+ 0x04,
+ 0x0D,
+ '1',
+ '.',
+ '3',
+ '.',
+ '6',
+ '.',
+ '1',
+ '.',
+ '5',
+ '.',
+ '5',
+ '.',
+ '1',
// criticality BOOLEAN DEFAULT FALSE,
- 0x01, 0x00,
+ 0x01,
+ 0x00,
// controlValue OCTET STRING OPTIONAL }
- 0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f', } );
+ 0x04,
+ 0x06,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f', } );
stream.flip();
// Allocate a LdapMessageContainer Container
- Asn1Container ldapMessageContainer =
+ Asn1Container ldapMessageContainer =
new LdapMessageContainer<MessageDecorator<? extends Message>>( codec );
// Decode the PDU
Modified: directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java Tue Jan 24 17:27:00 2012
@@ -64,13 +64,13 @@ public class LdapDecoderTest extends Abs
/** The ASN 1 decoder instance */
private static Asn1Decoder asn1Decoder;
-
+
@BeforeClass
public static void init()
{
asn1Decoder = new Asn1Decoder();
}
-
+
/**
* Decode an incoming buffer into LDAP messages. The result can be 0, 1 or many
@@ -83,7 +83,8 @@ public class LdapDecoderTest extends Abs
* @param decodedMessages The list of decoded messages
* @throws Exception If the decoding failed
*/
- private void decode( ByteBuffer buffer, LdapMessageContainer<MessageDecorator<? extends Message>> messageContainer, List<Message> decodedMessages ) throws DecoderException
+ private void decode( ByteBuffer buffer, LdapMessageContainer<MessageDecorator<? extends Message>> messageContainer,
+ List<Message> decodedMessages ) throws DecoderException
{
buffer.mark();
@@ -124,7 +125,7 @@ public class LdapDecoderTest extends Abs
}
}
-
+
/**
* Test the decoding of a full PDU
*/
@@ -132,26 +133,69 @@ public class LdapDecoderTest extends Abs
public void testDecodeFull()
{
Asn1Decoder ldapDecoder = new Asn1Decoder();
- LdapMessageContainer<MessageDecorator<? extends Message>> container =
+ LdapMessageContainer<MessageDecorator<? extends Message>> container =
new LdapMessageContainer<MessageDecorator<? extends Message>>( codec );
ByteBuffer stream = ByteBuffer.allocate( 0x35 );
stream.put( new byte[]
- {
- 0x30, 0x33, // 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'
- } );
+ {
+ 0x30, 0x33, // 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'
+ } );
stream.flip();
@@ -169,13 +213,13 @@ public class LdapDecoderTest extends Abs
assertEquals( TLVStateEnum.PDU_DECODED, container.getState() );
// Check the decoded PDU
- BindRequest bindRequest = (BindRequest)container.getMessage();
+ BindRequest bindRequest = ( BindRequest ) container.getMessage();
assertEquals( 1, bindRequest.getMessageId() );
assertTrue( bindRequest.isVersion3() );
assertEquals( "uid=akarasulu,dc=example,dc=com", bindRequest.getName().toString() );
assertTrue( bindRequest.isSimple() );
- assertEquals( "password", Strings.utf8ToString(bindRequest.getCredentials()) );
+ assertEquals( "password", Strings.utf8ToString( bindRequest.getCredentials() ) );
}
@@ -185,7 +229,7 @@ public class LdapDecoderTest extends Abs
@Test
public void testDecode2Messages() throws Exception
{
- LdapMessageContainer<MessageDecorator<? extends Message>> container =
+ LdapMessageContainer<MessageDecorator<? extends Message>> container =
new LdapMessageContainer<MessageDecorator<? extends Message>>( codec );
IoSession dummySession = new DummySession();
@@ -193,34 +237,121 @@ public class LdapDecoderTest extends Abs
ByteBuffer stream = ByteBuffer.allocate( 0x6A );
stream.put( new byte[]
- {
- 0x30, 0x33, // 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',
- 0x30, 0x33, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x02, // 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'
- } );
+ {
+ 0x30, 0x33, // 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',
+ 0x30,
+ 0x33, // LDAPMessage ::=SEQUENCE {
+ 0x02,
+ 0x01,
+ 0x02, // 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'
+ } );
stream.flip();
@@ -238,14 +369,14 @@ public class LdapDecoderTest extends Abs
}
// Check the decoded PDU
- BindRequest bindRequest = (BindRequest) ( result.get( 0 ) );
+ BindRequest bindRequest = ( BindRequest ) ( result.get( 0 ) );
assertEquals( 1, bindRequest.getMessageId() );
assertTrue( bindRequest.isVersion3() );
assertEquals( "uid=akarasulu,dc=example,dc=com", bindRequest.getName().toString() );
assertTrue( bindRequest.isSimple() );
- assertEquals( "password", Strings.utf8ToString(bindRequest.getCredentials()) );
-
+ assertEquals( "password", Strings.utf8ToString( bindRequest.getCredentials() ) );
+
// The second message
bindRequest = ( BindRequest ) ( result.get( 1 ) );
@@ -253,7 +384,7 @@ public class LdapDecoderTest extends Abs
assertTrue( bindRequest.isVersion3() );
assertEquals( "uid=akarasulu,dc=example,dc=com", bindRequest.getName().toString() );
assertTrue( bindRequest.isSimple() );
- assertEquals( "password", Strings.utf8ToString(bindRequest.getCredentials()) );
+ assertEquals( "password", Strings.utf8ToString( bindRequest.getCredentials() ) );
}
@@ -269,12 +400,21 @@ public class LdapDecoderTest extends Abs
ByteBuffer stream = ByteBuffer.allocate( 16 );
stream.put( new byte[]
{ 0x30, 0x33, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x60, 0x2E, // CHOICE { ..., bindRequest BindRequest, ...
+ 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', '=' } );
+ 0x02,
+ 0x01,
+ 0x03, // version INTEGER (1..127),
+ 0x04,
+ 0x1F, // name LDAPDN,
+ 'u',
+ 'i',
+ 'd',
+ '=' } );
stream.flip();
@@ -316,12 +456,21 @@ public class LdapDecoderTest extends Abs
ByteBuffer stream = ByteBuffer.allocate( 16 );
stream.put( new byte[]
{ 0x30, 0x33, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x60, 0x2E, // CHOICE { ..., bindRequest BindRequest, ...
+ 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', '=' } );
+ 0x02,
+ 0x01,
+ 0x03, // version INTEGER (1..127),
+ 0x04,
+ 0x1F, // name LDAPDN,
+ 'u',
+ 'i',
+ 'd',
+ '=' } );
stream.flip();
@@ -349,7 +498,14 @@ public class LdapDecoderTest extends Abs
// AuthenticationChoice
// AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING,
// ...
- 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' } );
+ 'p',
+ 'a',
+ 's',
+ 's',
+ 'w',
+ 'o',
+ 'r',
+ 'd' } );
stream.flip();
@@ -373,7 +529,7 @@ public class LdapDecoderTest extends Abs
assertTrue( bindRequest.isVersion3() );
assertEquals( "uid=akarasulu,dc=example,dc=com", bindRequest.getName().toString() );
assertTrue( bindRequest.isSimple() );
- assertEquals( "password", Strings.utf8ToString(bindRequest.getCredentials()) );
+ assertEquals( "password", Strings.utf8ToString( bindRequest.getCredentials() ) );
}
@@ -393,26 +549,66 @@ public class LdapDecoderTest extends Abs
// Length should be 0x33...
0x30,
0x32, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01,
+ 0x02,
+ 0x01,
0x01, // messageID MessageID
0x60,
0x2E, // CHOICE { ..., bindRequest BindRequest, ...
// BindRequest ::= APPLICATION[0] SEQUENCE {
- 0x02, 0x01,
+ 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
+ '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' } );
+ 'p',
+ 'a',
+ 's',
+ 's',
+ 'w',
+ 'o',
+ 'r',
+ 'd' } );
stream.flip();
// Allocate a LdapMessage Container
- LdapMessageContainer<MessageDecorator<? extends Message>> ldapMessageContainer =
+ LdapMessageContainer<MessageDecorator<? extends Message>> ldapMessageContainer =
new LdapMessageContainer<MessageDecorator<? extends Message>>( codec );
// Decode a BindRequest PDU
@@ -447,25 +643,64 @@ public class LdapDecoderTest extends Abs
{ 0x30,
0x33, // LDAPMessage ::=SEQUENCE {
// Length should be 0x01...
- 0x02, 0x02,
+ 0x02,
+ 0x02,
0x01, // messageID MessageID
0x60,
0x2E, // CHOICE { ..., bindRequest BindRequest, ...
// BindRequest ::= APPLICATION[0] SEQUENCE {
- 0x02, 0x01,
+ 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
+ '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' } );
+ 'p',
+ 'a',
+ 's',
+ 's',
+ 'w',
+ 'o',
+ 'r' } );
stream.flip();
// Allocate a LdapMessage Container
- Asn1Container ldapMessageContainer =
+ Asn1Container ldapMessageContainer =
new LdapMessageContainer<MessageDecorator<? extends Message>>( codec );
// Decode a BindRequest PDU
@@ -475,7 +710,8 @@ public class LdapDecoderTest extends Abs
}
catch ( DecoderException de )
{
- assertEquals( "ERR_00001_BAD_TRANSITION_FROM_STATE Bad transition from state MESSAGE_ID_STATE, tag 0x2E", de.getMessage() );
+ assertEquals( "ERR_00001_BAD_TRANSITION_FROM_STATE Bad transition from state MESSAGE_ID_STATE, tag 0x2E",
+ de.getMessage() );
return;
}
@@ -498,21 +734,61 @@ public class LdapDecoderTest extends Abs
{ 0x30,
0x33, // LDAPMessage ::=SEQUENCE {
// Length should be 0x01...
- 0x02, 0x01,
+ 0x02,
+ 0x01,
0x01, // messageID MessageID
0x2D,
0x2D, // CHOICE { ..., bindRequest BindRequest, ...
// BindRequest ::= APPLICATION[0] SEQUENCE {
- 0x02, 0x01,
+ 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
+ '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' } );
+ 'p',
+ 'a',
+ 's',
+ 's',
+ 'w',
+ 'o',
+ 'r',
+ 'd' } );
stream.flip();
@@ -526,7 +802,8 @@ public class LdapDecoderTest extends Abs
}
catch ( DecoderException de )
{
- assertEquals( "ERR_00001_BAD_TRANSITION_FROM_STATE Bad transition from state MESSAGE_ID_STATE, tag 0x2D", de.getMessage() );
+ assertEquals( "ERR_00001_BAD_TRANSITION_FROM_STATE Bad transition from state MESSAGE_ID_STATE, tag 0x2D",
+ de.getMessage() );
return;
}
@@ -573,7 +850,7 @@ public class LdapDecoderTest extends Abs
stream = ByteBuffer.allocate( 1 );
stream.put( new byte[]
{ ( byte ) 0x80 // End of the length
- } );
+ } );
stream.flip();
Modified: directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java Tue Jan 24 17:27:00 2012
@@ -100,8 +100,9 @@ public class LdapMessageTest extends Abs
ByteBuffer stream = ByteBuffer.allocate( 0x04 );
stream.put( new byte[]
{ 0x30, 0x02, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x00 // messageID MessageID
- } );
+ 0x02,
+ 0x00 // messageID MessageID
+ } );
stream.flip();
@@ -135,8 +136,10 @@ public class LdapMessageTest extends Abs
ByteBuffer stream = ByteBuffer.allocate( 0x05 );
stream.put( new byte[]
{ 0x30, 0x03, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, ( byte ) 0xff // messageID MessageID = -1
- } );
+ 0x02,
+ 0x01,
+ ( byte ) 0xff // messageID MessageID = -1
+ } );
stream.flip();
@@ -171,7 +174,12 @@ public class LdapMessageTest extends Abs
stream.put( new byte[]
{ 0x30, 0x06, // LDAPMessage ::=SEQUENCE {
// messageID MessageID = -1
- 0x02, 0x04, ( byte ) 0x7f, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff } );
+ 0x02,
+ 0x04,
+ ( byte ) 0x7f,
+ ( byte ) 0xff,
+ ( byte ) 0xff,
+ ( byte ) 0xff } );
stream.flip();
@@ -202,9 +210,12 @@ public class LdapMessageTest extends Abs
byte[] buffer = new byte[]
{ 0x30, 0x05, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID = 1
- 0x42, 0x00 // ProtocolOp
- };
+ 0x02,
+ 0x01,
+ 0x01, // messageID MessageID = 1
+ 0x42,
+ 0x00 // ProtocolOp
+ };
Asn1Decoder ldapDecoder = new Asn1Decoder();
@@ -288,16 +299,20 @@ public class LdapMessageTest extends Abs
ByteBuffer stream = ByteBuffer.allocate( 0x08 );
stream.put( new byte[]
{ 0x30, 0x06, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x02, 0x01, ( byte ) 0xF4, // messageID MessageID (500)
- 0x42, 0x00, // CHOICE { ..., unbindRequest UnbindRequest,...
+ 0x02,
+ 0x02,
+ 0x01,
+ ( byte ) 0xF4, // messageID MessageID (500)
+ 0x42,
+ 0x00, // CHOICE { ..., unbindRequest UnbindRequest,...
// UnbindRequest ::= [APPLICATION 2] NULL
- } );
+ } );
- String decodedPdu = Strings.dumpBytes(stream.array());
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
// Allocate a BindRequest Container
- LdapMessageContainer<UnbindRequestDecorator> container =
+ LdapMessageContainer<UnbindRequestDecorator> container =
new LdapMessageContainer<UnbindRequestDecorator>( codec );
try
@@ -325,7 +340,7 @@ public class LdapMessageTest extends Abs
// Check the length
assertEquals( 0x08, bb.limit() );
- String encodedPdu = Strings.dumpBytes(bb.array());
+ String encodedPdu = Strings.dumpBytes( bb.array() );
assertEquals( encodedPdu, decodedPdu );
}
Modified: directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapResultTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapResultTest.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapResultTest.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/LdapResultTest.java Tue Jan 24 17:27:00 2012
@@ -70,10 +70,14 @@ public class LdapResultTest extends Abst
stream.put( new byte[]
{ 0x30, 0x0E, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x69, 0x02, // CHOICE { ..., addResponse AddResponse, ...
- 0x0A, 0x00 // Empty resultCode
- } );
+ 0x02,
+ 0x01,
+ 0x01, // messageID MessageID
+ 0x69,
+ 0x02, // CHOICE { ..., addResponse AddResponse, ...
+ 0x0A,
+ 0x00 // Empty resultCode
+ } );
stream.flip();
@@ -107,10 +111,16 @@ public class LdapResultTest extends Abst
stream.put( new byte[]
{ 0x30, 0x0E, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x69, 0x02, // CHOICE { ..., addResponse AddResponse, ...
- 0x0A, 0x03, 0x01, 0x01 // resultCode too high
- } );
+ 0x02,
+ 0x01,
+ 0x01, // messageID MessageID
+ 0x69,
+ 0x02, // CHOICE { ..., addResponse AddResponse, ...
+ 0x0A,
+ 0x03,
+ 0x01,
+ 0x01 // resultCode too high
+ } );
stream.flip();
@@ -144,12 +154,19 @@ public class LdapResultTest extends Abst
byte[] buffer = new byte[]
{ 0x30, 0x0C, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x69, 0x07, // CHOICE { ..., addResponse AddResponse, ...
- 0x0A, 0x01, 0x00, // resultCode success
- 0x04, 0x00, // matchedDN LDAPDN,
- 0x04, 0x00 // errorMessage LDAPString,
- };
+ 0x02,
+ 0x01,
+ 0x01, // messageID MessageID
+ 0x69,
+ 0x07, // CHOICE { ..., addResponse AddResponse, ...
+ 0x0A,
+ 0x01,
+ 0x00, // resultCode success
+ 0x04,
+ 0x00, // matchedDN LDAPDN,
+ 0x04,
+ 0x00 // errorMessage LDAPString,
+ };
for ( int i = 0; i < 91; i++ )
{
@@ -189,9 +206,14 @@ public class LdapResultTest extends Abst
stream.put( new byte[]
{ 0x30, 0x08, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x69, 0x03, // CHOICE { ..., addResponse AddResponse, ...
- 0x0A, 0x01, 0x00, // resultCode success
+ 0x02,
+ 0x01,
+ 0x01, // messageID MessageID
+ 0x69,
+ 0x03, // CHOICE { ..., addResponse AddResponse, ...
+ 0x0A,
+ 0x01,
+ 0x00, // resultCode success
} );
stream.flip();
@@ -226,11 +248,17 @@ public class LdapResultTest extends Abst
stream.put( new byte[]
{ 0x30, 0x0A, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x69, 0x05, // CHOICE { ..., addResponse AddResponse, ...
- 0x0A, 0x01, 0x00, // resultCode success
- 0x04, 0x00 // Empty matched Dn
- } );
+ 0x02,
+ 0x01,
+ 0x01, // messageID MessageID
+ 0x69,
+ 0x05, // CHOICE { ..., addResponse AddResponse, ...
+ 0x0A,
+ 0x01,
+ 0x00, // resultCode success
+ 0x04,
+ 0x00 // Empty matched Dn
+ } );
stream.flip();
@@ -264,18 +292,25 @@ public class LdapResultTest extends Abst
stream.put( new byte[]
{ 0x30, 0x0C, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x69, 0x07, // CHOICE { ..., addResponse AddResponse, ...
- 0x0A, 0x01, 0x00, // resultCode success
- 0x04, 0x00, // Empty matched Dn
- 0x04, 0x00 // Empty errorMessage
- } );
+ 0x02,
+ 0x01,
+ 0x01, // messageID MessageID
+ 0x69,
+ 0x07, // CHOICE { ..., addResponse AddResponse, ...
+ 0x0A,
+ 0x01,
+ 0x00, // resultCode success
+ 0x04,
+ 0x00, // Empty matched Dn
+ 0x04,
+ 0x00 // Empty errorMessage
+ } );
- String decodedPdu = Strings.dumpBytes(stream.array());
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
// Allocate a LdapMessage Container
- LdapMessageContainer<AddResponseDecorator> container =
+ LdapMessageContainer<AddResponseDecorator> container =
new LdapMessageContainer<AddResponseDecorator>( codec );
// Decode the AddResponse PDU
@@ -304,7 +339,7 @@ public class LdapResultTest extends Abst
// Check the length
assertEquals( 0x0E, bb.limit() );
- String encodedPdu = Strings.dumpBytes(bb.array());
+ String encodedPdu = Strings.dumpBytes( bb.array() );
assertEquals( encodedPdu, decodedPdu );
}
@@ -328,14 +363,32 @@ public class LdapResultTest extends Abst
stream.put( new byte[]
{ 0x30, 0x18, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x69, 0x13, // CHOICE { ..., addResponse AddResponse, ...
- 0x0A, 0x01, 0x0A, // resultCode success (Referral)
- 0x04, 0x00, // Empty matched Dn
- 0x04, 0x00, // Empty errorMessage
- ( byte ) 0xA3, 0x0A, 0x04, 0x08, 'l', 'd', 'a', 'p', ':', '/', '/', '/' } );
+ 0x02,
+ 0x01,
+ 0x01, // messageID MessageID
+ 0x69,
+ 0x13, // CHOICE { ..., addResponse AddResponse, ...
+ 0x0A,
+ 0x01,
+ 0x0A, // resultCode success (Referral)
+ 0x04,
+ 0x00, // Empty matched Dn
+ 0x04,
+ 0x00, // Empty errorMessage
+ ( byte ) 0xA3,
+ 0x0A,
+ 0x04,
+ 0x08,
+ 'l',
+ 'd',
+ 'a',
+ 'p',
+ ':',
+ '/',
+ '/',
+ '/' } );
- String decodedPdu = Strings.dumpBytes(stream.array());
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
// Allocate a LdapMessage Container
@@ -375,7 +428,7 @@ public class LdapResultTest extends Abst
// Check the length
assertEquals( 0x1A, bb.limit() );
- String encodedPdu = Strings.dumpBytes(bb.array());
+ String encodedPdu = Strings.dumpBytes( bb.array() );
assertEquals( encodedPdu, decodedPdu );
}
@@ -400,20 +453,42 @@ public class LdapResultTest extends Abst
stream.put( new byte[]
{ 0x30,
0x22, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01,
+ 0x02,
+ 0x01,
0x01, // messageID MessageID
0x69,
0x1D, // CHOICE { ..., addResponse AddResponse, ...
- 0x0A, 0x01,
+ 0x0A,
+ 0x01,
0x0A, // resultCode success (Referral)
0x04,
0x00, // Empty matched Dn
0x04,
0x00, // Empty errorMessage
- ( byte ) 0xA3, 0x14, 0x04, 0x08, 'l', 'd', 'a', 'p', ':', '/', '/', '/', 0x04, 0x08, 'l', 'd', 'a',
- 'p', ':', '/', '/', '/' } );
+ ( byte ) 0xA3,
+ 0x14,
+ 0x04,
+ 0x08,
+ 'l',
+ 'd',
+ 'a',
+ 'p',
+ ':',
+ '/',
+ '/',
+ '/',
+ 0x04,
+ 0x08,
+ 'l',
+ 'd',
+ 'a',
+ 'p',
+ ':',
+ '/',
+ '/',
+ '/' } );
- String decodedPdu = Strings.dumpBytes(stream.array());
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
// Allocate a LdapMessage Container
@@ -458,7 +533,7 @@ public class LdapResultTest extends Abst
// Check the length
assertEquals( 0x24, bb.limit() );
- String encodedPdu = Strings.dumpBytes(bb.array());
+ String encodedPdu = Strings.dumpBytes( bb.array() );
assertEquals( encodedPdu, decodedPdu );
}
@@ -483,14 +558,34 @@ public class LdapResultTest extends Abst
stream.put( new byte[]
{ 0x30, 0x1A, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x69, 0x15, // CHOICE { ..., addResponse AddResponse, ...
- 0x0A, 0x01, 0x0A, // resultCode success (Referral)
- 0x04, 0x00, // Empty matched Dn
- 0x04, 0x00, // Empty errorMessage
- ( byte ) 0xA3, 0x0C, 0x04, 0x08, 'l', 'd', 'a', 'p', ':', '/', '/', '/', 0x04, 0x00 } );
+ 0x02,
+ 0x01,
+ 0x01, // messageID MessageID
+ 0x69,
+ 0x15, // CHOICE { ..., addResponse AddResponse, ...
+ 0x0A,
+ 0x01,
+ 0x0A, // resultCode success (Referral)
+ 0x04,
+ 0x00, // Empty matched Dn
+ 0x04,
+ 0x00, // Empty errorMessage
+ ( byte ) 0xA3,
+ 0x0C,
+ 0x04,
+ 0x08,
+ 'l',
+ 'd',
+ 'a',
+ 'p',
+ ':',
+ '/',
+ '/',
+ '/',
+ 0x04,
+ 0x00 } );
- String decodedPdu = Strings.dumpBytes(stream.array());
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
// Allocate a LdapMessage Container
@@ -540,7 +635,7 @@ public class LdapResultTest extends Abst
// Check the length
assertEquals( 0x1C, bb.limit() );
- String encodedPdu = Strings.dumpBytes(bb.array());
+ String encodedPdu = Strings.dumpBytes( bb.array() );
assertEquals( encodedPdu, decodedPdu );
}
@@ -565,17 +660,25 @@ public class LdapResultTest extends Abst
stream.put( new byte[]
{ 0x30, 0x0E, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x69, 0x09, // CHOICE { ..., addResponse AddResponse, ...
- 0x0A, 0x01, 0x0A, // resultCode success (Referral)
- 0x04, 0x00, // Empty matched Dn
- 0x04, 0x00, // Empty errorMessage
- ( byte ) 0xA3, 0x00, } );
+ 0x02,
+ 0x01,
+ 0x01, // messageID MessageID
+ 0x69,
+ 0x09, // CHOICE { ..., addResponse AddResponse, ...
+ 0x0A,
+ 0x01,
+ 0x0A, // resultCode success (Referral)
+ 0x04,
+ 0x00, // Empty matched Dn
+ 0x04,
+ 0x00, // Empty errorMessage
+ ( byte ) 0xA3,
+ 0x00, } );
stream.flip();
// Allocate a LdapMessage Container
- LdapMessageContainer<MessageDecorator<? extends Message>> container =
+ LdapMessageContainer<MessageDecorator<? extends Message>> container =
new LdapMessageContainer<MessageDecorator<? extends Message>>( codec );
// Decode the AddResponse PDU
Modified: directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.java Tue Jan 24 17:27:00 2012
@@ -68,35 +68,118 @@ public class AbandonRequestTest extends
ByteBuffer stream = ByteBuffer.allocate( 0x64 );
stream.put( new byte[]
{ 0x30, 0x62, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x03, // messageID MessageID
- 0x50, 0x01, 0x02, // CHOICE { ..., abandonRequest
+ 0x02,
+ 0x01,
+ 0x03, // messageID MessageID
+ 0x50,
+ 0x01,
+ 0x02, // CHOICE { ..., abandonRequest
// AbandonRequest,...
- ( byte ) 0xA0, 0x5A, // controls [0] Controls OPTIONAL }
- 0x30, 0x1A, // Control ::= SEQUENCE {
- // controlType LDAPOID,
- 0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '1',
- // criticality BOOLEAN DEFAULT FALSE,
- 0x01, 0x01, ( byte ) 0xFF,
- // controlValue OCTET STRING OPTIONAL }
- 0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f',
- 0x30, 0x17, // Control ::= SEQUENCE {
- // controlType LDAPOID,
- 0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
- // controlValue OCTET STRING OPTIONAL }
- 0x04, 0x06, 'g', 'h', 'i', 'j', 'k', 'l',
- 0x30, 0x12, // Control ::= SEQUENCE {
- // controlType LDAPOID,
- 0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '3',
- // criticality BOOLEAN DEFAULT FALSE }
- 0x01, 0x01, ( byte ) 0xFF,
- 0x30, 0x0F, // Control ::= SEQUENCE {
- // controlType LDAPOID}
- 0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '4' } );
+ ( byte ) 0xA0,
+ 0x5A, // controls [0] Controls OPTIONAL }
+ 0x30,
+ 0x1A, // Control ::= SEQUENCE {
+ // controlType LDAPOID,
+ 0x04,
+ 0x0D,
+ '1',
+ '.',
+ '3',
+ '.',
+ '6',
+ '.',
+ '1',
+ '.',
+ '5',
+ '.',
+ '5',
+ '.',
+ '1',
+ // criticality BOOLEAN DEFAULT FALSE,
+ 0x01,
+ 0x01,
+ ( byte ) 0xFF,
+ // controlValue OCTET STRING OPTIONAL }
+ 0x04,
+ 0x06,
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 0x30,
+ 0x17, // Control ::= SEQUENCE {
+ // controlType LDAPOID,
+ 0x04,
+ 0x0D,
+ '1',
+ '.',
+ '3',
+ '.',
+ '6',
+ '.',
+ '1',
+ '.',
+ '5',
+ '.',
+ '5',
+ '.',
+ '2',
+ // controlValue OCTET STRING OPTIONAL }
+ 0x04,
+ 0x06,
+ 'g',
+ 'h',
+ 'i',
+ 'j',
+ 'k',
+ 'l',
+ 0x30,
+ 0x12, // Control ::= SEQUENCE {
+ // controlType LDAPOID,
+ 0x04,
+ 0x0D,
+ '1',
+ '.',
+ '3',
+ '.',
+ '6',
+ '.',
+ '1',
+ '.',
+ '5',
+ '.',
+ '5',
+ '.',
+ '3',
+ // criticality BOOLEAN DEFAULT FALSE }
+ 0x01,
+ 0x01,
+ ( byte ) 0xFF,
+ 0x30,
+ 0x0F, // Control ::= SEQUENCE {
+ // controlType LDAPOID}
+ 0x04,
+ 0x0D,
+ '1',
+ '.',
+ '3',
+ '.',
+ '6',
+ '.',
+ '1',
+ '.',
+ '5',
+ '.',
+ '5',
+ '.',
+ '4' } );
stream.flip();
// Allocate a LdapMessageContainer Container
- LdapMessageContainer<AbandonRequestDecorator> ldapMessageContainer =
+ LdapMessageContainer<AbandonRequestDecorator> ldapMessageContainer =
new LdapMessageContainer<AbandonRequestDecorator>( codec );
// Decode the PDU
@@ -125,27 +208,28 @@ public class AbandonRequestTest extends
assertEquals( 4, controls.size() );
- CodecControl<? extends Control> control = (org.apache.directory.shared.ldap.codec.api.CodecControl<?> ) controls.get( "1.3.6.1.5.5.1" );
+ CodecControl<? extends Control> control = ( org.apache.directory.shared.ldap.codec.api.CodecControl<?> ) controls
+ .get( "1.3.6.1.5.5.1" );
assertEquals( "1.3.6.1.5.5.1", control.getOid() );
assertEquals( "0x61 0x62 0x63 0x64 0x65 0x66 ", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
assertTrue( control.isCritical() );
internalAbandonRequest.addControl( control );
- control = (org.apache.directory.shared.ldap.codec.api.CodecControl<?> ) controls.get( "1.3.6.1.5.5.2" );
+ control = ( org.apache.directory.shared.ldap.codec.api.CodecControl<?> ) controls.get( "1.3.6.1.5.5.2" );
assertEquals( "1.3.6.1.5.5.2", control.getOid() );
assertEquals( "0x67 0x68 0x69 0x6A 0x6B 0x6C ", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
assertFalse( control.isCritical() );
internalAbandonRequest.addControl( control );
- control = (org.apache.directory.shared.ldap.codec.api.CodecControl<?> ) controls.get( "1.3.6.1.5.5.3" );
+ control = ( org.apache.directory.shared.ldap.codec.api.CodecControl<?> ) controls.get( "1.3.6.1.5.5.3" );
assertEquals( "1.3.6.1.5.5.3", control.getOid() );
- assertEquals( "", Strings.dumpBytes((byte[]) control.getValue()) );
+ assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
assertTrue( control.isCritical() );
internalAbandonRequest.addControl( control );
- control = (org.apache.directory.shared.ldap.codec.api.CodecControl<?> ) controls.get( "1.3.6.1.5.5.4" );
+ control = ( org.apache.directory.shared.ldap.codec.api.CodecControl<?> ) controls.get( "1.3.6.1.5.5.4" );
assertEquals( "1.3.6.1.5.5.4", control.getOid() );
- assertEquals( "", Strings.dumpBytes((byte[]) control.getValue()) );
+ assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
assertFalse( control.isCritical() );
internalAbandonRequest.addControl( control );
@@ -192,16 +276,23 @@ public class AbandonRequestTest extends
stream.put( new byte[]
{ 0x30, 0x08, // LDAPMessage ::=SEQUENCE {
// messageID MessageID
- 0x02, 0x03, 0x00, ( byte ) 0x80, 0x13, 0x50, 0x01, 0x02 // CHOICE { ..., abandonRequest
+ 0x02,
+ 0x03,
+ 0x00,
+ ( byte ) 0x80,
+ 0x13,
+ 0x50,
+ 0x01,
+ 0x02 // CHOICE { ..., abandonRequest
// AbandonRequest,...
// AbandonRequest ::= [APPLICATION 16] MessageID
- } );
+ } );
- String decodedPdu = Strings.dumpBytes(stream.array());
+ String decodedPdu = Strings.dumpBytes( stream.array() );
stream.flip();
// Allocate a LdapMessageContainer Container
- LdapMessageContainer<AbandonRequestDecorator> ldapMessageContainer =
+ LdapMessageContainer<AbandonRequestDecorator> ldapMessageContainer =
new LdapMessageContainer<AbandonRequestDecorator>( codec );
// Decode the PDU
@@ -233,7 +324,7 @@ public class AbandonRequestTest extends
// Check the length
assertEquals( 0x0A, bb.limit() );
- String encodedPdu = Strings.dumpBytes(bb.array());
+ String encodedPdu = Strings.dumpBytes( bb.array() );
assertEquals( encodedPdu, decodedPdu );
}
@@ -256,15 +347,18 @@ public class AbandonRequestTest extends
ByteBuffer stream = ByteBuffer.allocate( 0x0A );
stream.put( new byte[]
{ 0x30, 0x08, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x50, 0x00 // CHOICE { ..., abandonRequest AbandonRequest,...
+ 0x02,
+ 0x01,
+ 0x01, // messageID MessageID
+ 0x50,
+ 0x00 // CHOICE { ..., abandonRequest AbandonRequest,...
// AbandonRequest ::= [APPLICATION 16] MessageID
- } );
+ } );
stream.flip();
// Allocate a LdapMessageContainer Container
- LdapMessageContainer<MessageDecorator<? extends Message>> ldapMessageContainer =
+ LdapMessageContainer<MessageDecorator<? extends Message>> ldapMessageContainer =
new LdapMessageContainer<MessageDecorator<? extends Message>>( codec );
// Decode the PDU
@@ -293,15 +387,19 @@ public class AbandonRequestTest extends
ByteBuffer stream = ByteBuffer.allocate( 0x0B );
stream.put( new byte[]
{ 0x30, 0x09, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x50, 0x01, ( byte ) 0xFF // CHOICE { ..., abandonRequest AbandonRequest,...
+ 0x02,
+ 0x01,
+ 0x01, // messageID MessageID
+ 0x50,
+ 0x01,
+ ( byte ) 0xFF // CHOICE { ..., abandonRequest AbandonRequest,...
// AbandonRequest ::= [APPLICATION 16] MessageID
- } );
+ } );
stream.flip();
// Allocate a LdapMessageContainer Container
- LdapMessageContainer<MessageDecorator<? extends Message>> ldapMessageContainer =
+ LdapMessageContainer<MessageDecorator<? extends Message>> ldapMessageContainer =
new LdapMessageContainer<MessageDecorator<? extends Message>>( codec );
// Decode the PDU