directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1065060 - /directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java
Date Sat, 29 Jan 2011 16:23:12 GMT
Author: akarasulu
Date: Sat Jan 29 16:23:11 2011
New Revision: 1065060

URL: http://svn.apache.org/viewvc?rev=1065060&view=rev
Log:
more test fixes

Modified:
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java?rev=1065060&r1=1065059&r2=1065060&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java
Sat Jan 29 16:23:11 2011
@@ -32,9 +32,12 @@ 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.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.ExtendedResponseDecorator;
 import org.apache.directory.shared.ldap.model.message.Control;
 import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
@@ -55,6 +58,8 @@ public class ExtendedResponseTest
     /** The encoder instance */
     LdapEncoder encoder = new LdapEncoder();
 
+    ILdapCodecService codec = new DefaultLdapCodecService();
+    
 
     /**
      * Test the decoding of a full ExtendedResponse
@@ -88,12 +93,13 @@ public class ExtendedResponseTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<ExtendedResponseDecorator> container = 
+            new LdapMessageContainer<ExtendedResponseDecorator>( codec );
 
         // Decode the ExtendedResponse PDU
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
         }
         catch ( DecoderException de )
         {
@@ -102,8 +108,7 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getExtendedResponse();
+        ExtendedResponse extendedResponse = container.getMessage();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
@@ -180,12 +185,13 @@ public class ExtendedResponseTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<ExtendedResponseDecorator> container = 
+            new LdapMessageContainer<ExtendedResponseDecorator>( codec );
 
         // Decode the ExtendedResponse PDU
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
         }
         catch ( DecoderException de )
         {
@@ -194,8 +200,7 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getExtendedResponse();
+        ExtendedResponse extendedResponse = container.getMessage();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
@@ -209,7 +214,8 @@ public class ExtendedResponseTest
 
         assertEquals( 1, controls.size() );
 
-        Control control = controls.get( "2.16.840.1.113730.3.4.2" );
+        @SuppressWarnings("unchecked")
+        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()) );
 
@@ -263,12 +269,13 @@ public class ExtendedResponseTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<ExtendedResponseDecorator> container = 
+            new LdapMessageContainer<ExtendedResponseDecorator>( codec );
 
         // Decode the ExtendedResponse PDU
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
         }
         catch ( DecoderException de )
         {
@@ -277,8 +284,7 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getExtendedResponse();
+        ExtendedResponse extendedResponse = container.getMessage();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
@@ -346,12 +352,13 @@ public class ExtendedResponseTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<ExtendedResponseDecorator> container = 
+            new LdapMessageContainer<ExtendedResponseDecorator>( codec );
 
         // Decode the ExtendedResponse PDU
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
         }
         catch ( DecoderException de )
         {
@@ -360,8 +367,7 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getExtendedResponse();
+        ExtendedResponse extendedResponse = container.getMessage();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
@@ -372,8 +378,8 @@ public class ExtendedResponseTest
         Map<String, Control> controls = extendedResponse.getControls();
 
         assertEquals( 1, controls.size() );
-
-        Control control = controls.get( "2.16.840.1.113730.3.4.2" );
+        @SuppressWarnings("unchecked")
+        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()) );
 
@@ -417,12 +423,13 @@ public class ExtendedResponseTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<ExtendedResponseDecorator> container = 
+            new LdapMessageContainer<ExtendedResponseDecorator>( codec );
 
         // Decode a DelRequest PDU
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
             fail( "We should never reach this point !!!" );
         }
         catch ( DecoderException de )
@@ -461,12 +468,13 @@ public class ExtendedResponseTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<ExtendedResponseDecorator> container = 
+            new LdapMessageContainer<ExtendedResponseDecorator>( codec );
 
         // Decode a DelRequest PDU
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
             fail( "We should never reach this point !!!" );
         }
         catch ( DecoderException de )
@@ -505,12 +513,13 @@ public class ExtendedResponseTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<ExtendedResponseDecorator> container = 
+            new LdapMessageContainer<ExtendedResponseDecorator>( codec );
 
         // Decode a DelRequest PDU
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
             fail( "We should never reach this point !!!" );
         }
         catch ( DecoderException de )
@@ -550,12 +559,13 @@ public class ExtendedResponseTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<ExtendedResponseDecorator> container = 
+            new LdapMessageContainer<ExtendedResponseDecorator>( codec );
 
         // Decode the ExtendedResponse PDU
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
         }
         catch ( DecoderException de )
         {
@@ -564,8 +574,7 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getExtendedResponse();
+        ExtendedResponse extendedResponse = container.getMessage();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
@@ -637,12 +646,13 @@ public class ExtendedResponseTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<ExtendedResponseDecorator> container = 
+            new LdapMessageContainer<ExtendedResponseDecorator>( codec );
 
         // Decode the ExtendedResponse PDU
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
         }
         catch ( DecoderException de )
         {
@@ -651,8 +661,7 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getExtendedResponse();
+        ExtendedResponse extendedResponse = container.getMessage();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
@@ -666,9 +675,10 @@ public class ExtendedResponseTest
 
         assertEquals( 1, controls.size() );
 
-        Control control = controls.get( "2.16.840.1.113730.3.4.2" );
+        @SuppressWarnings("unchecked")
+        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()) );
+        assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
 
         // Check the encoding
         try
@@ -729,12 +739,13 @@ public class ExtendedResponseTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<ExtendedResponseDecorator> container = 
+            new LdapMessageContainer<ExtendedResponseDecorator>( codec );
 
         // Decode the ExtendedResponse PDU
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
         }
         catch ( DecoderException de )
         {
@@ -743,8 +754,7 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getExtendedResponse();
+        ExtendedResponse extendedResponse = container.getMessage();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
@@ -817,12 +827,13 @@ public class ExtendedResponseTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<ExtendedResponseDecorator> container = 
+            new LdapMessageContainer<ExtendedResponseDecorator>( codec );
 
         // Decode the ExtendedResponse PDU
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
         }
         catch ( DecoderException de )
         {
@@ -831,8 +842,7 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getExtendedResponse();
+        ExtendedResponse extendedResponse = container.getMessage();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
@@ -846,9 +856,10 @@ public class ExtendedResponseTest
 
         assertEquals( 1, controls.size() );
 
-        Control control = controls.get( "2.16.840.1.113730.3.4.2" );
+        @SuppressWarnings("unchecked")
+        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()) );
+        assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
 
         // Check the encoding
         try



Mime
View raw message