ACS-1033 : Spring upgrade to 5.3.2 (#213)

- Update test as per 5de549d7d4
- before spring 5.3.0, AbstractFallbackSQLExceptionTranslator was translating org.postgresql.util.PSQLException as UncategorizedSQLException - now it returns null (ref. e9cded560d (diff-c6aa1c6a4b11e8a722808e945c4c5b6ef471c42871c7ce830554dde81ad7f2c2L89))

Co-authored-by: CezarLeahu <35226487+CezarLeahu@users.noreply.github.com>
This commit is contained in:
Denis Ungureanu
2020-12-23 12:21:03 +02:00
committed by GitHub
parent a79f782a91
commit f786f4ffaf
4 changed files with 23 additions and 11 deletions

View File

@@ -19,6 +19,8 @@
package org.alfresco.util.transaction; package org.alfresco.util.transaction;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import javax.transaction.HeuristicMixedException; import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException; import javax.transaction.HeuristicRollbackException;
@@ -135,6 +137,8 @@ public class SpringAwareUserTransaction
private long threadId = Long.MIN_VALUE; private long threadId = Long.MIN_VALUE;
/** make sure that we clean up the thread transaction stack properly */ /** make sure that we clean up the thread transaction stack properly */
private boolean finalized = false; private boolean finalized = false;
private Collection<String> labels = Collections.emptyList();
/** /**
* Creates a user transaction that defaults to {@link TransactionDefinition#PROPAGATION_REQUIRED}. * Creates a user transaction that defaults to {@link TransactionDefinition#PROPAGATION_REQUIRED}.
@@ -200,6 +204,21 @@ public class SpringAwareUserTransaction
return null; return null;
} }
/**
* Associate one or more labels with this transaction attribute.
* <p>This may be used for applying specific transactional behavior
* or follow a purely descriptive nature.
*/
public void setLabels(Collection<String> labels) {
this.labels = labels;
}
@Override
public Collection<String> getLabels()
{
return this.labels;
}
/** /**
* The {@link UserTransaction } must rollback regardless of the error. The * The {@link UserTransaction } must rollback regardless of the error. The
* {@link #rollback() rollback} behaviour is implemented by simulating a caught * {@link #rollback() rollback} behaviour is implemented by simulating a caught

View File

@@ -55,7 +55,7 @@
<dependency.alfresco-greenmail.version>6.2</dependency.alfresco-greenmail.version> <dependency.alfresco-greenmail.version>6.2</dependency.alfresco-greenmail.version>
<dependency.acs-event-model.version>0.0.11</dependency.acs-event-model.version> <dependency.acs-event-model.version>0.0.11</dependency.acs-event-model.version>
<dependency.spring.version>5.2.12.RELEASE</dependency.spring.version> <dependency.spring.version>5.3.2</dependency.spring.version>
<dependency.antlr.version>3.5.2</dependency.antlr.version> <dependency.antlr.version>3.5.2</dependency.antlr.version>
<dependency.jackson.version>2.11.3</dependency.jackson.version> <dependency.jackson.version>2.11.3</dependency.jackson.version>
<dependency.jackson-databind.version>2.11.2</dependency.jackson-databind.version> <dependency.jackson-databind.version>2.11.2</dependency.jackson-databind.version>

View File

@@ -243,7 +243,7 @@ public class QuickShareRestApiTest extends BaseWebScriptTest
// get content thumbnail for node (authenticated) // get content thumbnail for node (authenticated)
rsp = sendRequest(new GetRequest(AUTH_CONTENT_THUMBNAIL_URL.replace("{node_ref_3}", testNodeRef_3).replace("{thumbnailname}", "doclib")), expectedStatusOK, USER_ONE); rsp = sendRequest(new GetRequest(AUTH_CONTENT_THUMBNAIL_URL.replace("{node_ref_3}", testNodeRef_3).replace("{thumbnailname}", "doclib")), expectedStatusOK, USER_ONE);
String type = rsp.getContentType(); String type = rsp.getContentType();
assertEquals(TEST_MIMETYPE_PNG, type); assertEquals(TEST_MIMETYPE_PNG + ";charset=UTF-8", type);
// As user two ... // As user two ...
@@ -279,7 +279,7 @@ public class QuickShareRestApiTest extends BaseWebScriptTest
// get content thumbnail for share (note: can be unauthenticated) // get content thumbnail for share (note: can be unauthenticated)
rsp = sendRequest(new GetRequest(SHARE_CONTENT_THUMBNAIL_URL.replace("{shared_id}", sharedId).replace("{thumbnailname}", "doclib")), expectedStatusOK, USER_TWO); rsp = sendRequest(new GetRequest(SHARE_CONTENT_THUMBNAIL_URL.replace("{shared_id}", sharedId).replace("{thumbnailname}", "doclib")), expectedStatusOK, USER_TWO);
type = rsp.getContentType(); type = rsp.getContentType();
assertEquals(TEST_MIMETYPE_PNG, type); assertEquals(TEST_MIMETYPE_PNG + ";charset=UTF-8", type);
// As user one ... // As user one ...

View File

@@ -29,8 +29,6 @@ import javax.transaction.RollbackException;
import javax.transaction.Status; import javax.transaction.Status;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import junit.framework.TestCase;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.dialect.Dialect; import org.alfresco.repo.domain.dialect.Dialect;
import org.alfresco.repo.domain.dialect.PostgreSQLDialect; import org.alfresco.repo.domain.dialect.PostgreSQLDialect;
@@ -45,17 +43,12 @@ import org.alfresco.service.cmr.security.PersonService;
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.ReadOnlyServerException; import org.alfresco.service.transaction.ReadOnlyServerException;
import org.alfresco.test_category.OwnJVMTestsCategory;
import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.BaseSpringTest; import org.alfresco.util.BaseSpringTest;
import org.alfresco.util.PropertyMap; import org.alfresco.util.PropertyMap;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category;
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;
/** /**
@@ -192,7 +185,7 @@ public class TransactionServiceImplTest extends BaseSpringTest
@SuppressWarnings("unused") @SuppressWarnings("unused")
int i = 0; int i = 0;
} }
catch (UncategorizedSQLException e) catch (Exception e)
{ {
// or this - for PostgreSQL (org.postgresql.util.PSQLException: ERROR: transaction is read-only) // or this - for PostgreSQL (org.postgresql.util.PSQLException: ERROR: transaction is read-only)
if (dialect instanceof PostgreSQLDialect) if (dialect instanceof PostgreSQLDialect)