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.importer.ImporterBootstrap;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
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.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
@@ -58,24 +60,32 @@ public class TestData
|
|||||||
* @param applicationContext
|
* @param applicationContext
|
||||||
* @param workspaceName
|
* @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>()
|
||||||
{
|
{
|
||||||
// Bootstrap Users
|
public Object doWork() throws Exception
|
||||||
MutableAuthenticationDao authDAO = (MutableAuthenticationDao) applicationContext.getBean("alfDaoImpl");
|
|
||||||
if (authDAO.userExists("superuser") == false)
|
|
||||||
{
|
{
|
||||||
authDAO.createUser("superuser", "".toCharArray());
|
// Bootstrap Users
|
||||||
|
MutableAuthenticationDao authDAO = (MutableAuthenticationDao) applicationContext.getBean("alfDaoImpl");
|
||||||
|
if (authDAO.userExists("superuser") == false)
|
||||||
|
{
|
||||||
|
authDAO.createUser("superuser", "".toCharArray());
|
||||||
|
}
|
||||||
|
if (authDAO.userExists("user") == false)
|
||||||
|
{
|
||||||
|
authDAO.createUser("user", "".toCharArray());
|
||||||
|
}
|
||||||
|
if (authDAO.userExists("anonymous") == false)
|
||||||
|
{
|
||||||
|
authDAO.createUser("anonymous", "".toCharArray());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
if (authDAO.userExists("user") == false)
|
};
|
||||||
{
|
TransactionUtil.executeInUserTransaction(transactionService, createUserWork);
|
||||||
authDAO.createUser("user", "".toCharArray());
|
|
||||||
}
|
|
||||||
if (authDAO.userExists("anonymous") == false)
|
|
||||||
{
|
|
||||||
authDAO.createUser("anonymous", "".toCharArray());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user