You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2007/01/04 15:51:42 UTC
svn commit: r492587 -
/directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Author: elecharny
Date: Thu Jan 4 06:51:41 2007
New Revision: 492587
URL: http://svn.apache.org/viewvc?view=rev&rev=492587
Log:
Added a test which checks that returned values from a search are binary values if the inject initial value was binary
Modified:
directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Modified: directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java?view=diff&rev=492587&r1=492586&r2=492587
==============================================================================
--- directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java (original)
+++ directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java Thu Jan 4 06:51:41 2007
@@ -20,6 +20,7 @@
package org.apache.directory.server;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
@@ -58,6 +59,53 @@
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.
@@ -71,6 +119,7 @@
attributes.put( attribute );
attributes.put( "cn", cn );
attributes.put( "sn", sn );
+ attributes.put( "jpegPhoto", jpeg );
return attributes;
}
@@ -620,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 ) );
+ }
+ }
+ }
}
}