directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1064398 - in /directory/shared/trunk/dsml-parser/src: main/java/org/apache/directory/shared/dsmlv2/reponse/ test/java/org/apache/directory/shared/dsmlv2/addResponse/ test/java/org/apache/directory/shared/dsmlv2/authRequest/
Date Fri, 28 Jan 2011 01:05:56 GMT
Author: elecharny
Date: Fri Jan 28 01:05:56 2011
New Revision: 1064398

URL: http://svn.apache.org/viewvc?rev=1064398&view=rev
Log:
Fixed DSML bindRequest tests

Modified:
    directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java
    directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/addResponse/AddResponseTest.java
    directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/authRequest/AuthRequestTest.java

Modified: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java?rev=1064398&r1=1064397&r2=1064398&view=diff
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java
(original)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java
Fri Jan 28 01:05:56 2011
@@ -41,7 +41,14 @@ import org.apache.directory.shared.dsmlv
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.codec.controls.ControlDecorator;
 import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
+import org.apache.directory.shared.ldap.codec.decorators.AddResponseDecorator;
+import org.apache.directory.shared.ldap.codec.decorators.BindResponseDecorator;
+import org.apache.directory.shared.ldap.codec.decorators.CompareResponseDecorator;
+import org.apache.directory.shared.ldap.codec.decorators.DeleteResponseDecorator;
+import org.apache.directory.shared.ldap.codec.decorators.ExtendedResponseDecorator;
 import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
+import org.apache.directory.shared.ldap.codec.decorators.ModifyDnResponseDecorator;
+import org.apache.directory.shared.ldap.codec.decorators.ModifyResponseDecorator;
 import org.apache.directory.shared.ldap.codec.decorators.SearchResultDoneDecorator;
 import org.apache.directory.shared.ldap.codec.decorators.SearchResultEntryDecorator;
 import org.apache.directory.shared.ldap.codec.decorators.SearchResultReferenceDecorator;
@@ -49,22 +56,15 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.exception.LdapURLEncodingException;
 import org.apache.directory.shared.ldap.model.filter.LdapURL;
-import org.apache.directory.shared.ldap.model.message.AddResponse;
 import org.apache.directory.shared.ldap.model.message.AddResponseImpl;
-import org.apache.directory.shared.ldap.model.message.BindResponse;
 import org.apache.directory.shared.ldap.model.message.BindResponseImpl;
-import org.apache.directory.shared.ldap.model.message.CompareResponse;
 import org.apache.directory.shared.ldap.model.message.CompareResponseImpl;
-import org.apache.directory.shared.ldap.model.message.Control;
-import org.apache.directory.shared.ldap.model.message.DeleteResponse;
 import org.apache.directory.shared.ldap.model.message.DeleteResponseImpl;
 import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
 import org.apache.directory.shared.ldap.model.message.ExtendedResponseImpl;
 import org.apache.directory.shared.ldap.model.message.LdapResult;
 import org.apache.directory.shared.ldap.model.message.Message;
-import org.apache.directory.shared.ldap.model.message.ModifyDnResponse;
 import org.apache.directory.shared.ldap.model.message.ModifyDnResponseImpl;
-import org.apache.directory.shared.ldap.model.message.ModifyResponse;
 import org.apache.directory.shared.ldap.model.message.ModifyResponseImpl;
 import org.apache.directory.shared.ldap.model.message.ReferralImpl;
 import org.apache.directory.shared.ldap.model.message.Response;
