You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/02/10 11:49:57 UTC
svn commit: r376623 [38/38] - in /directory/sandbox/akarasulu/rc1/apacheds:
core-plugin/src/main/java/org/apache/directory/server/core/tools/schema/
core-plugin/src/test/java/org/apache/directory/server/core/tools/schema/
core-shared/src/main/java/org/...
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/PersistentSearchTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/PersistentSearchTest.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/PersistentSearchTest.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/PersistentSearchTest.java Fri Feb 10 02:48:07 2006
@@ -61,7 +61,6 @@
private LdapContext ctx = null;
-
/**
* Creation of required attributes of a person entry.
*/
@@ -115,7 +114,7 @@
ctx = null;
super.tearDown();
}
- catch( Throwable t )
+ catch ( Throwable t )
{
}
}
@@ -129,15 +128,15 @@
PSearchListener listener = new PSearchListener();
Thread t = new Thread( listener, "PSearchListener" );
t.start();
-
- while( ! listener.isReady )
+
+ while ( !listener.isReady )
{
Thread.sleep( 100 );
}
Thread.sleep( 250 );
- ctx.modifyAttributes( RDN, DirContext.REMOVE_ATTRIBUTE,
- new BasicAttributes( "description", PERSON_DESCRIPTION, true ) );
+ ctx.modifyAttributes( RDN, DirContext.REMOVE_ATTRIBUTE, new BasicAttributes( "description", PERSON_DESCRIPTION,
+ true ) );
long start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -147,7 +146,7 @@
break;
}
}
-
+
assertNotNull( listener.result );
// darn it getting normalized name back
assertEquals( RDN.toLowerCase(), listener.result.getName().toLowerCase() );
@@ -162,15 +161,15 @@
PSearchListener listener = new PSearchListener();
Thread t = new Thread( listener );
t.start();
-
- while( ! listener.isReady )
+
+ while ( !listener.isReady )
{
Thread.sleep( 100 );
}
Thread.sleep( 250 );
ctx.rename( RDN, "cn=Jack Black" );
-
+
long start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -180,13 +179,13 @@
break;
}
}
-
+
assertNotNull( listener.result );
// darn it getting normalized name back
assertEquals( "cn=Jack Black".toLowerCase(), listener.result.getName().toLowerCase() );
}
-
+
/**
* Shows correct notifications for delete(2) changes.
*/
@@ -195,15 +194,15 @@
PSearchListener listener = new PSearchListener();
Thread t = new Thread( listener );
t.start();
-
- while( ! listener.isReady )
+
+ while ( !listener.isReady )
{
Thread.sleep( 100 );
}
Thread.sleep( 250 );
ctx.destroySubcontext( RDN );
-
+
long start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -213,13 +212,13 @@
break;
}
}
-
+
assertNotNull( listener.result );
// darn it getting normalized name back
assertEquals( RDN.toLowerCase(), listener.result.getName().toLowerCase() );
}
-
+
/**
* Shows correct notifications for add(1) changes.
*/
@@ -228,15 +227,15 @@
PSearchListener listener = new PSearchListener();
Thread t = new Thread( listener );
t.start();
-
- while( ! listener.isReady )
+
+ while ( !listener.isReady )
{
Thread.sleep( 100 );
}
Thread.sleep( 250 );
ctx.createSubcontext( "cn=Jack Black", getPersonAttributes( "Black", "Jack Black" ) );
-
+
long start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -246,7 +245,7 @@
break;
}
}
-
+
assertNotNull( listener.result );
// darn it getting normalized name back
assertEquals( "cn=Jack Black".toLowerCase(), listener.result.getName().toLowerCase() );
@@ -264,15 +263,15 @@
PSearchListener listener = new PSearchListener( control );
Thread t = new Thread( listener, "PSearchListener" );
t.start();
-
- while( ! listener.isReady )
+
+ while ( !listener.isReady )
{
Thread.sleep( 100 );
}
Thread.sleep( 250 );
- ctx.modifyAttributes( RDN, DirContext.REMOVE_ATTRIBUTE,
- new BasicAttributes( "description", PERSON_DESCRIPTION, true ) );
+ ctx.modifyAttributes( RDN, DirContext.REMOVE_ATTRIBUTE, new BasicAttributes( "description", PERSON_DESCRIPTION,
+ true ) );
long start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -282,7 +281,7 @@
break;
}
}
-
+
assertNotNull( listener.result );
// darn it getting normalized name back
assertEquals( RDN.toLowerCase(), listener.result.getName().toLowerCase() );
@@ -301,15 +300,15 @@
PSearchListener listener = new PSearchListener( control );
Thread t = new Thread( listener );
t.start();
-
- while( ! listener.isReady )
+
+ while ( !listener.isReady )
{
Thread.sleep( 100 );
}
Thread.sleep( 250 );
ctx.rename( RDN, "cn=Jack Black" );
-
+
long start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -319,7 +318,7 @@
break;
}
}
-
+
assertNotNull( listener.result );
// darn it getting normalized name back
assertEquals( "cn=Jack Black".toLowerCase(), listener.result.getName().toLowerCase() );
@@ -327,7 +326,7 @@
assertEquals( ( RDN + ",ou=system" ).toLowerCase(), listener.result.control.getPreviousDn().toLowerCase() );
}
-
+
/**
* Shows correct notifications for delete(2) changes with returned
* EntryChangeControl.
@@ -339,15 +338,15 @@
PSearchListener listener = new PSearchListener( control );
Thread t = new Thread( listener );
t.start();
-
- while( ! listener.isReady )
+
+ while ( !listener.isReady )
{
Thread.sleep( 100 );
}
Thread.sleep( 250 );
ctx.destroySubcontext( RDN );
-
+
long start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -357,14 +356,14 @@
break;
}
}
-
+
assertNotNull( listener.result );
// darn it getting normalized name back
assertEquals( RDN.toLowerCase(), listener.result.getName().toLowerCase() );
assertEquals( listener.result.control.getChangeType(), ChangeType.DELETE );
}
-
+
/**
* Shows correct notifications for add(1) changes with returned
* EntryChangeControl.
@@ -376,15 +375,15 @@
PSearchListener listener = new PSearchListener( control );
Thread t = new Thread( listener );
t.start();
-
- while( ! listener.isReady )
+
+ while ( !listener.isReady )
{
Thread.sleep( 100 );
}
Thread.sleep( 250 );
ctx.createSubcontext( "cn=Jack Black", getPersonAttributes( "Black", "Jack Black" ) );
-
+
long start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -394,14 +393,14 @@
break;
}
}
-
+
assertNotNull( listener.result );
// darn it getting normalized name back
assertEquals( "cn=Jack Black".toLowerCase(), listener.result.getName().toLowerCase() );
assertEquals( listener.result.control.getChangeType(), ChangeType.ADD );
}
-
+
/**
* Shows correct notifications for only add(1) and modify(4) registered changes with returned
* EntryChangeControl.
@@ -415,15 +414,15 @@
PSearchListener listener = new PSearchListener( control );
Thread t = new Thread( listener );
t.start();
-
- while( ! listener.isReady )
+
+ while ( !listener.isReady )
{
Thread.sleep( 100 );
}
Thread.sleep( 250 );
ctx.createSubcontext( "cn=Jack Black", getPersonAttributes( "Black", "Jack Black" ) );
-
+
long start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -433,7 +432,7 @@
break;
}
}
-
+
assertNotNull( listener.result );
// darn it getting normalized name back
assertEquals( "cn=Jack Black".toLowerCase(), listener.result.getName().toLowerCase() );
@@ -441,9 +440,9 @@
listener.result = null;
t = new Thread( listener );
t.start();
-
+
ctx.destroySubcontext( "cn=Jack Black" );
-
+
start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -457,8 +456,8 @@
assertNull( listener.result );
// thread is still waiting for notifications try a modify
- ctx.modifyAttributes( RDN, DirContext.REMOVE_ATTRIBUTE,
- new BasicAttributes( "description", PERSON_DESCRIPTION, true ) );
+ ctx.modifyAttributes( RDN, DirContext.REMOVE_ATTRIBUTE, new BasicAttributes( "description", PERSON_DESCRIPTION,
+ true ) );
start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -468,13 +467,13 @@
break;
}
}
-
+
assertNotNull( listener.result );
// darn it getting normalized name back
assertEquals( RDN.toLowerCase(), listener.result.getName().toLowerCase() );
assertEquals( listener.result.control.getChangeType(), ChangeType.MODIFY );
}
-
+
/**
* Shows correct notifications for add(1) changes with returned
@@ -486,37 +485,36 @@
*
* PLUS ALL THIS GARBAGE IS TIME DEPENDENT!!!!!
*/
-// public void testPsearchAddWithECAndFalseChangesOnly() throws Exception
-// {
-// PersistentSearchControl control = new PersistentSearchControl();
-// control.setReturnECs( true );
-// control.setChangesOnly( false );
-// PSearchListener listener = new PSearchListener( control );
-// Thread t = new Thread( listener );
-// t.start();
-//
-// Thread.sleep( 3000 );
-//
-// assertEquals( 5, listener.count );
-// ctx.createSubcontext( "cn=Jack Black", getPersonAttributes( "Black", "Jack Black" ) );
-//
-// long start = System.currentTimeMillis();
-// while ( t.isAlive() )
-// {
-// Thread.sleep( 100 );
-// if ( System.currentTimeMillis() - start > 3000 )
-// {
-// break;
-// }
-// }
-//
-// assertEquals( 6, listener.count );
-// assertNotNull( listener.result );
-// // darn it getting normalized name back
-// assertEquals( "cn=Jack Black".toLowerCase(), listener.result.getName().toLowerCase() );
-// assertEquals( listener.result.control.getChangeType(), ChangeType.ADD );
-// }
-
+ // public void testPsearchAddWithECAndFalseChangesOnly() throws Exception
+ // {
+ // PersistentSearchControl control = new PersistentSearchControl();
+ // control.setReturnECs( true );
+ // control.setChangesOnly( false );
+ // PSearchListener listener = new PSearchListener( control );
+ // Thread t = new Thread( listener );
+ // t.start();
+ //
+ // Thread.sleep( 3000 );
+ //
+ // assertEquals( 5, listener.count );
+ // ctx.createSubcontext( "cn=Jack Black", getPersonAttributes( "Black", "Jack Black" ) );
+ //
+ // long start = System.currentTimeMillis();
+ // while ( t.isAlive() )
+ // {
+ // Thread.sleep( 100 );
+ // if ( System.currentTimeMillis() - start > 3000 )
+ // {
+ // break;
+ // }
+ // }
+ //
+ // assertEquals( 6, listener.count );
+ // assertNotNull( listener.result );
+ // // darn it getting normalized name back
+ // assertEquals( "cn=Jack Black".toLowerCase(), listener.result.getName().toLowerCase() );
+ // assertEquals( listener.result.control.getChangeType(), ChangeType.ADD );
+ // }
/**
* Shows notifications functioning with the JNDI notification API of the SUN
@@ -535,7 +533,7 @@
InitialDirContext idc = new InitialDirContext( env );
EventDirContext edc = ( EventDirContext ) ( idc.lookup( "" ) );
edc.addNamingListener( "", EventContext.ONELEVEL_SCOPE, listener );
-
+
while ( listener.list.isEmpty() )
{
Thread.sleep( 250 );
@@ -543,12 +541,12 @@
ctx.createSubcontext( rdn, getPersonAttributes( "Black", "Jack Black" ) );
ctx.destroySubcontext( rdn );
}
-
+
NamingEvent event = ( NamingEvent ) listener.list.get( 0 );
assertEquals( edc, event.getSource() );
}
-
+
/**
* Shows notifications functioning with the JNDI notification API of the SUN
* provider.
@@ -560,15 +558,15 @@
PSearchListener listener = new PSearchListener( control );
Thread t = new Thread( listener );
t.start();
-
- while( ! listener.isReady )
+
+ while ( !listener.isReady )
{
Thread.sleep( 100 );
}
Thread.sleep( 250 );
ctx.createSubcontext( "cn=Jack Black", getPersonAttributes( "Black", "Jack Black" ) );
-
+
long start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -578,7 +576,7 @@
break;
}
}
-
+
assertNotNull( listener.result );
// darn it getting normalized name back
assertEquals( "cn=Jack Black".toLowerCase(), listener.result.getName().toLowerCase() );
@@ -586,9 +584,9 @@
listener.result = null;
t = new Thread( listener );
t.start();
-
+
ctx.destroySubcontext( "cn=Jack Black" );
-
+
start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -603,8 +601,8 @@
// assertNull( listener.result );
// thread is still waiting for notifications try a modify
- ctx.modifyAttributes( RDN, DirContext.REMOVE_ATTRIBUTE,
- new BasicAttributes( "description", PERSON_DESCRIPTION, true ) );
+ ctx.modifyAttributes( RDN, DirContext.REMOVE_ATTRIBUTE, new BasicAttributes( "description", PERSON_DESCRIPTION,
+ true ) );
start = System.currentTimeMillis();
while ( t.isAlive() )
{
@@ -614,45 +612,48 @@
break;
}
}
-
+
assertNotNull( listener.result );
// darn it getting normalized name back
assertEquals( RDN.toLowerCase(), listener.result.getName().toLowerCase() );
assertEquals( listener.result.control.getChangeType(), ChangeType.MODIFY );
}
-
class JndiNotificationListener implements NamespaceChangeListener, ObjectChangeListener
{
ArrayList list = new ArrayList();
-
- public void objectAdded(NamingEvent evt)
+
+
+ public void objectAdded( NamingEvent evt )
{
list.add( 0, evt );
}
- public void objectRemoved(NamingEvent evt)
+
+ public void objectRemoved( NamingEvent evt )
{
list.add( 0, evt );
}
- public void objectRenamed(NamingEvent evt)
+
+ public void objectRenamed( NamingEvent evt )
{
list.add( 0, evt );
}
- public void namingExceptionThrown(NamingExceptionEvent evt)
+
+ public void namingExceptionThrown( NamingExceptionEvent evt )
{
list.add( 0, evt );
}
- public void objectChanged(NamingEvent evt)
+
+ public void objectChanged( NamingEvent evt )
{
list.add( 0, evt );
}
}
-
-
+
class PSearchListener implements Runnable
{
boolean isReady = false;
@@ -660,23 +661,34 @@
int count = 0;
final PersistentSearchControl control;
- PSearchListener() { control = new PersistentSearchControl(); }
- PSearchListener( PersistentSearchControl control ) { this.control = control; }
-
+
+ PSearchListener()
+ {
+ control = new PersistentSearchControl();
+ }
+
+
+ PSearchListener(PersistentSearchControl control)
+ {
+ this.control = control;
+ }
+
+
public void run()
{
NamingEnumeration list = null;
control.setCritical( true );
- Control[] ctxCtls = new Control[] { control };
-
+ Control[] ctxCtls = new Control[]
+ { control };
+
try
{
ctx.setRequestControls( ctxCtls );
isReady = true;
list = ctx.search( "", "objectClass=*", null );
EntryChangeControl ecControl = null;
-
- while( list.hasMore() )
+
+ while ( list.hasMore() )
{
Control[] controls = null;
SearchResult sresult = ( SearchResult ) list.next();
@@ -686,9 +698,9 @@
controls = ( ( HasControls ) sresult ).getControls();
if ( controls != null )
{
- for ( int ii = 0; ii < controls.length; ii ++ )
+ for ( int ii = 0; ii < controls.length; ii++ )
{
- if ( controls[ii].getID().equals(
+ if ( controls[ii].getID().equals(
org.apache.directory.shared.ldap.message.EntryChangeControl.CONTROL_OID ) )
{
EntryChangeControlDecoder decoder = new EntryChangeControlDecoder();
@@ -701,7 +713,7 @@
break;
}
}
- catch( Exception e )
+ catch ( Exception e )
{
e.printStackTrace();
}
@@ -709,24 +721,33 @@
{
if ( list != null )
{
- try { list.close(); } catch ( Exception e ) { e.printStackTrace(); };
+ try
+ {
+ list.close();
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ };
}
}
}
}
-
class PSearchNotification extends SearchResult
{
private static final long serialVersionUID = 1L;
final EntryChangeControl control;
-
- public PSearchNotification( SearchResult result, EntryChangeControl control )
+
+
+ public PSearchNotification(SearchResult result, EntryChangeControl control)
{
- super( result.getName(), result.getClassName(), result.getObject(), result.getAttributes(), result.isRelative() );
+ super( result.getName(), result.getClassName(), result.getObject(), result.getAttributes(), result
+ .isRelative() );
this.control = control;
}
-
+
+
public String toString()
{
StringBuffer buf = new StringBuffer();
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/ReferralTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/ReferralTest.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/ReferralTest.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/ReferralTest.java Fri Feb 10 02:48:07 2006
@@ -58,27 +58,27 @@
/**
* Create attributes for a person entry.
*/
- protected Attributes getPersonAttributes(String sn, String cn)
+ protected Attributes getPersonAttributes( String sn, String cn )
{
Attributes attributes = new BasicAttributes();
- Attribute attribute = new BasicAttribute("objectClass");
- attribute.add("top");
- attribute.add("person");
- attributes.put(attribute);
- attributes.put("cn", cn);
- attributes.put("sn", sn);
- attributes.put("description", cn + " is a person.");
+ Attribute attribute = new BasicAttribute( "objectClass" );
+ attribute.add( "top" );
+ attribute.add( "person" );
+ attributes.put( attribute );
+ attributes.put( "cn", cn );
+ attributes.put( "sn", sn );
+ attributes.put( "description", cn + " is a person." );
return attributes;
}
-
+
public void setUp() throws Exception
{
super.setUp();
addReferralEntry();
}
-
-
+
+
public void tearDown() throws Exception
{
if ( td.refCtx != null )
@@ -86,36 +86,36 @@
td.refCtx.close();
td.rootCtx.close();
}
-
+
super.tearDown();
}
-
+
/**
* Get's the root "ou=system" using the SUN JNDI provider on the embedded ApacheDS instance
*/
private LdapContext getSystemRoot() throws NamingException
{
Hashtable env = new Hashtable();
- env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
- env.put("java.naming.provider.url", "ldap://localhost:" + port + "/ou=system" );
- env.put("java.naming.security.principal", "uid=admin,ou=system" );
- env.put("java.naming.security.credentials", "secret" );
- env.put("java.naming.security.authentication", "simple");
- LdapContext ctx = new InitialLdapContext(env, null);
- assertNotNull(ctx);
+ env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
+ env.put( "java.naming.provider.url", "ldap://localhost:" + port + "/ou=system" );
+ env.put( "java.naming.security.principal", "uid=admin,ou=system" );
+ env.put( "java.naming.security.credentials", "secret" );
+ env.put( "java.naming.security.authentication", "simple" );
+ LdapContext ctx = new InitialLdapContext( env, null );
+ assertNotNull( ctx );
return ctx;
}
-
-
- class TestData {
+
+ class TestData
+ {
LdapContext rootCtx;
Name ctxDn;
LdapContext refCtx;
List refs;
}
-
-
+
+
public void addReferralEntry() throws NamingException
{
String ref0 = "ldap://fermi:10389/ou=users,ou=system";
@@ -126,7 +126,7 @@
// -------------------------------------------------------------------
// Adds a referral entry regardless of referral handling settings
// -------------------------------------------------------------------
-
+
// Add a referral entry ( should be fine with or without the control )
Attributes referral = new BasicAttributes( "objectClass", "top", true );
referral.get( "objectClass" ).add( "referral" );
@@ -138,13 +138,25 @@
// Just in case if server is a remote server destroy remaing referral
td.rootCtx.addToEnvironment( Context.REFERRAL, "ignore" );
- try { td.rootCtx.destroySubcontext( "uid=akarasulu,ou=users" ); } catch( NameNotFoundException e ) {}
- try { td.rootCtx.destroySubcontext( "ou=users" ); } catch( NameNotFoundException e ) {}
+ try
+ {
+ td.rootCtx.destroySubcontext( "uid=akarasulu,ou=users" );
+ }
+ catch ( NameNotFoundException e )
+ {
+ }
+ try
+ {
+ td.rootCtx.destroySubcontext( "ou=users" );
+ }
+ catch ( NameNotFoundException e )
+ {
+ }
try
{
td.refCtx = ( LdapContext ) td.rootCtx.createSubcontext( "ou=users", referral );
}
- catch( NameAlreadyBoundException e )
+ catch ( NameAlreadyBoundException e )
{
td.refCtx = ( LdapContext ) td.rootCtx.lookup( "ou=users" );
}
@@ -153,19 +165,18 @@
assertTrue( referral.get( "objectClass" ).contains( "referral" ) );
}
-
+
public void checkAncestorReferrals( ReferralException e ) throws Exception
{
assertEquals( "ldap://fermi:10389", e.getReferralInfo() );
assertTrue( e.skipReferral() );
- assertEquals( "ldap://hertz:10389/cn=alex karasulu,ou=apache,ou=users,dc=example,dc=com",
- e.getReferralInfo() );
+ assertEquals( "ldap://hertz:10389/cn=alex karasulu,ou=apache,ou=users,dc=example,dc=com", e.getReferralInfo() );
assertTrue( e.skipReferral() );
assertEquals( "ldap://maxwell:10389", e.getReferralInfo() );
assertFalse( e.skipReferral() );
}
-
+
public void checkParentReferrals( ReferralException e ) throws Exception
{
assertEquals( "ldap://fermi:10389", e.getReferralInfo() );
@@ -175,8 +186,8 @@
assertEquals( "ldap://maxwell:10389", e.getReferralInfo() );
assertFalse( e.skipReferral() );
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for an add operation with the parent context being a referral.
@@ -196,18 +207,18 @@
userEntry.put( "sn", "karasulu" );
userEntry.put( "cn", "alex karasulu" );
- try
+ try
{
td.refCtx.createSubcontext( "cn=alex karasulu", userEntry );
fail( "Should fail here throwing a ReferralException" );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkParentReferrals( e );
}
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for an add operation with an ancestor context being a referral.
@@ -227,18 +238,18 @@
userEntry.put( "sn", "karasulu" );
userEntry.put( "cn", "alex karasulu" );
- try
+ try
{
td.refCtx.createSubcontext( "cn=alex karasulu,ou=apache", userEntry );
fail( "Should fail here throwing a ReferralException" );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkAncestorReferrals( e );
}
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for an delete operation with the parent context being a referral.
@@ -254,18 +265,18 @@
// -------------------------------------------------------------------
td.refCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
td.refCtx.destroySubcontext( "cn=alex karasulu" );
fail( "Should fail here throwing a ReferralException" );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkParentReferrals( e );
}
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a delete operation with an ancestor context being a referral.
@@ -281,18 +292,18 @@
// -------------------------------------------------------------------
td.refCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
td.refCtx.destroySubcontext( "cn=alex karasulu,ou=apache" );
fail( "Should fail here throwing a ReferralException" );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkAncestorReferrals( e );
}
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a modify operation with the parent context being a referral.
@@ -308,19 +319,19 @@
// -------------------------------------------------------------------
td.refCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
- td.refCtx.modifyAttributes( "cn=alex karasulu", DirContext.ADD_ATTRIBUTE,
- new BasicAttributes( "description", "just some text", true ) );
+ td.refCtx.modifyAttributes( "cn=alex karasulu", DirContext.ADD_ATTRIBUTE, new BasicAttributes(
+ "description", "just some text", true ) );
fail( "Should fail here throwing a ReferralException" );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkParentReferrals( e );
}
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a modify operation with an ancestor context being a referral.
@@ -336,19 +347,19 @@
// -------------------------------------------------------------------
td.refCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
- td.refCtx.modifyAttributes( "cn=alex karasulu,ou=apache", DirContext.ADD_ATTRIBUTE,
- new BasicAttributes( "description", "just some text", true ) );
+ td.refCtx.modifyAttributes( "cn=alex karasulu,ou=apache", DirContext.ADD_ATTRIBUTE, new BasicAttributes(
+ "description", "just some text", true ) );
fail( "Should fail here throwing a ReferralException" );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkAncestorReferrals( e );
}
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a modify operation with the parent context being a referral.
@@ -364,20 +375,20 @@
// -------------------------------------------------------------------
td.refCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
- ModificationItem[] mods = new ModificationItem[] { new ModificationItem(
- DirContext.ADD_ATTRIBUTE, new BasicAttribute( "description", "just some text" ) ) };
+ ModificationItem[] mods = new ModificationItem[]
+ { new ModificationItem( DirContext.ADD_ATTRIBUTE, new BasicAttribute( "description", "just some text" ) ) };
td.refCtx.modifyAttributes( "cn=alex karasulu", mods );
fail( "Should fail here throwing a ReferralException" );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkParentReferrals( e );
}
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a modify operation with an ancestor context being a referral.
@@ -393,20 +404,20 @@
// -------------------------------------------------------------------
td.refCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
- ModificationItem[] mods = new ModificationItem[] { new ModificationItem(
- DirContext.ADD_ATTRIBUTE, new BasicAttribute( "description", "just some text" ) ) };
+ ModificationItem[] mods = new ModificationItem[]
+ { new ModificationItem( DirContext.ADD_ATTRIBUTE, new BasicAttribute( "description", "just some text" ) ) };
td.refCtx.modifyAttributes( "cn=alex karasulu,ou=apache", mods );
fail( "Should fail here throwing a ReferralException" );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkAncestorReferrals( e );
}
}
-
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a modify rdn interceptor operation (corresponds to a subset of the modify
@@ -423,18 +434,18 @@
// -------------------------------------------------------------------
td.refCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
td.refCtx.rename( "cn=alex karasulu", "cn=aok" );
fail( "Should fail here throwing a ReferralException" );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkParentReferrals( e );
}
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a modify rdn interceptor operation (corresponds to a subset of the modify
@@ -451,18 +462,18 @@
// -------------------------------------------------------------------
td.refCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
td.refCtx.rename( "cn=alex karasulu,ou=apache", "cn=aok,ou=apache" );
fail( "Should fail here throwing a ReferralException" );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkAncestorReferrals( e );
}
}
-
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a move interceptor operation (corresponds to a subset of the modify
@@ -479,21 +490,21 @@
// -------------------------------------------------------------------
td.refCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
td.refCtx.rename( "cn=alex karasulu", "cn=alex karasulu,ou=groups" );
fail( "Should fail here throwing a ReferralException" );
}
- catch( PartialResultException e )
+ catch ( PartialResultException e )
{
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkParentReferrals( e );
}
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a move interceptor operation (corresponds to a subset of the modify
@@ -510,21 +521,21 @@
// -------------------------------------------------------------------
td.refCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
td.refCtx.rename( "cn=alex karasulu,ou=apache", "cn=alex karasulu,ou=groups" );
fail( "Should fail here throwing a ReferralException" );
}
- catch( PartialResultException e )
+ catch ( PartialResultException e )
{
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkAncestorReferrals( e );
}
}
-
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a move interceptor operation (corresponds to a subset of the modify
@@ -541,21 +552,21 @@
// -------------------------------------------------------------------
td.refCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
td.refCtx.rename( "cn=alex karasulu", "cn=aok,ou=groups" );
fail( "Should fail here throwing a ReferralException" );
}
- catch( PartialResultException e )
+ catch ( PartialResultException e )
{
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkParentReferrals( e );
}
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a move interceptor operation (corresponds to a subset of the modify
@@ -572,21 +583,21 @@
// -------------------------------------------------------------------
td.refCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
td.refCtx.rename( "cn=alex karasulu,ou=apache", "cn=aok,ou=groups" );
fail( "Should fail here throwing a ReferralException" );
}
- catch( PartialResultException e )
+ catch ( PartialResultException e )
{
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
checkAncestorReferrals( e );
}
}
-
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a move interceptor operation (corresponds to a subset of the modify
@@ -604,7 +615,7 @@
createLocalUser();
td.rootCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
td.rootCtx.rename( "cn=akarasulu", "cn=akarasulu,ou=users" );
fail( "Should fail here throwing a LdapNamingException with ResultCodeEnum = AFFECTSMULTIPLEDSAS" );
@@ -612,12 +623,12 @@
// this should have a result code of 71 for affectsMultipleDSAs
// however there is absolutely no way for us to tell if this is
// the case because of JNDI exception resolution issues with LDAP
- catch( NamingException e )
+ catch ( NamingException e )
{
}
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a move interceptor operation (corresponds to a subset of the modify
@@ -635,7 +646,7 @@
createDeepLocalUser();
td.rootCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
td.rootCtx.rename( "cn=akarasulu,ou=deep", "cn=akarasulu,ou=users" );
fail( "Should fail here throwing a LdapNamingException with ResultCodeEnum = AFFECTSMULTIPLEDSAS" );
@@ -643,12 +654,12 @@
// this should have a result code of 71 for affectsMultipleDSAs
// however there is absolutely no way for us to tell if this is
// the case because of JNDI exception resolution issues with LDAP
- catch( NamingException e )
+ catch ( NamingException e )
{
}
}
-
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a move interceptor operation (corresponds to a subset of the modify
@@ -666,7 +677,7 @@
createLocalUser();
td.rootCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
td.rootCtx.rename( "cn=akarasulu", "cn=aok,ou=users" );
fail( "Should fail here throwing a LdapNamingException with ResultCodeEnum = AFFECTSMULTIPLEDSAS" );
@@ -674,12 +685,12 @@
// this should have a result code of 71 for affectsMultipleDSAs
// however there is absolutely no way for us to tell if this is
// the case because of JNDI exception resolution issues with LDAP
- catch( NamingException e )
+ catch ( NamingException e )
{
}
}
-
-
+
+
/**
* Checks for correct core behavoir when Context.REFERRAL is set to <b>throw</b>
* for a move interceptor operation (corresponds to a subset of the modify
@@ -697,7 +708,7 @@
createDeepLocalUser();
td.rootCtx.addToEnvironment( Context.REFERRAL, "throw" );
- try
+ try
{
td.rootCtx.rename( "cn=akarasulu,ou=deep", "cn=aok,ou=users" );
fail( "Should fail here throwing a LdapNamingException with ResultCodeEnum = AFFECTSMULTIPLEDSAS" );
@@ -705,12 +716,12 @@
// this should have a result code of 71 for affectsMultipleDSAs
// however there is absolutely no way for us to tell if this is
// the case because of JNDI exception resolution issues with LDAP
- catch( NamingException e )
+ catch ( NamingException e )
{
}
}
-
-
+
+
public void createLocalUser() throws Exception
{
LdapContext userCtx = null;
@@ -719,12 +730,18 @@
referral.put( "cn", "akarasulu" );
referral.put( "sn", "karasulu" );
- try { td.rootCtx.destroySubcontext( "uid=akarasulu" ); } catch( NameNotFoundException e ) {}
+ try
+ {
+ td.rootCtx.destroySubcontext( "uid=akarasulu" );
+ }
+ catch ( NameNotFoundException e )
+ {
+ }
try
{
userCtx = ( LdapContext ) td.rootCtx.createSubcontext( "cn=akarasulu", referral );
}
- catch( NameAlreadyBoundException e )
+ catch ( NameAlreadyBoundException e )
{
td.refCtx = ( LdapContext ) td.rootCtx.lookup( "cn=akarasulu" );
}
@@ -732,8 +749,8 @@
assertTrue( referral.get( "cn" ).contains( "akarasulu" ) );
assertTrue( referral.get( "sn" ).contains( "karasulu" ) );
}
-
-
+
+
public void createDeepLocalUser() throws Exception
{
LdapContext userCtx = null;
@@ -742,14 +759,26 @@
referral.put( "cn", "akarasulu" );
referral.put( "sn", "karasulu" );
- try { td.rootCtx.destroySubcontext( "uid=akarasulu,ou=deep" ); } catch( NameNotFoundException e ) {}
- try { td.rootCtx.destroySubcontext( "ou=deep" ); } catch( NameNotFoundException e ) {}
+ try
+ {
+ td.rootCtx.destroySubcontext( "uid=akarasulu,ou=deep" );
+ }
+ catch ( NameNotFoundException e )
+ {
+ }
+ try
+ {
+ td.rootCtx.destroySubcontext( "ou=deep" );
+ }
+ catch ( NameNotFoundException e )
+ {
+ }
try
{
td.rootCtx.createSubcontext( "ou=deep" );
userCtx = ( LdapContext ) td.rootCtx.createSubcontext( "cn=akarasulu,ou=deep", referral );
}
- catch( NameAlreadyBoundException e )
+ catch ( NameAlreadyBoundException e )
{
td.refCtx = ( LdapContext ) td.rootCtx.lookup( "cn=akarasulu,ou=deep" );
}
@@ -757,8 +786,8 @@
assertTrue( referral.get( "cn" ).contains( "akarasulu" ) );
assertTrue( referral.get( "sn" ).contains( "karasulu" ) );
}
-
-
+
+
public void testSearchBaseIsReferral() throws Exception
{
SearchControls controls = new SearchControls();
@@ -769,7 +798,7 @@
td.rootCtx.search( "ou=users", "(objectClass=*)", controls );
fail( "should never get here" );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
assertEquals( "ldap://fermi:10389/ou=users,ou=system??sub", e.getReferralInfo() );
assertTrue( e.skipReferral() );
@@ -780,7 +809,7 @@
}
}
-
+
public void testSearchBaseParentIsReferral() throws Exception
{
SearchControls controls = new SearchControls();
@@ -790,7 +819,7 @@
{
td.refCtx.search( "cn=alex karasulu", "(objectClass=*)", controls );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
assertEquals( "ldap://fermi:10389/cn=alex karasulu,ou=users,ou=system??base", e.getReferralInfo() );
assertTrue( e.skipReferral() );
@@ -801,7 +830,7 @@
}
}
-
+
public void testSearchBaseAncestorIsReferral() throws Exception
{
SearchControls controls = new SearchControls();
@@ -811,18 +840,20 @@
{
td.refCtx.search( "cn=alex karasulu,ou=apache", "(objectClass=*)", controls );
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
assertEquals( "ldap://fermi:10389/cn=alex karasulu,ou=apache,ou=users,ou=system??base", e.getReferralInfo() );
assertTrue( e.skipReferral() );
- assertEquals( "ldap://hertz:10389/cn=alex karasulu,ou=apache,ou=users,dc=example,dc=com??base", e.getReferralInfo() );
+ assertEquals( "ldap://hertz:10389/cn=alex karasulu,ou=apache,ou=users,dc=example,dc=com??base", e
+ .getReferralInfo() );
assertTrue( e.skipReferral() );
- assertEquals( "ldap://maxwell:10389/cn=alex karasulu,ou=apache,ou=users,ou=system??base", e.getReferralInfo() );
+ assertEquals( "ldap://maxwell:10389/cn=alex karasulu,ou=apache,ou=users,ou=system??base", e
+ .getReferralInfo() );
assertFalse( e.skipReferral() );
}
}
-
+
public void testSearchContinuations() throws Exception
{
SearchControls controls = new SearchControls();
@@ -831,29 +862,29 @@
Map results = new HashMap();
while ( list.hasMore() )
{
- SearchResult result = ( SearchResult) list.next();
- results.put ( result.getName(), result );
+ SearchResult result = ( SearchResult ) list.next();
+ results.put( result.getName(), result );
}
-
+
assertNotNull( results.get( "ou=users" ) );
-
+
// -------------------------------------------------------------------
// Now we will throw exceptions when searching for referrals
// -------------------------------------------------------------------
-
+
td.rootCtx.addToEnvironment( Context.REFERRAL, "throw" );
list = td.rootCtx.search( "", "(objectClass=*)", controls );
results = new HashMap();
-
+
try
{
while ( list.hasMore() )
{
SearchResult result = ( SearchResult ) list.next();
- results.put ( result.getName(), result );
+ results.put( result.getName(), result );
}
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
assertEquals( "ldap://fermi:10389/ou=users,ou=system??sub", e.getReferralInfo() );
assertTrue( e.skipReferral() );
@@ -862,24 +893,24 @@
assertEquals( "ldap://maxwell:10389/ou=users,ou=system??sub", e.getReferralInfo() );
assertFalse( e.skipReferral() );
}
-
+
assertNull( results.get( "ou=users" ) );
// try again but this time with single level scope
-
+
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
list = td.rootCtx.search( "", "(objectClass=*)", controls );
results = new HashMap();
-
+
try
{
while ( list.hasMore() )
{
SearchResult result = ( SearchResult ) list.next();
- results.put ( result.getName(), result );
+ results.put( result.getName(), result );
}
}
- catch( ReferralException e )
+ catch ( ReferralException e )
{
assertEquals( "ldap://fermi:10389/ou=users,ou=system??base", e.getReferralInfo() );
assertTrue( e.skipReferral() );
@@ -888,7 +919,7 @@
assertEquals( "ldap://maxwell:10389/ou=users,ou=system??base", e.getReferralInfo() );
assertFalse( e.skipReferral() );
}
-
+
assertNull( results.get( "ou=users" ) );
}
}
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/SearchTest.java Fri Feb 10 02:48:07 2006
@@ -15,6 +15,7 @@
*/
package org.apache.directory.server;
+
import java.util.Hashtable;
import javax.naming.NamingEnumeration;
@@ -44,25 +45,25 @@
public static final String RDN = "cn=Tori Amos";
public static final String RDN2 = "cn=Rolling-Stones";
public static final String PERSON_DESCRIPTION = "an American singer-songwriter";
-
-
+
/**
* Creation of required attributes of a person entry.
*/
- protected Attributes getPersonAttributes(String sn, String cn)
+ protected Attributes getPersonAttributes( String sn, String cn )
{
Attributes attributes = new BasicAttributes();
- Attribute attribute = new BasicAttribute("objectClass");
- attribute.add("top");
- attribute.add("person");
- attributes.put(attribute);
- attributes.put("cn", cn);
- attributes.put("sn", sn);
+ Attribute attribute = new BasicAttribute( "objectClass" );
+ attribute.add( "top" );
+ attribute.add( "person" );
+ attributes.put( attribute );
+ attributes.put( "cn", cn );
+ attributes.put( "sn", sn );
return attributes;
}
+
/**
* Create context and a person entry.
*/
@@ -71,37 +72,39 @@
super.setUp();
Hashtable env = new Hashtable();
- env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
- env.put("java.naming.provider.url", "ldap://localhost:" + port + "/ou=system");
- env.put("java.naming.security.principal", "uid=admin,ou=system");
- env.put("java.naming.security.credentials", "secret");
- env.put("java.naming.security.authentication", "simple");
+ env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
+ env.put( "java.naming.provider.url", "ldap://localhost:" + port + "/ou=system" );
+ env.put( "java.naming.security.principal", "uid=admin,ou=system" );
+ env.put( "java.naming.security.credentials", "secret" );
+ env.put( "java.naming.security.authentication", "simple" );
- ctx = new InitialLdapContext(env, null);
- assertNotNull(ctx);
+ ctx = new InitialLdapContext( env, null );
+ assertNotNull( ctx );
// Create a person with description
- Attributes attributes = this.getPersonAttributes("Amos", "Tori Amos");
- attributes.put("description", "an American singer-songwriter");
- ctx.createSubcontext(RDN, attributes);
+ Attributes attributes = this.getPersonAttributes( "Amos", "Tori Amos" );
+ attributes.put( "description", "an American singer-songwriter" );
+ ctx.createSubcontext( RDN, attributes );
// Create a second person with description
- attributes = this.getPersonAttributes("Jagger", "Rolling-Stones");
- attributes.put("description", "an English singer-songwriter");
- ctx.createSubcontext(RDN2, attributes);
+ attributes = this.getPersonAttributes( "Jagger", "Rolling-Stones" );
+ attributes.put( "description", "an English singer-songwriter" );
+ ctx.createSubcontext( RDN2, attributes );
}
+
/**
* Remove person entry and close context.
*/
public void tearDown() throws Exception
{
- ctx.unbind(RDN);
+ ctx.unbind( RDN );
ctx.close();
ctx = null;
super.tearDown();
}
+
/**
* Add a new attribute to a person entry.
*
@@ -111,80 +114,81 @@
{
// Setting up search controls for compare op
SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[] {"*"}); // no attributes
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+ ctls.setReturningAttributes( new String[]
+ { "*" } ); // no attributes
+ ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
// Search for all entries
- NamingEnumeration results = ctx.search(RDN, "(cn=*)", ctls);
+ NamingEnumeration results = ctx.search( RDN, "(cn=*)", ctls );
assertTrue( results.hasMore() );
- results = ctx.search(RDN2, "(cn=*)", ctls);
+ results = ctx.search( RDN2, "(cn=*)", ctls );
assertTrue( results.hasMore() );
-
+
// Search for all entries ending by Amos
- results = ctx.search(RDN, "(cn=*Amos)", ctls);
+ results = ctx.search( RDN, "(cn=*Amos)", ctls );
assertTrue( results.hasMore() );
- results = ctx.search(RDN2, "(cn=*Amos)", ctls);
+ results = ctx.search( RDN2, "(cn=*Amos)", ctls );
assertFalse( results.hasMore() );
// Search for all entries ending by amos
- results = ctx.search(RDN, "(cn=*amos)", ctls);
+ results = ctx.search( RDN, "(cn=*amos)", ctls );
assertTrue( results.hasMore() );
- results = ctx.search(RDN2, "(cn=*amos)", ctls);
+ results = ctx.search( RDN2, "(cn=*amos)", ctls );
assertFalse( results.hasMore() );
// Search for all entries starting by Tori
- results = ctx.search(RDN, "(cn=Tori*)", ctls);
+ results = ctx.search( RDN, "(cn=Tori*)", ctls );
assertTrue( results.hasMore() );
- results = ctx.search(RDN2, "(cn=Tori*)", ctls);
+ results = ctx.search( RDN2, "(cn=Tori*)", ctls );
assertFalse( results.hasMore() );
// Search for all entries starting by tori
- results = ctx.search(RDN, "(cn=tori*)", ctls);
+ results = ctx.search( RDN, "(cn=tori*)", ctls );
assertTrue( results.hasMore() );
- results = ctx.search(RDN2, "(cn=tori*)", ctls);
+ results = ctx.search( RDN2, "(cn=tori*)", ctls );
assertFalse( results.hasMore() );
// Search for all entries containing ori
- results = ctx.search(RDN, "(cn=*ori*)", ctls);
+ results = ctx.search( RDN, "(cn=*ori*)", ctls );
assertTrue( results.hasMore() );
- results = ctx.search(RDN2, "(cn=*ori*)", ctls);
+ 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);
+ results = ctx.search( RDN, "(cn=*o*i*)", ctls );
assertTrue( results.hasMore() );
- results = ctx.search(RDN2, "(cn=*o*i*)", ctls);
+ 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);
+ results = ctx.search( RDN, "(cn=*o* *o*)", ctls );
assertTrue( results.hasMore() );
- results = ctx.search(RDN2, "(cn=*o* *o*)", ctls);
+ results = ctx.search( RDN2, "(cn=*o* *o*)", ctls );
assertFalse( results.hasMore() );
- results = ctx.search(RDN2, "(cn=*o*-*o*)", ctls);
+ 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);
+ results = ctx.search( RDN, "(cn=To*A*)", ctls );
assertTrue( results.hasMore() );
- results = ctx.search(RDN2, "(cn=To*A*)", ctls);
+ 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);
+ results = ctx.search( RDN, "(cn=*ri*os)", ctls );
assertTrue( results.hasMore() );
- results = ctx.search(RDN2, "(cn=*ri*os)", ctls);
+ results = ctx.search( RDN2, "(cn=*ri*os)", ctls );
assertFalse( results.hasMore() );
}
}
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/UnknownExtendedOperationTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/UnknownExtendedOperationTest.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/UnknownExtendedOperationTest.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/UnknownExtendedOperationTest.java Fri Feb 10 02:48:07 2006
@@ -16,6 +16,7 @@
*/
package org.apache.directory.server;
+
import java.util.Hashtable;
import javax.naming.CommunicationException;
@@ -27,6 +28,7 @@
import org.apache.directory.server.unit.AbstractServerTest;
+
/**
* Check the behaviour of the server for an unknown extended operation. Created
* to demonstrate DIREVE-256 ("Extended operation causes client to hang.").
@@ -38,6 +40,7 @@
{
private LdapContext ctx = null;
+
/**
* Create context.
*/
@@ -46,16 +49,17 @@
super.setUp();
Hashtable env = new Hashtable();
- env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
- env.put("java.naming.provider.url", "ldap://localhost:" + port + "/ou=system");
- env.put("java.naming.security.principal", "uid=admin,ou=system");
- env.put("java.naming.security.credentials", "secret");
- env.put("java.naming.security.authentication", "simple");
+ env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
+ env.put( "java.naming.provider.url", "ldap://localhost:" + port + "/ou=system" );
+ env.put( "java.naming.security.principal", "uid=admin,ou=system" );
+ env.put( "java.naming.security.credentials", "secret" );
+ env.put( "java.naming.security.authentication", "simple" );
- ctx = new InitialLdapContext(env, null);
- assertNotNull(ctx);
+ ctx = new InitialLdapContext( env, null );
+ assertNotNull( ctx );
}
+
/**
* Close context.
*/
@@ -66,16 +70,20 @@
super.tearDown();
}
+
/**
* Calls an extended exception, which does not exist. Expected behaviour is
* a CommunicationException.
*/
public void testUnknownExtendedOperation() throws NamingException
{
- try {
- ctx.extendedOperation(new UnknownExtendedOperationRequest());
- fail("Calling an unknown extended operation should fail.");
- } catch (CommunicationException ce) {
+ try
+ {
+ ctx.extendedOperation( new UnknownExtendedOperationRequest() );
+ fail( "Calling an unknown extended operation should fail." );
+ }
+ catch ( CommunicationException ce )
+ {
// expected behaviour
}
}
@@ -88,18 +96,21 @@
private static final long serialVersionUID = 1L;
+
public String getID()
{
return "1.1"; // Never an OID for an extended operation
}
+
public byte[] getEncodedValue()
{
return null;
}
- public ExtendedResponse createExtendedResponse(String id, byte[] berValue, int offset, int length)
- throws NamingException
+
+ public ExtendedResponse createExtendedResponse( String id, byte[] berValue, int offset, int length )
+ throws NamingException
{
return null;
}
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/jndi/ServerContextFactoryTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/jndi/ServerContextFactoryTest.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/jndi/ServerContextFactoryTest.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-unit/src/test/java/org/apache/directory/server/jndi/ServerContextFactoryTest.java Fri Feb 10 02:48:07 2006
@@ -46,6 +46,7 @@
{
}
+
public void setUp() throws Exception
{
BasicAttributes attrs;
@@ -53,12 +54,12 @@
Set pcfgs = new HashSet();
MutableDirectoryPartitionConfiguration pcfg;
-
+
// Add partition 'testing'
pcfg = new MutableDirectoryPartitionConfiguration();
pcfg.setName( "testing" );
pcfg.setSuffix( "ou=testing" );
-
+
indexedAttrs = new HashSet();
indexedAttrs.add( "ou" );
indexedAttrs.add( "objectClass" );
@@ -74,20 +75,20 @@
attr.add( "testing" );
attrs.put( attr );
pcfg.setContextEntry( attrs );
-
+
pcfgs.add( pcfg );
-
+
// Add partition 'example'
pcfg = new MutableDirectoryPartitionConfiguration();
pcfg.setName( "example" );
pcfg.setSuffix( "dc=example" );
-
+
indexedAttrs = new HashSet();
indexedAttrs.add( "ou" );
indexedAttrs.add( "dc" );
indexedAttrs.add( "objectClass" );
pcfg.setIndexedAttributes( indexedAttrs );
-
+
attrs = new BasicAttributes( true );
attr = new BasicAttribute( "objectClass" );
attr.add( "top" );
@@ -98,14 +99,14 @@
attr.add( "example" );
attrs.put( attr );
pcfg.setContextEntry( attrs );
-
+
pcfgs.add( pcfg );
// Add partition 'MixedCase'
pcfg = new MutableDirectoryPartitionConfiguration();
pcfg.setName( "mixedcase" );
pcfg.setSuffix( "dc=MixedCase" );
-
+
indexedAttrs = new HashSet();
indexedAttrs.add( "dc" );
indexedAttrs.add( "objectClass" );
@@ -121,13 +122,14 @@
attr.add( "MixedCase" );
attrs.put( attr );
pcfg.setContextEntry( attrs );
-
+
pcfgs.add( pcfg );
-
+
configuration.setContextPartitionConfigurations( pcfgs );
super.setUp();
}
+
/**
* Makes sure the system context has the right attributes and values.