mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
More build related stuff
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4858 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,6 +27,7 @@ import org.alfresco.repo.dictionary.DictionaryDAO;
|
||||
import org.alfresco.repo.dictionary.M2Model;
|
||||
import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.transaction.TransactionUtil;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -43,26 +44,37 @@ import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class ConcurrentNodeServiceTest extends TestCase
|
||||
{
|
||||
public static final String NAMESPACE = "http://www.alfresco.org/test/BaseNodeServiceTest";
|
||||
|
||||
public static final String TEST_PREFIX = "test";
|
||||
|
||||
public static final QName TYPE_QNAME_TEST_CONTENT = QName.createQName(NAMESPACE, "content");
|
||||
|
||||
public static final QName ASPECT_QNAME_TEST_TITLED = QName.createQName(NAMESPACE, "titled");
|
||||
|
||||
public static final QName PROP_QNAME_TEST_TITLE = QName.createQName(NAMESPACE, "title");
|
||||
|
||||
public static final QName PROP_QNAME_TEST_MIMETYPE = QName.createQName(NAMESPACE, "mimetype");
|
||||
|
||||
public static final int COUNT = 10;
|
||||
|
||||
public static final int REPEATS = 10;
|
||||
|
||||
static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||
|
||||
private NodeService nodeService;
|
||||
|
||||
private TransactionService transactionService;
|
||||
|
||||
private NodeRef rootNodeRef;
|
||||
|
||||
private FullTextSearchIndexer luceneFTS;
|
||||
|
||||
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
|
||||
public ConcurrentNodeServiceTest()
|
||||
@@ -88,8 +100,8 @@ public class ConcurrentNodeServiceTest extends TestCase
|
||||
nodeService = (NodeService) ctx.getBean("dbNodeService");
|
||||
transactionService = (TransactionService) ctx.getBean("transactionComponent");
|
||||
luceneFTS = (FullTextSearchIndexer) ctx.getBean("LuceneFullTextSearchIndexer");
|
||||
this.authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent");
|
||||
|
||||
this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
|
||||
|
||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
||||
|
||||
// create a first store directly
|
||||
@@ -106,7 +118,7 @@ public class ConcurrentNodeServiceTest extends TestCase
|
||||
authenticationComponent.clearCurrentSecurityContext();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
||||
protected Map<QName, ChildAssociationRef> buildNodeGraph() throws Exception
|
||||
{
|
||||
return BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
|
||||
@@ -122,20 +134,60 @@ public class ConcurrentNodeServiceTest extends TestCase
|
||||
return null;// answer;
|
||||
}
|
||||
|
||||
public void test1() throws Exception
|
||||
{
|
||||
testConcurrent();
|
||||
}
|
||||
|
||||
public void test2() throws Exception
|
||||
{
|
||||
testConcurrent();
|
||||
}
|
||||
public void test3() throws Exception
|
||||
{
|
||||
testConcurrent();
|
||||
}
|
||||
public void test4() throws Exception
|
||||
{
|
||||
testConcurrent();
|
||||
}
|
||||
public void test5() throws Exception
|
||||
{
|
||||
testConcurrent();
|
||||
}
|
||||
public void test6() throws Exception
|
||||
{
|
||||
testConcurrent();
|
||||
}
|
||||
public void test7() throws Exception
|
||||
{
|
||||
testConcurrent();
|
||||
}
|
||||
public void test8() throws Exception
|
||||
{
|
||||
testConcurrent();
|
||||
}
|
||||
public void test9() throws Exception
|
||||
{
|
||||
testConcurrent();
|
||||
}
|
||||
public void test10() throws Exception
|
||||
{
|
||||
testConcurrent();
|
||||
}
|
||||
|
||||
public void testConcurrent() throws Exception
|
||||
{
|
||||
luceneFTS.pause();
|
||||
// TODO: LUCENE UPDATE ISSUE fix commit lock time out
|
||||
// TODO: LUCENE UPDATE ISSUE fix commit lock time out
|
||||
// IndexWriter.COMMIT_LOCK_TIMEOUT = 100000;
|
||||
int count = 10;
|
||||
int repeats = 10;
|
||||
|
||||
Map<QName, ChildAssociationRef> assocRefs = commitNodeGraph();
|
||||
Thread runner = null;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
for (int i = 0; i < COUNT; i++)
|
||||
{
|
||||
runner = new Nester("Concurrent-" + i, runner, repeats);
|
||||
runner = new Nester("Concurrent-" + i, runner, REPEATS);
|
||||
}
|
||||
if (runner != null)
|
||||
{
|
||||
@@ -152,14 +204,62 @@ public class ConcurrentNodeServiceTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
SearchService searcher = (SearchService) ctx.getBean(ServiceRegistry.SEARCH_SERVICE.getLocalName());
|
||||
assertEquals(2 * ((count * repeats) + 1), searcher.selectNodes(rootNodeRef, "/*", null,
|
||||
getNamespacePrefixReolsver(""), false).size());
|
||||
ResultSet results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*\"");
|
||||
// n6 has root aspect - there are three things at the root level in the
|
||||
// index
|
||||
assertEquals(3 * ((count * repeats) + 1), results.length());
|
||||
results.close();
|
||||
TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork<Object>()
|
||||
{
|
||||
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
// There are two nodes at the base level in each test
|
||||
assertEquals(2 * ((COUNT * REPEATS) + 1), nodeService.getChildAssocs(rootNodeRef).size());
|
||||
|
||||
SearchService searcher = (SearchService) ctx.getBean(ServiceRegistry.SEARCH_SERVICE.getLocalName());
|
||||
assertEquals(2 * ((COUNT * REPEATS) + 1), searcher.selectNodes(rootNodeRef, "/*", null,
|
||||
getNamespacePrefixReolsver(""), false).size());
|
||||
ResultSet results = null;
|
||||
try
|
||||
{
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*\"");
|
||||
// n6 has root aspect - there are three things at the root level in the
|
||||
// index
|
||||
assertEquals(3 * ((COUNT * REPEATS) + 1), results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*/*\"");
|
||||
// n6 has root aspect - there are three things at the root level in the
|
||||
// index
|
||||
assertEquals(3 * ((COUNT * REPEATS) + 1), results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*/*/*\"");
|
||||
// n6 has root aspect - there are three things at the root level in the
|
||||
// index
|
||||
assertEquals(2 * ((COUNT * REPEATS) + 1), results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*/*/*/*\"");
|
||||
// n6 has root aspect - there are three things at the root level in the
|
||||
// index
|
||||
assertEquals(1 * ((COUNT * REPEATS) + 1), results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*/*/*/*/*\"");
|
||||
// n6 has root aspect - there are three things at the root level in the
|
||||
// index
|
||||
assertEquals(0 * ((COUNT * REPEATS) + 1), results.length());
|
||||
results.close();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (results != null)
|
||||
{
|
||||
results.close();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,7 +282,7 @@ public class ConcurrentNodeServiceTest extends TestCase
|
||||
public void run()
|
||||
{
|
||||
authenticationComponent.setSystemUserAsCurrentUser();
|
||||
|
||||
|
||||
if (waiter != null)
|
||||
{
|
||||
System.out.println("Starting " + waiter.getName());
|
||||
@@ -207,7 +307,8 @@ public class ConcurrentNodeServiceTest extends TestCase
|
||||
try
|
||||
{
|
||||
waiter.join();
|
||||
System.out.println("Thread " + this.getName() + " has waited for " +(waiter == null ? "null" : waiter.getName()));
|
||||
System.out.println("Thread "
|
||||
+ this.getName() + " has waited for " + (waiter == null ? "null" : waiter.getName()));
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
|
Reference in New Issue
Block a user