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 2013/08/02 13:26:46 UTC
svn commit: r1509635 [4/5] - in /directory/apacheds/trunk:
ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/
server-integ/src/test/java/org/apache/directory/server/operations/add/
server-integ/src/test/java/org/apache/di...
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchNoRevertIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchNoRevertIT.java?rev=1509635&r1=1509634&r2=1509635&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchNoRevertIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchNoRevertIT.java Fri Aug 2 11:26:45 2013
@@ -35,7 +35,6 @@ import javax.naming.ldap.ManageReferralC
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.ldif.LdifEntry;
import org.apache.directory.api.ldap.model.ldif.LdifReader;
-import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.annotations.ApplyLdifs;
@@ -47,7 +46,6 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -134,18 +132,14 @@ import org.junit.runner.RunWith;
"dn: ou=Countries,ou=system",
"objectClass: top",
"objectClass: organizationalUnit",
- "ou: Countries"
-})
+ "ou: Countries" })
public class ReferralSearchNoRevertIT extends AbstractLdapTestUnit
{
- @Rule
- public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
-
@Before
public void setupReferrals() throws Exception
{
getLdapServer().getDirectoryService().getChangeLog().setEnabled( false );
-
+
String ldif =
"dn: c=europ,ou=Countries,ou=system\n" +
"objectClass: top\n" +
@@ -153,16 +147,16 @@ public class ReferralSearchNoRevertIT ex
"objectClass: extensibleObject\n" +
"c: europ\n" +
"ref: ldap://localhost:" + getLdapServer().getPort() + "/c=france,ou=system\n\n" +
-
+
"dn: c=america,ou=Countries,ou=system\n" +
"objectClass: top\n" +
"objectClass: referral\n" +
"objectClass: extensibleObject\n" +
"c: america\n" +
"ref: ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system\n\n";
-
+
LdifReader reader = new LdifReader( new StringReader( ldif ) );
-
+
while ( reader.hasNext() )
{
LdifEntry entry = reader.next();
@@ -172,8 +166,8 @@ public class ReferralSearchNoRevertIT ex
reader.close();
}
-
-
+
+
/**
* Test of an search operation with a referral after the entry
* has been moved.
@@ -186,10 +180,10 @@ public class ReferralSearchNoRevertIT ex
public void testSearchBaseWithReferralThrowAfterMove() throws Exception
{
DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.OBJECT_SCOPE );
-
+
try
{
ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls );
@@ -200,18 +194,18 @@ public class ReferralSearchNoRevertIT ex
String referral = ( String ) re.getReferralInfo();
assertEquals( "ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system??base", referral );
}
-
+
( ( LdapContext ) ctx ).setRequestControls( new javax.naming.ldap.Control[]
{ new ManageReferralControl() } );
-
+
// Now let's move the entry
ctx.rename( "c=america,ou=Countries,ou=system", "c=america,ou=system" );
-
+
controls.setSearchScope( SearchControls.OBJECT_SCOPE );
-
+
( ( LdapContext ) ctx ).setRequestControls( new javax.naming.ldap.Control[]
{} );
-
+
try
{
ctx.search( "c=america,ou=system", "(cn=alex karasulu)", controls );
@@ -223,8 +217,8 @@ public class ReferralSearchNoRevertIT ex
assertEquals( "ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system??base", referral );
}
}
-
-
+
+
@After
public void after()
{
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SchemaSearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SchemaSearchIT.java?rev=1509635&r1=1509634&r2=1509635&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SchemaSearchIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SchemaSearchIT.java Fri Aug 2 11:26:45 2013
@@ -35,13 +35,11 @@ import javax.naming.directory.DirContext
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
-import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.annotations.ApplyLdifs;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -164,27 +162,24 @@ import org.junit.runner.RunWith;
"dn: ou=syntaxes, cn=active-directory, ou=schema",
"objectclass: organizationalUnit",
"objectclass: top",
- "ou: syntaxes"
-})
+ "ou: syntaxes" })
public class SchemaSearchIT extends AbstractLdapTestUnit
{
- @Rule
- public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
private static final String DN = "cn=schema";
private static final String FILTER = "(objectclass=subschema)";
-
-
+
+
protected void checkForAttributes( Attributes attrs, String[] attrNames )
{
for ( int i = 0; i < attrNames.length; i++ )
{
String attrName = attrNames[i];
-
+
assertNotNull( "Check if attr " + attrName + " is present", attrs.get( attrNames[i] ) );
}
}
-
-
+
+
/**
* Check if modifyTimestamp and createTimestamp are present in the search result,
* if they are requested.
@@ -194,15 +189,15 @@ public class SchemaSearchIT extends Abst
{
DirContext ctx = getWiredContext( getLdapServer() );
SearchControls ctls = new SearchControls();
-
+
String[] attrNames =
{ "creatorsName", "createTimestamp", "modifiersName", "modifyTimestamp" };
-
+
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( attrNames );
-
+
NamingEnumeration<SearchResult> result = ctx.search( DN, FILTER, ctls );
-
+
if ( result.hasMore() )
{
SearchResult entry = result.next();
@@ -212,11 +207,11 @@ public class SchemaSearchIT extends Abst
{
fail( "entry " + DN + " not found" );
}
-
+
result.close();
}
-
-
+
+
/**
* Check if modifyTimestamp and createTimestamp are present in the search result,
* if + is requested.
@@ -226,13 +221,13 @@ public class SchemaSearchIT extends Abst
{
DirContext ctx = getWiredContext( getLdapServer() );
SearchControls ctls = new SearchControls();
-
+
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( new String[]
{ "+" } );
-
+
NamingEnumeration<SearchResult> result = ctx.search( DN, FILTER, ctls );
-
+
if ( result.hasMore() )
{
SearchResult entry = result.next();
@@ -244,11 +239,11 @@ public class SchemaSearchIT extends Abst
{
fail( "entry " + DN + " not found" );
}
-
+
result.close();
}
-
-
+
+
/**
* Test case for DIRSERVER-1083: Search on an custom attribute added to
* the dynamic schema fails when no result is found.
@@ -257,7 +252,7 @@ public class SchemaSearchIT extends Abst
public void testSearchingNewSchemaElements() throws Exception
{
DirContext ctx = getWiredContext( getLdapServer() );
-
+
// create an entry with the schema objectClass personActiveDirectory
Attributes person = new BasicAttributes( "objectClass", "top", true );
person.get( "objectClass" ).add( "person" );
@@ -269,12 +264,12 @@ public class SchemaSearchIT extends Abst
person.put( "useraccountcontrol", "7" );
person.put( "sAMAccountName", "foobar" );
ctx.createSubcontext( "cn=foobar,ou=system", person );
-
+
// Confirm creation with a lookup
Attributes read = ctx.getAttributes( "cn=foobar,ou=system" );
assertNotNull( read );
assertEquals( "3", read.get( "pwdLastSet" ).get() );
-
+
// Now search for foobar with pwdLastSet value of 3
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
@@ -286,14 +281,14 @@ public class SchemaSearchIT extends Abst
Attributes attributes = result.getAttributes();
assertEquals( "3", attributes.get( "pwdLastSet" ).get() );
results.close();
-
+
// Now search with bogus value for pwdLastSet
results = ctx.search( "ou=system", "(pwdLastSet=300)", searchControls );
assertFalse( results.hasMore() );
results.close();
}
-
-
+
+
/**
* Test case for DIRSERVER-: Ensure that schema entry is returned,
* even if no ManageDsaIT decorator is present in the search request.
@@ -302,25 +297,25 @@ public class SchemaSearchIT extends Abst
public void testRequestWithoutManageDsaITControl() throws Exception
{
DirContext ctx = getWiredContext( getLdapServer() );
-
+
// this removes the ManageDsaIT decorator from the search request
ctx.addToEnvironment( DirContext.REFERRAL, "throw" );
-
+
SearchControls ctls = new SearchControls();
String[] attrNames =
- {
- "objectClasses",
- "attributeTypes",
- "ldapSyntaxes",
- "matchingRules",
+ {
+ "objectClasses",
+ "attributeTypes",
+ "ldapSyntaxes",
+ "matchingRules",
"createTimestamp",
- "modifyTimestamp"
- };
+ "modifyTimestamp"
+ };
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( attrNames );
-
+
NamingEnumeration<SearchResult> result = ctx.search( DN, FILTER, ctls );
-
+
if ( result.hasMore() )
{
SearchResult entry = result.next();
@@ -330,11 +325,11 @@ public class SchemaSearchIT extends Abst
{
fail( "entry " + DN + " not found" );
}
-
+
result.close();
}
-
-
+
+
/**
* Test a search done on cn=schema
*/
@@ -342,20 +337,20 @@ public class SchemaSearchIT extends Abst
public void testSubSchemaSubEntrySearch() throws Exception
{
DirContext ctx = getWiredContext( getLdapServer() );
-
+
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope( SearchControls.OBJECT_SCOPE );
searchControls.setReturningAttributes( new String[]
{ "objectClasses" } );
NamingEnumeration<SearchResult> results = ctx.search( "cn=schema", "(ObjectClass=*)", searchControls );
-
+
assertTrue( results.hasMore() );
SearchResult result = results.next();
Attributes entry = result.getAttributes();
-
+
Attribute objectClasses = entry.get( "objectClasses" );
NamingEnumeration<?> ocs = objectClasses.getAll();
-
+
while ( ocs.hasMore() )
{
String oc = ( String ) ocs.nextElement();
@@ -366,7 +361,7 @@ public class SchemaSearchIT extends Abst
oc );
}
}
-
+
results.close();
}
}
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java?rev=1509635&r1=1509634&r2=1509635&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java Fri Aug 2 11:26:45 2013
@@ -61,7 +61,6 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.ldap.model.message.controls.SubentriesImpl;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.util.JndiUtils;
-import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.apache.directory.server.annotations.CreateLdapServer;
@@ -70,7 +69,6 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -180,22 +178,18 @@ import org.junit.runner.RunWith;
"objectClass: top",
"cn: Kim Wilde",
"sn: Wilde",
- "description: an American singer-songwriter+sexy blond"
-
-})
+ "description: an American singer-songwriter+sexy blond" })
public class SearchIT extends AbstractLdapTestUnit
{
- @Rule
- public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
private static final String BASE = "ou=system";
-
+
//public static LdapServer getLdapServer();
-
+
private static final String RDN = "cn=Tori Amos";
private static final String RDN2 = "cn=Rolling-Stones";
private static final String HEATHER_RDN = "cn=Heather Nova";
private static final String FILTER = "(objectclass=*)";
-
+
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,
@@ -219,8 +213,8 @@ public class SearchIT extends AbstractLd
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.
*/
@@ -236,11 +230,11 @@ public class SearchIT extends AbstractLd
attributes.put( "cn", cn );
attributes.put( "sn", sn );
attributes.put( "jpegPhoto", JPEG );
-
+
return attributes;
}
-
-
+
+
private void checkForAttributes( Attributes attrs, String[] attrNames )
{
for ( String attrName : attrNames )
@@ -248,8 +242,8 @@ public class SearchIT extends AbstractLd
assertNotNull( "Check if attr " + attrName + " is present", attrs.get( attrName ) );
}
}
-
-
+
+
/**
* For DIRSERVER-715 and part of DIRSERVER-169. May include other tests
* for binary attribute based searching.
@@ -260,7 +254,7 @@ public class SearchIT extends AbstractLd
DirContext ctx = ( DirContext ) getWiredContext( getLdapServer() ).lookup( BASE );
byte[] certData = new byte[]
{ 0x34, 0x56, 0x4e, 0x5f };
-
+
// Search for kate by cn first
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
@@ -270,7 +264,7 @@ public class SearchIT extends AbstractLd
assertNotNull( sr );
assertFalse( enm.hasMore() );
assertEquals( "cn=Kate Bush", sr.getName() );
-
+
enm = ctx.search( "", "(&(cn=Kate Bush)(userCertificate={0}))", new Object[]
{ certData }, controls );
assertTrue( enm.hasMore() );
@@ -278,7 +272,7 @@ public class SearchIT extends AbstractLd
assertNotNull( sr );
assertFalse( enm.hasMore() );
assertEquals( "cn=Kate Bush", sr.getName() );
-
+
enm = ctx.search( "", "(userCertificate=\\34\\56\\4E\\5F)", controls );
assertTrue( enm.hasMore() );
int count = 0;
@@ -287,23 +281,23 @@ public class SearchIT extends AbstractLd
expected.add( "cn=Tori Amos" );
expected.add( "cn=Rolling-Stones" );
expected.add( "cn=Heather Nova" );
-
+
while ( enm.hasMore() )
{
count++;
sr = enm.next();
assertNotNull( sr );
-
+
assertTrue( expected.contains( sr.getName() ) );
expected.remove( sr.getName() );
}
-
+
assertEquals( 4, count );
assertFalse( enm.hasMore() );
assertEquals( 0, expected.size() );
}
-
-
+
+
@Test
public void testSearch() throws Exception
{
@@ -311,11 +305,11 @@ public class SearchIT extends AbstractLd
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.OBJECT_SCOPE );
controls.setTimeLimit( 10 );
-
+
try
{
ctx.search( "myBadDN", "(objectClass=*)", controls );
-
+
fail(); // We should get an exception here
}
catch ( InvalidNameException ine )
@@ -330,15 +324,15 @@ public class SearchIT extends AbstractLd
{
fail();
}
-
+
try
{
controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
controls.setTimeLimit( 10 );
-
+
NamingEnumeration<SearchResult> result = ctx.search( "ou=system", "(objectClass=*)", controls );
-
+
assertTrue( result.hasMore() );
}
catch ( InvalidNameException ine )
@@ -351,8 +345,8 @@ public class SearchIT extends AbstractLd
fail();
}
}
-
-
+
+
/**
* Test a search with the empty "" baseDN
*/
@@ -363,20 +357,20 @@ public class SearchIT extends AbstractLd
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.OBJECT_SCOPE );
controls.setTimeLimit( 10 );
-
+
try
{
controls = new SearchControls();
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
controls.setTimeLimit( 10 );
-
+
NamingEnumeration<SearchResult> result = ctx.search( "", "(cn=Janis Joplin)", controls );
-
+
assertTrue( result.hasMore() );
-
+
SearchResult entry = result.next();
assertEquals( "cn=Janis Joplin,ou=system", entry.getName() );
-
+
assertFalse( result.hasMore() );
}
catch ( InvalidNameException ine )
@@ -390,8 +384,8 @@ public class SearchIT extends AbstractLd
fail();
}
}
-
-
+
+
/**
* Performs a single level search from ou=system base and
* returns the set of DNs found.
@@ -402,7 +396,7 @@ public class SearchIT extends AbstractLd
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
NamingEnumeration<SearchResult> ii = ctx.search( "", filter, controls );
-
+
// collect all results
HashSet<String> results = new HashSet<String>();
while ( ii.hasMore() )
@@ -410,11 +404,11 @@ public class SearchIT extends AbstractLd
SearchResult result = ii.next();
results.add( result.getName() );
}
-
+
return results;
}
-
-
+
+
@Test
public void testDirserver635() throws Exception
{
@@ -423,26 +417,26 @@ public class SearchIT extends AbstractLd
assertEquals( "returned size of results", 2, results.size() );
assertTrue( "contains cn=Tori Amos", results.contains( "cn=Tori Amos" ) );
assertTrue( "contains cn=Kate Bush", results.contains( "cn=Kate Bush" ) );
-
+
// -------------------------------------------------------------------
results = search( "(|(cn=*Amos)(cn=Kate*))" );
assertEquals( "returned size of results", 2, results.size() );
assertTrue( "contains cn=Tori Amos", results.contains( "cn=Tori Amos" ) );
assertTrue( "contains cn=Kate Bush", results.contains( "cn=Kate Bush" ) );
-
+
// -------------------------------------------------------------------
results = search( "(|(cn=Kate Bush)(cn=Tori*))" );
assertEquals( "returned size of results", 2, results.size() );
assertTrue( "contains cn=Tori Amos", results.contains( "cn=Tori Amos" ) );
assertTrue( "contains cn=Kate Bush", results.contains( "cn=Kate Bush" ) );
-
+
// -------------------------------------------------------------------
results = search( "(|(cn=*Amos))" );
assertEquals( "returned size of results", 1, results.size() );
assertTrue( "contains cn=Tori Amos", results.contains( "cn=Tori Amos" ) );
}
-
-
+
+
/**
* Search operation with a base Dn which contains a BER encoded value.
*/
@@ -450,18 +444,18 @@ public class SearchIT extends AbstractLd
public void testSearchWithBackslashEscapedBase() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
// create additional entry
Attributes attributes = this.getPersonAttributes( "Ferry", "Bryan Ferry" );
ctx.createSubcontext( "sn=Ferry", attributes );
-
+
SearchControls sctls = new SearchControls();
sctls.setSearchScope( SearchControls.OBJECT_SCOPE );
String filter = "(cn=Bryan Ferry)";
-
+
// sn=Ferry with BEROctetString values
String base = "sn=\\46\\65\\72\\72\\79";
-
+
try
{
// Check entry
@@ -481,8 +475,8 @@ public class SearchIT extends AbstractLd
fail( e.getMessage() );
}
}
-
-
+
+
/**
* Add a new attribute to a person entry.
*
@@ -492,88 +486,88 @@ public class SearchIT extends AbstractLd
public void testSearchValue() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
// Setting up search controls for compare op
SearchControls ctls = new SearchControls();
ctls.setReturningAttributes( new String[]
{ "*" } ); // no attributes
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
-
+
// Search for all entries
NamingEnumeration<SearchResult> results = ctx.search( RDN, "(cn=*)", ctls );
assertTrue( results.hasMore() );
-
+
results = ctx.search( RDN2, "(cn=*)", ctls );
assertTrue( results.hasMore() );
-
+
// Search for all entries ending by Amos
results = ctx.search( RDN, "(cn=*Amos)", ctls );
assertTrue( results.hasMore() );
-
+
results = ctx.search( RDN2, "(cn=*Amos)", ctls );
assertFalse( results.hasMore() );
-
+
// Search for all entries ending by amos
results = ctx.search( RDN, "(cn=*amos)", ctls );
assertTrue( results.hasMore() );
-
+
results = ctx.search( RDN2, "(cn=*amos)", ctls );
assertFalse( results.hasMore() );
-
+
// Search for all entries starting by Tori
results = ctx.search( RDN, "(cn=Tori*)", ctls );
assertTrue( results.hasMore() );
-
+
results = ctx.search( RDN2, "(cn=Tori*)", ctls );
assertFalse( results.hasMore() );
-
+
// Search for all entries starting by tori
results = ctx.search( RDN, "(cn=tori*)", ctls );
assertTrue( results.hasMore() );
-
+
results = ctx.search( RDN2, "(cn=tori*)", ctls );
assertFalse( results.hasMore() );
-
+
// Search for all entries containing ori
results = ctx.search( RDN, "(cn=*ori*)", ctls );
assertTrue( results.hasMore() );
-
+
results = ctx.search( RDN2, "(cn=*ori*)", ctls );
assertFalse( results.hasMore() );
-
+
// Search for all entries containing o and i
results = ctx.search( RDN, "(cn=*o*i*)", ctls );
assertTrue( results.hasMore() );
-
+
results = ctx.search( RDN2, "(cn=*o*i*)", ctls );
assertTrue( results.hasMore() );
-
+
// Search for all entries containing o, space and o
results = ctx.search( RDN, "(cn=*o* *o*)", ctls );
assertTrue( results.hasMore() );
-
+
results = ctx.search( RDN2, "(cn=*o* *o*)", ctls );
assertFalse( results.hasMore() );
-
+
results = ctx.search( RDN2, "(cn=*o*-*o*)", ctls );
assertTrue( results.hasMore() );
-
+
// Search for all entries starting by To and containing A
results = ctx.search( RDN, "(cn=To*A*)", ctls );
assertTrue( results.hasMore() );
-
+
results = ctx.search( RDN2, "(cn=To*A*)", ctls );
assertFalse( results.hasMore() );
-
+
// Search for all entries ending by os and containing ri
results = ctx.search( RDN, "(cn=*ri*os)", ctls );
assertTrue( results.hasMore() );
-
+
results = ctx.search( RDN2, "(cn=*ri*os)", ctls );
assertFalse( results.hasMore() );
}
-
-
+
+
/**
* Search operation with a base Dn with quotes
*
@@ -617,13 +611,13 @@ public class SearchIT extends AbstractLd
Set<String> results = search( "(|(sn=Bush)(numberOfOctaves=4))" );
assertEquals( "returned size of results", 1, results.size() );
assertTrue( "contains cn=Kate Bush", results.contains( "cn=Kate Bush" ) );
-
+
// if numberOfOctaves is undefined then this whole FILTER is undefined
results = search( "(&(sn=Bush)(numberOfOctaves=4))" );
assertEquals( "returned size of results", 0, results.size() );
}
-
-
+
+
@Test
public void testSearchSchema() throws Exception
{
@@ -631,29 +625,29 @@ public class SearchIT extends AbstractLd
controls.setSearchScope( SearchControls.OBJECT_SCOPE );
controls.setReturningAttributes( new String[]
{ "objectClasses" } );
-
+
LdapContext ctx = getWiredContext( getLdapServer() );
-
+
NamingEnumeration<SearchResult> results = ctx.search( "cn=schema", "objectClass=subschema", controls );
assertTrue( results.hasMore() );
SearchResult result = results.next();
assertNotNull( result );
assertFalse( results.hasMore() );
-
+
NamingEnumeration<? extends Attribute> attrs = result.getAttributes().getAll();
-
+
while ( attrs.hasMoreElements() )
{
Attribute attr = attrs.next();
String ID = attr.getID();
assertEquals( "objectClasses", ID );
}
-
+
assertNotNull( result.getAttributes().get( "objectClasses" ) );
assertEquals( 1, result.getAttributes().size() );
}
-
-
+
+
/**
* Creates an access decorator subentry under ou=system whose subtree covers
* the entire naming context.
@@ -666,9 +660,9 @@ public class SearchIT extends AbstractLd
private void createAccessControlSubentry( String cn, String subtree, String aciItem ) throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
DirContext adminCtx = ctx;
-
+
// modify ou=system to be an AP for an A/C AA if it is not already
Attributes ap = adminCtx.getAttributes( "", new String[]
{ "administrativeRole" } );
@@ -678,7 +672,7 @@ public class SearchIT extends AbstractLd
Attributes changes = new BasicAttributes( "administrativeRole", "accessControlSpecificArea", true );
adminCtx.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, changes );
}
-
+
// now add the A/C subentry below ou=system
Attributes subentry = new BasicAttributes( "cn", cn, true );
Attribute objectClass = new BasicAttribute( "objectClass" );
@@ -690,8 +684,8 @@ public class SearchIT extends AbstractLd
subentry.put( "prescriptiveACI", aciItem );
adminCtx.createSubcontext( "cn=" + cn, subentry );
}
-
-
+
+
/**
* Test case to demonstrate DIRSERVER-705 ("object class top missing in search
* result, if scope is base and attribute objectClass is requested explicitly").
@@ -700,16 +694,16 @@ public class SearchIT extends AbstractLd
public void testAddWithObjectclasses() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
SearchControls ctls = new SearchControls();
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( new String[]
{ "objectclass" } );
String filter = "(objectclass=*)";
String rdn = "cn=Kim Wilde";
-
+
NamingEnumeration<SearchResult> result = ctx.search( rdn, filter, ctls );
-
+
if ( result.hasMore() )
{
SearchResult entry = result.next();
@@ -723,11 +717,11 @@ public class SearchIT extends AbstractLd
{
fail( "entry " + rdn + " not found" );
}
-
+
ctx.destroySubcontext( rdn );
}
-
-
+
+
/**
* Test case to demonstrate DIRSERVER-705 ("object class top missing in search
* result, if scope is base and attribute objectClass is requested explicitly").
@@ -736,14 +730,14 @@ public class SearchIT extends AbstractLd
public void testAddWithMissingObjectclasses() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
String rdn = "cn=Kate Bush";
SearchControls ctls = new SearchControls();
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( new String[]
{ "objectclass" } );
String filter = "(objectclass=*)";
-
+
NamingEnumeration<SearchResult> result = ctx.search( rdn, filter, ctls );
if ( result.hasMore() )
{
@@ -754,22 +748,22 @@ public class SearchIT extends AbstractLd
assertTrue( loadedOcls.contains( "top" ) );
assertTrue( loadedOcls.contains( "person" ) );
assertTrue( loadedOcls.contains( "organizationalPerson" ) );
-
+
}
else
{
fail( "entry " + rdn + " not found" );
}
-
+
ctx.destroySubcontext( rdn );
}
-
-
+
+
@Test
public void testSubentryControl() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
// create a real access decorator subentry
createAccessControlSubentry( "anyBodyAdd", "{}", "{ " + " identificationTag \"addAci\", "
+ " precedence 14, " + " authenticationLevel none, " + " itemOrUserFirst userFirst: " + " { "
@@ -777,7 +771,7 @@ public class SearchIT extends AbstractLd
+ " { " + " protectedItems " + " { " + " entry, allUserAttributeTypesAndValues"
+ " }, " + " grantsAndDenials " + " { " + " grantAdd, grantBrowse "
+ " } " + " } " + " } " + " } " + "}" );
-
+
// prepare the subentry decorator to make the subentry visible
Subentries ctl = new SubentriesImpl();
ctl.setVisibility( true );
@@ -785,23 +779,23 @@ public class SearchIT extends AbstractLd
{ ctl };
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-
+
ctx.setRequestControls( JndiUtils.toJndiControls( getLdapServer().getDirectoryService().getLdapCodecService(),
reqControls ) );
NamingEnumeration<SearchResult> enm = ctx.search( "", "(objectClass=*)", searchControls );
Set<String> results = new HashSet<String>();
-
+
while ( enm.hasMore() )
{
SearchResult result = enm.next();
results.add( result.getName() );
}
-
+
assertEquals( "expected results size of", 1, results.size() );
assertTrue( results.contains( "cn=anyBodyAdd" ) );
}
-
-
+
+
/**
* Create a person entry with multivalued Rdn and check its content. This
* testcase was created to demonstrate DIRSERVER-628.
@@ -810,16 +804,16 @@ public class SearchIT extends AbstractLd
public void testMultiValuedRdnContent() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
String rdn = "cn=Kate Bush+sn=Bush";
ctx.createSubcontext( rdn, attrs );
-
+
SearchControls sctls = new SearchControls();
sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
String filter = "(sn=Bush)";
String base = "";
-
+
NamingEnumeration<SearchResult> enm = ctx.search( base, filter, sctls );
while ( enm.hasMore() )
{
@@ -832,11 +826,11 @@ public class SearchIT extends AbstractLd
assertNotNull( sn );
assertTrue( sn.contains( "Bush" ) );
}
-
+
ctx.destroySubcontext( rdn );
}
-
-
+
+
/**
* Create a person entry with multivalued Rdn and check its name.
*/
@@ -844,18 +838,18 @@ public class SearchIT extends AbstractLd
public void testMultiValuedRdnName() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
String rdn = "cn=Kate Bush+sn=Bush";
DirContext entry = ctx.createSubcontext( rdn, attrs );
String nameInNamespace = entry.getNameInNamespace();
-
+
SearchControls sctls = new SearchControls();
sctls.setSearchScope( SearchControls.OBJECT_SCOPE );
String filter = "(sn=Bush)";
-
+
NamingEnumeration<SearchResult> enm = ctx.search( rdn, filter, sctls );
-
+
if ( enm.hasMore() )
{
SearchResult sr = enm.next();
@@ -866,141 +860,141 @@ public class SearchIT extends AbstractLd
{
fail( "Entry not found:" + nameInNamespace );
}
-
+
enm.close();
-
+
// Now search with the sn=Bush+cn=Kate Bush RDN
String mixedRdn = "sn=Bush+cn=Kate Bush";
-
+
enm = ctx.search( mixedRdn, filter, sctls );
-
+
if ( enm.hasMore() )
{
SearchResult sr = enm.next();
assertNotNull( sr );
Dn expectedDn = new Dn( mixedRdn + ",ou=system" );
-
+
assertEquals( "Name in namespace", expectedDn, sr.getNameInNamespace() );
}
else
{
fail( "Entry not found:" + nameInNamespace );
}
-
+
ctx.destroySubcontext( rdn );
}
-
-
+
+
@Test
public void testSearchJpeg() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
NamingEnumeration<SearchResult> res = ctx.search( "", "(cn=Tori*)", controls );
-
+
// collect all results
while ( res.hasMore() )
{
SearchResult result = res.next();
-
+
Attributes attrs = result.getAttributes();
-
+
NamingEnumeration<? extends Attribute> all = attrs.getAll();
-
+
while ( all.hasMoreElements() )
{
Attribute attr = all.next();
-
+
if ( "jpegPhoto".equalsIgnoreCase( attr.getID() ) )
{
byte[] jpegVal = ( byte[] ) attr.get();
-
+
assertTrue( Arrays.equals( jpegVal, JPEG ) );
}
}
}
}
-
-
+
+
@Test
public void testSearchOID() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
NamingEnumeration<SearchResult> res = ctx.search( "", "(2.5.4.3=Tori*)", controls );
-
+
// ensure that the entry "cn=Tori Amos" was found
assertTrue( res.hasMore() );
-
+
SearchResult result = res.next();
-
+
// ensure that result is not null
assertNotNull( result );
-
+
String rdn = result.getName();
-
+
// ensure that the entry "cn=Tori Amos" was found
assertEquals( "cn=Tori Amos", rdn );
-
+
// ensure that no other value was found
assertFalse( res.hasMore() );
}
-
-
+
+
@Test
public void testSearchAttrCN() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
controls.setReturningAttributes( new String[]
{ "cn" } );
-
+
NamingEnumeration<SearchResult> res = ctx.search( "", "(commonName=Tori*)", controls );
-
+
assertTrue( res.hasMore() );
-
+
SearchResult result = res.next();
-
+
// ensure that result is not null
assertNotNull( result );
-
+
Attributes attrs = result.getAttributes();
-
+
// ensure the one and only attribute is "cn"
assertEquals( 1, attrs.size() );
assertNotNull( attrs.get( "cn" ) );
assertEquals( 1, attrs.get( "cn" ).size() );
assertEquals( "Tori Amos", attrs.get( "cn" ).get() );
}
-
-
+
+
@Test
public void testSearchAttrName() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
controls.setReturningAttributes( new String[]
{ "name" } );
-
+
NamingEnumeration<SearchResult> res = ctx.search( "", "(commonName=Tori*)", controls );
-
+
assertTrue( res.hasMore() );
-
+
SearchResult result = res.next();
-
+
// ensure that result is not null
assertNotNull( result );
-
+
Attributes attrs = result.getAttributes();
-
+
// ensure that "cn" and "sn" are returned
assertEquals( 2, attrs.size() );
assertNotNull( attrs.get( "cn" ) );
@@ -1010,29 +1004,29 @@ public class SearchIT extends AbstractLd
assertEquals( 1, attrs.get( "sn" ).size() );
assertEquals( "Amos", attrs.get( "sn" ).get() );
}
-
-
+
+
@Test
public void testSearchAttrCommonName() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
controls.setReturningAttributes( new String[]
{ "commonName" } );
-
+
NamingEnumeration<SearchResult> res = ctx.search( "", "(commonName=Tori*)", controls );
-
+
assertTrue( res.hasMore() );
-
+
SearchResult result = res.next();
-
+
// ensure that result is not null
assertNotNull( result );
-
+
Attributes attrs = result.getAttributes();
-
+
// requested attribute was "commonName", but ADS returns "cn".
// Other servers do the following:
// - OpenLDAP: also return "cn"
@@ -1044,29 +1038,29 @@ public class SearchIT extends AbstractLd
assertEquals( 1, attrs.get( "cn" ).size() );
assertEquals( "Tori Amos", attrs.get( "cn" ).get() );
}
-
-
+
+
@Test
public void testSearchAttrOID() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
controls.setReturningAttributes( new String[]
{ "2.5.4.3" } );
-
+
NamingEnumeration<SearchResult> res = ctx.search( "", "(commonName=Tori*)", controls );
-
+
assertTrue( res.hasMore() );
-
+
SearchResult result = res.next();
-
+
// ensure that result is not null
assertNotNull( result );
-
+
Attributes attrs = result.getAttributes();
-
+
// requested attribute was "2.5.4.3", but ADS returns "cn".
// Other servers do the following:
// - OpenLDAP: also return "cn"
@@ -1078,13 +1072,13 @@ public class SearchIT extends AbstractLd
assertEquals( 1, attrs.get( "cn" ).size() );
assertEquals( "Tori Amos", attrs.get( "cn" ).get() );
}
-
-
+
+
@Test
public void testSearchAttrC_L() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
// create administrative area
Attributes aaAttrs = new BasicAttributes( true );
Attribute aaObjectClass = new BasicAttribute( "objectClass" );
@@ -1095,7 +1089,7 @@ public class SearchIT extends AbstractLd
aaAttrs.put( "ou", "Collective Area" );
aaAttrs.put( "administrativeRole", "collectiveAttributeSpecificArea" );
DirContext aaCtx = ctx.createSubcontext( "ou=Collective Area", aaAttrs );
-
+
// create subentry
Attributes subentry = new BasicAttributes( true );
Attribute objectClass = new BasicAttribute( "objectClass" );
@@ -1107,57 +1101,57 @@ public class SearchIT extends AbstractLd
subentry.put( "cn", "Collective Subentry" );
subentry.put( "subtreeSpecification", "{ }" );
aaCtx.createSubcontext( "cn=Collective Subentry", subentry );
-
+
// create real enty
Attributes attributes = this.getPersonAttributes( "Bush", "Kate Bush" );
aaCtx.createSubcontext( "cn=Kate Bush", attributes );
-
+
// search
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
controls.setReturningAttributes( new String[]
{ "c-l" } );
-
+
NamingEnumeration<SearchResult> res = aaCtx.search( "", "(cn=Kate Bush)", controls );
-
+
assertTrue( res.hasMore() );
-
+
SearchResult result = res.next();
-
+
// ensure that result is not null
assertNotNull( result );
-
+
Attributes attrs = result.getAttributes();
-
+
// ensure the one and only attribute is "c-l"
assertEquals( 1, attrs.size() );
assertNotNull( attrs.get( "c-l" ) );
assertEquals( 1, attrs.get( "c-l" ).size() );
assertEquals( "Munich", attrs.get( "c-l" ).get() );
}
-
-
+
+
@Test
public void testSearchUsersAttrs() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
controls.setReturningAttributes( new String[]
{ "*" } );
-
+
NamingEnumeration<SearchResult> res = ctx.search( "", "(commonName=Tori Amos)", controls );
-
+
assertTrue( res.hasMore() );
-
+
SearchResult result = res.next();
-
+
// ensure that result is not null
assertNotNull( result );
-
+
Attributes attrs = result.getAttributes();
-
+
// ensure that all user attributes are returned
assertEquals( 6, attrs.size() );
assertNotNull( attrs.get( "cn" ) );
@@ -1169,29 +1163,29 @@ public class SearchIT extends AbstractLd
assertNull( attrs.get( "createtimestamp" ) );
assertNull( attrs.get( "creatorsname" ) );
}
-
-
+
+
@Test
public void testSearchOperationalAttrs() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
controls.setReturningAttributes( new String[]
{ "+" } );
-
+
NamingEnumeration<SearchResult> res = ctx.search( "", "(commonName=Tori Amos)", controls );
-
+
assertTrue( res.hasMore() );
-
+
SearchResult result = res.next();
-
+
// ensure that result is not null
assertNotNull( result );
-
+
Attributes attrs = result.getAttributes();
-
+
// ensure that all operational attributes are returned
// and no user attributes
assertEquals( 6, attrs.size() );
@@ -1206,29 +1200,29 @@ public class SearchIT extends AbstractLd
assertNotNull( attrs.get( "entrycsn" ) );
assertNotNull( attrs.get( "entryDn" ) );
}
-
-
+
+
@Test
public void testSearchAllAttrs() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
controls.setReturningAttributes( new String[]
{ "+", "*" } );
-
+
NamingEnumeration<SearchResult> res = ctx.search( "", "(commonName=Tori Amos)", controls );
-
+
assertTrue( res.hasMore() );
-
+
SearchResult result = res.next();
-
+
// ensure that result is not null
assertNotNull( result );
-
+
Attributes attrs = result.getAttributes();
-
+
// ensure that all user attributes are returned
assertEquals( 12, attrs.size() );
assertNotNull( attrs.get( "cn" ) );
@@ -1243,15 +1237,15 @@ public class SearchIT extends AbstractLd
assertNotNull( attrs.get( "entrycsn" ) );
assertNotNull( attrs.get( "entryDn" ) );
}
-
-
+
+
@Test
public void testSearchBadDN() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-
+
try
{
ctx.search( "cn=admin", "(objectClass=*)", controls );
@@ -1261,16 +1255,16 @@ public class SearchIT extends AbstractLd
assertTrue( true );
}
}
-
-
+
+
@Test
public void testSearchInvalidDN() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-
+
try
{
ctx.search( "myBadDN", "(objectClass=*)", controls );
@@ -1281,8 +1275,8 @@ public class SearchIT extends AbstractLd
assertTrue( true );
}
}
-
-
+
+
/**
* Check if operational attributes are present, if "+" is requested.
*/
@@ -1291,31 +1285,31 @@ public class SearchIT extends AbstractLd
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
SearchControls ctls = new SearchControls();
-
+
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( new String[]
{ "+" } );
-
+
NamingEnumeration<SearchResult> result = ctx.search( HEATHER_RDN, FILTER, ctls );
-
+
if ( result.hasMore() )
{
SearchResult entry = result.next();
-
+
String[] opAttrNames =
{ "creatorsName", "createTimestamp" };
-
+
checkForAttributes( entry.getAttributes(), opAttrNames );
}
else
{
fail( "entry " + HEATHER_RDN + " not found" );
}
-
+
result.close();
}
-
-
+
+
/**
* Check if user attributes are present, if "*" is requested.
*/
@@ -1324,31 +1318,31 @@ public class SearchIT extends AbstractLd
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
SearchControls ctls = new SearchControls();
-
+
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( new String[]
{ "*" } );
-
+
NamingEnumeration<SearchResult> result = ctx.search( HEATHER_RDN, FILTER, ctls );
-
+
if ( result.hasMore() )
{
SearchResult entry = result.next();
-
+
String[] userAttrNames =
{ "objectClass", "sn", "cn" };
-
+
checkForAttributes( entry.getAttributes(), userAttrNames );
}
else
{
fail( "entry " + HEATHER_RDN + " not found" );
}
-
+
result.close();
}
-
-
+
+
/**
* Check if no error occurs if " " is requested.
*/
@@ -1357,16 +1351,16 @@ public class SearchIT extends AbstractLd
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
SearchControls ctls = new SearchControls();
-
+
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( new String[]
{ " " } );
-
+
NamingEnumeration<SearchResult> result = ctx.search( HEATHER_RDN, FILTER, ctls );
result.close();
}
-
-
+
+
/**
* Check if no error occurs if "" is requested.
*/
@@ -1375,16 +1369,16 @@ public class SearchIT extends AbstractLd
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
SearchControls ctls = new SearchControls();
-
+
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( new String[]
{ "" } );
-
+
NamingEnumeration<SearchResult> result = ctx.search( HEATHER_RDN, FILTER, ctls );
result.close();
}
-
-
+
+
/**
* Check if no error occurs if "" is requested.
*/
@@ -1393,15 +1387,15 @@ public class SearchIT extends AbstractLd
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
SearchControls ctls = new SearchControls();
-
+
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( new String[0] );
-
+
NamingEnumeration<SearchResult> result = ctx.search( HEATHER_RDN, FILTER, ctls );
result.close();
}
-
-
+
+
/**
* Check if user and operational attributes are present, if both "*" and "+" are requested.
*/
@@ -1410,26 +1404,26 @@ public class SearchIT extends AbstractLd
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
SearchControls ctls = new SearchControls();
-
+
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( new String[]
{ "+", "*" } );
-
+
String[] userAttrNames =
{ "objectClass", "sn", "cn" };
-
+
String[] opAttrNames =
{ "creatorsName", "createTimestamp" };
-
+
NamingEnumeration<SearchResult> result = ctx.search( HEATHER_RDN, FILTER, ctls );
-
+
if ( result.hasMore() )
{
SearchResult entry = result.next();
Attributes attrs = entry.getAttributes();
-
+
assertNotNull( attrs );
-
+
checkForAttributes( attrs, userAttrNames );
checkForAttributes( attrs, opAttrNames );
}
@@ -1437,21 +1431,21 @@ public class SearchIT extends AbstractLd
{
fail( "entry " + HEATHER_RDN + " not found" );
}
-
+
result.close();
-
+
ctls.setReturningAttributes( new String[]
{ "*", "+" } );
-
+
result = ctx.search( HEATHER_RDN, FILTER, ctls );
-
+
if ( result.hasMore() )
{
SearchResult entry = result.next();
Attributes attrs = entry.getAttributes();
-
+
assertNotNull( attrs );
-
+
checkForAttributes( attrs, userAttrNames );
checkForAttributes( attrs, opAttrNames );
}
@@ -1459,16 +1453,16 @@ public class SearchIT extends AbstractLd
{
fail( "entry " + HEATHER_RDN + " not found" );
}
-
+
result.close();
}
-
-
+
+
@Test
public void testSubstringSearchWithEscapedCharsInFilter() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
Attributes attrs = new BasicAttributes( "objectClass", "inetOrgPerson", true );
attrs.get( "objectClass" ).add( "organizationalPerson" );
attrs.get( "objectClass" ).add( "person" );
@@ -1477,12 +1471,12 @@ public class SearchIT extends AbstractLd
attrs.put( "cn", "jimbean" );
attrs.put( "description", "(sex*pis\\tols)" );
ctx.createSubcontext( "cn=jimbean", attrs );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
controls.setReturningAttributes( new String[]
{ "cn" } );
-
+
String[] filters = new String[]
{ "(description=*\\28*)", "(description=*\\29*)", "(description=*\\2A*)", "(description=*\\5C*)" };
for ( String filter : filters )
@@ -1499,8 +1493,8 @@ public class SearchIT extends AbstractLd
assertFalse( res.hasMore() );
}
}
-
-
+
+
/**
* Test for DIRSERVER-1180 where search hangs when an invalid a substring
* expression missing an any field is used in a filter: i.e. (cn=**).
@@ -1517,9 +1511,9 @@ public class SearchIT extends AbstractLd
attrs.put( "givenName", "Jim" );
attrs.put( "sn", "Bean" );
attrs.put( "cn", "jimbean" );
-
+
ctx.createSubcontext( "cn=jimbean", attrs );
-
+
try
{
ctx.search( "", "(cn=**)", new SearchControls() );
@@ -1530,13 +1524,13 @@ public class SearchIT extends AbstractLd
assertTrue( true );
}
}
-
-
+
+
@Test
public void testSubstringSearchWithEscapedAsterisksInFilter_DIRSERVER_1181() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
Attributes vicious = new BasicAttributes( true );
Attribute ocls = new BasicAttribute( "objectClass" );
ocls.add( "top" );
@@ -1545,26 +1539,26 @@ public class SearchIT extends AbstractLd
vicious.put( "cn", "x*y*z*" );
vicious.put( "sn", "x*y*z*" );
ctx.createSubcontext( "cn=x*y*z*", vicious );
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
controls.setReturningAttributes( new String[]
{ "cn" } );
NamingEnumeration<SearchResult> res;
-
+
res = ctx.search( "", "(cn=*x\\2Ay\\2Az\\2A*)", controls );
assertTrue( res.hasMore() );
assertEquals( "x*y*z*", res.next().getAttributes().get( "cn" ).get() );
assertFalse( res.hasMore() );
-
+
res = ctx.search( "", "(cn=*{0}*)", new String[]
{ "x*y*z*" }, controls );
assertTrue( res.hasMore() );
assertEquals( "x*y*z*", res.next().getAttributes().get( "cn" ).get() );
assertFalse( res.hasMore() );
}
-
-
+
+
/**
* Test for DIRSERVER-1347: Unicode characters in filter value.
*/
@@ -1572,7 +1566,7 @@ public class SearchIT extends AbstractLd
public void testUnicodeFilter_DIRSERVER_1347() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
-
+
Attributes groupOfNames = new BasicAttributes( true );
Attribute groupOfNamesOC = new BasicAttribute( "objectClass" );
groupOfNamesOC.add( "top" );
@@ -1584,7 +1578,7 @@ public class SearchIT extends AbstractLd
member.add( "uid=r\u00e9dacteur1,ou=system" );
groupOfNames.put( member );
ctx.createSubcontext( "cn=groupOfNames", groupOfNames );
-
+
Attributes groupOfUniqueNames = new BasicAttributes( true );
Attribute groupOfUniqueNamesOC = new BasicAttribute( "objectClass" );
groupOfUniqueNamesOC.add( "top" );
@@ -1596,36 +1590,36 @@ public class SearchIT extends AbstractLd
uniqueMember.add( "uid=r\u00e9dacteur1,ou=system" );
groupOfUniqueNames.put( uniqueMember );
ctx.createSubcontext( "cn=groupOfUniqueNames", groupOfUniqueNames );
-
+
SearchControls controls = new SearchControls();
NamingEnumeration<SearchResult> res;
-
+
// search with unicode filter value
res = ctx.search( "", "(member=uid=r\u00e9dacteur1,ou=system)", controls );
assertTrue( res.hasMore() );
assertEquals( "groupOfNames", res.next().getAttributes().get( "cn" ).get() );
assertFalse( res.hasMore() );
-
+
// search with escaped filter value
res = ctx.search( "", "(member=uid=r\\c3\\a9dacteur1,ou=system)", controls );
assertTrue( res.hasMore() );
assertEquals( "groupOfNames", res.next().getAttributes().get( "cn" ).get() );
assertFalse( res.hasMore() );
-
+
// search with unicode filter value
res = ctx.search( "", "(uniqueMember=uid=r\u00e9dacteur1,ou=system)", controls );
assertTrue( res.hasMore() );
assertEquals( "groupOfUniqueNames", res.next().getAttributes().get( "cn" ).get() );
assertFalse( res.hasMore() );
-
+
// search with escaped filter value
res = ctx.search( "", "(uniqueMember=uid=r\\c3\\a9dacteur1,ou=system)", controls );
assertTrue( res.hasMore() );
assertEquals( "groupOfUniqueNames", res.next().getAttributes().get( "cn" ).get() );
assertFalse( res.hasMore() );
}
-
-
+
+
/**
* Check if no user attributes are present, if "1.1" is requested.
*/
@@ -1634,13 +1628,13 @@ public class SearchIT extends AbstractLd
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
SearchControls ctls = new SearchControls();
-
+
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( new String[]
{ "1.1" } );
-
+
NamingEnumeration<SearchResult> result = ctx.search( HEATHER_RDN, FILTER, ctls );
-
+
if ( result.hasMore() )
{
SearchResult entry = result.next();
@@ -1650,11 +1644,11 @@ public class SearchIT extends AbstractLd
{
fail( "entry " + HEATHER_RDN + " not found" );
}
-
+
result.close();
}
-
-
+
+
/**
* test an abandonned search request.
*/
@@ -1663,43 +1657,43 @@ public class SearchIT extends AbstractLd
{
LdapConnection asyncCnx = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
EntryCursor cursor = null;
-
+
try
{
// Use the client API as JNDI cannot be used to do a search without
// first binding. (hmmm, even client API won't allow searching without binding)
asyncCnx.bind( "uid=admin,ou=system", "secret" );
-
+
// First, add 100 entries in the server
for ( int i = 0; i < 100; i++ )
{
String dn = "cn=user" + i + "," + BASE;
Entry kate = new DefaultEntry( dn );
-
+
kate.add( "objectclass", "top", "person" );
kate.add( "sn", "Bush" );
kate.add( "cn", "user" + i );
-
+
asyncCnx.add( kate );
}
-
+
// Searches for all the entries in ou=system
cursor = asyncCnx.search( "ou=system", "(ObjectClass=*)", SearchScope.SUBTREE, "*" );
-
+
// Now loop on all the elements found, and abandon after 10 elements returned
int count = 0;
-
+
while ( cursor.next() )
{
count++;
-
+
if ( count == 10 )
{
// the message ID = 1 bind op + 100 add ops + 1 search op
asyncCnx.abandon( 102 );
}
}
-
+
assertEquals( 10, count );
}
catch ( LdapException e )
@@ -1714,8 +1708,8 @@ public class SearchIT extends AbstractLd
cursor.close();
}
}
-
-
+
+
@Test
public void testSearchSubstringWithPlus() throws Exception
{
@@ -1723,17 +1717,17 @@ public class SearchIT extends AbstractLd
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
controls.setTimeLimit( 10 );
-
+
NamingEnumeration<SearchResult> result = ctx.search( "ou=system", "(description=*+*)", controls );
-
+
assertTrue( result.hasMore() );
-
+
SearchResult entry = result.next();
-
+
assertEquals( "Kim Wilde", entry.getAttributes().get( "cn" ).get() );
}
-
-
+
+
@Test
public void testSearchSizeLimit() throws Exception
{
@@ -1744,23 +1738,23 @@ public class SearchIT extends AbstractLd
req.setFilter( "(ou=*)" );
req.setScope( SearchScope.SUBTREE );
req.setSizeLimit( sizeLimit );
-
+
Cursor<Response> cursor = connection.search( req );
long i = 0;
-
+
// Equivalent to : while ( cursor.next() )
for ( Response response : cursor )
{
++i;
}
-
+
cursor.close();
-
+
assertEquals( sizeLimit, i );
connection.close();
}
-
-
+
+
@Test
@Ignore("This test is failing because of the timing issue. Note that the SearchHandler handles time based searches correctly, this is just the below test's problem")
public void testSearchTimeLimit() throws Exception, InterruptedException
@@ -1770,31 +1764,31 @@ public class SearchIT extends AbstractLd
req.setBase( new Dn( "ou=schema" ) );
req.setFilter( "(objectClass=*)" );
req.setScope( SearchScope.SUBTREE );
-
+
Cursor<Response> cursor = connection.search( req );
int count = 0;
-
+
while ( cursor.next() )
{
++count;
}
-
+
cursor.close();
-
+
req.setTimeLimit( 1 );
cursor = connection.search( req );
int newCount = 0;
-
+
while ( cursor.next() )
{
++newCount;
}
-
+
assertTrue( newCount < count );
connection.close();
}
-
-
+
+
@Test
public void testSearchComplexFilter() throws Exception
{
@@ -1802,19 +1796,19 @@ public class SearchIT extends AbstractLd
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.OBJECT_SCOPE );
controls.setTimeLimit( 10 );
-
+
NamingEnumeration<SearchResult> result = ctx.search( "cn=Kim Wilde,ou=system",
"(&(&(ObjectClass=person)(!(ObjectClass=strongAuthenticationUser))(sn=Wilde)))", controls );
-
+
assertTrue( result.hasMore() );
SearchResult sr = result.next();
assertNotNull( sr );
assertEquals( "Kim Wilde", sr.getAttributes().get( "cn" ).get() );
-
+
// Now check with another version of the filter
result = ctx.search( "cn=Kim Wilde,ou=system",
"(&(sn=Wilde)(&(objectClass=person)(!(objectClass=strongAuthenticationUser))))", controls );
-
+
assertTrue( result.hasMore() );
sr = result.next();
assertNotNull( sr );
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java?rev=1509635&r1=1509634&r2=1509635&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java Fri Aug 2 11:26:45 2013
@@ -35,7 +35,6 @@ import javax.naming.directory.DirContext
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
-import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.annotations.ApplyLdifs;
@@ -45,7 +44,6 @@ import org.apache.directory.server.core.
import org.apache.directory.server.ldap.LdapServer;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -112,18 +110,14 @@ import org.junit.runner.RunWith;
"uid: jnewbie",
"userPassword: secret",
"cn: Joe Newbie",
- "sn: Newbie"
-})
+ "sn: Newbie" })
public class SearchLimitsIT extends AbstractLdapTestUnit
{
- @Rule
- public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
-
private int oldMaxTimeLimit;
private long oldMaxSizeLimit;
private DelayInducingInterceptor delayInterceptor;
-
-
+
+
@Before
public void setUp() throws Exception
{
@@ -132,8 +126,8 @@ public class SearchLimitsIT extends Abst
delayInterceptor = new DelayInducingInterceptor();
getLdapServer().getDirectoryService().addFirst( delayInterceptor );
}
-
-
+
+
@After
public void tearDown() throws Exception
{
@@ -141,12 +135,12 @@ public class SearchLimitsIT extends Abst
getLdapServer().setMaxSizeLimit( oldMaxSizeLimit );
getLdapServer().getDirectoryService().remove( delayInterceptor.getName() );
}
-
-
+
+
// -----------------------------------------------------------------------
// Time Limit Tests
// -----------------------------------------------------------------------
-
+
/**
* Sets up the server with unlimited search time limit but constrains time
* by request time limit value to cause a time limit exceeded exception on
@@ -157,7 +151,7 @@ public class SearchLimitsIT extends Abst
{
getLdapServer().setMaxTimeLimit( LdapServer.NO_TIME_LIMIT );
delayInterceptor.setDelayMillis( 500 );
-
+
try
{
getActorsWithLimit( "(objectClass=*)", 499, LdapServer.NO_SIZE_LIMIT );
@@ -167,8 +161,8 @@ public class SearchLimitsIT extends Abst
throw e;
}
}
-
-
+
+
/**
* Sets up the server with longer search time limit than the request's
* which constrains time by request time limit value to cause a time limit
@@ -179,11 +173,11 @@ public class SearchLimitsIT extends Abst
{
getLdapServer().setMaxTimeLimit( 10000 ); // this is in seconds
delayInterceptor.setDelayMillis( 500 );
-
+
getActorsWithLimit( "(objectClass=*)", 499, LdapServer.NO_SIZE_LIMIT );
}
-
-
+
+
/**
* Sets up the server with shorter search time limit than the request's
* which constrains time by using server max limit value to cause a time
@@ -194,11 +188,11 @@ public class SearchLimitsIT extends Abst
{
getLdapServer().setMaxTimeLimit( 1 ); // this is in seconds
delayInterceptor.setDelayMillis( 1100 );
-
+
getActorsWithLimit( "(objectClass=*)", 100000, LdapServer.NO_SIZE_LIMIT );
}
-
-
+
+
/**
* Sets up the server with limited search time with unlimited request
* time limit. Should work just fine for the administrative user.
@@ -208,12 +202,12 @@ public class SearchLimitsIT extends Abst
{
getLdapServer().setMaxTimeLimit( 1 ); // this is in seconds
delayInterceptor.setDelayMillis( 500 );
-
+
getActorsWithLimit( "(objectClass=*)",
LdapServer.NO_TIME_LIMIT, LdapServer.NO_SIZE_LIMIT );
}
-
-
+
+
/**
* Sets up the server with limited search time with unlimited request
* time limit. Should not work for non administrative users.
@@ -223,16 +217,16 @@ public class SearchLimitsIT extends Abst
{
getLdapServer().setMaxTimeLimit( 1 ); // this is in seconds
delayInterceptor.setDelayMillis( 500 );
-
+
getActorsWithLimitNonAdmin( "(objectClass=*)",
LdapServer.NO_TIME_LIMIT, LdapServer.NO_SIZE_LIMIT );
}
-
-
+
+
// -----------------------------------------------------------------------
// Size Limit Tests
// -----------------------------------------------------------------------
-
+
/**
* Sets up the server with unlimited search size limit but constrains size
* by request size limit value to cause a size limit exceeded exception on
@@ -242,11 +236,11 @@ public class SearchLimitsIT extends Abst
public void testRequestConstrainedUnlimitByConfigurationSize() throws Exception
{
getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-
+
getActorsWithLimit( "(objectClass=*)", LdapServer.NO_TIME_LIMIT, 1 );
}
-
-
+
+
/**
* Sets up the server with longer search size limit than the request's
* which constrains size by request size limit value to cause a size limit
@@ -256,11 +250,11 @@ public class SearchLimitsIT extends Abst
public void testRequestConstrainedLessThanConfigurationSize() throws Exception
{
getLdapServer().setMaxSizeLimit( 10000 );
-
+
getActorsWithLimit( "(objectClass=*)", LdapServer.NO_TIME_LIMIT, 1 );
}
-
-
+
+
/**
* Sets up the server with shorter search size limit than the request's
* which constrains size by using server max limit value. Should work
@@ -273,8 +267,8 @@ public class SearchLimitsIT extends Abst
Set<String> set = getActorsWithLimit( "(objectClass=*)", LdapServer.NO_TIME_LIMIT, 100000 );
assertEquals( 4, set.size() );
}
-
-
+
+
/**
* Sets up the server with shorter search size limit than the request's
* which constrains size by using server max limit value to cause a size
@@ -284,12 +278,12 @@ public class SearchLimitsIT extends Abst
public void testNonAdminRequestConstrainedGreaterThanConfigurationSize() throws Exception
{
getLdapServer().setMaxSizeLimit( 1 );
-
+
// We are not using the admin : it should fail
getActorsWithLimitNonAdmin( "(objectClass=*)", LdapServer.NO_TIME_LIMIT, 100000 );
}
-
-
+
+
/**
* Sets up the server with limited search size with unlimited request
* size limit. Should work just fine for the administrative user.
@@ -300,11 +294,11 @@ public class SearchLimitsIT extends Abst
getLdapServer().setMaxSizeLimit( 1 );
Set<String> set = getActorsWithLimit( "(objectClass=*)",
LdapServer.NO_TIME_LIMIT, LdapServer.NO_SIZE_LIMIT );
-
+
assertEquals( 4, set.size() );
}
-
-
+
+
/**
* Sets up the server with limited search size with unlimited request
* size limit. Should not work for non administrative users.
@@ -316,8 +310,8 @@ public class SearchLimitsIT extends Abst
getActorsWithLimitNonAdmin( "(objectClass=*)",
LdapServer.NO_TIME_LIMIT, LdapServer.NO_SIZE_LIMIT );
}
-
-
+
+
/**
* Test for DIRSERVER-1235.
* Sets up the server with unlimited search size limit but constrains size
@@ -333,11 +327,11 @@ public class SearchLimitsIT extends Abst
public void testRequestConstraintedLessThanExpectedSize() throws Exception
{
getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-
+
getActorsWithLimit( "(objectClass=*)", LdapServer.NO_TIME_LIMIT, 3 );
}
-
-
+
+
/**
* Test for DIRSERVER-1235.
* Sets up the server with unlimited search size limit but constrains size
@@ -351,8 +345,8 @@ public class SearchLimitsIT extends Abst
Set<String> set = getActorsWithLimit( "(objectClass=*)", LdapServer.NO_TIME_LIMIT, 4 );
assertEquals( 4, set.size() );
}
-
-
+
+
/**
* Test for DIRSERVER-1235.
* Sets up the server with unlimited search size limit but constrains size
@@ -366,8 +360,8 @@ public class SearchLimitsIT extends Abst
Set<String> set = getActorsWithLimit( "(objectClass=*)", LdapServer.NO_TIME_LIMIT, 5 );
assertEquals( 4, set.size() );
}
-
-
+
+
/**
* Test for DIRSERVER-1235.
* Reads an entry using object scope and size limit 1, no exception
@@ -377,26 +371,26 @@ public class SearchLimitsIT extends Abst
public void testRequestObjectScopeAndSizeLimit() throws Exception
{
getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-
+
DirContext ctx = getWiredContext( getLdapServer() );
String filter = "(objectClass=*)";
SearchControls controls = new SearchControls();
controls.setTimeLimit( 0 );
controls.setCountLimit( 1 );
controls.setSearchScope( SearchControls.OBJECT_SCOPE );
-
+
NamingEnumeration<SearchResult> namingEnumeration =
ctx.search( "ou=actors,ou=system", filter, controls );
assertTrue( namingEnumeration.hasMore() );
namingEnumeration.next();
assertFalse( namingEnumeration.hasMore() );
}
-
-
+
+
// -----------------------------------------------------------------------
// Utility Methods
// -----------------------------------------------------------------------
-
+
/**
* Do a search request from the ou=actors,ou=system base, with a principal
* which is the administrator.
@@ -409,19 +403,19 @@ public class SearchLimitsIT extends Abst
controls.setTimeLimit( timeLimitMillis );
controls.setCountLimit( sizeLimit );
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-
+
NamingEnumeration<SearchResult> namingEnumeration =
ctx.search( "ou=actors,ou=system", filter, controls );
-
+
while ( namingEnumeration.hasMore() )
{
results.add( namingEnumeration.next().getNameInNamespace() );
}
-
+
return results;
}
-
-
+
+
/**
* Do a search request from the ou=actors,ou=system base, with a principal
* which is not the administrator.
@@ -435,15 +429,15 @@ public class SearchLimitsIT extends Abst
controls.setTimeLimit( timeLimitMillis );
controls.setCountLimit( sizeLimit );
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-
+
NamingEnumeration<SearchResult> namingEnumeration =
ctx.search( "ou=actors,ou=system", filter, controls );
-
+
while ( namingEnumeration.hasMore() )
{
results.add( namingEnumeration.next().getNameInNamespace() );
}
-
+
return results;
}
}
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java?rev=1509635&r1=1509634&r2=1509635&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java Fri Aug 2 11:26:45 2013
@@ -36,7 +36,6 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.ldap.model.message.SearchRequestImpl;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
-import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.annotations.ContextEntry;
@@ -57,7 +56,6 @@ import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Rule;
import org.junit.Test;
@@ -68,9 +66,6 @@ import org.junit.Test;
*/
public class ClientInitialRefreshIT
{
- @Rule
- public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
-
private static LdapServer providerServer;
private static SchemaManager schemaManager;
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/schema/SchemaIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/schema/SchemaIT.java?rev=1509635&r1=1509634&r2=1509635&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/schema/SchemaIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/schema/SchemaIT.java Fri Aug 2 11:26:45 2013
@@ -49,12 +49,10 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.ldap.model.schema.parsers.AttributeTypeDescriptionSchemaParser;
import org.apache.directory.api.ldap.model.schema.parsers.ObjectClassDescriptionSchemaParser;
import org.apache.directory.api.ldap.util.JndiUtils;
-import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
import org.apache.directory.server.core.annotations.ApplyLdifs;
import org.apache.directory.server.core.annotations.CreateDS;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -68,9 +66,6 @@ import org.junit.runner.RunWith;
@CreateDS(name = "SchemaIT-class")
public class SchemaIT extends AbstractLdapTestUnit
{
- @Rule
- public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
-
private static final String SUBSCHEMA_SUBENTRY = "subschemaSubentry";
private static final AttributeTypeDescriptionSchemaParser ATTRIBUTE_TYPE_DESCRIPTION_SCHEMA_PARSER = new AttributeTypeDescriptionSchemaParser();
private static final ObjectClassDescriptionSchemaParser OBJECT_CLASS_DESCRIPTION_SCHEMA_PARSER = new ObjectClassDescriptionSchemaParser();
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsIT.java?rev=1509635&r1=1509634&r2=1509635&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsIT.java Fri Aug 2 11:26:45 2013
@@ -31,7 +31,6 @@ import javax.naming.directory.InitialDir
import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms;
import org.apache.directory.api.ldap.model.ldif.LdifUtils;
-import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.annotations.SaslMechanism;
@@ -45,7 +44,6 @@ import org.apache.directory.server.ldap.
import org.apache.directory.server.ldap.handlers.sasl.ntlm.NtlmMechanismHandler;
import org.apache.directory.server.ldap.handlers.sasl.plain.PlainMechanismHandler;
import org.apache.directory.server.operations.bind.BogusNtlmProvider;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -81,9 +79,6 @@ import org.junit.runner.RunWith;
ntlmProvider = BogusNtlmProvider.class)
public class LdapsIT extends AbstractLdapTestUnit
{
- @Rule
- public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
-
private static final String RDN = "cn=The Person";
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsUpdateCertificateIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsUpdateCertificateIT.java?rev=1509635&r1=1509634&r2=1509635&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsUpdateCertificateIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsUpdateCertificateIT.java Fri Aug 2 11:26:45 2013
@@ -35,7 +35,6 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.util.Strings;
-import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.annotations.SaslMechanism;
@@ -50,7 +49,6 @@ import org.apache.directory.server.ldap.
import org.apache.directory.server.ldap.handlers.sasl.ntlm.NtlmMechanismHandler;
import org.apache.directory.server.ldap.handlers.sasl.plain.PlainMechanismHandler;
import org.apache.directory.server.operations.bind.BogusNtlmProvider;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -86,10 +84,6 @@ import org.junit.runner.RunWith;
ntlmProvider = BogusNtlmProvider.class)
public class LdapsUpdateCertificateIT extends AbstractLdapTestUnit
{
- @Rule
- public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
-
-
/**
* Create an entry for a person.
*/
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsConfidentialityIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsConfidentialityIT.java?rev=1509635&r1=1509634&r2=1509635&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsConfidentialityIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsConfidentialityIT.java Fri Aug 2 11:26:45 2013
@@ -54,7 +54,6 @@ import javax.net.ssl.SSLSession;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.name.Dn;
-import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.annotations.CreateDS;
@@ -65,7 +64,6 @@ import org.apache.directory.server.integ
import org.apache.directory.server.ldap.handlers.extended.StartTlsHandler;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
@@ -94,9 +92,6 @@ import org.slf4j.LoggerFactory;
{ StartTlsHandler.class })
public class StartTlsConfidentialityIT extends AbstractLdapTestUnit
{
- @Rule
- public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
-
private static final Logger LOG = LoggerFactory.getLogger( StartTlsConfidentialityIT.class );
private static final String[] CERT_IDS = new String[]
{ "userCertificate" };
@@ -266,7 +261,7 @@ public class StartTlsConfidentialityIT e
new ModificationItem( DirContext.ADD_ATTRIBUTE, new BasicAttribute( "cn", "fbar" ) )
};
ctx.modifyAttributes( "cn=foo bar,ou=system", mods );
- Attributes reread = ( Attributes ) ctx.getAttributes( "cn=foo bar,ou=system" );
+ Attributes reread = ctx.getAttributes( "cn=foo bar,ou=system" );
assertTrue( reread.get( "cn" ).contains( "fbar" ) );
// -------------------------------------------------------------------
@@ -282,7 +277,7 @@ public class StartTlsConfidentialityIT e
catch ( NameNotFoundException e )
{
}
- reread = ( Attributes ) ctx.getAttributes( "cn=fbar,ou=system" );
+ reread = ctx.getAttributes( "cn=fbar,ou=system" );
assertTrue( reread.get( "cn" ).contains( "fbar" ) );
// -------------------------------------------------------------------