Test fix (RepoAdminServiceImplTest.testConcurrentDynamicModelDelete)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20697 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2010-06-18 09:29:54 +00:00
parent 4872eb9909
commit 570c8a7f03
3 changed files with 29 additions and 39 deletions

View File

@@ -163,7 +163,7 @@
<property name="contentService" ref="ContentService"/> <property name="contentService" ref="ContentService"/>
<property name="transactionService" ref="transactionService"/> <property name="transactionService" ref="transactionService"/>
<property name="namespaceService" ref="namespaceService"/> <property name="namespaceService" ref="namespaceService"/>
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="nodeService"/>
<property name="messageService" ref="messageService"/> <property name="messageService" ref="messageService"/>
<property name="tenantAdminService" ref="tenantAdminService"/> <property name="tenantAdminService" ref="tenantAdminService"/>

View File

@@ -40,8 +40,6 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.admin.RepoAdminService; import org.alfresco.service.cmr.admin.RepoAdminService;
import org.alfresco.service.cmr.dictionary.ClassDefinition; import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
@@ -53,7 +51,6 @@ import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -72,8 +69,6 @@ public class RepoAdminServiceImplTest extends TestCase
private RepoAdminService repoAdminService; private RepoAdminService repoAdminService;
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
private TransactionService transactionService;
private NodeService nodeService; private NodeService nodeService;
private ContentService contentService; private ContentService contentService;
private SearchService searchService; private SearchService searchService;
@@ -83,7 +78,7 @@ public class RepoAdminServiceImplTest extends TestCase
final static String MKR = "{MKR}"; final static String MKR = "{MKR}";
public static final String MODEL_MKR_XML = public static final String MODEL_MKR_XML =
"<model name='test"+MKR+":testModel"+MKR+"' xmlns='http://www.alfresco.org/model/dictionary/1.0'>" + "<model name='ratest-"+MKR+":testModel"+MKR+"' xmlns='http://www.alfresco.org/model/dictionary/1.0'>" +
" <description>Test model "+MKR+"</description>" + " <description>Test model "+MKR+"</description>" +
" <author>Alfresco</author>" + " <author>Alfresco</author>" +
@@ -96,17 +91,17 @@ public class RepoAdminServiceImplTest extends TestCase
" </imports>" + " </imports>" +
" <namespaces>" + " <namespaces>" +
" <namespace uri='http://www.alfresco.org/test/testmodel"+MKR+"/1.0' prefix='test"+MKR+"'/>" + " <namespace uri='http://www.alfresco.org/test/testmodel"+MKR+"/1.0' prefix='ratest-"+MKR+"'/>" +
" </namespaces>" + " </namespaces>" +
" <types>" + " <types>" +
" <type name='test"+MKR+":base'>" + " <type name='ratest-"+MKR+":base'>" +
" <title>Base</title>" + " <title>Base</title>" +
" <description>The Base Type</description>" + " <description>The Base Type</description>" +
" <parent>cm:content</parent>" + " <parent>cm:content</parent>" +
" <properties>" + " <properties>" +
" <property name='test"+MKR+":prop1'>" + " <property name='ratest-"+MKR+":prop1'>" +
" <type>d:text</type>" + " <type>d:text</type>" +
" </property>" + " </property>" +
" </properties>" + " </properties>" +
@@ -123,8 +118,6 @@ public class RepoAdminServiceImplTest extends TestCase
repoAdminService = (RepoAdminService) ctx.getBean("RepoAdminService"); repoAdminService = (RepoAdminService) ctx.getBean("RepoAdminService");
dictionaryService = (DictionaryService) ctx.getBean("DictionaryService"); dictionaryService = (DictionaryService) ctx.getBean("DictionaryService");
transactionService = (TransactionService) ctx.getBean("TransactionService");
nodeService = (NodeService) ctx.getBean("NodeService"); nodeService = (NodeService) ctx.getBean("NodeService");
contentService = (ContentService) ctx.getBean("ContentService"); contentService = (ContentService) ctx.getBean("ContentService");
searchService = (SearchService) ctx.getBean("SearchService"); searchService = (SearchService) ctx.getBean("SearchService");
@@ -472,6 +465,12 @@ public class RepoAdminServiceImplTest extends TestCase
String model = MODEL_MKR_XML.replace(MKR, i+""); String model = MODEL_MKR_XML.replace(MKR, i+"");
InputStream modelStream = new ByteArrayInputStream(model.getBytes("UTF-8")); InputStream modelStream = new ByteArrayInputStream(model.getBytes("UTF-8"));
repoAdminService.deployModel(modelStream, modelPrefix+i); repoAdminService.deployModel(modelStream, modelPrefix+i);
logger.info("["+i+"] Deployed - test model: "+modelPrefix+i);
}
else
{
logger.warn("["+i+"] Already deployed - test model: "+modelPrefix+i);
} }
} }
} }
@@ -592,10 +591,6 @@ public class RepoAdminServiceImplTest extends TestCase
{ {
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>()
{
public Object execute() throws Throwable
{
if (opType == 1) if (opType == 1)
{ {
// Deploy model // Deploy model
@@ -603,19 +598,15 @@ public class RepoAdminServiceImplTest extends TestCase
InputStream modelStream = new ByteArrayInputStream(model.getBytes("UTF-8")); InputStream modelStream = new ByteArrayInputStream(model.getBytes("UTF-8"));
repoAdminService.deployModel(modelStream, modelPrefix+i); repoAdminService.deployModel(modelStream, modelPrefix+i);
logger.info("["+i+"] Deploying test model: "+modelPrefix+i+" ["+AlfrescoTransactionSupport.getTransactionId()+"]"); logger.info("["+i+"] Deploying - test model: "+modelPrefix+i);
} }
else if (opType == 2) else if (opType == 2)
{ {
// Undeploy model // Undeploy model
repoAdminService.undeployModel(modelPrefix+i); repoAdminService.undeployModel(modelPrefix+i);
logger.info("["+i+"] Undeployed test model: "+modelPrefix+i+" ["+AlfrescoTransactionSupport.getTransactionId()+"]"); logger.info("["+i+"] Undeployed - test model: "+modelPrefix+i);
} }
return null;
}
});
} }
catch (Throwable t) catch (Throwable t)
{ {
@@ -623,7 +614,7 @@ public class RepoAdminServiceImplTest extends TestCase
t.printStackTrace(new PrintWriter(sw)); t.printStackTrace(new PrintWriter(sw));
errorStackTrace = sw.toString(); errorStackTrace = sw.toString();
logger.error("["+i+"] Failed to deploy test model: "+t); logger.error("["+i+"] Failed to "+(opType == 1 ? "deploy" : "undeploy")+" test model: "+t);
} }
} }
} }

View File

@@ -50,7 +50,6 @@ import org.alfresco.util.Pair;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.extensions.surf.util.AbstractLifecycleBean; import org.springframework.extensions.surf.util.AbstractLifecycleBean;
/** /**
@@ -285,10 +284,10 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
// ignore - model no longer exists // ignore - model no longer exists
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
logger.debug("onDictionaryInit: "+inre+" (assume concurrency failure)"); logger.debug("onDictionaryInit: "+inre+" (assume concurrently deleted)");
} }
throw new ConcurrencyFailureException(inre.getMessage()); continue;
} }
} }
} }