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 2012/02/28 17:41:47 UTC
svn commit: r1294724 - in /directory/apacheds/branches/apacheds-txns:
ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/
server-integ/src/test/java/org/apache/directory/server/suites/
test-framework/src/main/java/o...
Author: elecharny
Date: Tue Feb 28 16:41:46 2012
New Revision: 1294724
URL: http://svn.apache.org/viewvc?rev=1294724&view=rev
Log:
o The PagedSearch tests are ran again in server-integ
o Removed some useless System.out.println
Modified:
directory/apacheds/branches/apacheds-txns/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
directory/apacheds/branches/apacheds-txns/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java
directory/apacheds/branches/apacheds-txns/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTxnTest.java
Modified: directory/apacheds/branches/apacheds-txns/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java?rev=1294724&r1=1294723&r2=1294724&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java (original)
+++ directory/apacheds/branches/apacheds-txns/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java Tue Feb 28 16:41:46 2012
@@ -45,7 +45,6 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.message.SearchRequest;
import org.apache.directory.shared.ldap.model.message.SearchRequestImpl;
import org.apache.directory.shared.ldap.model.message.SearchResultDone;
-import org.apache.directory.shared.ldap.model.message.SearchResultEntry;
import org.apache.directory.shared.ldap.model.message.SearchScope;
import org.apache.directory.shared.ldap.model.message.controls.ManageDsaITImpl;
import org.apache.directory.shared.ldap.model.name.Dn;
@@ -89,219 +88,204 @@ import org.junit.runner.RunWith;
})
public class ClientSearchRequestTest extends AbstractLdapTestUnit
{
- private LdapNetworkConnection connection;
-
-
- @Before
- public void setup() throws Exception
- {
- connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
- }
-
-
- @After
- public void shutdown() throws Exception
- {
- LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer() );
- }
-
-
- @Test
- public void testSimpleSearch() throws Exception
- {
- EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL );
- int count = 0;
-
- while ( cursor.next() )
- {
- Entry entry = cursor.get();
- assertNotNull( entry );
- count++;
- }
-
- SearchResultDone done = cursor.getSearchResultDone();
-
- assertNotNull( done );
- assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
- assertEquals( 5, count );
- cursor.close();
- }
-
-
- @Test
- public void testSimpleSearchWithControl() throws Exception
- {
- SearchRequest searchRequest = new SearchRequestImpl().setBase( new Dn( "ou=system" ) )
- .setFilter( "(objectclass=*)" )
- .setScope( SearchScope.ONELEVEL ).addControl( new ManageDsaITImpl() );
- EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL );
- int count = 0;
-
- while ( cursor.next() )
- {
- Entry entry = cursor.get();
- assertNotNull( entry );
- count++;
- }
-
- SearchResultDone done = cursor.getSearchResultDone();
-
- assertNotNull( done );
- assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
- assertEquals( 5, count );
- cursor.close();
- }
-
-
- @Test
- public void testSearch() throws Exception
- {
- EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)",
- SearchScope.ONELEVEL,
- "*", "+" );
- int count = 0;
-
- while ( cursor.next() )
- {
- assertNotNull( cursor.get() );
- count++;
- }
-
- SearchResultDone done = cursor.getSearchResultDone();
-
- assertNotNull( done );
- assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
- assertEquals( 5, count );
- cursor.close();
- }
-
-
- @Test
- public void testSearchEquality() throws Exception
- {
- EntryCursor cursor = connection.search( "ou=system", "(objectclass=organizationalUnit)",
- SearchScope.ONELEVEL, "*", "+" );
- int count = 0;
-
- while ( cursor.next() )
- {
- Entry entry = cursor.get();
- assertNotNull( entry );
- count++;
- }
-
- assertEquals( 4, count );
- cursor.close();
- }
-
-
- @Test
- public void testAsyncSearch() throws Exception
- {
- SearchFuture searchFuture = connection.searchAsync( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL, "*",
- "+" );
- int count = 0;
- Response searchResponse = null;
-
- do
- {
- searchResponse = ( Response ) searchFuture.get( 1000, TimeUnit.MILLISECONDS );
- assertNotNull( searchResponse );
- if ( !( searchResponse instanceof SearchResultDone ) )
- {
- count++;
- }
- }
- while ( !( searchResponse instanceof SearchResultDone ) );
-
- assertEquals( 5, count );
- }
-
-
- /**
- * Test a search with a Substring filter
- * @throws Exception
- */
- @Test
- public void testSearchPersonSubstring() throws Exception
- {
- SearchFuture searchFuture = connection.searchAsync( "ou=system", "(objectclass=*)", SearchScope.SUBTREE, "*", "+" );
-
- Response searchResponse = null;
-
- do
- {
- searchResponse = ( Response ) searchFuture.get( 100000, TimeUnit.MILLISECONDS );
-
- if ( !( searchResponse instanceof SearchResultDone ) )
- {
- System.out.println( ( ( SearchResultEntry ) searchResponse ).getEntry() );
- }
-
- }
- while ( !( searchResponse instanceof SearchResultDone ) );
-
- searchFuture = connection.searchAsync( "ou=system", "(objectclass=*ers*)", SearchScope.SUBTREE,
- "*", "+" );
-
- int count = 0;
-
- do
- {
- searchResponse = ( Response ) searchFuture.get( 100000, TimeUnit.MILLISECONDS );
- assertNotNull( searchResponse );
-
- if ( !( searchResponse instanceof SearchResultDone ) )
- {
- count++;
- System.out.println( ( ( SearchResultEntry ) searchResponse ).getEntry().get( "objectClass" ) );
- }
- }
- while ( !( searchResponse instanceof SearchResultDone ) );
-
- assertEquals( 3, count );
- }
-
-
- @Test
- public void testSearchWithDerefAlias() throws Exception
- {
- SearchRequest searchRequest = new SearchRequestImpl();
- searchRequest.setBase( new Dn( "ou=users,ou=system" ) );
- searchRequest.setFilter( "(objectClass=*)" );
- searchRequest.setScope( SearchScope.ONELEVEL );
- searchRequest.addAttributes( "*" );
-
- int count = 0;
- Cursor<Response> cursor = connection.search( searchRequest );
-
- while ( cursor.next() )
- {
- count++;
- }
- cursor.close();
-
- // due to dereferencing of aliases we get only one entry
- assertEquals( 2, count );
-
- count = 0;
- searchRequest.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
- cursor = connection.search( searchRequest );
-
- while ( cursor.next() )
- {
- count++;
- }
- cursor.close();
-
- assertEquals( 3, count );
- }
-
-
- @Test(expected = LdapException.class)
- public void testSearchUTF8() throws Exception
- {
- connection.search( "ou=system", "(sn=Emmanuel L\u00e9charny)", SearchScope.ONELEVEL, "*", "+" );
- fail();
- }
+private LdapNetworkConnection connection;
+
+
+@Before
+public void setup() throws Exception
+{
+ connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+}
+
+
+@After
+public void shutdown() throws Exception
+{
+ LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer() );
+}
+
+
+@Test
+public void testSimpleSearch() throws Exception
+{
+ EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL );
+ int count = 0;
+
+ while ( cursor.next() )
+ {
+ Entry entry = cursor.get();
+ assertNotNull( entry );
+ count++;
+ }
+
+ SearchResultDone done = cursor.getSearchResultDone();
+
+ assertNotNull( done );
+ assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
+ assertEquals( 5, count );
+ cursor.close();
+}
+
+
+@Test
+public void testSimpleSearchWithControl() throws Exception
+{
+ SearchRequest searchRequest = new SearchRequestImpl().setBase( new Dn( "ou=system" ) )
+ .setFilter( "(objectclass=*)" )
+ .setScope( SearchScope.ONELEVEL ).addControl( new ManageDsaITImpl() );
+ EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL );
+ int count = 0;
+
+ while ( cursor.next() )
+ {
+ Entry entry = cursor.get();
+ assertNotNull( entry );
+ count++;
+ }
+
+ SearchResultDone done = cursor.getSearchResultDone();
+
+ assertNotNull( done );
+ assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
+ assertEquals( 5, count );
+ cursor.close();
+}
+
+
+@Test
+public void testSearch() throws Exception
+{
+ EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)",
+ SearchScope.ONELEVEL,
+ "*", "+" );
+ int count = 0;
+
+ while ( cursor.next() )
+ {
+ assertNotNull( cursor.get() );
+ count++;
+ }
+
+ SearchResultDone done = cursor.getSearchResultDone();
+
+ assertNotNull( done );
+ assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
+ assertEquals( 5, count );
+ cursor.close();
+}
+
+
+@Test
+public void testSearchEquality() throws Exception
+{
+ EntryCursor cursor = connection.search( "ou=system", "(objectclass=organizationalUnit)",
+ SearchScope.ONELEVEL, "*", "+" );
+ int count = 0;
+
+ while ( cursor.next() )
+ {
+ Entry entry = cursor.get();
+ assertNotNull( entry );
+ count++;
+ }
+
+ assertEquals( 4, count );
+ cursor.close();
+}
+
+
+@Test
+public void testAsyncSearch() throws Exception
+{
+ SearchFuture searchFuture = connection.searchAsync( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL, "*",
+ "+" );
+ int count = 0;
+ Response searchResponse = null;
+
+ do
+ {
+ searchResponse = ( Response ) searchFuture.get( 1000, TimeUnit.MILLISECONDS );
+ assertNotNull( searchResponse );
+ if ( !( searchResponse instanceof SearchResultDone ) )
+ {
+ count++;
+ }
+ }
+ while ( !( searchResponse instanceof SearchResultDone ) );
+
+ assertEquals( 5, count );
+}
+
+
+/**
+ * Test a search with a Substring filter
+ * @throws Exception
+ */
+@Test
+public void testSearchPersonSubstring() throws Exception
+{
+ Response searchResponse = null;
+
+ SearchFuture searchFuture = connection.searchAsync( "ou=system", "(objectclass=*ers*)", SearchScope.SUBTREE,
+ "*", "+" );
+
+ int count = 0;
+
+ do
+ {
+ searchResponse = ( Response ) searchFuture.get( 100000, TimeUnit.MILLISECONDS );
+ assertNotNull( searchResponse );
+
+ if ( !( searchResponse instanceof SearchResultDone ) )
+ {
+ count++;
+ }
+ }
+ while ( !( searchResponse instanceof SearchResultDone ) );
+
+ assertEquals( 3, count );
+}
+
+
+@Test
+public void testSearchWithDerefAlias() throws Exception
+{
+ SearchRequest searchRequest = new SearchRequestImpl();
+ searchRequest.setBase( new Dn( "ou=users,ou=system" ) );
+ searchRequest.setFilter( "(objectClass=*)" );
+ searchRequest.setScope( SearchScope.ONELEVEL );
+ searchRequest.addAttributes( "*" );
+
+ int count = 0;
+ Cursor<Response> cursor = connection.search( searchRequest );
+
+ while ( cursor.next() )
+ {
+ count++;
+ }
+ cursor.close();
+
+ // due to dereferencing of aliases we get only one entry
+ assertEquals( 2, count );
+
+ count = 0;
+ searchRequest.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
+ cursor = connection.search( searchRequest );
+
+ while ( cursor.next() )
+ {
+ count++;
+ }
+ cursor.close();
+
+ assertEquals( 3, count );
+}
+
+
+@Test(expected = LdapException.class)
+public void testSearchUTF8() throws Exception
+{
+ connection.search( "ou=system", "(sn=Emmanuel L\u00e9charny)", SearchScope.ONELEVEL, "*", "+" );
+ fail();
+}
}
Modified: directory/apacheds/branches/apacheds-txns/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java?rev=1294724&r1=1294723&r2=1294724&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java (original)
+++ directory/apacheds/branches/apacheds-txns/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java Tue Feb 28 16:41:46 2012
@@ -52,6 +52,7 @@ import org.apache.directory.server.opera
import org.apache.directory.server.operations.modifydn.MoveIT;
import org.apache.directory.server.operations.search.IndexedNegationSearchIT;
import org.apache.directory.server.operations.search.NegationSearchIT;
+import org.apache.directory.server.operations.search.PagedSearchIT;
import org.apache.directory.server.operations.search.PersistentSearchIT;
import org.apache.directory.server.operations.search.ReferralSearchIT;
import org.apache.directory.server.operations.search.ReferralSearchNoRevertIT;
@@ -120,7 +121,7 @@ import org.junit.runners.Suite;
// operations.search
IndexedNegationSearchIT.class,
NegationSearchIT.class,
- //PagedSearchIT.class,
+ PagedSearchIT.class,
PersistentSearchIT.class,
ReferralSearchIT.class,
ReferralSearchNoRevertIT.class,
Modified: directory/apacheds/branches/apacheds-txns/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java?rev=1294724&r1=1294723&r2=1294724&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java (original)
+++ directory/apacheds/branches/apacheds-txns/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java Tue Feb 28 16:41:46 2012
@@ -276,7 +276,6 @@ public class FrameworkRunner extends Blo
else
{
Description description = getDescription();
- System.out.println( "reverting for " + description );
// Revert the ldifs
// We use a class or suite DS, just revert the current test's modifications
revert( directoryService, revision );
@@ -291,7 +290,6 @@ public class FrameworkRunner extends Blo
finally
{
Description description = getDescription();
- System.out.println( "reverting for " + description );
// help GC to get rid of the directory service with all its references
suite = null;
classDS = null;
Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTxnTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTxnTest.java?rev=1294724&r1=1294723&r2=1294724&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTxnTest.java (original)
+++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTxnTest.java Tue Feb 28 16:41:46 2012
@@ -19,6 +19,7 @@
*/
package org.apache.directory.server.xdbm.impl.avl;
+
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -51,31 +52,31 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
import org.apache.directory.shared.util.Strings;
import org.apache.directory.shared.util.exception.Exceptions;
-
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+
public class AvlPartitionTxnTest
{
private static AvlPartition partition;
private static SchemaManager schemaManager = null;
-
+
/** txn and operation execution manager factories */
private static TxnManagerFactory txnManagerFactory;
private static OperationExecutionManagerFactory executionManagerFactory;
-
/** Operation execution manager */
private static OperationExecutionManager executionManager;
/** Txn manager */
private static TxnManager txnManager;
-
+
/** log dir */
private static File logDir;
-
+
+
@BeforeClass
public static void setup() throws Exception
{
@@ -87,7 +88,7 @@ public class AvlPartitionTxnTest
int targetPos = path.indexOf( "target" );
workingDirectory = path.substring( 0, targetPos + 6 );
}
-
+
logDir = new File( workingDirectory + File.separatorChar + "txnlog" + File.separatorChar );
logDir.mkdirs();
txnManagerFactory = new TxnManagerFactory( logDir.getPath(), 1 << 13, 1 << 14 );
@@ -106,7 +107,7 @@ public class AvlPartitionTxnTest
if ( !loaded )
{
- fail( "Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()) );
+ fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
}
}
@@ -137,20 +138,20 @@ public class AvlPartitionTxnTest
fail();
}
}
-
+
@After
public void destroyStore() throws Exception
{
partition.destroy();
-
+
if ( logDir != null )
{
- FileUtils.deleteDirectory( logDir);
+ FileUtils.deleteDirectory( logDir );
}
}
-
-
+
+
@Test
public void testAddsConcurrentWithSearch()
{
@@ -158,16 +159,15 @@ public class AvlPartitionTxnTest
{
int numThreads = 10;
AddsConcurrentWithSearchTestThread threads[] = new AddsConcurrentWithSearchTestThread[numThreads];
-
-
- for ( int idx =0; idx < numThreads; idx++ )
+
+ for ( int idx = 0; idx < numThreads; idx++ )
{
threads[idx] = new AddsConcurrentWithSearchTestThread();
threads[idx].start();
}
-
+
txnManager.beginTransaction( false );
-
+
// dn id 12
Dn martinDn = new Dn( schemaManager, "cn=Marting King,ou=Sales,o=Good Times Co." );
DefaultEntry entry = new DefaultEntry( schemaManager, martinDn );
@@ -179,10 +179,10 @@ public class AvlPartitionTxnTest
AddOperationContext addContext = new AddOperationContext( schemaManager, entry );
executionManager.add( partition, addContext );
-
+
// Sleep some
Thread.sleep( 100 );
-
+
// dn id 13
Dn jimmyDn = new Dn( schemaManager, "cn=Jimmy Wales, ou=Sales,o=Good Times Co." );
entry = new DefaultEntry( schemaManager, jimmyDn );
@@ -191,13 +191,13 @@ public class AvlPartitionTxnTest
entry.add( "cn", "Jimmy Wales" );
entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
entry.add( "entryUUID", Strings.getUUIDString( 13 ).toString() );
-
+
addContext = new AddOperationContext( schemaManager, entry );
executionManager.add( partition, addContext );
-
+
txnManager.commitTransaction();
-
- for ( int idx =0; idx < numThreads; idx++ )
+
+ for ( int idx = 0; idx < numThreads; idx++ )
{
threads[idx].join();
}
@@ -208,7 +208,7 @@ public class AvlPartitionTxnTest
assertTrue( false );
}
}
-
+
private static boolean removeDirectory( File directory )
{
@@ -216,20 +216,19 @@ public class AvlPartitionTxnTest
{
return false;
}
-
+
if ( !directory.exists() )
{
return true;
}
-
+
if ( !directory.isDirectory() )
{
- return false;
+ return false;
}
-
String[] list = directory.list();
-
+
if ( list != null )
{
for ( int i = 0; i < list.length; i++ )
@@ -251,55 +250,53 @@ public class AvlPartitionTxnTest
return directory.delete();
}
-
+
class AddsConcurrentWithSearchTestThread extends Thread
{
private void doSearch() throws Exception
{
int numEntries = 0;
-
+
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
ExprNode filter = new PresenceNode( schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT ) );
-
+
Dn baseDn = new Dn( schemaManager, "ou=Sales,o=Good Times Co." );
-
+
txnManager.beginTransaction( true );
- IndexCursor<UUID> cursor = partition.getSearchEngine().cursor( baseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
-
+ IndexCursor<UUID> cursor = partition.getSearchEngine().cursor( baseDn, AliasDerefMode.NEVER_DEREF_ALIASES,
+ filter, controls );
+
while ( cursor.next() )
{
numEntries++;
}
-
+
assertTrue( numEntries == 2 || numEntries == 4 );
- //System.out.println("Num entries: " + numEntries );
-
+
txnManager.commitTransaction();
}
public void run()
- {
+ {
try
{
Random sleepRandomizer = new Random();
int sleepTime = sleepRandomizer.nextInt( 10 ) * 100;
-
+
Thread.sleep( sleepTime );
-
+
doSearch();
}
- catch( Exception e )
+ catch ( Exception e )
{
e.printStackTrace();
fail();
assertTrue( false );
}
-
-
-
+
}
} // end of class RemoveInsertTestThread