From f786f4ffafe111da7e1eae39c4c543a38c28ee01 Mon Sep 17 00:00:00 2001 From: Denis Ungureanu Date: Wed, 23 Dec 2020 12:21:03 +0200 Subject: [PATCH] ACS-1033 : Spring upgrade to 5.3.2 (#213) - Update test as per https://github.com/spring-projects/spring-framework/commit/5de549d7d4324c7e30ac607e15ebac444f8c3f28 - before spring 5.3.0, AbstractFallbackSQLExceptionTranslator was translating org.postgresql.util.PSQLException as UncategorizedSQLException - now it returns null (ref. https://github.com/spring-projects/spring-framework/commit/e9cded560d6ecb73aa5bfca57e06b09fa0013294#diff-c6aa1c6a4b11e8a722808e945c4c5b6ef471c42871c7ce830554dde81ad7f2c2L89) Co-authored-by: CezarLeahu <35226487+CezarLeahu@users.noreply.github.com> --- .../SpringAwareUserTransaction.java | 19 +++++++++++++++++++ pom.xml | 2 +- .../quickshare/QuickShareRestApiTest.java | 4 ++-- .../TransactionServiceImplTest.java | 9 +-------- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/org/alfresco/util/transaction/SpringAwareUserTransaction.java b/core/src/main/java/org/alfresco/util/transaction/SpringAwareUserTransaction.java index 2e8d6c9c26..3ad66f6b4e 100644 --- a/core/src/main/java/org/alfresco/util/transaction/SpringAwareUserTransaction.java +++ b/core/src/main/java/org/alfresco/util/transaction/SpringAwareUserTransaction.java @@ -19,6 +19,8 @@ package org.alfresco.util.transaction; import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Collections; import javax.transaction.HeuristicMixedException; import javax.transaction.HeuristicRollbackException; @@ -135,6 +137,8 @@ public class SpringAwareUserTransaction private long threadId = Long.MIN_VALUE; /** make sure that we clean up the thread transaction stack properly */ private boolean finalized = false; + + private Collection labels = Collections.emptyList(); /** * Creates a user transaction that defaults to {@link TransactionDefinition#PROPAGATION_REQUIRED}. @@ -200,6 +204,21 @@ public class SpringAwareUserTransaction return null; } + /** + * Associate one or more labels with this transaction attribute. + *

This may be used for applying specific transactional behavior + * or follow a purely descriptive nature. + */ + public void setLabels(Collection labels) { + this.labels = labels; + } + + @Override + public Collection getLabels() + { + return this.labels; + } + /** * The {@link UserTransaction } must rollback regardless of the error. The * {@link #rollback() rollback} behaviour is implemented by simulating a caught diff --git a/pom.xml b/pom.xml index 6f4543f8e2..10e64f5f9f 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ 6.2 0.0.11 - 5.2.12.RELEASE + 5.3.2 3.5.2 2.11.3 2.11.2 diff --git a/remote-api/src/test/java/org/alfresco/repo/web/scripts/quickshare/QuickShareRestApiTest.java b/remote-api/src/test/java/org/alfresco/repo/web/scripts/quickshare/QuickShareRestApiTest.java index 711f3a3868..875831a23c 100644 --- a/remote-api/src/test/java/org/alfresco/repo/web/scripts/quickshare/QuickShareRestApiTest.java +++ b/remote-api/src/test/java/org/alfresco/repo/web/scripts/quickshare/QuickShareRestApiTest.java @@ -243,7 +243,7 @@ public class QuickShareRestApiTest extends BaseWebScriptTest // 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); String type = rsp.getContentType(); - assertEquals(TEST_MIMETYPE_PNG, type); + assertEquals(TEST_MIMETYPE_PNG + ";charset=UTF-8", type); // As user two ... @@ -279,7 +279,7 @@ public class QuickShareRestApiTest extends BaseWebScriptTest // 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); type = rsp.getContentType(); - assertEquals(TEST_MIMETYPE_PNG, type); + assertEquals(TEST_MIMETYPE_PNG + ";charset=UTF-8", type); // As user one ... diff --git a/repository/src/test/java/org/alfresco/repo/transaction/TransactionServiceImplTest.java b/repository/src/test/java/org/alfresco/repo/transaction/TransactionServiceImplTest.java index ebf1ab3c7c..d87f7452b9 100644 --- a/repository/src/test/java/org/alfresco/repo/transaction/TransactionServiceImplTest.java +++ b/repository/src/test/java/org/alfresco/repo/transaction/TransactionServiceImplTest.java @@ -29,8 +29,6 @@ import javax.transaction.RollbackException; import javax.transaction.Status; import javax.transaction.UserTransaction; -import junit.framework.TestCase; - import org.alfresco.model.ContentModel; import org.alfresco.repo.domain.dialect.Dialect; 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.QName; 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.PropertyMap; import org.junit.Before; import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.springframework.context.ApplicationContext; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.dao.TransientDataAccessResourceException; -import org.springframework.jdbc.UncategorizedSQLException; import org.springframework.transaction.PlatformTransactionManager; /** @@ -192,7 +185,7 @@ public class TransactionServiceImplTest extends BaseSpringTest @SuppressWarnings("unused") int i = 0; } - catch (UncategorizedSQLException e) + catch (Exception e) { // or this - for PostgreSQL (org.postgresql.util.PSQLException: ERROR: transaction is read-only) if (dialect instanceof PostgreSQLDialect)