directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1065008 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/util/ test/java/org/apache/directory/shared/ldap/codec/
Date Sat, 29 Jan 2011 11:54:22 GMT
Author: akarasulu
Date: Sat Jan 29 11:54:21 2011
New Revision: 1065008

URL: http://svn.apache.org/viewvc?rev=1065008&view=rev
Log:
started fixing some tests

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/JndiUtils.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/JndiUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/JndiUtils.java?rev=1065008&r1=1065007&r2=1065008&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/JndiUtils.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/JndiUtils.java
Sat Jan 29 11:54:21 2011
@@ -91,8 +91,6 @@ import org.apache.directory.shared.ldap.
 /**
  * An utility class to convert back and forth JNDI classes to ADS classes.
  * 
- * TODO: We have a similar class in shared-ldap-jndi!!!
- * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public final class JndiUtils

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java?rev=1065008&r1=1065007&r2=1065008&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java
Sat Jan 29 11:54:21 2011
@@ -34,9 +34,12 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.ldap.codec.decorators.AbandonRequestDecorator;
+import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
 import org.apache.directory.shared.ldap.model.message.AbandonRequest;
 import org.apache.directory.shared.ldap.model.message.AbandonRequestImpl;
 import org.apache.directory.shared.ldap.model.message.Control;
+import org.apache.directory.shared.ldap.model.message.Message;
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -48,11 +51,13 @@ public class LdapControlTest
 {
     /** The encoder instance */
     LdapEncoder encoder = new LdapEncoder();
+    ILdapCodecService codec = new DefaultLdapCodecService();
 
 
     /**
      * Test the decoding of a Request with controls
      */
+    @SuppressWarnings("unchecked")
     @Test
     public void testDecodeRequestWithControls()
     {
@@ -86,7 +91,8 @@ public class LdapControlTest
         stream.flip();
 
         // Allocate a LdapMessageContainer Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<AbandonRequestDecorator> ldapMessageContainer = 
+            new LdapMessageContainer<AbandonRequestDecorator>( codec );
 
         // Decode the PDU
         try
@@ -100,7 +106,7 @@ public class LdapControlTest
         }
 
         // Check that everything is OK
-        AbandonRequest abandonRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getAbandonRequest();
+        AbandonRequestDecorator abandonRequest = ldapMessageContainer.getMessage();
 
         // Copy the message
         AbandonRequest internalAbandonRequest = new AbandonRequestImpl( abandonRequest.getMessageId()
);
@@ -114,25 +120,25 @@ public class LdapControlTest
 
         assertEquals( 4, controls.size() );
 
-        Control control = controls.get( "1.3.6.1.5.5.1" );
+        ICodecControl<Control> control = ( ICodecControl<Control> ) controls.get(
"1.3.6.1.5.5.1" );
         assertEquals( "1.3.6.1.5.5.1", control.getOid() );
-        assertEquals( "0x61 0x62 0x63 0x64 0x65 0x66 ", Strings.dumpBytes((byte[]) control.getValue())
);
+        assertEquals( "0x61 0x62 0x63 0x64 0x65 0x66 ", Strings.dumpBytes( ( byte[] ) control.getValue()
) );
         assertTrue( control.isCritical() );
         internalAbandonRequest.addControl( control );
 
-        control = controls.get( "1.3.6.1.5.5.2" );
+        control = ( ICodecControl<Control> ) controls.get( "1.3.6.1.5.5.2" );
         assertEquals( "1.3.6.1.5.5.2", control.getOid() );
         assertEquals( "0x67 0x68 0x69 0x6A 0x6B 0x6C ", Strings.dumpBytes((byte[]) control.getValue())
);
         assertFalse( control.isCritical() );
         internalAbandonRequest.addControl( control );
 
-        control = controls.get( "1.3.6.1.5.5.3" );
+        control = ( ICodecControl<Control> ) controls.get( "1.3.6.1.5.5.3" );
         assertEquals( "1.3.6.1.5.5.3", control.getOid() );
         assertEquals( "", Strings.dumpBytes((byte[]) control.getValue()) );
         assertTrue( control.isCritical() );
         internalAbandonRequest.addControl( control );
 
-        control = controls.get( "1.3.6.1.5.5.4" );
+        control = ( ICodecControl<Control> ) controls.get( "1.3.6.1.5.5.4" );
         assertEquals( "1.3.6.1.5.5.4", control.getOid() );
         assertEquals( "", Strings.dumpBytes((byte[]) control.getValue()) );
         assertFalse( control.isCritical() );
@@ -158,8 +164,7 @@ public class LdapControlTest
                 fail( de.getMessage() );
             }
 
