mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fixed tests using non-transactional components without starting transactions
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4716 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -23,6 +23,8 @@ import java.util.Properties;
|
||||
import org.alfresco.repo.importer.ImporterBootstrap;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||
import org.alfresco.repo.transaction.TransactionUtil;
|
||||
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
@@ -58,8 +60,13 @@ public class TestData
|
||||
* @param applicationContext
|
||||
* @param workspaceName
|
||||
*/
|
||||
public static void generateTestData(ApplicationContext applicationContext, String workspaceName)
|
||||
public static void generateTestData(final ApplicationContext applicationContext, String workspaceName)
|
||||
{
|
||||
final ServiceRegistry serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||
TransactionService transactionService = serviceRegistry.getTransactionService();
|
||||
TransactionWork<Object> createUserWork = new TransactionWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
// Bootstrap Users
|
||||
MutableAuthenticationDao authDAO = (MutableAuthenticationDao) applicationContext.getBean("alfDaoImpl");
|
||||
@@ -75,7 +82,10 @@ public class TestData
|
||||
{
|
||||
authDAO.createUser("anonymous", "".toCharArray());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
TransactionUtil.executeInUserTransaction(transactionService, createUserWork);
|
||||
|
||||
try
|
||||
{
|
||||
|
Reference in New Issue
Block a user