@@ -794,7 +794,7 @@ public final class Dsmlv2ResponseGrammar
     {
         public void action( Dsmlv2Container container ) throws XmlPullParserException
         {
-            AddResponse addResponse = new AddResponseImpl();
+            AddResponseDecorator addResponse = new AddResponseDecorator( new AddResponseImpl()
);
 
             container.getBatchResponse().addResponse( addResponse );
 
@@ -836,7 +836,7 @@ public final class Dsmlv2ResponseGrammar
     {
         public void action( Dsmlv2Container container ) throws XmlPullParserException
         {
-            BindResponse bindResponse = new BindResponseImpl();
+            BindResponseDecorator bindResponse = new BindResponseDecorator( new BindResponseImpl()
);
 
             container.getBatchResponse().addResponse( bindResponse );
 
@@ -879,7 +879,7 @@ public final class Dsmlv2ResponseGrammar
     {
         public void action( Dsmlv2Container container ) throws XmlPullParserException
         {
-            CompareResponse compareResponse = new CompareResponseImpl();
+            CompareResponseDecorator compareResponse = new CompareResponseDecorator( new
CompareResponseImpl() );
 
             container.getBatchResponse().addResponse( compareResponse );
 
@@ -921,7 +921,7 @@ public final class Dsmlv2ResponseGrammar
     {
         public void action( Dsmlv2Container container ) throws XmlPullParserException
         {
-            DeleteResponse delResponse = new DeleteResponseImpl();
+            DeleteResponseDecorator delResponse = new DeleteResponseDecorator( new DeleteResponseImpl()
);
 
             container.getBatchResponse().addResponse( delResponse );
 
@@ -963,7 +963,7 @@ public final class Dsmlv2ResponseGrammar
     {
         public void action( Dsmlv2Container container ) throws XmlPullParserException
         {
-            ModifyResponse modifyResponse = new ModifyResponseImpl();
+            ModifyResponseDecorator modifyResponse = new ModifyResponseDecorator( new ModifyResponseImpl()
);
 
             container.getBatchResponse().addResponse( modifyResponse );
 
@@ -1005,7 +1005,7 @@ public final class Dsmlv2ResponseGrammar
     {
         public void action( Dsmlv2Container container ) throws XmlPullParserException
         {
-            ModifyDnResponse modifyDNResponse = new ModifyDnResponseImpl();
+            ModifyDnResponseDecorator modifyDNResponse = new ModifyDnResponseDecorator( new
ModifyDnResponseImpl() );
 
             container.getBatchResponse().addResponse( modifyDNResponse );
 
@@ -1047,7 +1047,7 @@ public final class Dsmlv2ResponseGrammar
     {
         public void action( Dsmlv2Container container ) throws XmlPullParserException
         {
-            ExtendedResponse extendedResponse = null;
+            ExtendedResponseDecorator extendedResponse = null;
 
             // Checking and adding the batchRequest's attributes
             String attributeValue;
@@ -1059,11 +1059,11 @@ public final class Dsmlv2ResponseGrammar
 
             if ( attributeValue != null )
             {
-                extendedResponse = new ExtendedResponseImpl( ParserUtils.parseAndVerifyRequestID(
attributeValue, xpp ) );
+                extendedResponse = new ExtendedResponseDecorator( new ExtendedResponseImpl(
ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ) );
             }
             else
             {
-                extendedResponse = new ExtendedResponseImpl( -1 );
+                extendedResponse = new ExtendedResponseDecorator( new ExtendedResponseImpl(
-1 ) );
             }
 
             container.getBatchResponse().addResponse( extendedResponse );
@@ -1196,7 +1196,7 @@ public final class Dsmlv2ResponseGrammar
      */
     private void createAndAddControl( Dsmlv2Container container, Message parent ) throws
XmlPullParserException
     {
-        Control control = null;
+        ControlDecorator control = null;
 
         XmlPullParser xpp = container.getParser();
 
@@ -1212,7 +1212,7 @@ public final class Dsmlv2ResponseGrammar
                 throw new XmlPullParserException( I18n.err( I18n.ERR_03006 ), xpp, null );
             }
 
-            control = new ControlImpl( attributeValue );
+            control = new ControlDecorator( new ControlImpl( attributeValue ) );
             parent.addControl( control );
         }
         else
@@ -1247,6 +1247,7 @@ public final class Dsmlv2ResponseGrammar
         public void action( Dsmlv2Container container ) throws XmlPullParserException
         {
             Response ldapResponse = container.getBatchResponse().getCurrentResponse();
+            
             // Search Response is a special case
             if ( ldapResponse instanceof SearchResponse )
             {

Modified: directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/addResponse/AddResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/addResponse/AddResponseTest.java?rev=1064398&r1=1064397&r2=1064398&view=diff
==============================================================================
--- directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/addResponse/AddResponseTest.java
(original)
+++ directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/addResponse/AddResponseTest.java
Fri Jan 28 01:05:56 2011
@@ -23,11 +23,13 @@ package org.apache.directory.shared.dsml
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.util.Collection;
+import java.util.Map;
 
 import org.apache.directory.junit.tools.Concurrent;
 import org.apache.directory.junit.tools.ConcurrentJunitRunner;
@@ -36,9 +38,9 @@ import org.apache.directory.shared.dsmlv
 import org.apache.directory.shared.ldap.model.exception.LdapURLEncodingException;
 import org.apache.directory.shared.ldap.model.filter.LdapURL;
 import org.apache.directory.shared.ldap.model.message.AddResponse;
+import org.apache.directory.shared.ldap.model.message.Control;
 import org.apache.directory.shared.ldap.model.message.LdapResult;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
-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;
@@ -112,15 +114,15 @@ public class AddResponseTest extends Abs
         }
 
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
+        Map<String, Control> controls = addResponse.getControls();
 
         assertEquals( 1, addResponse.getControls().size() );
 
-        Control control = addResponse.getCurrentControl();
+        Control control = controls.get( "1.2.840.113556.1.4.643" );
 
+        assertNotNull( control );
         assertTrue( control.isCritical() );
-
         assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
-
         assertEquals( "Some text", Strings.utf8ToString((byte[]) control.getValue()) );
     }
 
@@ -147,9 +149,13 @@ public class AddResponseTest extends Abs
         }
 
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
-        Control control = addResponse.getCurrentControl();
+        Map<String, Control> controls = addResponse.getControls();
 
         assertEquals( 1, addResponse.getControls().size() );
+
+        Control control = controls.get( "1.2.840.113556.1.4.643" );
+
+        assertNotNull( control );
         assertTrue( control.isCritical() );
         assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
         assertFalse( control.hasValue() );
@@ -177,15 +183,15 @@ public class AddResponseTest extends Abs
         }
 
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
+        Map<String, Control> controls = addResponse.getControls();
 
         assertEquals( 2, addResponse.getControls().size() );
 
-        Control control = addResponse.getCurrentControl();
+        Control control = controls.get( "1.2.840.113556.1.4.789" );
 
+        assertNotNull( control );
         assertFalse( control.isCritical() );
-
         assertEquals( "1.2.840.113556.1.4.789", control.getOid() );
-
         assertEquals( "Some other text", Strings.utf8ToString((byte[]) control.getValue())
);
     }
 
@@ -212,15 +218,15 @@ public class AddResponseTest extends Abs
         }
 
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
+        Map<String, Control> controls = addResponse.getControls();
 
         assertEquals( 3, addResponse.getControls().size() );
 
-        Control control = addResponse.getCurrentControl();
+        Control control = controls.get( "1.2.840.113556.1.4.456" );
 
+        assertNotNull( control );
         assertTrue( control.isCritical() );
-
         assertEquals( "1.2.840.113556.1.4.456", control.getOid() );
-
         assertFalse( control.hasValue() );
     }
 

Modified: directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/authRequest/AuthRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/authRequest/AuthRequestTest.java?rev=1064398&r1=1064397&r2=1064398&view=diff
==============================================================================
--- directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/authRequest/AuthRequestTest.java
(original)
+++ directory/shared/trunk/dsml-parser/src/test/java/org/apache/directory/shared/dsmlv2/authRequest/AuthRequestTest.java
Fri Jan 28 01:05:56 2011
@@ -23,9 +23,12 @@ package org.apache.directory.shared.dsml
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.util.Map;
+
 import org.apache.directory.junit.tools.Concurrent;
 import org.apache.directory.junit.tools.ConcurrentJunitRunner;
 import org.apache.directory.shared.dsmlv2.AbstractTest;
@@ -141,9 +144,13 @@ public class AuthRequestTest extends Abs
         }
 
         BindRequest abandonRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();
-        Control control = abandonRequest.getCurrentControl();
+        Map<String, Control> controls = abandonRequest.getControls();
 
         assertEquals( 1, abandonRequest.getControls().size() );
+
+        Control control = controls.get( "1.2.840.113556.1.4.643" );
+
+        assertNotNull( control );
         assertTrue( control.isCritical() );
         assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
         assertEquals( "Some text", Strings.utf8ToString((byte[]) control.getValue()) );
@@ -172,9 +179,13 @@ public class AuthRequestTest extends Abs
         }
 
         BindRequest abandonRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();
-        Control control = abandonRequest.getCurrentControl();
+        Map<String, Control> controls = abandonRequest.getControls();
 
         assertEquals( 1, abandonRequest.getControls().size() );
+
+        Control control = controls.get( "1.2.840.113556.1.4.643" );
+
+        assertNotNull( control );
         assertTrue( control.isCritical() );
         assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
         assertEquals( "DSMLv2.0 rocks!!", Strings.utf8ToString((byte[]) control.getValue())
);
@@ -203,9 +214,13 @@ public class AuthRequestTest extends Abs
         }
 
         BindRequest abandonRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();
-        Control control = abandonRequest.getCurrentControl();
+        Map<String, Control> controls = abandonRequest.getControls();
 
         assertEquals( 1, abandonRequest.getControls().size() );
+
+        Control control = controls.get( "1.2.840.113556.1.4.643" );
+
+        assertNotNull( control );
         assertTrue( control.isCritical() );
         assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
         assertFalse( control.hasValue() );
@@ -233,9 +248,13 @@ public class AuthRequestTest extends Abs
         }
 
         BindRequest abandonRequest = (BindRequest) parser.getBatchRequest().getCurrentRequest();
-        Control control = abandonRequest.getCurrentControl();
+        Map<String, Control> controls = abandonRequest.getControls();
 
         assertEquals( 2, abandonRequest.getControls().size() );
+
+        Control control = controls.get( "1.2.840.113556.1.4.789" );
+
+        assertNotNull( control );
         assertFalse( control.isCritical() );
         assertEquals( "1.2.840.113556.1.4.789", control.getOid() );
         assertEquals( "Some other text", Strings.utf8ToString((byte[]) control.getValue())
);
@@ -264,9 +283,13 @@ public class AuthRequestTest extends Abs
         }
 
         BindRequest abandonRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();
-        Control control = abandonRequest.getCurrentControl();
+        Map<String, Control> controls = abandonRequest.getControls();
 
         assertEquals( 3, abandonRequest.getControls().size() );
+
+        Control control = controls.get( "1.2.840.113556.1.4.456" );
+
+        assertNotNull( control );
         assertTrue( control.isCritical() );
         assertEquals( "1.2.840.113556.1.4.456", control.getOid() );
         assertFalse( control.hasValue() );



Mime
View raw message