-            AbandonRequest abandonRequest2 = ( ( LdapMessageContainer ) ldapMessageContainer
)
-                .getAbandonRequest();
+            AbandonRequest abandonRequest2 = ldapMessageContainer.getMessage();
 
             assertEquals( abandonRequest, abandonRequest2 );
         }
@@ -197,7 +202,8 @@ public class LdapControlTest
         stream.flip();
 
         // Allocate a LdapMessageContainer Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        Asn1Container ldapMessageContainer = 
+            new LdapMessageContainer<MessageDecorator<? extends Message>>( codec
);
 
         // Decode the PDU
         try
@@ -240,7 +246,8 @@ public class LdapControlTest
         stream.flip();
 
         // Allocate a LdapMessageContainer Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        Asn1Container ldapMessageContainer = 
+            new LdapMessageContainer<MessageDecorator<? extends Message>>( codec
);
 
         // Decode the PDU
         try
@@ -283,7 +290,8 @@ public class LdapControlTest
         stream.flip();
 
         // Allocate a LdapMessageContainer Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        Asn1Container ldapMessageContainer = 
+            new LdapMessageContainer<MessageDecorator<? extends Message>>( codec
);
 
         // Decode the PDU
         try

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java?rev=1065008&r1=1065007&r2=1065008&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapDecoderTest.java
Sat Jan 29 11:54:21 2011
@@ -35,7 +35,10 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.ber.tlv.TLVStateEnum;
+import org.apache.directory.shared.ldap.codec.decorators.BindRequestDecorator;
+import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
 import org.apache.directory.shared.ldap.model.message.BindRequest;
+import org.apache.directory.shared.ldap.model.message.Message;
 import org.apache.directory.shared.util.Strings;
 import org.apache.mina.core.buffer.IoBuffer;
 import org.apache.mina.core.filterchain.IoFilter.NextFilter;
