mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-4226 - PostgreSQL: fix TransactionServiceImplTest.testReadOnlyTxn
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21591 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -31,9 +31,12 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransacti
|
|||||||
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;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
import org.hibernate.dialect.Dialect;
|
||||||
|
import org.hibernate.dialect.PostgreSQLDialect;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||||
import org.springframework.dao.TransientDataAccessResourceException;
|
import org.springframework.dao.TransientDataAccessResourceException;
|
||||||
|
import org.springframework.jdbc.UncategorizedSQLException;
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,6 +52,8 @@ public class TransactionServiceImplTest extends TestCase
|
|||||||
private TransactionServiceImpl transactionService;
|
private TransactionServiceImpl transactionService;
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
|
||||||
|
private Dialect dialect;
|
||||||
|
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
transactionManager = (PlatformTransactionManager) ctx.getBean("transactionManager");
|
transactionManager = (PlatformTransactionManager) ctx.getBean("transactionManager");
|
||||||
@@ -59,6 +64,8 @@ public class TransactionServiceImplTest extends TestCase
|
|||||||
transactionService.setSysAdminParams((SysAdminParams) ctx.getBean("sysAdminParams"));
|
transactionService.setSysAdminParams((SysAdminParams) ctx.getBean("sysAdminParams"));
|
||||||
|
|
||||||
nodeService = (NodeService) ctx.getBean("dbNodeService");
|
nodeService = (NodeService) ctx.getBean("dbNodeService");
|
||||||
|
|
||||||
|
dialect = (Dialect) ctx.getBean("dialect");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPropagatingTxn() throws Exception
|
public void testPropagatingTxn() throws Exception
|
||||||
@@ -136,15 +143,30 @@ public class TransactionServiceImplTest extends TestCase
|
|||||||
}
|
}
|
||||||
catch (InvalidDataAccessApiUsageException e)
|
catch (InvalidDataAccessApiUsageException e)
|
||||||
{
|
{
|
||||||
|
// expected this ...
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
int i = 0;
|
int i = 0;
|
||||||
// expected this ...
|
|
||||||
}
|
}
|
||||||
catch (TransientDataAccessResourceException e)
|
catch (TransientDataAccessResourceException e)
|
||||||
{
|
{
|
||||||
|
// or this
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
int i = 0;
|
int i = 0;
|
||||||
// or this
|
}
|
||||||
|
catch (UncategorizedSQLException e)
|
||||||
|
{
|
||||||
|
// or this - for PostgreSQL (org.postgresql.util.PSQLException: ERROR: transaction is read-only)
|
||||||
|
if (dialect instanceof PostgreSQLDialect)
|
||||||
|
{
|
||||||
|
// ALF-4226
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user