directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r492586 - /directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Date Thu, 04 Jan 2007 14:49:40 GMT
Author: elecharny
Date: Thu Jan  4 06:49:39 2007
New Revision: 492586

URL: http://svn.apache.org/viewvc?view=rev&rev=492586
Log:
Added a test to check that binary attributes are returned as binary when searched for.

Modified:
    directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java

Modified: directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java?view=diff&rev=492586&r1=492585&r2=492586
==============================================================================
--- directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
(original)
+++ directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Thu Jan  4 06:49:39 2007
@@ -20,8 +20,10 @@
 package org.apache.directory.server;
 
 
+import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.Iterator;
 import java.util.Set;
 
 import javax.naming.NamingEnumeration;
@@ -57,7 +59,52 @@
     public static final String RDN2 = "cn=Rolling-Stones";
     public static final String PERSON_DESCRIPTION = "an American singer-songwriter";
 
-
+    private static final byte[] jpeg = new byte[]
+        {
+            (byte)0xff, (byte)0xd8, (byte)0xff, (byte)0xe0, 0x00, 0x10, 0x4a, 0x46, 
+            0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x48,
+            0x00, 0x48, 0x00, 0x00, (byte)0xff, (byte)0xe1, 0x00, 0x16, 
+            0x45, 0x78, 0x69, 0x66, 0x00, 0x00, 0x4d, 0x4d,
+            0x00, 0x2a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 
+            0x00, 0x00, 0x00, 0x00, (byte)0xff, (byte)0xfe, 0x00, 0x17,
+            0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 
+            0x77, 0x69, 0x74, 0x68, 0x20, 0x54, 0x68, 0x65,
+            0x20, 0x47, 0x49, 0x4d, 0x50, (byte)0xff, (byte)0xdb, 0x00, 
+            0x43, 0x00, 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a,
+            0x10, 0x0e, 0x0d, 0x0e, 0x12, 0x11, 0x10, 0x13, 
+            0x18, 0x28, 0x1a, 0x18, 0x16, 0x16, 0x18, 0x31,
+            0x23, 0x25, 0x1d, 0x28, 0x3a, 0x33, 0x3d, 0x3c, 
+            0x39, 0x33, 0x38, 0x37, 0x40, 0x48, 0x5c, 0x4e,
+            0x40, 0x44, 0x57, 0x45, 0x37, 0x38, 0x50, 0x6d, 
+            0x51, 0x57, 0x5f, 0x62, 0x67, 0x68, 0x67, 0x3e,
+            0x4d, 0x71, 0x79, 0x70, 0x64, 0x78, 0x5c, 0x65, 
+            0x67, 0x63, (byte)0xff, (byte)0xdb, 0x00, 0x43, 0x01, 0x11,
+            0x12, 0x12, 0x18, 0x15, 0x18, 0x2f, 0x1a, 0x1a, 
+            0x2f, 0x63, 0x42, 0x38, 0x42, 0x63, 0x63, 0x63,
+            0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 
+            0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
+            0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 
+            0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
+            0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 
+            0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, (byte)0xff,
+            (byte)0xc0, 0x00, 0x11, 0x08, 0x00, 0x01, 0x00, 0x01, 
+            0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03,
+            0x11, 0x01, (byte)0xff, (byte)0xc4, 0x00, 0x15, 0x00, 0x01, 
+            0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+            0x05, (byte)0xff, (byte)0xc4, 0x00, 0x14, 0x10, 0x01, 0x00,
+            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xff,
+            (byte)0xc4, 0x00, 0x15, 0x01, 0x01, 0x01, 0x00, 0x00, 
+            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+            0x00, 0x00, 0x00, 0x00, 0x05, 0x06, (byte)0xff, (byte)0xc4, 
+            0x00, 0x14, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00,
+            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+            0x00, 0x00, 0x00, 0x00, (byte)0xff, (byte)0xda, 0x00, 0x0c,
+            0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 
+            0x3f, 0x00, (byte)0x8a, 0x00, (byte)0xb5, (byte)0xe3, (byte)0xff, (byte)0xd9,
+        };
+    
     /**
      * Creation of required attributes of a person entry.
      */
@@ -67,9 +114,12 @@
         Attribute attribute = new BasicAttribute( "objectClass" );
         attribute.add( "top" );
         attribute.add( "person" );
+        attribute.add( "organizationalPerson" );
+        attribute.add( "inetOrgPerson" );
         attributes.put( attribute );
         attributes.put( "cn", cn );
         attributes.put( "sn", sn );
+        attributes.put( "jpegPhoto", jpeg );
 
         return attributes;
     }
@@ -619,5 +669,34 @@
         }
 
         ctx.destroySubcontext( rdn );
+    }
+
+    public void testSearchJpeg() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        NamingEnumeration res = ctx.search( "", "(cn=Tori*)", controls );
+        
+        // collect all results 
+        while ( res.hasMore() )
+        {
+            SearchResult result = ( SearchResult ) res.next();
+
+            Attributes attrs = result.getAttributes();
+            
+            NamingEnumeration all = attrs.getAll();
+                
+            while ( all.hasMoreElements() )
+            {
+                Attribute attr = (Attribute)all.next();
+                
+                if ( "jpegPhoto".equalsIgnoreCase( attr.getID() ) )
+                {
+                    byte[] jpegVal = (byte[])attr.get();
+                    
+                    assertTrue( Arrays.equals( jpegVal, jpeg ) );
+                }
+            }
+        }
     }
 }



Mime
View raw message