diff --git a/packaging/war/src/main/webapp/META-INF/context.xml b/packaging/war/src/main/webapp/META-INF/context.xml index deee50d1d2..3ec256150b 100644 --- a/packaging/war/src/main/webapp/META-INF/context.xml +++ b/packaging/war/src/main/webapp/META-INF/context.xml @@ -4,7 +4,7 @@ - + diff --git a/packaging/war/src/main/webapp/WEB-INF/web.xml b/packaging/war/src/main/webapp/WEB-INF/web.xml index e01023e21b..679600abf5 100644 --- a/packaging/war/src/main/webapp/WEB-INF/web.xml +++ b/packaging/war/src/main/webapp/WEB-INF/web.xml @@ -500,7 +500,7 @@ org.hibernate.dialect.MySQLInnoDBDialect, org.alfresco.repo.domain.hibernate.dialect.AlfrescoOracle9Dialect, org.alfresco.repo.domain.hibernate.dialect.AlfrescoSybaseAnywhereDialect, - org.alfresco.repo.domain.hibernate.dialect.AlfrescoSQLServerDialect, org.hibernate.dialect.PostgreSQLDialect + org.alfresco.repo.domain.hibernate.dialect.SQLServerDialect, org.hibernate.dialect.PostgreSQLDialect properties/hibernate.dialect java.lang.String diff --git a/remote-api/src/test/java/org/alfresco/rest/test/workflow/api/impl/ProcessesImplTest.java b/remote-api/src/test/java/org/alfresco/rest/test/workflow/api/impl/ProcessesImplTest.java index bc6e8a37de..2bda2539f4 100644 --- a/remote-api/src/test/java/org/alfresco/rest/test/workflow/api/impl/ProcessesImplTest.java +++ b/remote-api/src/test/java/org/alfresco/rest/test/workflow/api/impl/ProcessesImplTest.java @@ -2,7 +2,7 @@ * #%L * Alfresco Remote API * %% - * Copyright (C) 2005 - 2023 Alfresco Software Limited + * Copyright (C) 2005 - 2025 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -212,7 +212,7 @@ public class ProcessesImplTest extends TestCase implements RecognizedParamsExtra { // the tests are always run on PostgreSQL only // Dialect dialect = (Dialect) applicationContext.getBean("dialect"); -// if (dialect instanceof AlfrescoSQLServerDialect) +// if (dialect instanceof SQLServerDialect) // { // REPO-1104: we do not run this test on MS SQL server because it will fail // until the Activiti defect related to REPO-1104 will be fixed diff --git a/repository/src/main/resources/alfresco/dao/dao-context.xml b/repository/src/main/resources/alfresco/dao/dao-context.xml index 58c6545f3f..951401eb30 100644 --- a/repository/src/main/resources/alfresco/dao/dao-context.xml +++ b/repository/src/main/resources/alfresco/dao/dao-context.xml @@ -143,7 +143,7 @@ - + diff --git a/repository/src/test/java/org/alfresco/AllDBTestsTestSuite.java b/repository/src/test/java/org/alfresco/AllDBTestsTestSuite.java index 1a975a4634..3de4f3e130 100644 --- a/repository/src/test/java/org/alfresco/AllDBTestsTestSuite.java +++ b/repository/src/test/java/org/alfresco/AllDBTestsTestSuite.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2021 Alfresco Software Limited + * Copyright (C) 2005 - 2025 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -53,6 +53,7 @@ import org.junit.runners.Suite; // From AppContext05TestSuite org.alfresco.repo.domain.node.NodeDAOTest.class, + org.alfresco.repo.domain.subscriptions.SubscriptionDAOTest.class, org.alfresco.repo.security.permissions.impl.AclDaoComponentTest.class, org.alfresco.repo.domain.contentdata.ContentDataDAOTest.class, org.alfresco.repo.domain.encoding.EncodingDAOTest.class, diff --git a/repository/src/test/java/org/alfresco/repo/domain/subscriptions/SubscriptionDAOTest.java b/repository/src/test/java/org/alfresco/repo/domain/subscriptions/SubscriptionDAOTest.java index f62cb32860..873fc796f5 100644 --- a/repository/src/test/java/org/alfresco/repo/domain/subscriptions/SubscriptionDAOTest.java +++ b/repository/src/test/java/org/alfresco/repo/domain/subscriptions/SubscriptionDAOTest.java @@ -1,241 +1,232 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.repo.domain.subscriptions; - -import junit.framework.TestCase; - -import org.alfresco.query.PagingRequest; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.subscriptions.PagingFollowingResults; -import org.alfresco.service.cmr.subscriptions.PagingSubscriptionResults; -import org.alfresco.service.cmr.subscriptions.SubscriptionItemTypeEnum; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.alfresco.util.ApplicationContextHelper; -import org.alfresco.util.testing.category.NeverRunsTests; -import org.junit.experimental.categories.Category; -import org.springframework.context.ApplicationContext; - -@Category({OwnJVMTestsCategory.class, NeverRunsTests.class}) -public class SubscriptionDAOTest extends TestCase -{ - private ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); - private TransactionService transactionService; - private RetryingTransactionHelper txnHelper; - private PersonService personService; - - private SubscriptionsDAO subscriptionsDAO; - - protected NodeRef getUserNodeRef(final String userId) - { - final PersonService ps = personService; - - return AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public NodeRef doWork() throws Exception - { - return ps.getPerson(userId); - } - }, AuthenticationUtil.getSystemUserName()); - } - - protected void insert(final String userId, final NodeRef node) throws Exception - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - subscriptionsDAO.insertSubscription(userId, node); - return null; - } - }; - txnHelper.doInTransaction(callback, false, false); - } - - protected void delete(final String userId, final NodeRef node) throws Exception - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - subscriptionsDAO.deleteSubscription(userId, node); - return null; - } - }; - txnHelper.doInTransaction(callback, false, false); - } - - protected int count(final String userId) throws Exception - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Integer execute() throws Throwable - { - return subscriptionsDAO.countSubscriptions(userId, SubscriptionItemTypeEnum.USER); - } - }; - - return txnHelper.doInTransaction(callback, false, false); - } - - protected boolean hasSubscribed(final String userId, final NodeRef node) throws Exception - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Boolean execute() throws Throwable - { - return subscriptionsDAO.hasSubscribed(userId, node); - } - }; - - return txnHelper.doInTransaction(callback, false, false); - } - - protected PagingSubscriptionResults select(final String userId) throws Exception - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public PagingSubscriptionResults execute() throws Throwable - { - return subscriptionsDAO.selectSubscriptions(userId, SubscriptionItemTypeEnum.USER, new PagingRequest( - 100000, null)); - } - }; - - return txnHelper.doInTransaction(callback, false, false); - } - - protected int countFollowers(final String userId) throws Exception - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public Integer execute() throws Throwable - { - return subscriptionsDAO.countFollowers(userId); - } - }; - - return txnHelper.doInTransaction(callback, false, false); - } - - protected PagingFollowingResults selectFollowing(final String userId) throws Exception - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public PagingFollowingResults execute() throws Throwable - { - return subscriptionsDAO.selectFollowing(userId, new PagingRequest(100000, null)); - } - }; - - return txnHelper.doInTransaction(callback, false, false); - } - - protected PagingFollowingResults selectFollowers(final String userId) throws Exception - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - public PagingFollowingResults execute() throws Throwable - { - return subscriptionsDAO.selectFollowers(userId, new PagingRequest(100000, null)); - } - }; - - return txnHelper.doInTransaction(callback, false, false); - } - - @Override - public void setUp() throws Exception - { - ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); - transactionService = serviceRegistry.getTransactionService(); - txnHelper = transactionService.getRetryingTransactionHelper(); - - personService = serviceRegistry.getPersonService(); - - subscriptionsDAO = (SubscriptionsDAO) ctx.getBean("subscriptionsDAO"); - } - - public void testInsertAndDelete() throws Exception - { - String userId = "admin"; - String userId2 = "guest"; - NodeRef nodeRef = getUserNodeRef(userId2); - - // check subscription first - if (hasSubscribed(userId, nodeRef)) - { - delete(userId, nodeRef); - } - boolean hasSubscribed = hasSubscribed(userId, nodeRef); - assertFalse(hasSubscribed); - - // count subscriptions - int count = count(userId); - assertTrue(count >= 0); - - // insert - insert(userId, nodeRef); - insert(userId, nodeRef); - assertEquals(count + 1, count(userId)); - assertTrue(hasSubscribed(userId, nodeRef)); - - // select - PagingSubscriptionResults psr = select(userId); - assertNotNull(psr); - assertNotNull(psr.getPage()); - assertTrue(psr.getPage().contains(nodeRef)); - - PagingFollowingResults following = selectFollowing(userId); - assertNotNull(following); - assertNotNull(following.getPage()); - assertTrue(following.getPage().contains(userId2)); - - assertEquals(psr.getPage().size(), following.getPage().size()); - - // count followers - int followerCount = countFollowers(userId2); - assertTrue(followerCount >= 0); - - // select followers - PagingFollowingResults followers = selectFollowers(userId2); - assertNotNull(followers); - assertNotNull(followers.getPage()); - assertTrue(followers.getPage().contains(userId)); - - // delete - delete(userId, nodeRef); - assertEquals(count, count(userId)); - assertFalse(hasSubscribed(userId, nodeRef)); - } -} +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2025 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.domain.subscriptions; + +import junit.framework.TestCase; +import org.junit.experimental.categories.Category; +import org.springframework.context.ApplicationContext; + +import org.alfresco.query.PagingRequest; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.ServiceRegistry; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.security.PersonService; +import org.alfresco.service.cmr.subscriptions.PagingFollowingResults; +import org.alfresco.service.cmr.subscriptions.PagingSubscriptionResults; +import org.alfresco.service.cmr.subscriptions.SubscriptionItemTypeEnum; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.test_category.OwnJVMTestsCategory; +import org.alfresco.util.ApplicationContextHelper; +import org.alfresco.util.testing.category.DBTests; + +@Category({OwnJVMTestsCategory.class, DBTests.class}) +public class SubscriptionDAOTest extends TestCase +{ + private ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); + private TransactionService transactionService; + private RetryingTransactionHelper txnHelper; + private PersonService personService; + + private SubscriptionsDAO subscriptionsDAO; + + protected NodeRef getUserNodeRef(final String userId) + { + final PersonService ps = personService; + + return AuthenticationUtil.runAs(new RunAsWork() { + @Override + public NodeRef doWork() throws Exception + { + return ps.getPerson(userId); + } + }, AuthenticationUtil.getSystemUserName()); + } + + protected void insert(final String userId, final NodeRef node) throws Exception + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() { + public Object execute() throws Throwable + { + subscriptionsDAO.insertSubscription(userId, node); + return null; + } + }; + txnHelper.doInTransaction(callback, false, false); + } + + protected void delete(final String userId, final NodeRef node) throws Exception + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() { + public Object execute() throws Throwable + { + subscriptionsDAO.deleteSubscription(userId, node); + return null; + } + }; + txnHelper.doInTransaction(callback, false, false); + } + + protected int count(final String userId) throws Exception + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() { + public Integer execute() throws Throwable + { + return subscriptionsDAO.countSubscriptions(userId, SubscriptionItemTypeEnum.USER); + } + }; + + return txnHelper.doInTransaction(callback, false, false); + } + + protected boolean hasSubscribed(final String userId, final NodeRef node) throws Exception + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() { + public Boolean execute() throws Throwable + { + return subscriptionsDAO.hasSubscribed(userId, node); + } + }; + + return txnHelper.doInTransaction(callback, false, false); + } + + protected PagingSubscriptionResults select(final String userId) throws Exception + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() { + public PagingSubscriptionResults execute() throws Throwable + { + return subscriptionsDAO.selectSubscriptions(userId, SubscriptionItemTypeEnum.USER, new PagingRequest( + 100000, null)); + } + }; + + return txnHelper.doInTransaction(callback, false, false); + } + + protected int countFollowers(final String userId) throws Exception + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() { + public Integer execute() throws Throwable + { + return subscriptionsDAO.countFollowers(userId); + } + }; + + return txnHelper.doInTransaction(callback, false, false); + } + + protected PagingFollowingResults selectFollowing(final String userId) throws Exception + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() { + public PagingFollowingResults execute() throws Throwable + { + return subscriptionsDAO.selectFollowing(userId, new PagingRequest(100000, null)); + } + }; + + return txnHelper.doInTransaction(callback, false, false); + } + + protected PagingFollowingResults selectFollowers(final String userId) throws Exception + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() { + public PagingFollowingResults execute() throws Throwable + { + return subscriptionsDAO.selectFollowers(userId, new PagingRequest(100000, null)); + } + }; + + return txnHelper.doInTransaction(callback, false, false); + } + + @Override + public void setUp() throws Exception + { + ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); + transactionService = serviceRegistry.getTransactionService(); + txnHelper = transactionService.getRetryingTransactionHelper(); + + personService = serviceRegistry.getPersonService(); + + subscriptionsDAO = (SubscriptionsDAO) ctx.getBean("subscriptionsDAO"); + } + + public void testInsertAndDelete() throws Exception + { + String userId = "admin"; + String userId2 = "guest"; + NodeRef nodeRef = getUserNodeRef(userId2); + + // check subscription first + if (hasSubscribed(userId, nodeRef)) + { + delete(userId, nodeRef); + } + boolean hasSubscribed = hasSubscribed(userId, nodeRef); + assertFalse(hasSubscribed); + + // count subscriptions + int count = count(userId); + assertTrue(count >= 0); + + // insert + insert(userId, nodeRef); + insert(userId, nodeRef); + assertEquals(count + 1, count(userId)); + assertTrue(hasSubscribed(userId, nodeRef)); + + // select + PagingSubscriptionResults psr = select(userId); + assertNotNull(psr); + assertNotNull(psr.getPage()); + assertTrue(psr.getPage().contains(nodeRef)); + + PagingFollowingResults following = selectFollowing(userId); + assertNotNull(following); + assertNotNull(following.getPage()); + assertTrue(following.getPage().contains(userId2)); + + assertEquals(psr.getPage().size(), following.getPage().size()); + + // count followers + int followerCount = countFollowers(userId2); + assertTrue(followerCount >= 0); + + // select followers + PagingFollowingResults followers = selectFollowers(userId2); + assertNotNull(followers); + assertNotNull(followers.getPage()); + assertTrue(followers.getPage().contains(userId)); + + // delete + delete(userId, nodeRef); + assertEquals(count, count(userId)); + assertFalse(hasSubscribed(userId, nodeRef)); + } +}