directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r267442 - /directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java
Date Sat, 03 Sep 2005 10:20:30 GMT
Author: elecharny
Date: Sat Sep  3 03:20:23 2005
New Revision: 267442

URL: http://svn.apache.org/viewcvs?rev=267442&view=rev
Log:
Fixed the SearchTest to make it compatible with the SearchRequest bean modifications.

Modified:
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java

Modified: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java?rev=267442&r1=267441&r2=267442&view=diff
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java
(original)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java
Sat Sep  3 03:20:23 2005
@@ -19,6 +19,8 @@
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 
+import javax.naming.directory.Attributes;
+
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.codec.EncoderException;
 import org.apache.asn1new.ber.Asn1Decoder;
@@ -35,7 +37,6 @@
 import org.apache.asn1new.ldap.pojo.filters.SubstringFilter;
 import org.apache.asn1new.util.StringUtils;
 
-import org.apache.log4j.PropertyConfigurator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -188,23 +189,23 @@
         Assert.assertEquals("objectclass", assertion.getAttributeDesc().toString());
         Assert.assertEquals("ttt", assertion.getAssertionValue().toString());
         
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x81 ), decodedPdu.substring( 0,
0x81 ) );
         }
         catch ( EncoderException ee )
         {
@@ -352,26 +353,26 @@
         Assert.assertEquals("ttt", assertion.getAssertionValue().toString());
 
         // The attributes
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
         
         // Check the length
         Assert.assertEquals(0x90, message.computeLength());
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x81 ), decodedPdu.substring( 0,
0x81 ) );
         }
         catch ( EncoderException ee )
         {
@@ -507,26 +508,26 @@
         Assert.assertEquals("ttt", assertion.getAssertionValue().toString());
 
         // The attributes
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
         
         // Check the length
         Assert.assertEquals(0x7B, message.computeLength());
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x6C ), decodedPdu.substring( 0,
0x6C ) );
         }
         catch ( EncoderException ee )
         {
@@ -613,10 +614,10 @@
         Assert.assertEquals("objectClass", presentFilter.getAttributeDescription().toString());
         
         // The attributes
-        ArrayList attributes = sr.getAttributes();
-        
-        Assert.assertEquals( null, attributes );
+        Attributes attributes = sr.getAttributes();
         
+       	Assert.assertNull( attributes );
+
         // Check the length
         Assert.assertEquals(0x3A, message.computeLength());
 
@@ -720,26 +721,26 @@
         Assert.assertEquals("t", substringFilter.getInitialSubstrings().toString());
 
         // The attributes
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
-        
+
         // Check the length
         Assert.assertEquals(0x64, message.computeLength());
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x53 ), decodedPdu.substring( 0,
0x53 ) );
         }
         catch ( EncoderException ee )
         {
@@ -834,26 +835,26 @@
         Assert.assertEquals(null, substringFilter.getFinalSubstrings());
 
         // The attributes
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
-        
+
         // Check the length
         Assert.assertEquals(0x64, message.computeLength());
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x53 ), decodedPdu.substring( 0,
0x53 ) );
         }
         catch ( EncoderException ee )
         {
@@ -949,26 +950,26 @@
         Assert.assertEquals("t", substringFilter.getFinalSubstrings().toString());
 
         // The attributes
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
         
         // Check the length
         Assert.assertEquals(0x67, message.computeLength());
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x58 ), decodedPdu.substring( 0,
0x58 ) );
         }
         catch ( EncoderException ee )
         {
@@ -1065,26 +1066,26 @@
         Assert.assertEquals("t", substringFilter.getFinalSubstrings().toString());
 
         // The attributes
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
         
         // Check the length
         Assert.assertEquals(0x6A, message.computeLength());
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x5B ), decodedPdu.substring( 0,
0x5B ) );
         }
         catch ( EncoderException ee )
         {
@@ -1179,26 +1180,26 @@
         Assert.assertEquals("t", ((LdapString)substringFilter.getAnySubstrings().get(0)).toString());
 
         // The attributes
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
         
         // Check the length
         Assert.assertEquals(0x67, message.computeLength());
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x58 ), decodedPdu.substring( 0,
0x58 ) );
         }
         catch ( EncoderException ee )
         {
@@ -1296,26 +1297,26 @@
         Assert.assertEquals("t", substringFilter.getFinalSubstrings().toString());
 
         // The attributes
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
         
         // Check the length
         Assert.assertEquals(0x6A, message.computeLength());
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x5B ), decodedPdu.substring( 0,
0x5B ) );
         }
         catch ( EncoderException ee )
         {
@@ -1410,26 +1411,26 @@
         Assert.assertEquals("*", ((LdapString)substringFilter.getAnySubstrings().get(0)).toString());
 
         // The attributes
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
         
         // Check the length
         Assert.assertEquals(0x67, message.computeLength());
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x58 ), decodedPdu.substring( 0,
0x58 ) );
         }
         catch ( EncoderException ee )
         {
@@ -1528,26 +1529,26 @@
         Assert.assertEquals(null, substringFilter.getFinalSubstrings());
 
         // The attributes
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
         
         // Check the length
         Assert.assertEquals(0x6A, message.computeLength());
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x5B ), decodedPdu.substring( 0,
0x5B ) );
         }
         catch ( EncoderException ee )
         {
@@ -1660,26 +1661,26 @@
         Assert.assertEquals("abok", assertion.getAssertionValue().toString());
 
         // The attributes
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
         
         // Check the length
         Assert.assertEquals(0x96, message.computeLength());
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x87 ), decodedPdu.substring( 0,
0x87 ) );
         }
         catch ( EncoderException ee )
         {
@@ -1750,26 +1751,26 @@
         Assert.assertEquals( true, sr.isTypesOnly() );
         
         // The attributes
-        ArrayList attributes = sr.getAttributes();
+        Attributes attributes = sr.getAttributes();
         
         for (int i = 0; i < attributes.size(); i++) 
         {
-            LdapString attribute = (LdapString)attributes.get(i);
-            
-            Assert.assertEquals("attr" + i, attribute.toString());
+        	Assert.assertNotNull( attributes.get( "attr" + i ) );
         }
         
         // Check the length
         Assert.assertEquals(0x65, message.computeLength());
 
         // Check the encoding
+        // We won't check the whole PDU, as it may differs because
+        // attributes may have been reordered
         try
         {
             ByteBuffer bb = message.encode( null );
             
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
-            Assert.assertEquals(encodedPdu, decodedPdu );
+            Assert.assertEquals(encodedPdu.substring( 0, 0x56 ), decodedPdu.substring( 0,
0x56 ) );
         }
         catch ( EncoderException ee )
         {



Mime
View raw message