Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/intermediate/IntermediateResponseTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/intermediate/IntermediateResponseTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/intermediate/IntermediateResponseTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/intermediate/IntermediateResponseTest.java Mon Feb 1 15:04:10 2010 @@ -31,9 +31,9 @@ import org.apache.directory.shared.asn1.ber.IAsn1Container; import org.apache.directory.shared.asn1.codec.DecoderException; import org.apache.directory.shared.asn1.codec.EncoderException; -import org.apache.directory.shared.ldap.codec.ControlCodec; import org.apache.directory.shared.ldap.codec.LdapMessageCodec; import org.apache.directory.shared.ldap.codec.LdapMessageContainer; +import org.apache.directory.shared.ldap.codec.controls.CodecControl; import org.apache.directory.shared.ldap.util.StringTools; import org.junit.Test; @@ -165,13 +165,13 @@ assertEquals( "value", StringTools.utf8ToString( intermediateResponse.getResponseValue() ) ); // Check the Control - List controls = message.getControls(); + List controls = message.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = message.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = message.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x3A, message.computeLength() ); @@ -247,13 +247,13 @@ assertEquals( "", StringTools.utf8ToString( intermediateResponse.getResponseValue() ) ); // Check the Control - List controls = message.getControls(); + List controls = message.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = message.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = message.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x33, message.computeLength() ); Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java Mon Feb 1 15:04:10 2010 @@ -33,10 +33,10 @@ import org.apache.directory.shared.asn1.ber.IAsn1Container; import org.apache.directory.shared.asn1.codec.DecoderException; import org.apache.directory.shared.asn1.codec.EncoderException; -import org.apache.directory.shared.ldap.codec.ControlCodec; import org.apache.directory.shared.ldap.codec.LdapMessageCodec; import org.apache.directory.shared.ldap.codec.LdapMessageContainer; import org.apache.directory.shared.ldap.codec.ResponseCarryingException; +import org.apache.directory.shared.ldap.codec.controls.CodecControl; import org.apache.directory.shared.ldap.entry.EntryAttribute; import org.apache.directory.shared.ldap.entry.Modification; import org.apache.directory.shared.ldap.message.InternalMessage; @@ -1186,13 +1186,13 @@ assertEquals( 0, attributeValue.size() ); // Check the Control - List controls = message.getControls(); + List controls = message.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = message.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = message.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x54, message.computeLength() ); Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponseTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponseTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponseTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponseTest.java Mon Feb 1 15:04:10 2010 @@ -31,9 +31,9 @@ import org.apache.directory.shared.asn1.ber.IAsn1Container; import org.apache.directory.shared.asn1.codec.DecoderException; import org.apache.directory.shared.asn1.codec.EncoderException; -import org.apache.directory.shared.ldap.codec.ControlCodec; import org.apache.directory.shared.ldap.codec.LdapMessageCodec; import org.apache.directory.shared.ldap.codec.LdapMessageContainer; +import org.apache.directory.shared.ldap.codec.controls.CodecControl; import org.apache.directory.shared.ldap.message.ResultCodeEnum; import org.apache.directory.shared.ldap.util.StringTools; import org.junit.Test; @@ -171,13 +171,13 @@ assertEquals( "", modifyResponse.getLdapResult().getErrorMessage() ); // Check the Control - List controls = message.getControls(); + List controls = message.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = message.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = message.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x2B, message.computeLength() ); Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java Mon Feb 1 15:04:10 2010 @@ -31,10 +31,10 @@ import org.apache.directory.shared.asn1.ber.IAsn1Container; import org.apache.directory.shared.asn1.codec.DecoderException; import org.apache.directory.shared.asn1.codec.EncoderException; -import org.apache.directory.shared.ldap.codec.ControlCodec; import org.apache.directory.shared.ldap.codec.LdapMessageCodec; import org.apache.directory.shared.ldap.codec.LdapMessageContainer; import org.apache.directory.shared.ldap.codec.ResponseCarryingException; +import org.apache.directory.shared.ldap.codec.controls.CodecControl; import org.apache.directory.shared.ldap.message.InternalMessage; import org.apache.directory.shared.ldap.message.ModifyDnResponseImpl; import org.apache.directory.shared.ldap.message.ResultCodeEnum; @@ -335,13 +335,13 @@ assertEquals( "ou=system", modifyDNRequest.getNewSuperior().toString() ); // Check the Control - List controls = message.getControls(); + List controls = message.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = message.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = message.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x65, message.computeLength() ); @@ -491,13 +491,13 @@ assertEquals( "cn=testDNModify", modifyDNRequest.getNewRDN().toString() ); // Check the Control - List controls = message.getControls(); + List controls = message.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = message.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = message.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x5A, message.computeLength() ); Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.java Mon Feb 1 15:04:10 2010 @@ -31,9 +31,9 @@ import org.apache.directory.shared.asn1.ber.IAsn1Container; import org.apache.directory.shared.asn1.codec.DecoderException; import org.apache.directory.shared.asn1.codec.EncoderException; -import org.apache.directory.shared.ldap.codec.ControlCodec; import org.apache.directory.shared.ldap.codec.LdapMessageCodec; import org.apache.directory.shared.ldap.codec.LdapMessageContainer; +import org.apache.directory.shared.ldap.codec.controls.CodecControl; import org.apache.directory.shared.ldap.message.ResultCodeEnum; import org.apache.directory.shared.ldap.util.StringTools; import org.junit.Test; @@ -173,13 +173,13 @@ assertEquals( "", modifyDNResponse.getLdapResult().getErrorMessage() ); // Check the Control - List controls = message.getControls(); + List controls = message.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = message.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = message.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x2B, message.computeLength() ); Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java Mon Feb 1 15:04:10 2010 @@ -34,10 +34,10 @@ import org.apache.directory.shared.asn1.ber.IAsn1Container; import org.apache.directory.shared.asn1.codec.DecoderException; import org.apache.directory.shared.asn1.codec.EncoderException; -import org.apache.directory.shared.ldap.codec.ControlCodec; import org.apache.directory.shared.ldap.codec.LdapConstants; import org.apache.directory.shared.ldap.codec.LdapMessageCodec; import org.apache.directory.shared.ldap.codec.LdapMessageContainer; +import org.apache.directory.shared.ldap.codec.controls.CodecControl; import org.apache.directory.shared.ldap.constants.SchemaConstants; import org.apache.directory.shared.ldap.entry.EntryAttribute; import org.apache.directory.shared.ldap.filter.SearchScope; @@ -253,8 +253,11 @@ 0x04, 0x05, 'a', 't', 't', 'r', '2', // AttributeDescription // ::= LDAPString ( 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, 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(); @@ -299,13 +302,13 @@ } // Check the Control - List controls = message.getControls(); + List controls = message.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = message.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = message.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x0081, message.computeLength() ); @@ -344,39 +347,46 @@ 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 + 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 { + 0x0A, 0x01, 0x03, // derefAliases ENUMERATED { // neverDerefAliases (0), // derefInSearching (1), // derefFindingBaseObj (2), // derefAlways (3) }, // sizeLimit INTEGER (0 .. maxInt), (1000) - 0x02, 0x02, 0x03, ( byte ) 0xE8, + 0x02, 0x02, 0x03, ( byte ) 0xE8, // timeLimit INTEGER (0 .. maxInt), (1000) - 0x02, 0x02, 0x03, ( byte ) 0xE8, 0x01, 0x01, ( byte ) 0xFF, // typesOnly + 0x02, 0x02, 0x03, ( byte ) 0xE8, + 0x01, 0x01, ( byte ) 0xFF, // typesOnly // BOOLEAN, // (TRUE) // filter Filter, - ( byte ) 0xA4, 0x12, // Filter ::= CHOICE { + ( byte ) 0xA4, 0x12, // Filter ::= CHOICE { // substrings [4] SubstringFilter // } // SubstringFilter ::= SEQUENCE { - 0x04, 0x0B, // type AttributeDescription, - 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's', 0x30, 0x03, ( byte ) 0x81, 0x01, 't', // - 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF + 0x04, 0x0B, // type AttributeDescription, + 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's', + 0x30, 0x03, + ( byte ) 0x81, 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 } ); Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java Mon Feb 1 15:04:10 2010 @@ -38,12 +38,12 @@ import org.apache.directory.shared.asn1.codec.DecoderException; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.ldap.codec.AttributeValueAssertion; -import org.apache.directory.shared.ldap.codec.ControlCodec; import org.apache.directory.shared.ldap.codec.LdapConstants; import org.apache.directory.shared.ldap.codec.LdapMessageCodec; import org.apache.directory.shared.ldap.codec.LdapMessageContainer; import org.apache.directory.shared.ldap.codec.ResponseCarryingException; -import org.apache.directory.shared.ldap.codec.search.controls.subEntry.SubEntryControlCodec; +import org.apache.directory.shared.ldap.codec.controls.CodecControl; +import org.apache.directory.shared.ldap.codec.search.controls.subentries.SubentriesControlCodec; import org.apache.directory.shared.ldap.constants.SchemaConstants; import org.apache.directory.shared.ldap.entry.EntryAttribute; import org.apache.directory.shared.ldap.filter.SearchScope; @@ -1050,20 +1050,21 @@ ( 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', + ( 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 Asn1Decoder(); @@ -1093,14 +1094,14 @@ // this is a constant in Java 5 API String pagedResultsControlOID = "1.2.840.113556.1.4.319"; - ControlCodec pagedResultsControl = message.getControls( 0 ); - assertEquals( pagedResultsControlOID, pagedResultsControl.getControlType() ); - assertTrue( pagedResultsControl.getCriticality() ); + CodecControl pagedResultsControl = message.getControls( 0 ); + assertEquals( pagedResultsControlOID, pagedResultsControl.getOid() ); + assertTrue( pagedResultsControl.isCritical() ); // this is a constant in Java 5 API String manageReferralControlOID = "2.16.840.1.113730.3.4.2"; - ControlCodec manageReferralControl = message.getControls( 1 ); - assertEquals( manageReferralControlOID, manageReferralControl.getControlType() ); + CodecControl manageReferralControl = message.getControls( 1 ); + assertEquals( manageReferralControlOID, manageReferralControl.getOid() ); SearchRequestCodec sr = message.getSearchRequest(); assertEquals( "dc=my-domain,dc=com", sr.getBaseObject().toString() ); @@ -1118,7 +1119,7 @@ { ByteBuffer bb = message.encode( null ); String encodedPdu = StringTools.dumpBytes( bb.array() ); - assertEquals( encodedPdu, decodedPdu ); + assertEquals( decodedPdu, encodedPdu ); } catch ( EncoderException ee ) { @@ -1352,10 +1353,11 @@ // SubEntry Control String subEntryControlOID = "1.3.6.1.4.1.4203.1.10.1"; - ControlCodec subEntryControl = message.getControls( 0 ); - assertEquals( subEntryControlOID, subEntryControl.getControlType() ); - assertTrue( subEntryControl.getCriticality() ); - assertTrue( ( ( SubEntryControlCodec ) subEntryControl.getControlValue() ).isVisible() ); + CodecControl subEntryControl = message.getControls( 0 ); + assertEquals( subEntryControlOID, subEntryControl.getOid() ); + assertTrue( subEntryControl.isCritical() ); + assertTrue( subEntryControl instanceof SubentriesControlCodec ); + assertTrue( ((SubentriesControlCodec)subEntryControl).isVisible() ); SearchRequestCodec sr = message.getSearchRequest(); assertEquals( "dc=my-domain,dc=com", sr.getBaseObject().toString() ); @@ -1373,7 +1375,7 @@ { ByteBuffer bb = message.encode( null ); String encodedPdu = StringTools.dumpBytes( bb.array() ); - assertEquals( encodedPdu, decodedPdu ); + assertEquals( decodedPdu, encodedPdu ); } catch ( EncoderException ee ) { Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java Mon Feb 1 15:04:10 2010 @@ -31,9 +31,9 @@ import org.apache.directory.shared.asn1.ber.IAsn1Container; import org.apache.directory.shared.asn1.codec.DecoderException; import org.apache.directory.shared.asn1.codec.EncoderException; -import org.apache.directory.shared.ldap.codec.ControlCodec; import org.apache.directory.shared.ldap.codec.LdapMessageCodec; import org.apache.directory.shared.ldap.codec.LdapMessageContainer; +import org.apache.directory.shared.ldap.codec.controls.CodecControl; import org.apache.directory.shared.ldap.message.ResultCodeEnum; import org.apache.directory.shared.ldap.util.StringTools; import org.junit.Test; @@ -170,13 +170,13 @@ assertEquals( "", searchResultDone.getLdapResult().getErrorMessage() ); // Check the Control - List controls = message.getControls(); + List controls = message.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = message.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = message.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x2B, message.computeLength() ); Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java Mon Feb 1 15:04:10 2010 @@ -33,9 +33,9 @@ import org.apache.directory.shared.asn1.ber.IAsn1Container; import org.apache.directory.shared.asn1.codec.DecoderException; import org.apache.directory.shared.asn1.codec.EncoderException; -import org.apache.directory.shared.ldap.codec.ControlCodec; import org.apache.directory.shared.ldap.codec.LdapMessageCodec; import org.apache.directory.shared.ldap.codec.LdapMessageContainer; +import org.apache.directory.shared.ldap.codec.controls.CodecControl; import org.apache.directory.shared.ldap.entry.Entry; import org.apache.directory.shared.ldap.entry.EntryAttribute; import org.apache.directory.shared.ldap.util.StringTools; @@ -949,13 +949,13 @@ } // Check the Control - List controls = message.getControls(); + List controls = message.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = message.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = message.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x54, message.computeLength() ); @@ -1129,13 +1129,13 @@ } // Check the Control - List controls = message.getControls(); + List controls = message.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = message.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = message.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x56, message.computeLength() ); Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultReferenceTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultReferenceTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultReferenceTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultReferenceTest.java Mon Feb 1 15:04:10 2010 @@ -33,9 +33,9 @@ import org.apache.directory.shared.asn1.ber.IAsn1Container; import org.apache.directory.shared.asn1.codec.DecoderException; import org.apache.directory.shared.asn1.codec.EncoderException; -import org.apache.directory.shared.ldap.codec.ControlCodec; import org.apache.directory.shared.ldap.codec.LdapMessageCodec; import org.apache.directory.shared.ldap.codec.LdapMessageContainer; +import org.apache.directory.shared.ldap.codec.controls.CodecControl; import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException; import org.apache.directory.shared.ldap.util.LdapURL; import org.apache.directory.shared.ldap.util.StringTools; @@ -283,13 +283,13 @@ assertTrue( ldapUrlsSet.size() == 0 ); // Check the Control - List controls = message.getControls(); + List controls = message.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = message.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = message.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x3F5, message.computeLength() ); Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlTest.java Mon Feb 1 15:04:10 2010 @@ -20,21 +20,21 @@ package org.apache.directory.shared.ldap.codec.search.controls; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.nio.ByteBuffer; import org.apache.directory.shared.asn1.ber.Asn1Decoder; import org.apache.directory.shared.asn1.codec.DecoderException; -import org.apache.directory.shared.ldap.codec.search.controls.ChangeType; import org.apache.directory.shared.ldap.codec.search.controls.entryChange.EntryChangeControlCodec; import org.apache.directory.shared.ldap.codec.search.controls.entryChange.EntryChangeControlContainer; import org.apache.directory.shared.ldap.codec.search.controls.entryChange.EntryChangeControlDecoder; import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.util.StringTools; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertNull; /** @@ -64,6 +64,8 @@ bb.flip(); EntryChangeControlContainer container = new EntryChangeControlContainer(); + container.setEntryChangeControl( new EntryChangeControlCodec() ); + try { decoder.decode( bb, container ); @@ -102,6 +104,8 @@ bb.flip(); EntryChangeControlContainer container = new EntryChangeControlContainer(); + container.setEntryChangeControl( new EntryChangeControlCodec() ); + try { decoder.decode( bb, container ); @@ -139,6 +143,8 @@ bb.flip(); EntryChangeControlContainer container = new EntryChangeControlContainer(); + container.setEntryChangeControl( new EntryChangeControlCodec() ); + try { decoder.decode( bb, container ); @@ -179,7 +185,8 @@ bb.flip(); EntryChangeControlContainer container = new EntryChangeControlContainer(); - + container.setEntryChangeControl( new EntryChangeControlCodec() ); + try { decoder.decode( bb, container ); @@ -214,7 +221,8 @@ bb.flip(); EntryChangeControlContainer container = new EntryChangeControlContainer(); - + container.setEntryChangeControl( new EntryChangeControlCodec() ); + try { decoder.decode( bb, container ); @@ -252,7 +260,8 @@ bb.flip(); EntryChangeControlContainer container = new EntryChangeControlContainer(); - + container.setEntryChangeControl( new EntryChangeControlCodec() ); + try { decoder.decode( bb, container ); @@ -290,7 +299,8 @@ bb.flip(); EntryChangeControlContainer container = new EntryChangeControlContainer(); - + container.setEntryChangeControl( new EntryChangeControlCodec() ); + try { decoder.decode( bb, container ); @@ -312,15 +322,21 @@ @Test public void testEncodeEntryChangeControl() throws Exception { - ByteBuffer bb = ByteBuffer.allocate( 0x0D ); + ByteBuffer bb = ByteBuffer.allocate( 0x2A ); 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, 0x28, // Control + 0x04, 0x17, // OID (SyncRequestValue) + '2', '.', '1', '6', '.', '8', '4', '0', + '.', '1', '.', '1', '1', '3', '7', '3', + '0', '.', '3', '.', '4', '.', '7', + 0x04, 0x0D, + 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() ); @@ -330,7 +346,7 @@ entry.setChangeType( ChangeType.MODDN ); entry.setChangeNumber( 16 ); entry.setPreviousDn( new LdapDN( "a=b" ) ); - bb = entry.encode( null ); + bb = entry.encode( ByteBuffer.allocate( entry.computeLength() ) ); String decoded = StringTools.dumpBytes( bb.array() ); assertEquals( expected, decoded ); } @@ -342,16 +358,22 @@ @Test public void testEncodeEntryChangeControlLong() throws Exception { - ByteBuffer bb = ByteBuffer.allocate( 0x13 ); + ByteBuffer bb = ByteBuffer.allocate( 0x30 ); bb.put( new byte[] { - 0x30, 0x11, // EntryChangeNotification ::= SEQUENCE { - 0x0A, 0x01, 0x08, // changeType ENUMERATED { - // modDN (8) - // } - 0x04, 0x03, 'a', '=', 'b', // previousDN LDAPDN OPTIONAL, -- modifyDN ops. only - 0x02, 0x07, // changeNumber INTEGER OPTIONAL -- if supported - 0x12, 0x34, 0x56, 0x78, (byte)0x9a, (byte)0xbc, (byte)0xde + 0x30, 0x2E, // Control + 0x04, 0x17, // OID (SyncRequestValue) + '2', '.', '1', '6', '.', '8', '4', '0', + '.', '1', '.', '1', '1', '3', '7', '3', + '0', '.', '3', '.', '4', '.', '7', + 0x04, 0x13, + 0x30, 0x11, // EntryChangeNotification ::= SEQUENCE { + 0x0A, 0x01, 0x08, // changeType ENUMERATED { + // modDN (8) + // } + 0x04, 0x03, 'a', '=', 'b', // previousDN LDAPDN OPTIONAL, -- modifyDN ops. only + 0x02, 0x07, // changeNumber INTEGER OPTIONAL -- if supported + 0x12, 0x34, 0x56, 0x78, (byte)0x9a, (byte)0xbc, (byte)0xde } ); String expected = StringTools.dumpBytes( bb.array() ); @@ -361,7 +383,7 @@ entry.setChangeType( ChangeType.MODDN ); entry.setChangeNumber( 5124095576030430L ); entry.setPreviousDn( new LdapDN( "a=b" ) ); - bb = entry.encode( null ); + bb = entry.encode( ByteBuffer.allocate( entry.computeLength() ) ); String decoded = StringTools.dumpBytes( bb.array() ); assertEquals( expected, decoded ); } Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlTest.java Mon Feb 1 15:04:10 2010 @@ -20,20 +20,20 @@ package org.apache.directory.shared.ldap.codec.search.controls; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.nio.ByteBuffer; import org.apache.directory.shared.asn1.ber.Asn1Decoder; import org.apache.directory.shared.asn1.codec.DecoderException; -import org.apache.directory.shared.ldap.codec.search.controls.pSearch.PSearchControlCodec; -import org.apache.directory.shared.ldap.codec.search.controls.pSearch.PSearchControlContainer; -import org.apache.directory.shared.ldap.codec.search.controls.pSearch.PSearchControlDecoder; +import org.apache.directory.shared.ldap.codec.search.controls.persistentSearch.PersistentSearchControlCodec; +import org.apache.directory.shared.ldap.codec.search.controls.persistentSearch.PersistentSearchControlContainer; +import org.apache.directory.shared.ldap.codec.search.controls.persistentSearch.PersistentSearchControlDecoder; import org.apache.directory.shared.ldap.util.StringTools; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - /** * Test the PSearchControlTest codec @@ -48,23 +48,29 @@ @Test public void testEncodePSearchControl() throws Exception { - ByteBuffer bb = ByteBuffer.allocate( 0x0b ); + ByteBuffer bb = ByteBuffer.allocate( 0x28 ); bb.put( new byte[] { - 0x30, 0x09, // PersistentSearch ::= SEQUENCE { - 0x02, 0x01, 0x01, // changeTypes INTEGER, - 0x01, 0x01, 0x00, // changesOnly BOOLEAN, - 0x01, 0x01, 0x00 // returnECs BOOLEAN + 0x30, 0x26, // Control + 0x04, 0x17, // OID (SyncRequestValue) + '2', '.', '1', '6', '.', '8', '4', '0', + '.', '1', '.', '1', '1', '3', '7', '3', + '0', '.', '3', '.', '4', '.', '3', + 0x04, 0x0B, + 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(); - PSearchControlCodec ctrl = new PSearchControlCodec(); + PersistentSearchControlCodec ctrl = new PersistentSearchControlCodec(); ctrl.setChangesOnly( false ); ctrl.setReturnECs( false ); ctrl.setChangeTypes( 1 ); - bb = ctrl.encode( null ); + bb = ctrl.encode(ByteBuffer.allocate( ctrl.computeLength() ) ); String decoded = StringTools.dumpBytes( bb.array() ); assertEquals( expected, decoded ); } @@ -75,7 +81,7 @@ @Test public void testDecodeModifyDNRequestSuccessChangeTypesAddModDN() { - Asn1Decoder decoder = new PSearchControlDecoder(); + Asn1Decoder decoder = new PersistentSearchControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x0b ); bb.put( new byte[] { @@ -86,7 +92,9 @@ } ); bb.flip(); - PSearchControlContainer container = new PSearchControlContainer(); + PersistentSearchControlContainer container = new PersistentSearchControlContainer(); + container.setPSearchControl( new PersistentSearchControlCodec() ); + try { decoder.decode( bb, container ); @@ -96,10 +104,10 @@ fail( de.getMessage() ); } - PSearchControlCodec control = container.getPSearchControl(); + PersistentSearchControlCodec control = container.getPSearchControl(); int changeTypes = control.getChangeTypes(); - assertEquals( PSearchControlCodec.CHANGE_TYPE_ADD, changeTypes & PSearchControlCodec.CHANGE_TYPE_ADD ); - assertEquals( PSearchControlCodec.CHANGE_TYPE_MODDN, changeTypes & PSearchControlCodec.CHANGE_TYPE_MODDN ); + assertEquals( PersistentSearchControlCodec.CHANGE_TYPE_ADD, changeTypes & PersistentSearchControlCodec.CHANGE_TYPE_ADD ); + assertEquals( PersistentSearchControlCodec.CHANGE_TYPE_MODDN, changeTypes & PersistentSearchControlCodec.CHANGE_TYPE_MODDN ); assertEquals( false, control.isChangesOnly() ); assertEquals( false, control.isReturnECs() ); } @@ -111,7 +119,7 @@ @Test public void testDecodeModifyDNRequestSuccessChangeTypes0() { - Asn1Decoder decoder = new PSearchControlDecoder(); + Asn1Decoder decoder = new PersistentSearchControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x0b ); bb.put( new byte[] { @@ -122,7 +130,9 @@ } ); bb.flip(); - PSearchControlContainer container = new PSearchControlContainer(); + PersistentSearchControlContainer container = new PersistentSearchControlContainer(); + container.setPSearchControl( new PersistentSearchControlCodec() ); + try { decoder.decode( bb, container ); @@ -141,7 +151,7 @@ @Test public void testDecodeModifyDNRequestSuccessChangeTypes22() { - Asn1Decoder decoder = new PSearchControlDecoder(); + Asn1Decoder decoder = new PersistentSearchControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x0b ); bb.put( new byte[] { @@ -152,7 +162,9 @@ } ); bb.flip(); - PSearchControlContainer container = new PSearchControlContainer(); + PersistentSearchControlContainer container = new PersistentSearchControlContainer(); + container.setPSearchControl( new PersistentSearchControlCodec() ); + try { decoder.decode( bb, container ); @@ -170,7 +182,7 @@ @Test public void testDecodeModifyDNRequestSuccessNullSequence() { - Asn1Decoder decoder = new PSearchControlDecoder(); + Asn1Decoder decoder = new PersistentSearchControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x02 ); bb.put( new byte[] { @@ -178,7 +190,9 @@ } ); bb.flip(); - PSearchControlContainer container = new PSearchControlContainer(); + PersistentSearchControlContainer container = new PersistentSearchControlContainer(); + container.setPSearchControl( new PersistentSearchControlCodec() ); + try { decoder.decode( bb, container ); @@ -196,7 +210,7 @@ @Test public void testDecodeModifyDNRequestSuccessWithoutChangeTypes() { - Asn1Decoder decoder = new PSearchControlDecoder(); + Asn1Decoder decoder = new PersistentSearchControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x08 ); bb.put( new byte[] { @@ -206,7 +220,9 @@ } ); bb.flip(); - PSearchControlContainer container = new PSearchControlContainer(); + PersistentSearchControlContainer container = new PersistentSearchControlContainer(); + container.setPSearchControl( new PersistentSearchControlCodec() ); + try { decoder.decode( bb, container ); @@ -224,7 +240,7 @@ @Test public void testDecodeModifyDNRequestSuccessWithoutChangesOnly() { - Asn1Decoder decoder = new PSearchControlDecoder(); + Asn1Decoder decoder = new PersistentSearchControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x08 ); bb.put( new byte[] { @@ -234,7 +250,9 @@ } ); bb.flip(); - PSearchControlContainer container = new PSearchControlContainer(); + PersistentSearchControlContainer container = new PersistentSearchControlContainer(); + container.setPSearchControl( new PersistentSearchControlCodec() ); + try { decoder.decode( bb, container ); @@ -252,7 +270,7 @@ @Test public void testDecodeModifyDNRequestSuccessWithoutReturnECs() { - Asn1Decoder decoder = new PSearchControlDecoder(); + Asn1Decoder decoder = new PersistentSearchControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x08 ); bb.put( new byte[] { @@ -262,7 +280,9 @@ } ); bb.flip(); - PSearchControlContainer container = new PSearchControlContainer(); + PersistentSearchControlContainer container = new PersistentSearchControlContainer(); + container.setPSearchControl( new PersistentSearchControlCodec() ); + try { decoder.decode( bb, container ); Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PagedSearchControlTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PagedSearchControlTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PagedSearchControlTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PagedSearchControlTest.java Mon Feb 1 15:04:10 2010 @@ -20,20 +20,21 @@ package org.apache.directory.shared.ldap.codec.search.controls; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.nio.ByteBuffer; import java.util.Arrays; import org.apache.directory.shared.asn1.ber.Asn1Decoder; import org.apache.directory.shared.asn1.codec.DecoderException; -import org.apache.directory.shared.ldap.codec.search.controls.pagedSearch.PagedSearchControlCodec; -import org.apache.directory.shared.ldap.codec.search.controls.pagedSearch.PagedSearchControlContainer; -import org.apache.directory.shared.ldap.codec.search.controls.pagedSearch.PagedSearchControlDecoder; +import org.apache.directory.shared.ldap.codec.search.controls.pagedSearch.PagedResultsControlCodec; +import org.apache.directory.shared.ldap.codec.search.controls.pagedSearch.PagedResultsControlContainer; +import org.apache.directory.shared.ldap.codec.search.controls.pagedSearch.PagedResultsControlDecoder; import org.apache.directory.shared.ldap.util.StringTools; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertNotNull; /** @@ -49,17 +50,18 @@ @Test public void testEncodePagedSearchControl() throws Exception { - Asn1Decoder decoder = new PagedSearchControlDecoder(); - ByteBuffer bb = ByteBuffer.allocate( 0x0b ); + Asn1Decoder decoder = new PagedResultsControlDecoder(); + ByteBuffer bb = ByteBuffer.allocate( 0x2A ); bb.put( new byte[] { - 0x30, 0x09, // realSearchControlValue ::= SEQUENCE { - 0x02, 0x01, 0x20, // size INTEGER, - 0x04, 0x04, 't', 'e', 's', 't' // cookie OCTET STRING, + 0x30, 0x09, // realSearchControlValue ::= SEQUENCE { + 0x02, 0x01, 0x20, // size INTEGER, + 0x04, 0x04, 't', 'e', 's', 't' // cookie OCTET STRING, } ); bb.flip(); - PagedSearchControlContainer container = new PagedSearchControlContainer(); + PagedResultsControlContainer container = new PagedResultsControlContainer(); + container.setPagedSearchControl( new PagedResultsControlCodec() ); try { @@ -71,19 +73,35 @@ fail( de.getMessage() ); } - PagedSearchControlCodec pagedSearch = container.getPagedSearchControl(); + PagedResultsControlCodec pagedSearch = container.getPagedSearchControl(); assertEquals( 32, pagedSearch.getSize() ); assertTrue( Arrays.equals( StringTools.getBytesUtf8( "test" ), pagedSearch.getCookie() ) ); - String expected = StringTools.dumpBytes( bb.array() ); bb.flip(); - PagedSearchControlCodec ctrl = new PagedSearchControlCodec(); + ByteBuffer buffer = ByteBuffer.allocate( 0x27 ); + buffer.put( new byte[] + { + 0x30, 0x25, // Control + 0x04, 0x16, // OID (PagedSearch) + '1', '.', '2', '.', '8', '4', '0', '.', + '1', '1', '3', '5', '5', '6', '.', '1', + '.', '4', '.', '3', '1', '9', + 0x04, 0x0B, + 0x30, 0x09, // realSearchControlValue ::= SEQUENCE { + 0x02, 0x01, 0x20, // size INTEGER, + 0x04, 0x04, 't', 'e', 's', 't' // cookie OCTET STRING, + } ); + buffer.flip(); + + PagedResultsControlCodec ctrl = new PagedResultsControlCodec(); ctrl.setSize( 32 ); ctrl.setCookie( StringTools.getBytesUtf8( "test" ) ); - bb = ctrl.encode( null ); + + bb = ctrl.encode( ByteBuffer.allocate( ctrl.computeLength() ) ); String decoded = StringTools.dumpBytes( bb.array() ); + String expected = StringTools.dumpBytes( buffer.array() ); assertEquals( expected, decoded ); } @@ -94,7 +112,7 @@ @Test public void testDecodePagedSearchRequestNoCookie() { - Asn1Decoder decoder = new PagedSearchControlDecoder(); + Asn1Decoder decoder = new PagedResultsControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x05 ); bb.put( new byte[] { @@ -103,7 +121,8 @@ } ); bb.flip(); - PagedSearchControlContainer container = new PagedSearchControlContainer(); + PagedResultsControlContainer container = new PagedResultsControlContainer(); + container.setPagedSearchControl( new PagedResultsControlCodec() ); try { @@ -123,16 +142,17 @@ @Test public void testDecodePagedSearchRequestNoSize() { - Asn1Decoder decoder = new PagedSearchControlDecoder(); + Asn1Decoder decoder = new PagedResultsControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x08 ); bb.put( new byte[] { - 0x30, 0x06, // realSearchControlValue ::= SEQUENCE { + 0x30, 0x06, // realSearchControlValue ::= SEQUENCE { 0x04, 0x04, 't', 'e', 's', 't' // cookie OCTET STRING, } ); bb.flip(); - PagedSearchControlContainer container = new PagedSearchControlContainer(); + PagedResultsControlContainer container = new PagedResultsControlContainer(); + container.setPagedSearchControl( new PagedResultsControlCodec() ); try { @@ -152,7 +172,7 @@ @Test public void testDecodePagedSearchRequestNoSizeNoCookie() { - Asn1Decoder decoder = new PagedSearchControlDecoder(); + Asn1Decoder decoder = new PagedResultsControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x02 ); bb.put( new byte[] { @@ -160,7 +180,8 @@ } ); bb.flip(); - PagedSearchControlContainer container = new PagedSearchControlContainer(); + PagedResultsControlContainer container = new PagedResultsControlContainer(); + container.setPagedSearchControl( new PagedResultsControlCodec() ); try { @@ -180,17 +201,18 @@ @Test public void testEncodePagedSearchControlNegativeSize() throws Exception { - Asn1Decoder decoder = new PagedSearchControlDecoder(); + Asn1Decoder decoder = new PagedResultsControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x0b ); bb.put( new byte[] { - 0x30, 0x09, // realSearchControlValue ::= SEQUENCE { - 0x02, 0x01, (byte)0xFF, // size INTEGER, + 0x30, 0x09, // realSearchControlValue ::= SEQUENCE { + 0x02, 0x01, (byte)0xFF, // size INTEGER, 0x04, 0x04, 't', 'e', 's', 't' // cookie OCTET STRING, } ); bb.flip(); - PagedSearchControlContainer container = new PagedSearchControlContainer(); + PagedResultsControlContainer container = new PagedResultsControlContainer(); + container.setPagedSearchControl( new PagedResultsControlCodec() ); try { @@ -202,19 +224,36 @@ fail( de.getMessage() ); } - PagedSearchControlCodec pagedSearch = container.getPagedSearchControl(); + PagedResultsControlCodec pagedSearch = container.getPagedSearchControl(); assertEquals( Integer.MAX_VALUE, pagedSearch.getSize() ); assertTrue( Arrays.equals( StringTools.getBytesUtf8( "test" ), pagedSearch.getCookie() ) ); - String expected = StringTools.dumpBytes( bb.array() ); bb.flip(); - PagedSearchControlCodec ctrl = new PagedSearchControlCodec(); + + ByteBuffer buffer = ByteBuffer.allocate( 0x27 ); + buffer.put( new byte[] + { + 0x30, 0x25, // Control + 0x04, 0x16, // OID (PagedSearch) + '1', '.', '2', '.', '8', '4', '0', '.', + '1', '1', '3', '5', '5', '6', '.', '1', + '.', '4', '.', '3', '1', '9', + 0x04, 0x0B, + 0x30, 0x09, // realSearchControlValue ::= SEQUENCE { + 0x02, 0x01, (byte)0xFF, // size INTEGER, + 0x04, 0x04, 't', 'e', 's', 't' // cookie OCTET STRING, + } ); + buffer.flip(); + + PagedResultsControlCodec ctrl = new PagedResultsControlCodec(); ctrl.setSize( -1 ); ctrl.setCookie( StringTools.getBytesUtf8( "test" ) ); - bb = ctrl.encode( null ); + + bb = ctrl.encode( ByteBuffer.allocate( ctrl.computeLength() ) ); String decoded = StringTools.dumpBytes( bb.array() ); + String expected = StringTools.dumpBytes( buffer.array() ); assertEquals( expected, decoded ); } @@ -225,18 +264,19 @@ @Test public void testEncodePagedSearchControlEmptySize() throws Exception { - Asn1Decoder decoder = new PagedSearchControlDecoder(); + Asn1Decoder decoder = new PagedResultsControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x0a ); bb.put( new byte[] { - 0x30, 0x08, // realSearchControlValue ::= SEQUENCE { - 0x02, 0x00, // size INTEGER, + 0x30, 0x08, // realSearchControlValue ::= SEQUENCE { + 0x02, 0x00, // size INTEGER, 0x04, 0x04, 't', 'e', 's', 't' // cookie OCTET STRING, } ); bb.flip(); - PagedSearchControlContainer container = new PagedSearchControlContainer(); - + PagedResultsControlContainer container = new PagedResultsControlContainer(); + container.setPagedSearchControl( new PagedResultsControlCodec() ); + try { decoder.decode( bb, container ); @@ -255,7 +295,7 @@ @Test public void testEncodePagedSearchControlEmptyCookie() throws Exception { - Asn1Decoder decoder = new PagedSearchControlDecoder(); + Asn1Decoder decoder = new PagedResultsControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x07 ); bb.put( new byte[] { @@ -264,10 +304,10 @@ 0x04, 0x00 // cookie OCTET STRING, } ); bb.flip(); - String expected = StringTools.dumpBytes( bb.array() ); - PagedSearchControlContainer container = new PagedSearchControlContainer(); - + PagedResultsControlContainer container = new PagedResultsControlContainer(); + container.setPagedSearchControl( new PagedResultsControlCodec() ); + try { decoder.decode( bb, container ); @@ -278,16 +318,34 @@ fail( de.getMessage() ); } - PagedSearchControlCodec pagedSearch = container.getPagedSearchControl(); + PagedResultsControlCodec pagedSearch = container.getPagedSearchControl(); assertEquals( 32, pagedSearch.getSize() ); assertNotNull( pagedSearch.getCookie() ); assertEquals( StringTools.EMPTY_BYTES, pagedSearch.getCookie() ); - PagedSearchControlCodec ctrl = new PagedSearchControlCodec(); + ByteBuffer buffer = ByteBuffer.allocate( 0x23 ); + buffer.put( new byte[] + { + 0x30, 0x21, // Control + 0x04, 0x16, // OID (PagedSearch) + '1', '.', '2', '.', '8', '4', '0', '.', + '1', '1', '3', '5', '5', '6', '.', '1', + '.', '4', '.', '3', '1', '9', + 0x04, 0x07, + 0x30, 0x05, // realSearchControlValue ::= SEQUENCE { + 0x02, 0x01, 0x20, // size INTEGER, + 0x04, 0x00 // cookie OCTET STRING, + } ); + buffer.flip(); + + PagedResultsControlCodec ctrl = new PagedResultsControlCodec(); ctrl.setSize( 32 ); ctrl.setCookie( null ); - bb = ctrl.encode( null ); + + bb = ctrl.encode( ByteBuffer.allocate( ctrl.computeLength() ) ); String decoded = StringTools.dumpBytes( bb.array() ); + String expected = StringTools.dumpBytes( buffer.array() ); assertEquals( expected, decoded ); + } } \ No newline at end of file Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java Mon Feb 1 15:04:10 2010 @@ -20,18 +20,21 @@ package org.apache.directory.shared.ldap.codec.search.controls; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.nio.ByteBuffer; import org.apache.directory.shared.asn1.ber.Asn1Decoder; -import org.apache.directory.shared.asn1.ber.IAsn1Container; import org.apache.directory.shared.asn1.codec.DecoderException; -import org.apache.directory.shared.ldap.codec.search.controls.subEntry.SubEntryControlCodec; -import org.apache.directory.shared.ldap.codec.search.controls.subEntry.SubEntryControlContainer; -import org.apache.directory.shared.ldap.codec.search.controls.subEntry.SubEntryControlDecoder; +import org.apache.directory.shared.asn1.codec.EncoderException; +import org.apache.directory.shared.ldap.codec.search.controls.subentries.SubentriesControlCodec; +import org.apache.directory.shared.ldap.codec.search.controls.subentries.SubentriesControlContainer; +import org.apache.directory.shared.ldap.codec.search.controls.subentries.SubentriesControlDecoder; +import org.apache.directory.shared.ldap.util.StringTools; import org.junit.Test; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertFalse; /** @@ -47,14 +50,17 @@ @Test public void testDecodeSubEntryVisibilityTrue() { - Asn1Decoder decoder = new SubEntryControlDecoder(); + Asn1Decoder decoder = new SubentriesControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x03 ); bb.put( new byte[] - { 0x01, 0x01, ( byte ) 0xFF // Visibility ::= BOOLEAN + { + 0x01, 0x01, ( byte ) 0xFF // Visibility ::= BOOLEAN } ); bb.flip(); - SubEntryControlContainer container = new SubEntryControlContainer(); + SubentriesControlContainer container = new SubentriesControlContainer(); + container.setSubEntryControl( new SubentriesControlCodec() ); + try { decoder.decode( bb, container ); @@ -65,8 +71,34 @@ fail( de.getMessage() ); } - SubEntryControlCodec control = container.getSubEntryControl(); + SubentriesControlCodec control = container.getSubEntryControl(); assertTrue( control.isVisible() ); + // test encoding + try + { + ByteBuffer buffer = ByteBuffer.allocate( 0x20 ); + buffer.put( new byte[] + { + 0x30, 0x1E, // Control + 0x04, 0x17, // OID (Subentries) + '1', '.', '3', '.', '6', '.', '1', '.', + '4', '.', '1', '.', '4', '2', '0', '3', + '.', '1', '.', '1', '0', '.', '1', + 0x04, 0x03, + 0x01, 0x01, (byte)0xFF // Visibility ::= BOOLEAN + } ); + + buffer.flip(); + + bb = control.encode( ByteBuffer.allocate( control.computeLength() ) ); + String expected = StringTools.dumpBytes( buffer.array() ); + String decoded = StringTools.dumpBytes( bb.array() ); + assertEquals( expected, decoded ); + } + catch( EncoderException e ) + { + fail( e.getMessage() ); + } } @@ -76,14 +108,17 @@ @Test public void testDecodeSubEntryVisibilityFalse() { - Asn1Decoder decoder = new SubEntryControlDecoder(); + Asn1Decoder decoder = new SubentriesControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x03 ); bb.put( new byte[] - { 0x01, 0x01, 0x00 // Visibility ::= BOOLEAN + { + 0x01, 0x01, 0x00 // Visibility ::= BOOLEAN } ); bb.flip(); - SubEntryControlContainer container = new SubEntryControlContainer(); + SubentriesControlContainer container = new SubentriesControlContainer(); + container.setSubEntryControl( new SubentriesControlCodec() ); + try { decoder.decode( bb, container ); @@ -94,8 +129,35 @@ fail( de.getMessage() ); } - SubEntryControlCodec control = container.getSubEntryControl(); + SubentriesControlCodec control = container.getSubEntryControl(); assertFalse( control.isVisible() ); + + // test encoding + try + { + ByteBuffer buffer = ByteBuffer.allocate( 0x20 ); + buffer.put( new byte[] + { + 0x30, 0x1E, // Control + 0x04, 0x17, // OID (Subentries) + '1', '.', '3', '.', '6', '.', '1', '.', + '4', '.', '1', '.', '4', '2', '0', '3', + '.', '1', '.', '1', '0', '.', '1', + 0x04, 0x03, + 0x01, 0x01, 0x00 // Visibility ::= BOOLEAN + } ); + + buffer.flip(); + + bb = control.encode( ByteBuffer.allocate( control.computeLength() ) ); + String expected = StringTools.dumpBytes( buffer.array() ); + String decoded = StringTools.dumpBytes( bb.array() ); + assertEquals( expected, decoded ); + } + catch( EncoderException e ) + { + fail( e.getMessage() ); + } } @@ -105,17 +167,19 @@ @Test public void testDecodeSubEntryEmptyVisibility() { - Asn1Decoder decoder = new SubEntryControlDecoder(); + Asn1Decoder decoder = new SubentriesControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x02 ); bb.put( new byte[] - { 0x01, 0x00 // Visibility ::= BOOLEAN + { + 0x01, 0x00 // Visibility ::= BOOLEAN } ); bb.flip(); // Allocate a LdapMessage Container - IAsn1Container container = new SubEntryControlContainer(); + SubentriesControlContainer container = new SubentriesControlContainer(); + container.setSubEntryControl( new SubentriesControlCodec() ); // Decode a SubEntryControl PDU try @@ -136,17 +200,19 @@ @Test public void testDecodeSubEntryBad() { - Asn1Decoder decoder = new SubEntryControlDecoder(); + Asn1Decoder decoder = new SubentriesControlDecoder(); ByteBuffer bb = ByteBuffer.allocate( 0x03 ); bb.put( new byte[] - { 0x02, 0x01, 0x01 // Visibility ::= BOOLEAN + { + 0x02, 0x01, 0x01 // Visibility ::= BOOLEAN } ); bb.flip(); // Allocate a LdapMessage Container - IAsn1Container container = new SubEntryControlContainer(); + SubentriesControlContainer container = new SubentriesControlContainer(); + container.setSubEntryControl( new SubentriesControlCodec() ); // Decode a SubEntryControl PDU try Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java Mon Feb 1 15:04:10 2010 @@ -31,9 +31,9 @@ import org.apache.directory.shared.asn1.ber.IAsn1Container; import org.apache.directory.shared.asn1.codec.DecoderException; import org.apache.directory.shared.asn1.codec.EncoderException; -import org.apache.directory.shared.ldap.codec.ControlCodec; import org.apache.directory.shared.ldap.codec.LdapMessageCodec; import org.apache.directory.shared.ldap.codec.LdapMessageContainer; +import org.apache.directory.shared.ldap.codec.controls.CodecControl; import org.apache.directory.shared.ldap.util.StringTools; import org.junit.Test; @@ -142,13 +142,13 @@ assertEquals( 1, ldapMessage.getMessageId() ); // Check the Control - List controls = ldapMessage.getControls(); + List controls = ldapMessage.getControls(); assertEquals( 1, controls.size() ); - ControlCodec control = ldapMessage.getControls( 0 ); - assertEquals( "2.16.840.1.113730.3.4.2", control.getControlType() ); - assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) ); + CodecControl control = ldapMessage.getControls( 0 ); + assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() ); + assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) ); // Check the length assertEquals( 0x24, ldapMessage.computeLength() ); Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractMessageTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractMessageTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractMessageTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractMessageTest.java Mon Feb 1 15:04:10 2010 @@ -23,7 +23,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.apache.directory.shared.ldap.message.control.ControlImpl; +import org.apache.directory.shared.ldap.codec.controls.CodecControlImpl; import org.junit.Test; @@ -127,16 +127,11 @@ private static final long serialVersionUID = 1L; }; - msg0.add( new ControlImpl( "0.0" ) + msg0.add( new CodecControlImpl( "0.0" ) { private static final long serialVersionUID = 1L; - public void setOid( String oid ) - { - } - - public boolean isCritical() { return false; Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractResultResponseTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractResultResponseTest.java?rev=905297&r1=905296&r2=905297&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractResultResponseTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AbstractResultResponseTest.java Mon Feb 1 15:04:10 2010 @@ -25,7 +25,7 @@ import javax.naming.InvalidNameException; -import org.apache.directory.shared.ldap.message.control.ControlImpl; +import org.apache.directory.shared.ldap.codec.controls.CodecControlImpl; import org.apache.directory.shared.ldap.name.LdapDN; import org.junit.Test; @@ -187,16 +187,11 @@ private static final long serialVersionUID = 1L; }; - msg0.add( new ControlImpl( "0.0" ) + msg0.add( new CodecControlImpl( "0.0" ) { private static final long serialVersionUID = 1L; - public void setOid( String oid ) - { - } - - public boolean isCritical() { return false;