mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
Backport/[MNT-24490] Reference for AlfrescoSQLServerDialect changed to SQLServerDialect
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<!-- Resource defaultTransactionIsolation="-1" defaultAutoCommit="false" maxActive="100" initialSize="10" password="alfresco" username="alfresco" url="jdbc:mysql:///alfresco" driverClassName="org.gjt.mm.mysql.Driver" type="javax.sql.DataSource" auth="Container" name="jdbc/dataSource"/-->
|
<!-- Resource defaultTransactionIsolation="-1" defaultAutoCommit="false" maxActive="100" initialSize="10" password="alfresco" username="alfresco" url="jdbc:mysql:///alfresco" driverClassName="org.gjt.mm.mysql.Driver" type="javax.sql.DataSource" auth="Container" name="jdbc/dataSource"/-->
|
||||||
<Environment override="false" type="java.lang.Boolean" name="properties/startup.enable" description="A flag that globally enables or disables startup of the major Alfresco subsystems." value="true"/>
|
<Environment override="false" type="java.lang.Boolean" name="properties/startup.enable" description="A flag that globally enables or disables startup of the major Alfresco subsystems." value="true"/>
|
||||||
<Environment override="false" type="java.lang.String" name="properties/dir.root" description="The filesystem directory below which content and index data is stored. Should be on a shared disk if this is a clustered installation."/>
|
<Environment override="false" type="java.lang.String" name="properties/dir.root" description="The filesystem directory below which content and index data is stored. Should be on a shared disk if this is a clustered installation."/>
|
||||||
<Environment override="false" type="java.lang.String" name="properties/hibernate.dialect" description="The fully qualified name of a org.hibernate.dialect.Dialect subclass that allows Hibernate to generate SQL optimized for a particular relational database. Choose from org.hibernate.dialect.DerbyDialect, 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"/>
|
<Environment override="false" type="java.lang.String" name="properties/hibernate.dialect" description="The fully qualified name of a org.hibernate.dialect.Dialect subclass that allows Hibernate to generate SQL optimized for a particular relational database. Choose from org.hibernate.dialect.DerbyDialect, org.hibernate.dialect.MySQLInnoDBDialect, org.alfresco.repo.domain.hibernate.dialect.AlfrescoOracle9Dialect, org.alfresco.repo.domain.hibernate.dialect.AlfrescoSybaseAnywhereDialect, org.alfresco.repo.domain.hibernate.dialect.SQLServerDialect, org.hibernate.dialect.PostgreSQLDialect"/>
|
||||||
<Environment override="false" type="java.lang.String" name="properties/hibernate.query.substitutions" description="Mapping from tokens in Hibernate queries to SQL tokens. For PostgreSQL, set this to "true TRUE, false FALSE"."/>
|
<Environment override="false" type="java.lang.String" name="properties/hibernate.query.substitutions" description="Mapping from tokens in Hibernate queries to SQL tokens. For PostgreSQL, set this to "true TRUE, false FALSE"."/>
|
||||||
<Environment override="false" type="java.lang.Boolean" name="properties/hibernate.jdbc.use_get_generated_keys" description="Enable use of JDBC3 PreparedStatement.getGeneratedKeys() to retrieve natively generated keys after insert. Requires JDBC3+ driver. Set to false if your driver has problems with the Hibernate identifier generators. By default, tries to determine the driver capabilities using connection metadata."/>
|
<Environment override="false" type="java.lang.Boolean" name="properties/hibernate.jdbc.use_get_generated_keys" description="Enable use of JDBC3 PreparedStatement.getGeneratedKeys() to retrieve natively generated keys after insert. Requires JDBC3+ driver. Set to false if your driver has problems with the Hibernate identifier generators. By default, tries to determine the driver capabilities using connection metadata."/>
|
||||||
<Environment override="false" type="java.lang.String" name="properties/hibernate.default_schema" description="Qualify unqualified table names with the given schema/tablespace in generated SQL. It may be necessary to set this when the target database has more than one schema."/>
|
<Environment override="false" type="java.lang.String" name="properties/hibernate.default_schema" description="Qualify unqualified table names with the given schema/tablespace in generated SQL. It may be necessary to set this when the target database has more than one schema."/>
|
||||||
|
@@ -500,7 +500,7 @@
|
|||||||
org.hibernate.dialect.MySQLInnoDBDialect,
|
org.hibernate.dialect.MySQLInnoDBDialect,
|
||||||
org.alfresco.repo.domain.hibernate.dialect.AlfrescoOracle9Dialect,
|
org.alfresco.repo.domain.hibernate.dialect.AlfrescoOracle9Dialect,
|
||||||
org.alfresco.repo.domain.hibernate.dialect.AlfrescoSybaseAnywhereDialect,
|
org.alfresco.repo.domain.hibernate.dialect.AlfrescoSybaseAnywhereDialect,
|
||||||
org.alfresco.repo.domain.hibernate.dialect.AlfrescoSQLServerDialect, org.hibernate.dialect.PostgreSQLDialect</description>
|
org.alfresco.repo.domain.hibernate.dialect.SQLServerDialect, org.hibernate.dialect.PostgreSQLDialect</description>
|
||||||
<env-entry-name>properties/hibernate.dialect</env-entry-name>
|
<env-entry-name>properties/hibernate.dialect</env-entry-name>
|
||||||
<env-entry-type>java.lang.String</env-entry-type>
|
<env-entry-type>java.lang.String</env-entry-type>
|
||||||
<env-entry-value/> <!-- Empty value included for JBoss compatibility -->
|
<env-entry-value/> <!-- Empty value included for JBoss compatibility -->
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* 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.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* 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
|
// the tests are always run on PostgreSQL only
|
||||||
// Dialect dialect = (Dialect) applicationContext.getBean("dialect");
|
// 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
|
// 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
|
// until the Activiti defect related to REPO-1104 will be fixed
|
||||||
|
@@ -143,7 +143,7 @@
|
|||||||
</bean>
|
</bean>
|
||||||
<bean id="nodeDAO.org.alfresco.repo.domain.dialect.Dialect" class="org.alfresco.repo.domain.node.ibatis.NodeDAOImpl" parent="nodeDAObase" />
|
<bean id="nodeDAO.org.alfresco.repo.domain.dialect.Dialect" class="org.alfresco.repo.domain.node.ibatis.NodeDAOImpl" parent="nodeDAObase" />
|
||||||
<bean id="nodeDAO.org.alfresco.repo.domain.dialect.MySQLInnoDBDialect" class="org.alfresco.repo.domain.node.ibatis.NodeDAOImpl$MySQL" parent="nodeDAO.org.alfresco.repo.domain.dialect.Dialect" />
|
<bean id="nodeDAO.org.alfresco.repo.domain.dialect.MySQLInnoDBDialect" class="org.alfresco.repo.domain.node.ibatis.NodeDAOImpl$MySQL" parent="nodeDAO.org.alfresco.repo.domain.dialect.Dialect" />
|
||||||
<bean id="nodeDAO.org.alfresco.repo.domain.dialect.AlfrescoSQLServerDialect" class="org.alfresco.repo.domain.node.ibatis.NodeDAOImpl$MSSQL" parent="nodeDAO.org.alfresco.repo.domain.dialect.Dialect" />
|
<bean id="nodeDAO.org.alfresco.repo.domain.dialect.SQLServerDialect" class="org.alfresco.repo.domain.node.ibatis.NodeDAOImpl$MSSQL" parent="nodeDAO.org.alfresco.repo.domain.dialect.Dialect" />
|
||||||
|
|
||||||
<!-- WARNING: Experimental/unsupported - see MySQLClusterNDBDialect ! -->
|
<!-- WARNING: Experimental/unsupported - see MySQLClusterNDBDialect ! -->
|
||||||
<bean id="nodeDAO.org.alfresco.repo.domain.dialect.AlfrescoMySQLClusterNDBDialect" class="org.alfresco.repo.domain.node.ibatis.NodeDAOImpl$MySQLClusterNDB" parent="nodeDAO.org.alfresco.repo.domain.dialect.Dialect" />
|
<bean id="nodeDAO.org.alfresco.repo.domain.dialect.AlfrescoMySQLClusterNDBDialect" class="org.alfresco.repo.domain.node.ibatis.NodeDAOImpl$MySQLClusterNDB" parent="nodeDAO.org.alfresco.repo.domain.dialect.Dialect" />
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -53,6 +53,7 @@ import org.junit.runners.Suite;
|
|||||||
|
|
||||||
// From AppContext05TestSuite
|
// From AppContext05TestSuite
|
||||||
org.alfresco.repo.domain.node.NodeDAOTest.class,
|
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.security.permissions.impl.AclDaoComponentTest.class,
|
||||||
org.alfresco.repo.domain.contentdata.ContentDataDAOTest.class,
|
org.alfresco.repo.domain.contentdata.ContentDataDAOTest.class,
|
||||||
org.alfresco.repo.domain.encoding.EncodingDAOTest.class,
|
org.alfresco.repo.domain.encoding.EncodingDAOTest.class,
|
||||||
|
@@ -1,241 +1,232 @@
|
|||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
* provided under the following open source license terms:
|
* provided under the following open source license terms:
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.domain.subscriptions;
|
package org.alfresco.repo.domain.subscriptions;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
import org.junit.experimental.categories.Category;
|
||||||
import org.alfresco.query.PagingRequest;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.subscriptions.PagingFollowingResults;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.subscriptions.PagingSubscriptionResults;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.service.cmr.subscriptions.SubscriptionItemTypeEnum;
|
import org.alfresco.service.cmr.subscriptions.PagingFollowingResults;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.cmr.subscriptions.PagingSubscriptionResults;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.service.cmr.subscriptions.SubscriptionItemTypeEnum;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.alfresco.util.testing.category.DBTests;
|
||||||
|
|
||||||
@Category({OwnJVMTestsCategory.class, NeverRunsTests.class})
|
@Category({OwnJVMTestsCategory.class, DBTests.class})
|
||||||
public class SubscriptionDAOTest extends TestCase
|
public class SubscriptionDAOTest extends TestCase
|
||||||
{
|
{
|
||||||
private ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
private ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||||
private TransactionService transactionService;
|
private TransactionService transactionService;
|
||||||
private RetryingTransactionHelper txnHelper;
|
private RetryingTransactionHelper txnHelper;
|
||||||
private PersonService personService;
|
private PersonService personService;
|
||||||
|
|
||||||
private SubscriptionsDAO subscriptionsDAO;
|
private SubscriptionsDAO subscriptionsDAO;
|
||||||
|
|
||||||
protected NodeRef getUserNodeRef(final String userId)
|
protected NodeRef getUserNodeRef(final String userId)
|
||||||
{
|
{
|
||||||
final PersonService ps = personService;
|
final PersonService ps = personService;
|
||||||
|
|
||||||
return AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
|
return AuthenticationUtil.runAs(new RunAsWork<NodeRef>() {
|
||||||
{
|
@Override
|
||||||
@Override
|
public NodeRef doWork() throws Exception
|
||||||
public NodeRef doWork() throws Exception
|
{
|
||||||
{
|
return ps.getPerson(userId);
|
||||||
return ps.getPerson(userId);
|
}
|
||||||
}
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
}
|
||||||
}
|
|
||||||
|
protected void insert(final String userId, final NodeRef node) throws Exception
|
||||||
protected void insert(final String userId, final NodeRef node) throws Exception
|
{
|
||||||
{
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>() {
|
||||||
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
public Object execute() throws Throwable
|
||||||
{
|
{
|
||||||
public Object execute() throws Throwable
|
subscriptionsDAO.insertSubscription(userId, node);
|
||||||
{
|
return null;
|
||||||
subscriptionsDAO.insertSubscription(userId, node);
|
}
|
||||||
return null;
|
};
|
||||||
}
|
txnHelper.doInTransaction(callback, false, false);
|
||||||
};
|
}
|
||||||
txnHelper.doInTransaction(callback, false, false);
|
|
||||||
}
|
protected void delete(final String userId, final NodeRef node) throws Exception
|
||||||
|
{
|
||||||
protected void delete(final String userId, final NodeRef node) throws Exception
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>() {
|
||||||
{
|
public Object execute() throws Throwable
|
||||||
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
{
|
||||||
{
|
subscriptionsDAO.deleteSubscription(userId, node);
|
||||||
public Object execute() throws Throwable
|
return null;
|
||||||
{
|
}
|
||||||
subscriptionsDAO.deleteSubscription(userId, node);
|
};
|
||||||
return null;
|
txnHelper.doInTransaction(callback, false, false);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
txnHelper.doInTransaction(callback, false, false);
|
protected int count(final String userId) throws Exception
|
||||||
}
|
{
|
||||||
|
RetryingTransactionCallback<Integer> callback = new RetryingTransactionCallback<Integer>() {
|
||||||
protected int count(final String userId) throws Exception
|
public Integer execute() throws Throwable
|
||||||
{
|
{
|
||||||
RetryingTransactionCallback<Integer> callback = new RetryingTransactionCallback<Integer>()
|
return subscriptionsDAO.countSubscriptions(userId, SubscriptionItemTypeEnum.USER);
|
||||||
{
|
}
|
||||||
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
|
||||||
return txnHelper.doInTransaction(callback, false, false);
|
{
|
||||||
}
|
RetryingTransactionCallback<Boolean> callback = new RetryingTransactionCallback<Boolean>() {
|
||||||
|
public Boolean execute() throws Throwable
|
||||||
protected boolean hasSubscribed(final String userId, final NodeRef node) throws Exception
|
{
|
||||||
{
|
return subscriptionsDAO.hasSubscribed(userId, node);
|
||||||
RetryingTransactionCallback<Boolean> callback = new RetryingTransactionCallback<Boolean>()
|
}
|
||||||
{
|
};
|
||||||
public Boolean execute() throws Throwable
|
|
||||||
{
|
return txnHelper.doInTransaction(callback, false, false);
|
||||||
return subscriptionsDAO.hasSubscribed(userId, node);
|
}
|
||||||
}
|
|
||||||
};
|
protected PagingSubscriptionResults select(final String userId) throws Exception
|
||||||
|
{
|
||||||
return txnHelper.doInTransaction(callback, false, false);
|
RetryingTransactionCallback<PagingSubscriptionResults> callback = new RetryingTransactionCallback<PagingSubscriptionResults>() {
|
||||||
}
|
public PagingSubscriptionResults execute() throws Throwable
|
||||||
|
{
|
||||||
protected PagingSubscriptionResults select(final String userId) throws Exception
|
return subscriptionsDAO.selectSubscriptions(userId, SubscriptionItemTypeEnum.USER, new PagingRequest(
|
||||||
{
|
100000, null));
|
||||||
RetryingTransactionCallback<PagingSubscriptionResults> callback = new RetryingTransactionCallback<PagingSubscriptionResults>()
|
}
|
||||||
{
|
};
|
||||||
public PagingSubscriptionResults execute() throws Throwable
|
|
||||||
{
|
return txnHelper.doInTransaction(callback, false, false);
|
||||||
return subscriptionsDAO.selectSubscriptions(userId, SubscriptionItemTypeEnum.USER, new PagingRequest(
|
}
|
||||||
100000, null));
|
|
||||||
}
|
protected int countFollowers(final String userId) throws Exception
|
||||||
};
|
{
|
||||||
|
RetryingTransactionCallback<Integer> callback = new RetryingTransactionCallback<Integer>() {
|
||||||
return txnHelper.doInTransaction(callback, false, false);
|
public Integer execute() throws Throwable
|
||||||
}
|
{
|
||||||
|
return subscriptionsDAO.countFollowers(userId);
|
||||||
protected int countFollowers(final String userId) throws Exception
|
}
|
||||||
{
|
};
|
||||||
RetryingTransactionCallback<Integer> callback = new RetryingTransactionCallback<Integer>()
|
|
||||||
{
|
return txnHelper.doInTransaction(callback, false, false);
|
||||||
public Integer execute() throws Throwable
|
}
|
||||||
{
|
|
||||||
return subscriptionsDAO.countFollowers(userId);
|
protected PagingFollowingResults selectFollowing(final String userId) throws Exception
|
||||||
}
|
{
|
||||||
};
|
RetryingTransactionCallback<PagingFollowingResults> callback = new RetryingTransactionCallback<PagingFollowingResults>() {
|
||||||
|
public PagingFollowingResults execute() throws Throwable
|
||||||
return txnHelper.doInTransaction(callback, false, false);
|
{
|
||||||
}
|
return subscriptionsDAO.selectFollowing(userId, new PagingRequest(100000, null));
|
||||||
|
}
|
||||||
protected PagingFollowingResults selectFollowing(final String userId) throws Exception
|
};
|
||||||
{
|
|
||||||
RetryingTransactionCallback<PagingFollowingResults> callback = new RetryingTransactionCallback<PagingFollowingResults>()
|
return txnHelper.doInTransaction(callback, false, false);
|
||||||
{
|
}
|
||||||
public PagingFollowingResults execute() throws Throwable
|
|
||||||
{
|
protected PagingFollowingResults selectFollowers(final String userId) throws Exception
|
||||||
return subscriptionsDAO.selectFollowing(userId, new PagingRequest(100000, null));
|
{
|
||||||
}
|
RetryingTransactionCallback<PagingFollowingResults> callback = new RetryingTransactionCallback<PagingFollowingResults>() {
|
||||||
};
|
public PagingFollowingResults execute() throws Throwable
|
||||||
|
{
|
||||||
return txnHelper.doInTransaction(callback, false, false);
|
return subscriptionsDAO.selectFollowers(userId, new PagingRequest(100000, null));
|
||||||
}
|
}
|
||||||
|
};
|
||||||
protected PagingFollowingResults selectFollowers(final String userId) throws Exception
|
|
||||||
{
|
return txnHelper.doInTransaction(callback, false, false);
|
||||||
RetryingTransactionCallback<PagingFollowingResults> callback = new RetryingTransactionCallback<PagingFollowingResults>()
|
}
|
||||||
{
|
|
||||||
public PagingFollowingResults execute() throws Throwable
|
@Override
|
||||||
{
|
public void setUp() throws Exception
|
||||||
return subscriptionsDAO.selectFollowers(userId, new PagingRequest(100000, null));
|
{
|
||||||
}
|
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
};
|
transactionService = serviceRegistry.getTransactionService();
|
||||||
|
txnHelper = transactionService.getRetryingTransactionHelper();
|
||||||
return txnHelper.doInTransaction(callback, false, false);
|
|
||||||
}
|
personService = serviceRegistry.getPersonService();
|
||||||
|
|
||||||
@Override
|
subscriptionsDAO = (SubscriptionsDAO) ctx.getBean("subscriptionsDAO");
|
||||||
public void setUp() throws Exception
|
}
|
||||||
{
|
|
||||||
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
public void testInsertAndDelete() throws Exception
|
||||||
transactionService = serviceRegistry.getTransactionService();
|
{
|
||||||
txnHelper = transactionService.getRetryingTransactionHelper();
|
String userId = "admin";
|
||||||
|
String userId2 = "guest";
|
||||||
personService = serviceRegistry.getPersonService();
|
NodeRef nodeRef = getUserNodeRef(userId2);
|
||||||
|
|
||||||
subscriptionsDAO = (SubscriptionsDAO) ctx.getBean("subscriptionsDAO");
|
// check subscription first
|
||||||
}
|
if (hasSubscribed(userId, nodeRef))
|
||||||
|
{
|
||||||
public void testInsertAndDelete() throws Exception
|
delete(userId, nodeRef);
|
||||||
{
|
}
|
||||||
String userId = "admin";
|
boolean hasSubscribed = hasSubscribed(userId, nodeRef);
|
||||||
String userId2 = "guest";
|
assertFalse(hasSubscribed);
|
||||||
NodeRef nodeRef = getUserNodeRef(userId2);
|
|
||||||
|
// count subscriptions
|
||||||
// check subscription first
|
int count = count(userId);
|
||||||
if (hasSubscribed(userId, nodeRef))
|
assertTrue(count >= 0);
|
||||||
{
|
|
||||||
delete(userId, nodeRef);
|
// insert
|
||||||
}
|
insert(userId, nodeRef);
|
||||||
boolean hasSubscribed = hasSubscribed(userId, nodeRef);
|
insert(userId, nodeRef);
|
||||||
assertFalse(hasSubscribed);
|
assertEquals(count + 1, count(userId));
|
||||||
|
assertTrue(hasSubscribed(userId, nodeRef));
|
||||||
// count subscriptions
|
|
||||||
int count = count(userId);
|
// select
|
||||||
assertTrue(count >= 0);
|
PagingSubscriptionResults psr = select(userId);
|
||||||
|
assertNotNull(psr);
|
||||||
// insert
|
assertNotNull(psr.getPage());
|
||||||
insert(userId, nodeRef);
|
assertTrue(psr.getPage().contains(nodeRef));
|
||||||
insert(userId, nodeRef);
|
|
||||||
assertEquals(count + 1, count(userId));
|
PagingFollowingResults following = selectFollowing(userId);
|
||||||
assertTrue(hasSubscribed(userId, nodeRef));
|
assertNotNull(following);
|
||||||
|
assertNotNull(following.getPage());
|
||||||
// select
|
assertTrue(following.getPage().contains(userId2));
|
||||||
PagingSubscriptionResults psr = select(userId);
|
|
||||||
assertNotNull(psr);
|
assertEquals(psr.getPage().size(), following.getPage().size());
|
||||||
assertNotNull(psr.getPage());
|
|
||||||
assertTrue(psr.getPage().contains(nodeRef));
|
// count followers
|
||||||
|
int followerCount = countFollowers(userId2);
|
||||||
PagingFollowingResults following = selectFollowing(userId);
|
assertTrue(followerCount >= 0);
|
||||||
assertNotNull(following);
|
|
||||||
assertNotNull(following.getPage());
|
// select followers
|
||||||
assertTrue(following.getPage().contains(userId2));
|
PagingFollowingResults followers = selectFollowers(userId2);
|
||||||
|
assertNotNull(followers);
|
||||||
assertEquals(psr.getPage().size(), following.getPage().size());
|
assertNotNull(followers.getPage());
|
||||||
|
assertTrue(followers.getPage().contains(userId));
|
||||||
// count followers
|
|
||||||
int followerCount = countFollowers(userId2);
|
// delete
|
||||||
assertTrue(followerCount >= 0);
|
delete(userId, nodeRef);
|
||||||
|
assertEquals(count, count(userId));
|
||||||
// select followers
|
assertFalse(hasSubscribed(userId, nodeRef));
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user