@@ -56,6 +59,8 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class LdapDecoderTest
 {
+    ILdapCodecService codec = new DefaultLdapCodecService();
+    
     private static class LdapProtocolDecoderOutput extends AbstractProtocolDecoderOutput

     {
         public LdapProtocolDecoderOutput()
@@ -97,8 +102,9 @@ public class LdapDecoderTest
     public void testDecodeFull()
     {
         LdapDecoder ldapDecoder = new LdapDecoder();
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
-        ldapDecoder.setLdapMessageContainer( (LdapMessageContainer)ldapMessageContainer );
+        LdapMessageContainer<MessageDecorator<? extends Message>> container =

+            new LdapMessageContainer<MessageDecorator<? extends Message>>( codec
);
+        ldapDecoder.setLdapMessageContainer( container );
 
         ByteBuffer stream = ByteBuffer.allocate( 0x35 );
         stream.put( new byte[]
@@ -152,11 +158,12 @@ public class LdapDecoderTest
     public void testDecode2Messages() throws Exception
     {
         LdapDecoder ldapDecoder = new LdapDecoder();
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
-        ldapDecoder.setLdapMessageContainer( (LdapMessageContainer)ldapMessageContainer );
+        LdapMessageContainer<MessageDecorator<? extends Message>> container =

+            new LdapMessageContainer<MessageDecorator<? extends Message>>( codec
);
+        ldapDecoder.setLdapMessageContainer( container );
 
         IoSession dummySession = new DummySession();
-        dummySession.setAttribute( "messageContainer", ldapMessageContainer );
+        dummySession.setAttribute( "messageContainer", container );
 
         IoBuffer stream = IoBuffer.allocate( 0x6A );
         stream.put( new byte[]
@@ -246,12 +253,12 @@ public class LdapDecoderTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<BindRequestDecorator> container = new LdapMessageContainer<BindRequestDecorator>(
codec );
 
         // Decode a BindRequest PDU
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
         }
         catch ( DecoderException de )
         {
@@ -259,10 +266,10 @@ public class LdapDecoderTest
             fail( de.getMessage() );
         }
 
-        assertEquals( TLVStateEnum.VALUE_STATE_PENDING, ldapMessageContainer.getState() );
+        assertEquals( TLVStateEnum.VALUE_STATE_PENDING, container.getState() );
 
         // Check the decoded PDU
-        BindRequest bindRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getBindRequest();
+        BindRequest bindRequest = container.getMessage();
 
         assertEquals( 1, bindRequest.getMessageId() );
         assertTrue( bindRequest.isVersion3() );
@@ -293,12 +300,12 @@ public class LdapDecoderTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<BindRequestDecorator> container = new LdapMessageContainer<BindRequestDecorator>(
codec );
 
         // Decode a BindRequest PDU first block of data
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
         }
         catch ( DecoderException de )
         {
@@ -306,7 +313,7 @@ public class LdapDecoderTest
             fail( de.getMessage() );
         }
 
-        assertEquals( TLVStateEnum.VALUE_STATE_PENDING, ldapMessageContainer.getState() );
+        assertEquals( TLVStateEnum.VALUE_STATE_PENDING, container.getState() );
 
         // Second block of data
         stream = ByteBuffer.allocate( 37 );
@@ -323,7 +330,7 @@ public class LdapDecoderTest
         // Decode a BindRequest PDU second block of data
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
         }
         catch ( DecoderException de )
         {
@@ -331,10 +338,10 @@ public class LdapDecoderTest
             fail( de.getMessage() );
         }
 
-        assertEquals( ldapMessageContainer.getState(), TLVStateEnum.PDU_DECODED );
+        assertEquals( container.getState(), TLVStateEnum.PDU_DECODED );
 
         // Check the decoded PDU
-        BindRequest bindRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getBindRequest();
+        BindRequest bindRequest = container.getMessage();
 
         assertEquals( 1, bindRequest.getMessageId() );
         assertTrue( bindRequest.isVersion3() );
@@ -379,7 +386,8 @@ public class LdapDecoderTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<MessageDecorator<? extends Message>> ldapMessageContainer
= 
+            new LdapMessageContainer<MessageDecorator<? extends Message>>( codec
);
 
         // Decode a BindRequest PDU
         try
@@ -431,7 +439,8 @@ public class LdapDecoderTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        Asn1Container ldapMessageContainer = 
+            new LdapMessageContainer<MessageDecorator<? extends Message>>( codec
);
 
         // Decode a BindRequest PDU
         try
@@ -482,7 +491,7 @@ public class LdapDecoderTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<?
extends Message>>( codec );
 
         // Decode a BindRequest PDU
         try
@@ -500,9 +509,9 @@ public class LdapDecoderTest
 
 
     /**
-     * Test the decoding of a splitted Length.
+     * Test the decoding of a split Length.
      * 
-     * The length is 3 bytes long, but the PDU has been splitted 
+     * The length is 3 bytes long, but the PDU has been split
      * just after the first byte 
      */
     @Test
@@ -519,7 +528,7 @@ public class LdapDecoderTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<?
extends Message>>( codec );
 
         // Decode a BindRequest PDU first block of data
         try

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java?rev=1065008&r1=1065007&r2=1065008&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java
Sat Jan 29 11:54:21 2011
@@ -32,6 +32,8 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
+import org.apache.directory.shared.ldap.codec.decorators.UnbindRequestDecorator;
 import org.apache.directory.shared.ldap.model.message.Message;
 import org.apache.directory.shared.ldap.model.message.UnbindRequest;
 import org.apache.directory.shared.ldap.model.message.UnbindRequestImpl;
@@ -51,6 +53,8 @@ public class LdapMessageTest
 {
     /** The encoder instance */
     LdapEncoder encoder = new LdapEncoder();
+    
+    ILdapCodecService codec = new DefaultLdapCodecService();
 
 
     // ~ Methods
@@ -73,7 +77,7 @@ public class LdapMessageTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<?
extends Message>>( codec );
 
         // Decode a BindRequest PDU
         try
@@ -108,7 +112,7 @@ public class LdapMessageTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<?
extends Message>>( codec );
 
         // Decode a BindRequest PDU
         try
@@ -143,7 +147,7 @@ public class LdapMessageTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<?
extends Message>>( codec );
 
         // Decode a BindRequest PDU
         try
@@ -178,7 +182,7 @@ public class LdapMessageTest
         stream.flip();
 
         // Allocate a LdapMessage Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<?
extends Message>>( codec );
 
         // Decode a BindRequest PDU
         try
@@ -219,7 +223,7 @@ public class LdapMessageTest
             stream.flip();
 
             // Allocate a LdapMessage Container
-            Asn1Container ldapMessageContainer = new LdapMessageContainer();
+            Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<?
extends Message>>( codec );
 
             // Decode a BindRequest PDU
             try
@@ -299,11 +303,12 @@ public class LdapMessageTest
         stream.flip();
 
         // Allocate a BindRequest Container
-        Asn1Container ldapMessageContainer = new LdapMessageContainer();
+        LdapMessageContainer<UnbindRequestDecorator> container = 
+            new LdapMessageContainer<UnbindRequestDecorator>( codec );
 
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+            ldapDecoder.decode( stream, container );
         }
         catch ( DecoderException de )
         {
@@ -311,7 +316,7 @@ public class LdapMessageTest
             fail( de.getMessage() );
         }
 
-        Message message = ( ( LdapMessageContainer ) ldapMessageContainer ).getMessage();
+        Message message = container.getMessage();
 
         assertEquals( 500, message.getMessageId() );
 
@@ -335,5 +340,4 @@ public class LdapMessageTest
             fail( ee.getMessage() );
         }
     }
-
 }



Mime
View raw message