directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vte...@apache.org
Subject svn commit: r153144 - in incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder: AbstractEncoderTestCase.java add/AddRequestEncoderTest.java extended/ExtendedResponseEncoderTest.java modify/ModifyRequestEncoderTest.java search/SearchResponseEntryEncoderTest.java
Date Thu, 10 Feb 2005 02:33:29 GMT
Author: vtence
Date: Wed Feb  9 18:33:27 2005
New Revision: 153144

URL: http://svn.apache.org/viewcvs?view=rev&rev=153144
Log:
Removed dependency on snacc for encoder tests

Removed:
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/extended/ExtendedResponseEncoderTest.java
Modified:
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/AbstractEncoderTestCase.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/modify/ModifyRequestEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseEntryEncoderTest.java

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/AbstractEncoderTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/AbstractEncoderTestCase.java?view=diff&r1=153143&r2=153144
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/AbstractEncoderTestCase.java
(original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/AbstractEncoderTestCase.java
Wed Feb  9 18:33:27 2005
@@ -126,23 +126,6 @@
     }
 
 
-    /**
-     * Decodes the accumulated bytes emitted from the encoder being tested using
-     * the Snacc4J decoder.
-     *
-     * @return the decoded LDAP Message envelope
-     */
-    protected Message decode()
-    {
-        Properties env = new Properties();
-        env.setProperty( Provider.BERLIB_PROVIDER,
-                "org.apache.ldap.common.berlib.snacc.SnaccProvider" );
-        MessageDecoder decoder = new MessageDecoder( env );
-        ByteArrayInputStream in = new ByteArrayInputStream( accumulator.array(),
-                0, accumulator.position() );
-        return ( Message ) decoder.decode( null, in );
-    }
-
     protected byte[] getEncoded()
     {
         byte[] encoded = new byte[accumulator.position()];

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoderTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoderTest.java?view=diff&r1=153143&r2=153144
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoderTest.java
(original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoderTest.java
Wed Feb  9 18:33:27 2005
@@ -20,6 +20,7 @@
 import org.apache.asn1.ber.DefaultMutableTupleNode;
 import org.apache.asn1.ber.TupleNode;
 import org.apache.ldap.common.berlib.asn1.encoder.AbstractEncoderTestCase;
+import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils;
 import org.apache.ldap.common.message.AddRequestImpl;
 import org.apache.ldap.common.message.LockableAttributesImpl;
 
@@ -27,17 +28,11 @@
 
 
 /**
- * TODO: fix me! Snacc generated PDU doesnt match snickers one
- * TestCase for the AddRequestEncoder class.
- *
  * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
  *         Project</a> $Rev$
  */
 public class AddRequestEncoderTest extends AbstractEncoderTestCase
 {
-    /**
-     * Tests the encode method.
-     */
     public void testEncode() throws NamingException
     {
         AddRequestImpl request = new AddRequestImpl( 33 );
@@ -48,32 +43,11 @@
         attrs.put( "dc", "example.com" );
         request.setEntry( attrs );
 
+        byte[] expected = new byte[] {0x30, 0x4E, 0x02, 0x01, 0x21, 0x68, 0x49, 0x04, 0x10,
0x64, 0x63, 0x3D, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x6F, 0x72,
0x67, 0x30, 0x35, 0x30, 0x1E, 0x04, 0x0B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x43, 0x6C,
0x61, 0x73, 0x73, 0x31, 0x0F, 0x04, 0x08, 0x64, 0x63, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
0x04, 0x03, 0x74, 0x6F, 0x70, 0x30, 0x13, 0x04, 0x02, 0x64, 0x63, 0x31, 0x0D, 0x04, 0x0B,
0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D};
+
         // Encode stub into tuple tree then into the accumulator
         TupleNode node = AddRequestEncoder.INSTANCE.encode( request );
         encode( ( DefaultMutableTupleNode ) node );
-        assertEquals( request, decode() );
+        TestUtils.assertEquals( expected, getEncoded() );
     }
-
-    /**
-     * TODO: study differences between snacc and snickers PDUs
-     * PDUs might be equivalent yet different in sub elements order
-     */
-    
-//    public void testCanEncodeAddRequests() throws NamingException
-//    {
-//        AddRequestImpl request = new AddRequestImpl( 33 );
-//        request.setName( "dc=apache,dc=org" );
-//        LockableAttributesImpl attrs = new LockableAttributesImpl( request );
-//        attrs.put( "objectClass", "top" );
-//        attrs.put( "objectClass", "dcObject" );
-//        attrs.put( "dc", "example.com" );
-//        request.setEntry( attrs );
-//
-//        byte[] expected = new byte[] {0x30, 0x4E, 0x02, 0x01, 0x21, 0x68, 0x49, 0x04, 0x10,
0x64, 0x63, 0x3D, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x6F, 0x72,
0x67, 0x30, 0x35, 0x30, 0x1E, 0x04, 0x0B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x43, 0x6C,
0x61, 0x73, 0x73, 0x31, 0x0F, 0x04, 0x03, 0x74, 0x6F, 0x70, 0x04, 0x08, 0x64, 0x63, 0x4F,
0x62, 0x6A, 0x65, 0x63, 0x74, 0x30, 0x13, 0x04, 0x02, 0x64, 0x63, 0x31, 0x0D, 0x04, 0x0B,
0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D};
-//
-//        // Encode stub into tuple tree then into the accumulator
-//        TupleNode node = AddRequestEncoder.INSTANCE.encode( request );
-//        encode( ( DefaultMutableTupleNode ) node );
-//        TestUtils.assertEquals( expected, getEncoded() );
-//    }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/modify/ModifyRequestEncoderTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/modify/ModifyRequestEncoderTest.java?view=diff&r1=153143&r2=153144
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/modify/ModifyRequestEncoderTest.java
(original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/modify/ModifyRequestEncoderTest.java
Wed Feb  9 18:33:27 2005
@@ -21,6 +21,7 @@
 import org.apache.asn1.ber.TupleNode;
 import org.apache.asn1.codec.DecoderException;
 import org.apache.ldap.common.berlib.asn1.encoder.AbstractEncoderTestCase;
+import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils;
 import org.apache.ldap.common.message.LockableAttributeImpl;
 import org.apache.ldap.common.message.ModifyRequest;
 import org.apache.ldap.common.message.ModifyRequestImpl;
@@ -30,10 +31,6 @@
 
 
 /**
- * TODO: fix me! Snacc generated PDU doesnt match snickers one
- *
- * Tests the ModifyRequest encoder.
- *
  * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
  *         Project</a>
  */
@@ -72,33 +69,15 @@
         return req;
     }
 
-
-    /**
-     * Tests the encoder's encode() method.
-     */
     public void testEncode() throws DecoderException
     {
         ModifyRequest req = getRequest();
 
+        byte[] expected = new byte[] {0x30, 0x76, 0x02, 0x01, 0x2D, 0x66, 0x71, 0x04, 0x19,
0x63, 0x6E, 0x3D, 0x61, 0x64, 0x6D, 0x69, 0x6E, 0x2C, 0x64, 0x63, 0x3D, 0x61, 0x70, 0x61,
0x63, 0x68, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x6F, 0x72, 0x67, 0x30, 0x54, 0x30, 0x20, 0x0A,
0x01, 0x00, 0x30, 0x1B, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x31, 0x12, 0x04, 0x04,
0x76, 0x61, 0x6C, 0x32, 0x04, 0x04, 0x76, 0x61, 0x6C, 0x31, 0x04, 0x04, 0x76, 0x61, 0x6C,
0x30, 0x30, 0x14, 0x0A, 0x01, 0x01, 0x30, 0x0F, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31,
0x31, 0x06, 0x04, 0x04, 0x76, 0x61, 0x6C, 0x33, 0x30, 0x1A, 0x0A, 0x01, 0x02, 0x30, 0x15,
0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32, 0x31, 0x0C, 0x04, 0x04, 0x76, 0x61, 0x6C, 0x35,
0x04, 0x04, 0x76, 0x61, 0x6C, 0x34};
+
         // Encode stub into tuple tree then into the accumulator
         TupleNode node = ModifyRequestEncoder.INSTANCE.encode( req );
         encode( ( DefaultMutableTupleNode ) node );
-        assertEquals( req, decode() );
+        TestUtils.assertEquals( expected, getEncoded() );
     }
-
-    /**
-     * TODO: study differences between snacc and snickers PDUs
-     * PDUs might be equivalent yet different in sub elements order
-     */
-
-//    public void testEncode() throws DecoderException
-//    {
-//        ModifyRequest req = getRequest();
-//        byte[] expected = new byte[] {0x30, 0x76, 0x02, 0x01, 0x2D, 0x66, 0x71, 0x04, 0x19,
0x63, 0x6E, 0x3D, 0x61, 0x64, 0x6D, 0x69, 0x6E, 0x2C, 0x64, 0x63, 0x3D, 0x61, 0x70, 0x61,
0x63, 0x68, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x6F, 0x72, 0x67, 0x30, 0x54, 0x30, 0x20, 0x0A,
0x01, 0x00, 0x30, 0x1B, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x31, 0x12, 0x04, 0x04,
0x76, 0x61, 0x6C, 0x32, 0x04, 0x04, 0x76, 0x61, 0x6C, 0x30, 0x04, 0x04, 0x76, 0x61, 0x6C,
0x31, 0x30, 0x14, 0x0A, 0x01, 0x01, 0x30, 0x0F, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31,
0x31, 0x06, 0x04, 0x04, 0x76, 0x61, 0x6C, 0x33, 0x30, 0x1A, 0x0A, 0x01, 0x02, 0x30, 0x15,
0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32, 0x31, 0x0C, 0x04, 0x04, 0x76, 0x61, 0x6C, 0x35,
0x04, 0x04, 0x76, 0x61, 0x6C, 0x34};
-//
-//        // Encode stub into tuple tree then into the accumulator
-//        TupleNode node = ModifyRequestEncoder.INSTANCE.encode( req );
-//        encode( ( DefaultMutableTupleNode ) node );
-//        TestUtils.assertEquals( expected, getEncoded() );
-//    }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseEntryEncoderTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseEntryEncoderTest.java?view=diff&r1=153143&r2=153144
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseEntryEncoderTest.java
(original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseEntryEncoderTest.java
Wed Feb  9 18:33:27 2005
@@ -20,21 +20,17 @@
 import org.apache.asn1.ber.DefaultMutableTupleNode;
 import org.apache.asn1.ber.TupleNode;
 import org.apache.ldap.common.berlib.asn1.encoder.AbstractEncoderTestCase;
+import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils;
 import org.apache.ldap.common.message.LockableAttributesImpl;
 import org.apache.ldap.common.message.SearchResponseEntryImpl;
 
 
 /**
- * TestCase for the SearchResponseEntryEncoder.
- *
  * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
  *         Project</a> $Rev$
  */
 public class SearchResponseEntryEncoderTest extends AbstractEncoderTestCase
 {
-    /**
-     * Tests the encoder's encode() method.
-     */
     public void testEncode()
     {
         // Construct the Search response
@@ -46,35 +42,12 @@
         attrs.put( "dc", "example.com" );
         response.setAttributes( attrs );
 
+        byte[] expected = new byte[] {0x30, 0x4F, 0x02, 0x01, 0x2D, 0x64, 0x4A, 0x04, 0x11,
0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63,
0x6F, 0x6D, 0x30, 0x35, 0x30, 0x1E, 0x04, 0x0B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x43,
0x6C, 0x61, 0x73, 0x73, 0x31, 0x0F, 0x04, 0x08, 0x64, 0x63, 0x4F, 0x62, 0x6A, 0x65, 0x63,
0x74, 0x04, 0x03, 0x74, 0x6F, 0x70, 0x30, 0x13, 0x04, 0x02, 0x64, 0x63, 0x31, 0x0D, 0x04,
0x0B, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D};
+
         // Encode stub into tuple tree then into the accumulator
         TupleNode node = SearchResponseEntryEncoder.INSTANCE.encode( response );
         encode( ( DefaultMutableTupleNode ) node );
-
-        // Test to see if original stub equals the round trip generated stub
-        assertTrue( response.equals( decode() ) );
+        TestUtils.assertEquals( expected, getEncoded() );
     }
-
-    /**
-     * TODO: study differences between snacc and snickers PDUs
-     * PDUs might be equivalent yet different in sub elements order
-     */
-//    public void testEncode()
-//    {
-//        // Construct the Search response
-//        SearchResponseEntryImpl response = new SearchResponseEntryImpl( 45 );
-//        response.setObjectName( "dc=example,dc=com" );
-//        LockableAttributesImpl attrs = new LockableAttributesImpl( response );
-//        attrs.put( "objectClass", "top" );
-//        attrs.put( "objectClass", "dcObject" );
-//        attrs.put( "dc", "example.com" );
-//        response.setAttributes( attrs );
-//
-//        byte[] expected = new byte[] {0x30, 0x4F, 0x02, 0x01, 0x2D, 0x64, 0x4A, 0x04, 0x11,
0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63,
0x6F, 0x6D, 0x30, 0x35, 0x30, 0x1E, 0x04, 0x0B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x43,
0x6C, 0x61, 0x73, 0x73, 0x31, 0x0F, 0x04, 0x03, 0x74, 0x6F, 0x70, 0x04, 0x08, 0x64, 0x63,
0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x30, 0x13, 0x04, 0x02, 0x64, 0x63, 0x31, 0x0D, 0x04,
0x0B, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D};
-//
-//        // Encode stub into tuple tree then into the accumulator
-//        TupleNode node = SearchResponseEntryEncoder.INSTANCE.encode( response );
-//        encode( ( DefaultMutableTupleNode ) node );
-//        TestUtils.assertEquals( expected, getEncoded() );
-//    }
 
 }



Mime
View raw message