directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1065039 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java
Date Sat, 29 Jan 2011 15:31:44 GMT
Author: elecharny
Date: Sat Jan 29 15:31:44 2011
New Revision: 1065039

URL: http://svn.apache.org/viewvc?rev=1065039&view=rev
Log:
Fixed unbindRequest tests. 
Fixed a bug in the grammar

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=1065039&r1=1065038&r2=1065039&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
Sat Jan 29 15:31:44 2011
@@ -20,7 +20,7 @@
 package org.apache.directory.shared.ldap.codec;
 
 
-import org.apache.directory.shared.asn1.DecoderException; 
+import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.asn1.ber.grammar.AbstractGrammar;
 import org.apache.directory.shared.asn1.ber.grammar.Action;
 import org.apache.directory.shared.asn1.ber.grammar.Grammar;
@@ -131,6 +131,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.message.SearchResultDoneImpl;
 import org.apache.directory.shared.ldap.model.message.SearchResultEntryImpl;
 import org.apache.directory.shared.ldap.model.message.SearchResultReferenceImpl;
+import org.apache.directory.shared.ldap.model.message.UnbindRequestImpl;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.model.name.Rdn;
 import org.apache.directory.shared.util.StringConstants;
@@ -300,7 +301,8 @@ public final class LdapMessageGrammar ex
                 public void action( LdapMessageContainer<UnbindRequestDecorator> container
) throws DecoderException
                 {
                     // Create the UnbindRequest LdapMessage instance and store it in the
container
-                    UnbindRequestDecorator unbindRequest = container.getMessage();
+                    UnbindRequestDecorator unbindRequest = new UnbindRequestDecorator( 
+                        container.getLdapCodecService(), new UnbindRequestImpl( container.getMessageId()
) );
                     container.setMessage( unbindRequest );
 
                     TLV tlv = container.getCurrentTLV();

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=1065039&r1=1065038&r2=1065039&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
Sat Jan 29 15:31:44 2011
@@ -32,12 +32,15 @@ import org.apache.directory.junit.tools.
 import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
-import org.apache.directory.shared.asn1.ber.Asn1Container;
-import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.DefaultLdapCodecService;
+import org.apache.directory.shared.ldap.codec.ICodecControl;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.codec.LdapEncoder;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.UnbindRequestDecorator;
+import org.apache.directory.shared.ldap.model.message.Control;
 import org.apache.directory.shared.ldap.model.message.UnbindRequest;
 import org.apache.directory.shared.ldap.model.message.UnbindRequestImpl;
-import org.apache.directory.shared.ldap.model.message.Control;
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -51,8 +54,10 @@ import org.junit.runner.RunWith;
 public class UnBindRequestTest
 {
     /** The encoder instance */
-    LdapEncoder encoder = new LdapEncoder();
+    private LdapEncoder encoder = new LdapEncoder();
 
+    /** The codec service */
+    private ILdapCodecService codec = new DefaultLdapCodecService();
 
     /**
      * Test the decoding of a UnBindRequest with no controls
@@ -74,7 +79,7 @@ public class UnBindRequestTest
         stream.flip();
 
         // Allocate a BindRequest Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<UnbindRequestDecorator> ldapMessageContainer = new LdapMessageContainer<UnbindRequestDecorator>(
codec );
 
         try
         {
@@ -86,7 +91,7 @@ public class UnBindRequestTest
             fail( de.getMessage() );
         }
 
-        UnbindRequest unbindRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getUnbindRequest();
+        UnbindRequest unbindRequest = ldapMessageContainer.getMessage();
 
         assertEquals( 1, unbindRequest.getMessageId() );
 
@@ -138,7 +143,7 @@ public class UnBindRequestTest
         stream.flip();
 
         // Allocate a BindRequest Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<UnbindRequestDecorator> ldapMessageContainer = new LdapMessageContainer<UnbindRequestDecorator>(
codec );
 
         try
         {
@@ -150,7 +155,7 @@ public class UnBindRequestTest
             fail( de.getMessage() );
         }
 
-        UnbindRequest unbindRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getUnbindRequest();
+        UnbindRequest unbindRequest = ldapMessageContainer.getMessage();
 
         assertEquals( 1, unbindRequest.getMessageId() );
 
@@ -159,7 +164,7 @@ public class UnBindRequestTest
 
         assertEquals( 1, controls.size() );
 
-        Control control = controls.get( "2.16.840.1.113730.3.4.2" );
+        ICodecControl<Control> control = ( ICodecControl<Control> ) controls.get(
"2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
         assertEquals( "", Strings.dumpBytes((byte[]) control.getValue()) );
 
@@ -206,7 +211,7 @@ public class UnBindRequestTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<UnbindRequestDecorator> ldapMessageContainer = new LdapMessageContainer<UnbindRequestDecorator>(
codec );
 
         // Decode a UnbindRequest message
         try



Mime
View raw message