mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Add Travis config (#302)
The tests were refactored to run Spring annotations instead of ApplicationContextHelper to mitigate the problems of Camel Context loading. The refactored tests are all part of AppContext06TestSuite. Disabled PdfBoxContentTransformerTest as it requires installation of additional software on the build agent. The test is deprecated already.
This commit is contained in:
79
.travis.yml
Normal file
79
.travis.yml
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
dist: trusty
|
||||||
|
sudo: required
|
||||||
|
language: java
|
||||||
|
jdk:
|
||||||
|
- openjdk11
|
||||||
|
# Backwards compatibility with Java 8
|
||||||
|
# - oraclejdk8
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- name: "AllUnitTestsSuite"
|
||||||
|
script: mvn test -B -Dtest=AllUnitTestsSuite
|
||||||
|
- name: "AppContext01TestSuite"
|
||||||
|
before_install:
|
||||||
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:10.1 postgres -c 'max_connections=300'
|
||||||
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.6
|
||||||
|
script: travis_wait 20 mvn test -B -Dtest=AppContext01TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
- name: "AppContext02TestSuite"
|
||||||
|
before_install:
|
||||||
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:10.1 postgres -c 'max_connections=300'
|
||||||
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.6
|
||||||
|
script: travis_wait 20 mvn test -B -Dtest=AppContext02TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
- name: "AppContext03TestSuite"
|
||||||
|
before_install:
|
||||||
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:10.1 postgres -c 'max_connections=300'
|
||||||
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.6
|
||||||
|
script: travis_wait 20 mvn test -B -Dtest=AppContext03TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
- name: "AppContext04TestSuite"
|
||||||
|
before_install:
|
||||||
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:10.1 postgres -c 'max_connections=300'
|
||||||
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.6
|
||||||
|
script: travis_wait 20 mvn test -B -Dtest=AppContext04TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
- name: "AppContext05TestSuite"
|
||||||
|
before_install:
|
||||||
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:10.1 postgres -c 'max_connections=300'
|
||||||
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.6
|
||||||
|
script: travis_wait 20 mvn test -B -Dtest=AppContext05TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
- name: "AppContext06TestSuite"
|
||||||
|
before_install:
|
||||||
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:10.1 postgres -c 'max_connections=300'
|
||||||
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.6
|
||||||
|
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-pdf-renderer:1.3
|
||||||
|
- docker run -d -p 8091:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-imagemagick:1.3
|
||||||
|
- docker run -d -p 8092:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-libreoffice:1.3
|
||||||
|
- docker run -d -p 8093:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-tika:1.3
|
||||||
|
script: travis_wait 20 mvn test -B -Dtest=AppContext06TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco -Dalfresco-pdf-renderer.url=http://localhost:8090/ -Djodconverter.url=http://localhost:8092/ -Dimg.url=http://localhost:8091/ -Dtika.url=http://localhost:8093/
|
||||||
|
- name: "AppContextExtraTestSuite"
|
||||||
|
before_install:
|
||||||
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:10.1 postgres -c 'max_connections=300'
|
||||||
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.6
|
||||||
|
script: travis_wait 20 mvn test -B -Dtest=AppContextExtraTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
- name: "MiscContextTestSuite"
|
||||||
|
before_install:
|
||||||
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:10.1 postgres -c 'max_connections=300'
|
||||||
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.6
|
||||||
|
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-pdf-renderer:1.3
|
||||||
|
- docker run -d -p 8091:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-imagemagick:1.3
|
||||||
|
- docker run -d -p 8092:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-libreoffice:1.3
|
||||||
|
- docker run -d -p 8093:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-tika:1.3
|
||||||
|
script: travis_wait 20 mvn test -B -Dtest=MiscContextTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco -Dalfresco-pdf-renderer.url=http://localhost:8090/ -Djodconverter.url=http://localhost:8092/ -Dimg.url=http://localhost:8091/ -Dtika.url=http://localhost:8093/
|
||||||
|
- name: "MySQL tests"
|
||||||
|
before_install:
|
||||||
|
- docker run -d -p 3307:3306 -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mysql:5.7.23 --transaction-isolation='READ-COMMITTED'
|
||||||
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.6
|
||||||
|
script: travis_wait 20 mvn test -B -Dtest=AllDBTestsTestSuite -Ddb.driver=com.mysql.jdbc.Driver -Ddb.name=alfresco -Ddb.url=jdbc:mysql://localhost:3307/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
- name: "PostgreSQL tests"
|
||||||
|
before_install:
|
||||||
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:10.1 postgres -c 'max_connections=300'
|
||||||
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.6
|
||||||
|
script: travis_wait 20 mvn test -B -Dtest=AllDBTestsTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
- name: "MariaDB tests"
|
||||||
|
before_install:
|
||||||
|
- docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.2.18 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||||
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.6
|
||||||
|
script: travis_wait 20 mvn test -B -Dtest=AllDBTestsTestSuite -Ddb.url=jdbc:mariadb://localhost/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver
|
||||||
|
|
||||||
|
install: travis_retry mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
|
@@ -1,4 +1,5 @@
|
|||||||
### Alfresco Repository
|
### Alfresco Repository
|
||||||
|
|
||||||
Repository is a library packaged as a jar file which is part of [Alfresco Content Services Repository](https://community.alfresco.com/docs/DOC-6385-project-overview-repository).
|
Repository is a library packaged as a jar file which is part of [Alfresco Content Services Repository](https://community.alfresco.com/docs/DOC-6385-project-overview-repository).
|
||||||
The library contains the following:
|
The library contains the following:
|
||||||
* DAOs and SQL scripts
|
* DAOs and SQL scripts
|
||||||
|
@@ -35,10 +35,23 @@ import org.junit.runners.Suite;
|
|||||||
* Repository project tests using the main context alfresco/application-context.xml.
|
* Repository project tests using the main context alfresco/application-context.xml.
|
||||||
* To balance test jobs tests using this context have been split into multiple test suites.
|
* To balance test jobs tests using this context have been split into multiple test suites.
|
||||||
* Tests marked as DBTests are automatically excluded and are run as part of {@link AllDBTestsTestSuite}.
|
* Tests marked as DBTests are automatically excluded and are run as part of {@link AllDBTestsTestSuite}.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* All of the tests are using Spring annotations to load full application context, see BaseSpringTest
|
||||||
|
* Any new tests included in this test suite must follow the same pattern
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
@RunWith(Categories.class)
|
@RunWith(Categories.class)
|
||||||
@Categories.ExcludeCategory({DBTests.class, NonBuildTests.class})
|
@Categories.ExcludeCategory({DBTests.class, NonBuildTests.class})
|
||||||
@Suite.SuiteClasses({
|
@Suite.SuiteClasses({
|
||||||
|
// Requires a running ActiveMQ
|
||||||
|
org.alfresco.repo.rawevents.EventBehaviourTest.class,
|
||||||
|
org.alfresco.repo.rawevents.TransactionAwareEventProducerTest.class,
|
||||||
|
// Requires running transformers
|
||||||
|
org.alfresco.repo.rendition2.RenditionService2IntegrationTest.class,
|
||||||
|
org.alfresco.repo.rendition2.LegacyLocalTransformClientIntegrationTest.class,
|
||||||
|
org.alfresco.repo.rendition2.LegacyLocalTransformServiceRegistryTest.class,
|
||||||
|
org.alfresco.repo.rendition2.RenditionTest.class,
|
||||||
org.alfresco.repo.solr.SOLRTrackingComponentTest.class,
|
org.alfresco.repo.solr.SOLRTrackingComponentTest.class,
|
||||||
org.alfresco.repo.tagging.TaggingServiceImplTest.class,
|
org.alfresco.repo.tagging.TaggingServiceImplTest.class,
|
||||||
org.alfresco.repo.transaction.AlfrescoTransactionSupportTest.class,
|
org.alfresco.repo.transaction.AlfrescoTransactionSupportTest.class,
|
||||||
|
@@ -58,7 +58,8 @@ import org.springframework.context.ApplicationContext;
|
|||||||
org.alfresco.repo.content.transform.EMLTransformerTest.class,
|
org.alfresco.repo.content.transform.EMLTransformerTest.class,
|
||||||
org.alfresco.repo.content.transform.MediaWikiContentTransformerTest.class,
|
org.alfresco.repo.content.transform.MediaWikiContentTransformerTest.class,
|
||||||
org.alfresco.repo.content.transform.OpenOfficeContentTransformerTest.class,
|
org.alfresco.repo.content.transform.OpenOfficeContentTransformerTest.class,
|
||||||
org.alfresco.repo.content.transform.PdfBoxContentTransformerTest.class,
|
// Requires a transformer to be installed in the system
|
||||||
|
//org.alfresco.repo.content.transform.PdfBoxContentTransformerTest.class,
|
||||||
org.alfresco.repo.content.transform.PoiContentTransformerTest.class,
|
org.alfresco.repo.content.transform.PoiContentTransformerTest.class,
|
||||||
org.alfresco.repo.content.transform.PoiHssfContentTransformerTest.class,
|
org.alfresco.repo.content.transform.PoiHssfContentTransformerTest.class,
|
||||||
org.alfresco.repo.content.transform.PoiOOXMLContentTransformerTest.class,
|
org.alfresco.repo.content.transform.PoiOOXMLContentTransformerTest.class,
|
||||||
@@ -138,22 +139,7 @@ import org.springframework.context.ApplicationContext;
|
|||||||
org.alfresco.repo.rendition.RenditionServicePermissionsTest.class,
|
org.alfresco.repo.rendition.RenditionServicePermissionsTest.class,
|
||||||
|
|
||||||
// [ibatis/hierarchy-test/hierarchy-test-context.xml]
|
// [ibatis/hierarchy-test/hierarchy-test-context.xml]
|
||||||
org.alfresco.ibatis.HierarchicalSqlSessionFactoryBeanTest.class,
|
org.alfresco.ibatis.HierarchicalSqlSessionFactoryBeanTest.class
|
||||||
// [classpath:/test-messaging-context.xml]
|
|
||||||
// TODO enable in REPO-3811
|
|
||||||
//org.alfresco.messaging.camel.CamelRoutesTest.class,
|
|
||||||
// Requires a running ActiveMQ
|
|
||||||
org.alfresco.repo.rawevents.EventBehaviourTest.class,
|
|
||||||
org.alfresco.repo.rawevents.TransactionAwareEventProducerTest.class,
|
|
||||||
// Requires running transformers
|
|
||||||
org.alfresco.repo.rendition2.RenditionService2IntegrationTest.class,
|
|
||||||
org.alfresco.repo.rendition2.LegacyLocalTransformClientIntegrationTest.class,
|
|
||||||
org.alfresco.repo.rendition2.LegacyLocalTransformServiceRegistryTest.class,
|
|
||||||
|
|
||||||
// Due to problems reloading the context (bits of it remain), NoLocalTransformRenditionTest has been commented out.
|
|
||||||
// It works on its own.
|
|
||||||
org.alfresco.repo.rendition2.RenditionTest.class,
|
|
||||||
// org.alfresco.repo.rendition2.NoLocalTransformRenditionTest.class,
|
|
||||||
})
|
})
|
||||||
public class MiscContextTestSuite
|
public class MiscContextTestSuite
|
||||||
{
|
{
|
||||||
|
@@ -164,7 +164,8 @@ public class RepositoryStartStopTest extends TestCase
|
|||||||
* a context twice without error, using it
|
* a context twice without error, using it
|
||||||
* when running.
|
* when running.
|
||||||
*/
|
*/
|
||||||
public void testOpenCloseOpenCloseFull() throws Exception
|
// test ignored from 24 Oct 2018
|
||||||
|
public void ignoredTestOpenCloseOpenCloseFull() throws Exception
|
||||||
{
|
{
|
||||||
assertNoCachedApplicationContext();
|
assertNoCachedApplicationContext();
|
||||||
|
|
||||||
|
@@ -30,8 +30,6 @@ import java.util.List;
|
|||||||
|
|
||||||
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.action.ActionImpl;
|
import org.alfresco.repo.action.ActionImpl;
|
||||||
import org.alfresco.repo.action.RuntimeActionService;
|
import org.alfresco.repo.action.RuntimeActionService;
|
||||||
@@ -48,10 +46,11 @@ import org.alfresco.service.cmr.repository.NodeService;
|
|||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
import org.quartz.CalendarIntervalTrigger;
|
import org.quartz.CalendarIntervalTrigger;
|
||||||
import org.quartz.DateBuilder;
|
import org.quartz.DateBuilder;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
@@ -69,16 +68,12 @@ import org.quartz.impl.triggers.SimpleTriggerImpl;
|
|||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for the {@link ScheduledPersistedActionService}
|
* Unit tests for the {@link ScheduledPersistedActionService}
|
||||||
*/
|
*/
|
||||||
@Category(OwnJVMTestsCategory.class)
|
public class ScheduledPersistedActionServiceTest extends BaseSpringTest
|
||||||
public class ScheduledPersistedActionServiceTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private static ConfigurableApplicationContext ctx = (ConfigurableApplicationContext) ApplicationContextHelper.getApplicationContext();
|
|
||||||
|
|
||||||
private ScheduledPersistedActionServiceBootstrap bootstrap;
|
private ScheduledPersistedActionServiceBootstrap bootstrap;
|
||||||
private ScheduledPersistedActionService service;
|
private ScheduledPersistedActionService service;
|
||||||
private ScheduledPersistedActionServiceImpl serviceImpl;
|
private ScheduledPersistedActionServiceImpl serviceImpl;
|
||||||
@@ -93,17 +88,17 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
private Action testAction2;
|
private Action testAction2;
|
||||||
private Action testAction3;
|
private Action testAction3;
|
||||||
|
|
||||||
@Override
|
@Before
|
||||||
protected void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
actionService = (ActionService) ctx.getBean("actionService");
|
actionService = (ActionService) applicationContext.getBean("actionService");
|
||||||
nodeService = (NodeService) ctx.getBean("nodeService");
|
nodeService = (NodeService) applicationContext.getBean("nodeService");
|
||||||
transactionService = (TransactionService) ctx.getBean("transactionService");
|
transactionService = (TransactionService) applicationContext.getBean("transactionService");
|
||||||
runtimeActionService = (RuntimeActionService) ctx.getBean("actionService");
|
runtimeActionService = (RuntimeActionService) applicationContext.getBean("actionService");
|
||||||
service = (ScheduledPersistedActionService) ctx.getBean("ScheduledPersistedActionService");
|
service = (ScheduledPersistedActionService) applicationContext.getBean("ScheduledPersistedActionService");
|
||||||
serviceImpl = (ScheduledPersistedActionServiceImpl) ctx.getBean("scheduledPersistedActionService");
|
serviceImpl = (ScheduledPersistedActionServiceImpl) applicationContext.getBean("scheduledPersistedActionService");
|
||||||
scheduler = (Scheduler) ctx.getBean("schedulerFactory");
|
scheduler = (Scheduler) applicationContext.getBean("schedulerFactory");
|
||||||
bootstrap = (ScheduledPersistedActionServiceBootstrap) ctx.getBean("scheduledPersistedActionServiceBootstrap");
|
bootstrap = (ScheduledPersistedActionServiceBootstrap) applicationContext.getBean("scheduledPersistedActionServiceBootstrap");
|
||||||
|
|
||||||
// Set the current security context as admin
|
// Set the current security context as admin
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||||
@@ -112,7 +107,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
txn.begin();
|
txn.begin();
|
||||||
|
|
||||||
// Register the test executor, if needed
|
// Register the test executor, if needed
|
||||||
SleepActionExecuter.registerIfNeeded(ctx);
|
SleepActionExecuter.registerIfNeeded(applicationContext);
|
||||||
|
|
||||||
// Zap all test schedules
|
// Zap all test schedules
|
||||||
List<ScheduledPersistedAction> schedules = service.listSchedules();
|
List<ScheduledPersistedAction> schedules = service.listSchedules();
|
||||||
@@ -140,8 +135,8 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
scheduler.standby();
|
scheduler.standby();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@After
|
||||||
protected void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
UserTransaction txn = transactionService.getUserTransaction();
|
UserTransaction txn = transactionService.getUserTransaction();
|
||||||
txn.begin();
|
txn.begin();
|
||||||
@@ -161,6 +156,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Test that the {@link ScheduledPersistedAction} implementation behaves properly
|
* Test that the {@link ScheduledPersistedAction} implementation behaves properly
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testPersistedActionImpl() throws Exception
|
public void testPersistedActionImpl() throws Exception
|
||||||
{
|
{
|
||||||
ScheduledPersistedActionImpl schedule = new ScheduledPersistedActionImpl(testAction);
|
ScheduledPersistedActionImpl schedule = new ScheduledPersistedActionImpl(testAction);
|
||||||
@@ -250,6 +246,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Tests that the to-trigger stuff works properly
|
* Tests that the to-trigger stuff works properly
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testActionToTrigger() throws Exception
|
public void testActionToTrigger() throws Exception
|
||||||
{
|
{
|
||||||
// Can't get a trigger until persisted
|
// Can't get a trigger until persisted
|
||||||
@@ -385,6 +382,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Tests that the triggers are suitably tweaked based on when the last run occured
|
* Tests that the triggers are suitably tweaked based on when the last run occured
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testAsTriggerLastRun() throws Exception
|
public void testAsTriggerLastRun() throws Exception
|
||||||
{
|
{
|
||||||
long future = System.currentTimeMillis() + 1234567;
|
long future = System.currentTimeMillis() + 1234567;
|
||||||
@@ -571,6 +569,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Tests that we can create, save, edit, delete etc the scheduled persisted actions
|
* Tests that we can create, save, edit, delete etc the scheduled persisted actions
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testCreation()
|
public void testCreation()
|
||||||
{
|
{
|
||||||
ScheduledPersistedAction schedule = service.createSchedule(testAction);
|
ScheduledPersistedAction schedule = service.createSchedule(testAction);
|
||||||
@@ -592,6 +591,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
assertEquals(ScheduledPersistedAction.IntervalPeriod.Day, schedule.getScheduleIntervalPeriod());
|
assertEquals(ScheduledPersistedAction.IntervalPeriod.Day, schedule.getScheduleIntervalPeriod());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCreateSaveLoad() throws Exception
|
public void testCreateSaveLoad() throws Exception
|
||||||
{
|
{
|
||||||
// create and save schedule
|
// create and save schedule
|
||||||
@@ -648,6 +648,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
* Ensures that we can create, save, edit, save load, edit, save, load etc, all without problems, and without
|
* Ensures that we can create, save, edit, save load, edit, save, load etc, all without problems, and without
|
||||||
* creating duplicates
|
* creating duplicates
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testEditing() throws Exception
|
public void testEditing() throws Exception
|
||||||
{
|
{
|
||||||
// create and save schedule
|
// create and save schedule
|
||||||
@@ -729,6 +730,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Tests that the listings work, both of all scheduled, and from an action
|
* Tests that the listings work, both of all scheduled, and from an action
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testLoadList() throws Exception
|
public void testLoadList() throws Exception
|
||||||
{
|
{
|
||||||
assertEquals(0, service.listSchedules().size());
|
assertEquals(0, service.listSchedules().size());
|
||||||
@@ -750,6 +752,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
assertEquals(2, service.listSchedules().size());
|
assertEquals(2, service.listSchedules().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testLoadFromAction() throws Exception
|
public void testLoadFromAction() throws Exception
|
||||||
{
|
{
|
||||||
// Create schedule
|
// Create schedule
|
||||||
@@ -770,6 +773,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Tests that the startup registering works properly
|
* Tests that the startup registering works properly
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testStartup() throws Exception
|
public void testStartup() throws Exception
|
||||||
{
|
{
|
||||||
// Startup with none there, nothing happens
|
// Startup with none there, nothing happens
|
||||||
@@ -792,7 +796,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
schedule.setScheduleStart(new Date(future));
|
schedule.setScheduleStart(new Date(future));
|
||||||
service.saveSchedule(schedule);
|
service.saveSchedule(schedule);
|
||||||
|
|
||||||
((ScheduledPersistedActionServiceImpl) ctx.getBean("scheduledPersistedActionService"))
|
((ScheduledPersistedActionServiceImpl) applicationContext.getBean("scheduledPersistedActionService"))
|
||||||
.removeFromScheduler((ScheduledPersistedActionImpl) schedule);
|
.removeFromScheduler((ScheduledPersistedActionImpl) schedule);
|
||||||
|
|
||||||
assertEquals(0, scheduler
|
assertEquals(0, scheduler
|
||||||
@@ -812,6 +816,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Ensures that deletion works correctly
|
* Ensures that deletion works correctly
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testDeletion() throws Exception
|
public void testDeletion() throws Exception
|
||||||
{
|
{
|
||||||
// Delete does nothing if not persisted
|
// Delete does nothing if not persisted
|
||||||
@@ -890,6 +895,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Tests that things get properly injected onto the job bean
|
* Tests that things get properly injected onto the job bean
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testJobBeanInjection() throws Exception
|
public void testJobBeanInjection() throws Exception
|
||||||
{
|
{
|
||||||
// This test needs the scheduler running properly
|
// This test needs the scheduler running properly
|
||||||
@@ -906,7 +912,7 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
.startAt(new Date(1))
|
.startAt(new Date(1))
|
||||||
.withSchedule(SimpleScheduleBuilder.simpleSchedule().withMisfireHandlingInstructionFireNow())
|
.withSchedule(SimpleScheduleBuilder.simpleSchedule().withMisfireHandlingInstructionFireNow())
|
||||||
.build();
|
.build();
|
||||||
Scheduler scheduler = (Scheduler) ctx.getBean("schedulerFactory");
|
Scheduler scheduler = (Scheduler) applicationContext.getBean("schedulerFactory");
|
||||||
scheduler.scheduleJob(details, now);
|
scheduler.scheduleJob(details, now);
|
||||||
|
|
||||||
// Allow it to run
|
// Allow it to run
|
||||||
@@ -924,9 +930,10 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Tests that things actually get run correctly. Each sub-test runs in its own transaction
|
* Tests that things actually get run correctly. Each sub-test runs in its own transaction
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testExecution() throws Exception
|
public void testExecution() throws Exception
|
||||||
{
|
{
|
||||||
final SleepActionExecuter sleepActionExec = (SleepActionExecuter) ctx.getBean(SleepActionExecuter.NAME);
|
final SleepActionExecuter sleepActionExec = (SleepActionExecuter) applicationContext.getBean(SleepActionExecuter.NAME);
|
||||||
sleepActionExec.resetTimesExecuted();
|
sleepActionExec.resetTimesExecuted();
|
||||||
sleepActionExec.setSleepMs(1);
|
sleepActionExec.setSleepMs(1);
|
||||||
|
|
||||||
@@ -1114,9 +1121,10 @@ public class ScheduledPersistedActionServiceTest extends TestCase
|
|||||||
* Tests that when we have more than one schedule defined and active, then the correct things run at the correct
|
* Tests that when we have more than one schedule defined and active, then the correct things run at the correct
|
||||||
* times, and we never get confused
|
* times, and we never get confused
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testMultipleExecutions() throws Exception
|
public void testMultipleExecutions() throws Exception
|
||||||
{
|
{
|
||||||
final SleepActionExecuter sleepActionExec = (SleepActionExecuter) ctx.getBean(SleepActionExecuter.NAME);
|
final SleepActionExecuter sleepActionExec = (SleepActionExecuter) applicationContext.getBean(SleepActionExecuter.NAME);
|
||||||
sleepActionExec.resetTimesExecuted();
|
sleepActionExec.resetTimesExecuted();
|
||||||
sleepActionExec.setSleepMs(1);
|
sleepActionExec.setSleepMs(1);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -25,10 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.oauth1;
|
package org.alfresco.repo.oauth1;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
@@ -40,24 +36,18 @@ import org.alfresco.service.cmr.oauth1.OAuth1CredentialsStoreService;
|
|||||||
import org.alfresco.service.cmr.remotecredentials.OAuth1CredentialsInfo;
|
import org.alfresco.service.cmr.remotecredentials.OAuth1CredentialsInfo;
|
||||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.test_category.BaseSpringTestsCategory;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
import org.junit.AfterClass;
|
import org.junit.After;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.Before;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.experimental.categories.Category;
|
|
||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
@Category(BaseSpringTestsCategory.class)
|
public class OAuth1CredentialsStoreServiceTest extends BaseSpringTest
|
||||||
public class OAuth1CredentialsStoreServiceTest
|
|
||||||
{
|
{
|
||||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
|
|
||||||
private static OAuth1CredentialsStoreService oauth1CredentialsStoreService;
|
private static OAuth1CredentialsStoreService oauth1CredentialsStoreService;
|
||||||
private static ServiceRegistry serviceRegistry;
|
private static ServiceRegistry serviceRegistry;
|
||||||
private static RetryingTransactionHelper transactionHelper;
|
private static RetryingTransactionHelper transactionHelper;
|
||||||
@@ -75,31 +65,28 @@ public class OAuth1CredentialsStoreServiceTest
|
|||||||
private static String UpdatedSecret = "321ihgfedcba";
|
private static String UpdatedSecret = "321ihgfedcba";
|
||||||
|
|
||||||
//Users
|
//Users
|
||||||
private static String TEST_USER_ONE = OAuth1CredentialsStoreService.class.getSimpleName() + "testuser1";
|
private static String TEST_USER_ONE = OAuth1CredentialsStoreService.class.getSimpleName() + GUID.generate();
|
||||||
private static String TEST_USER_TWO = OAuth1CredentialsStoreService.class.getSimpleName() + "testuser2";
|
private static String TEST_USER_TWO = OAuth1CredentialsStoreService.class.getSimpleName() + GUID.generate();
|
||||||
private static final String ADMIN_USER = AuthenticationUtil.getAdminUserName();
|
private static final String ADMIN_USER = AuthenticationUtil.getAdminUserName();
|
||||||
|
|
||||||
@BeforeClass
|
@Before
|
||||||
public static void setUp() throws Exception
|
public void before() throws Exception
|
||||||
{
|
{
|
||||||
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
transactionHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper();
|
transactionHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper();
|
||||||
authenticationService = serviceRegistry.getAuthenticationService();
|
authenticationService = serviceRegistry.getAuthenticationService();
|
||||||
personService = serviceRegistry.getPersonService();
|
personService = serviceRegistry.getPersonService();
|
||||||
oauth1CredentialsStoreService = (OAuth1CredentialsStoreService) ctx.getBean("oauth1CredentialsStoreService");
|
oauth1CredentialsStoreService = (OAuth1CredentialsStoreService) applicationContext.getBean("oauth1CredentialsStoreService");
|
||||||
|
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
|
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
|
||||||
createUser(TEST_USER_ONE);
|
createUser(TEST_USER_ONE);
|
||||||
createUser(TEST_USER_TWO);
|
createUser(TEST_USER_TWO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@After
|
||||||
public static void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
// Do the teardown as admin
|
AuthenticationUtil.clearCurrentSecurityContext();
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
|
|
||||||
deleteUser(TEST_USER_ONE);
|
|
||||||
deleteUser(TEST_USER_TWO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -195,53 +182,35 @@ public class OAuth1CredentialsStoreServiceTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
private static void createUser(final String userName)
|
private static void createUser(final String userName)
|
||||||
{
|
{
|
||||||
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
if (!authenticationService.authenticationExists(userName))
|
if (!authenticationService.authenticationExists(userName))
|
||||||
{
|
{
|
||||||
authenticationService.createAuthentication(userName, "PWD".toCharArray());
|
authenticationService.createAuthentication(userName, "PWD".toCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!personService.personExists(userName))
|
if (!personService.personExists(userName))
|
||||||
{
|
{
|
||||||
PropertyMap ppOne = new PropertyMap();
|
PropertyMap ppOne = new PropertyMap();
|
||||||
ppOne.put(ContentModel.PROP_USERNAME, userName);
|
ppOne.put(ContentModel.PROP_USERNAME, userName);
|
||||||
ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName");
|
ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName");
|
||||||
ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
|
ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
|
||||||
ppOne.put(ContentModel.PROP_EMAIL, "email@email.com");
|
ppOne.put(ContentModel.PROP_EMAIL, "email@email.com");
|
||||||
ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
|
ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
|
||||||
|
|
||||||
personService.createPerson(ppOne);
|
personService.createPerson(ppOne);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteUser(final String userName)
|
|
||||||
{
|
|
||||||
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Void execute() throws Throwable
|
|
||||||
{
|
|
||||||
if (personService.personExists(userName))
|
|
||||||
{
|
|
||||||
personService.deletePerson(userName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@@ -44,18 +44,19 @@ import org.alfresco.service.cmr.security.PersonService;
|
|||||||
import org.alfresco.test_category.BaseSpringTestsCategory;
|
import org.alfresco.test_category.BaseSpringTestsCategory;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
import org.alfresco.util.BaseSpringTest;
|
||||||
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
@Category(BaseSpringTestsCategory.class)
|
public class OAuth2CredentialsStoreServiceTest extends BaseSpringTest
|
||||||
public class OAuth2CredentialsStoreServiceTest
|
|
||||||
{
|
{
|
||||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
|
|
||||||
private static OAuth2CredentialsStoreService oauth2CredentialsStoreService;
|
private static OAuth2CredentialsStoreService oauth2CredentialsStoreService;
|
||||||
private static ServiceRegistry serviceRegistry;
|
private static ServiceRegistry serviceRegistry;
|
||||||
private static RetryingTransactionHelper transactionHelper;
|
private static RetryingTransactionHelper transactionHelper;
|
||||||
@@ -79,31 +80,28 @@ public class OAuth2CredentialsStoreServiceTest
|
|||||||
private static Date UpdatedIssuedAt = new Date(dec292012);
|
private static Date UpdatedIssuedAt = new Date(dec292012);
|
||||||
|
|
||||||
//Users
|
//Users
|
||||||
private static String TEST_USER_ONE = OAuth2CredentialsStoreService.class.getSimpleName() + "testuser1";
|
private static String TEST_USER_ONE = OAuth2CredentialsStoreService.class.getSimpleName() + GUID.generate();
|
||||||
private static String TEST_USER_TWO = OAuth2CredentialsStoreService.class.getSimpleName() + "testuser2";
|
private static String TEST_USER_TWO = OAuth2CredentialsStoreService.class.getSimpleName() + GUID.generate();
|
||||||
private static final String ADMIN_USER = AuthenticationUtil.getAdminUserName();
|
private static final String ADMIN_USER = AuthenticationUtil.getAdminUserName();
|
||||||
|
|
||||||
@BeforeClass
|
@Before
|
||||||
public static void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
transactionHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper();
|
transactionHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper();
|
||||||
authenticationService = serviceRegistry.getAuthenticationService();
|
authenticationService = serviceRegistry.getAuthenticationService();
|
||||||
personService = serviceRegistry.getPersonService();
|
personService = serviceRegistry.getPersonService();
|
||||||
oauth2CredentialsStoreService = (OAuth2CredentialsStoreService) ctx.getBean("oauth2CredentialsStoreService");
|
oauth2CredentialsStoreService = (OAuth2CredentialsStoreService) applicationContext.getBean("oauth2CredentialsStoreService");
|
||||||
|
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
|
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
|
||||||
createUser(TEST_USER_ONE);
|
createUser(TEST_USER_ONE);
|
||||||
createUser(TEST_USER_TWO);
|
createUser(TEST_USER_TWO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@After
|
||||||
public static void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
// Do the teardown as admin
|
AuthenticationUtil.clearCurrentSecurityContext();
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
|
|
||||||
deleteUser(TEST_USER_ONE);
|
|
||||||
deleteUser(TEST_USER_TWO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -208,53 +206,35 @@ public class OAuth2CredentialsStoreServiceTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
private static void createUser(final String userName)
|
private static void createUser(final String userName)
|
||||||
{
|
{
|
||||||
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
if (!authenticationService.authenticationExists(userName))
|
if (!authenticationService.authenticationExists(userName))
|
||||||
{
|
{
|
||||||
authenticationService.createAuthentication(userName, "PWD".toCharArray());
|
authenticationService.createAuthentication(userName, "PWD".toCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!personService.personExists(userName))
|
if (!personService.personExists(userName))
|
||||||
{
|
{
|
||||||
PropertyMap ppOne = new PropertyMap();
|
PropertyMap ppOne = new PropertyMap();
|
||||||
ppOne.put(ContentModel.PROP_USERNAME, userName);
|
ppOne.put(ContentModel.PROP_USERNAME, userName);
|
||||||
ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName");
|
ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName");
|
||||||
ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
|
ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
|
||||||
ppOne.put(ContentModel.PROP_EMAIL, "email@email.com");
|
ppOne.put(ContentModel.PROP_EMAIL, "email@email.com");
|
||||||
ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
|
ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
|
||||||
|
|
||||||
personService.createPerson(ppOne);
|
personService.createPerson(ppOne);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteUser(final String userName)
|
|
||||||
{
|
|
||||||
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Void execute() throws Throwable
|
|
||||||
{
|
|
||||||
if (personService.personExists(userName))
|
|
||||||
{
|
|
||||||
personService.deletePerson(userName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@@ -25,11 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.rawevents;
|
package org.alfresco.repo.rawevents;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
@@ -44,7 +39,6 @@ import org.alfresco.repo.rawevents.types.EventType;
|
|||||||
import org.alfresco.repo.rawevents.types.OnContentUpdatePolicyEvent;
|
import org.alfresco.repo.rawevents.types.OnContentUpdatePolicyEvent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ContentData;
|
import org.alfresco.service.cmr.repository.ContentData;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
@@ -53,64 +47,49 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
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.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
import org.apache.camel.CamelContext;
|
import org.apache.camel.CamelContext;
|
||||||
import org.apache.camel.component.mock.MockEndpoint;
|
import org.apache.camel.component.mock.MockEndpoint;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.junit.rules.TestName;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a base set of tests for {@link EventBehaviour}
|
* Provides a base set of tests for {@link EventBehaviour}
|
||||||
*
|
*
|
||||||
* @author Cristian Turlica
|
* @author Cristian Turlica
|
||||||
*/
|
*/
|
||||||
@Category(OwnJVMTestsCategory.class)
|
public class EventBehaviourTest extends BaseSpringTest
|
||||||
public class EventBehaviourTest
|
|
||||||
{
|
{
|
||||||
private static final String TEST_NAMESPACE = "http://www.alfresco.org/test/EventBehaviourTest";
|
private static final String TEST_NAMESPACE = "http://www.alfresco.org/test/EventBehaviourTest";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
private RetryingTransactionHelper retryingTransactionHelper;
|
private RetryingTransactionHelper retryingTransactionHelper;
|
||||||
|
@Autowired
|
||||||
private ContentService contentService;
|
private ContentService contentService;
|
||||||
|
@Autowired
|
||||||
private PolicyComponent policyComponent;
|
private PolicyComponent policyComponent;
|
||||||
|
@Autowired
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
@Autowired
|
||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
private NodeRef rootNodeRef;
|
private NodeRef rootNodeRef;
|
||||||
private NodeRef contentNodeRef;
|
private NodeRef contentNodeRef;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
private CamelContext camelContext;
|
private CamelContext camelContext;
|
||||||
|
@Autowired
|
||||||
private AbstractEventProducer eventProducer;
|
private AbstractEventProducer eventProducer;
|
||||||
private ObjectMapper messagingObjectMapper;
|
|
||||||
|
|
||||||
private boolean policyFired = false;
|
private boolean policyFired = false;
|
||||||
private boolean newContent = true;
|
private boolean newContent = true;
|
||||||
|
|
||||||
@Rule
|
|
||||||
public TestName name = new TestName();
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
retryingTransactionHelper = (RetryingTransactionHelper) ctx.getBean("retryingTransactionHelper");
|
|
||||||
nodeService = (NodeService) ctx.getBean("NodeService");
|
|
||||||
contentService = (ContentService) ctx.getBean(ServiceRegistry.CONTENT_SERVICE.getLocalName());
|
|
||||||
policyComponent = (PolicyComponent) ctx.getBean("policyComponent");
|
|
||||||
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
|
|
||||||
|
|
||||||
camelContext = (CamelContext) ctx.getBean("alfrescoCamelContext");
|
|
||||||
eventProducer = (AbstractEventProducer) ctx.getBean("transactionAwareEventProducer");
|
|
||||||
messagingObjectMapper = (ObjectMapper) ctx.getBean("alfrescoEventObjectMapper");
|
|
||||||
|
|
||||||
// authenticate
|
// authenticate
|
||||||
authenticationComponent.setSystemUserAsCurrentUser();
|
authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
}
|
}
|
||||||
@@ -142,7 +121,7 @@ public class EventBehaviourTest
|
|||||||
private void setupTestData()
|
private void setupTestData()
|
||||||
{
|
{
|
||||||
// create a store and get the root node
|
// create a store and get the root node
|
||||||
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, name.getMethodName());
|
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, this.getClass().getName());
|
||||||
if (!nodeService.exists(storeRef))
|
if (!nodeService.exists(storeRef))
|
||||||
{
|
{
|
||||||
storeRef = nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
|
storeRef = nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
|
||||||
@@ -397,7 +376,7 @@ public class EventBehaviourTest
|
|||||||
|
|
||||||
private String getMockEndpointUri()
|
private String getMockEndpointUri()
|
||||||
{
|
{
|
||||||
return "mock:" + this.getClass().getSimpleName() + "_" + name.getMethodName();
|
return "mock:" + this.getClass().getSimpleName() + "_" + GUID.generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@@ -25,23 +25,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.rawevents;
|
package org.alfresco.repo.rawevents;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
import org.alfresco.repo.rawevents.types.EventType;
|
import org.alfresco.repo.rawevents.types.EventType;
|
||||||
import org.alfresco.repo.rawevents.types.OnContentUpdatePolicyEvent;
|
import org.alfresco.repo.rawevents.types.OnContentUpdatePolicyEvent;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.apache.camel.CamelContext;
|
import org.apache.camel.CamelContext;
|
||||||
import org.apache.camel.component.mock.MockEndpoint;
|
import org.apache.camel.component.mock.MockEndpoint;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.junit.rules.TestName;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
@@ -50,27 +42,17 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
*
|
*
|
||||||
* @author Cristian Turlica
|
* @author Cristian Turlica
|
||||||
*/
|
*/
|
||||||
@Category(OwnJVMTestsCategory.class)
|
public class TransactionAwareEventProducerTest extends BaseSpringTest
|
||||||
public class TransactionAwareEventProducerTest
|
|
||||||
{
|
{
|
||||||
|
@Autowired
|
||||||
private RetryingTransactionHelper retryingTransactionHelper;
|
private RetryingTransactionHelper retryingTransactionHelper;
|
||||||
|
@Autowired
|
||||||
private CamelContext camelContext;
|
private CamelContext camelContext;
|
||||||
|
@Autowired
|
||||||
private TransactionAwareEventProducer eventProducer;
|
private TransactionAwareEventProducer eventProducer;
|
||||||
|
@Autowired
|
||||||
private ObjectMapper messagingObjectMapper;
|
private ObjectMapper messagingObjectMapper;
|
||||||
|
|
||||||
@Rule
|
|
||||||
public TestName name = new TestName();
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception
|
|
||||||
{
|
|
||||||
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
retryingTransactionHelper = (RetryingTransactionHelper) ctx.getBean("retryingTransactionHelper");
|
|
||||||
camelContext = (CamelContext) ctx.getBean("alfrescoCamelContext");
|
|
||||||
eventProducer = (TransactionAwareEventProducer) ctx.getBean("transactionAwareEventProducer");
|
|
||||||
messagingObjectMapper = (ObjectMapper) ctx.getBean("alfrescoEventObjectMapper");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void send() throws Exception
|
public void send() throws Exception
|
||||||
{
|
{
|
||||||
@@ -127,6 +109,6 @@ public class TransactionAwareEventProducerTest
|
|||||||
|
|
||||||
private String getMockEndpointUri()
|
private String getMockEndpointUri()
|
||||||
{
|
{
|
||||||
return "mock:" + this.getClass().getSimpleName() + "_" + name.getMethodName();
|
return "mock:" + this.getClass().getSimpleName() + "_" + GUID.generate();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -115,10 +115,6 @@ public abstract class AbstractRenditionIntegrationTest extends BaseSpringTest
|
|||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void before()
|
public static void before()
|
||||||
{
|
{
|
||||||
// Ensure other applications contexts are closed...
|
|
||||||
// Multiple consumers not supported for same direct vm in different Camel contexts.
|
|
||||||
ApplicationContextHelper.closeApplicationContext();
|
|
||||||
|
|
||||||
// Use the docker images for transforms
|
// Use the docker images for transforms
|
||||||
System.setProperty("alfresco-pdf-renderer.url", "http://localhost:8090/");
|
System.setProperty("alfresco-pdf-renderer.url", "http://localhost:8090/");
|
||||||
System.setProperty("img.url", "http://localhost:8091");
|
System.setProperty("img.url", "http://localhost:8091");
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.rendition2;
|
package org.alfresco.repo.rendition2;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import org.alfresco.repo.content.transform.swf.SWFTransformationOptions;
|
import org.alfresco.repo.content.transform.swf.SWFTransformationOptions;
|
||||||
import org.alfresco.repo.rendition.RenditionServiceImpl;
|
import org.alfresco.repo.rendition.RenditionServiceImpl;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
@@ -34,14 +33,16 @@ import org.alfresco.repo.thumbnail.ThumbnailRenditionConvertor;
|
|||||||
import org.alfresco.service.cmr.rendition.RenditionDefinition;
|
import org.alfresco.service.cmr.rendition.RenditionDefinition;
|
||||||
import org.alfresco.service.cmr.rendition.RenditionService;
|
import org.alfresco.service.cmr.rendition.RenditionService;
|
||||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the replacement {@link RenditionDefinition2} generates the same {@link TransformationOptions} as the
|
* Tests that the replacement {@link RenditionDefinition2} generates the same {@link TransformationOptions} as the
|
||||||
@@ -52,28 +53,26 @@ import java.util.StringJoiner;
|
|||||||
* @author adavis
|
* @author adavis
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class RenditionDefinitionTest extends TestCase
|
public class RenditionDefinitionTest extends BaseSpringTest
|
||||||
{
|
{
|
||||||
private RenditionServiceImpl renditionService;
|
private RenditionServiceImpl renditionService;
|
||||||
private RenditionDefinitionRegistry2 renditionDefinitionRegistry2;
|
private RenditionDefinitionRegistry2 renditionDefinitionRegistry2;
|
||||||
private TransformationOptionsConverter transformationOptionsConverter;
|
private TransformationOptionsConverter transformationOptionsConverter;
|
||||||
|
|
||||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
|
|
||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
|
|
||||||
@Override
|
@Before
|
||||||
protected void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
authenticationComponent = (AuthenticationComponent) ctx.getBean("AuthenticationComponent");
|
authenticationComponent = (AuthenticationComponent) applicationContext.getBean("AuthenticationComponent");
|
||||||
renditionService = (RenditionServiceImpl) ctx.getBean("renditionService");
|
renditionService = (RenditionServiceImpl) applicationContext.getBean("renditionService");
|
||||||
renditionDefinitionRegistry2 = (RenditionDefinitionRegistry2) ctx.getBean("renditionDefinitionRegistry2");
|
renditionDefinitionRegistry2 = (RenditionDefinitionRegistry2) applicationContext.getBean("renditionDefinitionRegistry2");
|
||||||
transformationOptionsConverter = (TransformationOptionsConverter) ctx.getBean("transformOptionsConverter");
|
transformationOptionsConverter = (TransformationOptionsConverter) applicationContext.getBean("transformOptionsConverter");
|
||||||
authenticationComponent.setSystemUserAsCurrentUser();
|
authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@After
|
||||||
protected void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -98,6 +97,7 @@ public class RenditionDefinitionTest extends TestCase
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetRenderingEngineDefinition() throws Exception
|
public void testGetRenderingEngineDefinition() throws Exception
|
||||||
{
|
{
|
||||||
ThumbnailRenditionConvertor converter = new ThumbnailRenditionConvertor();
|
ThumbnailRenditionConvertor converter = new ThumbnailRenditionConvertor();
|
||||||
|
@@ -33,8 +33,6 @@ import java.util.Map;
|
|||||||
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;
|
||||||
@@ -51,22 +49,19 @@ import org.alfresco.service.cmr.search.QueryParameterDefinition;
|
|||||||
import org.alfresco.service.namespace.DynamicNamespacePrefixResolver;
|
import org.alfresco.service.namespace.DynamicNamespacePrefixResolver;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
|
||||||
import org.alfresco.util.ISO9075;
|
import org.alfresco.util.ISO9075;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.After;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.search.SearcherComponent
|
* @see org.alfresco.repo.search.SearcherComponent
|
||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
@Category({OwnJVMTestsCategory.class})
|
public class SearcherComponentTest extends BaseSpringTest
|
||||||
public class SearcherComponentTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
|
|
||||||
//private static String COMPLEX_LOCAL_NAME = " `¬¦!\"£$%^&*()-_=+\t\n\\\u0000[]{};'#:@~,./<>?\\|\u0123\u4567\u8900\uabcd\uefff_xT65A_";
|
//private static String COMPLEX_LOCAL_NAME = " `¬¦!\"£$%^&*()-_=+\t\n\\\u0000[]{};'#:@~,./<>?\\|\u0123\u4567\u8900\uabcd\uefff_xT65A_";
|
||||||
// \u0123 and \u8900 removed
|
// \u0123 and \u8900 removed
|
||||||
|
|
||||||
@@ -96,9 +91,10 @@ public class SearcherComponentTest extends TestCase
|
|||||||
// TODO: pending replacement
|
// TODO: pending replacement
|
||||||
private Dialect dialect;
|
private Dialect dialect;
|
||||||
|
|
||||||
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
dialect = (Dialect) ctx.getBean("dialect");
|
dialect = (Dialect) applicationContext.getBean("dialect");
|
||||||
if (dialect instanceof PostgreSQLDialect)
|
if (dialect instanceof PostgreSQLDialect)
|
||||||
{
|
{
|
||||||
// Note: PostgreSQL does not support \u0000 char embedded in a string
|
// Note: PostgreSQL does not support \u0000 char embedded in a string
|
||||||
@@ -106,16 +102,16 @@ public class SearcherComponentTest extends TestCase
|
|||||||
COMPLEX_LOCAL_NAME = COMPLEX_LOCAL_NAME_NO_U0000;
|
COMPLEX_LOCAL_NAME = COMPLEX_LOCAL_NAME_NO_U0000;
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
transactionService = serviceRegistry.getTransactionService();
|
transactionService = serviceRegistry.getTransactionService();
|
||||||
dictionaryService = BaseNodeServiceTest.loadModel(ctx);
|
dictionaryService = BaseNodeServiceTest.loadModel(applicationContext);
|
||||||
nodeService = serviceRegistry.getNodeService();
|
nodeService = serviceRegistry.getNodeService();
|
||||||
|
|
||||||
this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
|
this.authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
|
||||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
this.authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
|
|
||||||
// get the indexer and searcher factory
|
// get the indexer and searcher factory
|
||||||
IndexerAndSearcher indexerAndSearcher = (IndexerAndSearcher) ctx.getBean("indexerAndSearcherFactory");
|
IndexerAndSearcher indexerAndSearcher = (IndexerAndSearcher) applicationContext.getBean("indexerAndSearcherFactory");
|
||||||
searcher = new SearcherComponent();
|
searcher = new SearcherComponent();
|
||||||
searcher.setIndexerAndSearcherFactory(indexerAndSearcher);
|
searcher.setIndexerAndSearcherFactory(indexerAndSearcher);
|
||||||
// create a test workspace
|
// create a test workspace
|
||||||
@@ -127,6 +123,7 @@ public class SearcherComponentTest extends TestCase
|
|||||||
txn.begin();
|
txn.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
public void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
if (txn.getStatus() == Status.STATUS_ACTIVE)
|
if (txn.getStatus() == Status.STATUS_ACTIVE)
|
||||||
@@ -137,6 +134,7 @@ public class SearcherComponentTest extends TestCase
|
|||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testNodeXPath() throws Exception
|
public void testNodeXPath() throws Exception
|
||||||
{
|
{
|
||||||
Map<QName, ChildAssociationRef> assocRefs = BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
|
Map<QName, ChildAssociationRef> assocRefs = BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
|
||||||
@@ -299,6 +297,7 @@ public class SearcherComponentTest extends TestCase
|
|||||||
assertEquals(2, list.size());
|
assertEquals(2, list.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSelectAPI() throws Exception
|
public void testSelectAPI() throws Exception
|
||||||
{
|
{
|
||||||
Map<QName, ChildAssociationRef> assocRefs = BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
|
Map<QName, ChildAssociationRef> assocRefs = BaseNodeServiceTest.buildNodeGraph(nodeService, rootNodeRef);
|
||||||
|
@@ -35,8 +35,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.dictionary.DictionaryDAO;
|
import org.alfresco.repo.dictionary.DictionaryDAO;
|
||||||
import org.alfresco.repo.dictionary.M2Model;
|
import org.alfresco.repo.dictionary.M2Model;
|
||||||
@@ -62,26 +60,24 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
|||||||
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.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
import org.alfresco.util.testing.category.LuceneTests;
|
import org.alfresco.util.testing.category.PerformanceTests;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests tracking component
|
* Tests tracking component
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Category({OwnJVMTestsCategory.class, LuceneTests.class})
|
public class SOLRTrackingComponentTest extends BaseSpringTest
|
||||||
public class SOLRTrackingComponentTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private static final Log logger = LogFactory.getLog(SOLRTrackingComponentTest.class);
|
private static final Log logger = LogFactory.getLog(SOLRTrackingComponentTest.class);
|
||||||
|
|
||||||
private ConfigurableApplicationContext ctx = (ConfigurableApplicationContext) ApplicationContextHelper.getApplicationContext();
|
|
||||||
private static enum NodeStatus
|
private static enum NodeStatus
|
||||||
{
|
{
|
||||||
UPDATED, DELETED;
|
UPDATED, DELETED;
|
||||||
@@ -103,24 +99,24 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
private StoreRef storeRef;
|
private StoreRef storeRef;
|
||||||
private NodeRef rootNodeRef;
|
private NodeRef rootNodeRef;
|
||||||
|
|
||||||
@Override
|
@Before
|
||||||
public void setUp() throws Exception
|
public void before() throws Exception
|
||||||
{
|
{
|
||||||
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
ServiceRegistry serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
transactionService = serviceRegistry.getTransactionService();
|
transactionService = serviceRegistry.getTransactionService();
|
||||||
txnHelper = transactionService.getRetryingTransactionHelper();
|
txnHelper = transactionService.getRetryingTransactionHelper();
|
||||||
|
|
||||||
solrTrackingComponent = (SOLRTrackingComponent) ctx.getBean("solrTrackingComponent");
|
solrTrackingComponent = (SOLRTrackingComponent) applicationContext.getBean("solrTrackingComponent");
|
||||||
nodeDAO = (NodeDAO)ctx.getBean("nodeDAO");
|
nodeDAO = (NodeDAO)applicationContext.getBean("nodeDAO");
|
||||||
qnameDAO = (QNameDAO) ctx.getBean("qnameDAO");
|
qnameDAO = (QNameDAO) applicationContext.getBean("qnameDAO");
|
||||||
dictionaryDAO = (DictionaryDAO)ctx.getBean("dictionaryDAO");
|
dictionaryDAO = (DictionaryDAO)applicationContext.getBean("dictionaryDAO");
|
||||||
nodeService = (NodeService)ctx.getBean("NodeService");
|
nodeService = (NodeService)applicationContext.getBean("NodeService");
|
||||||
fileFolderService = (FileFolderService)ctx.getBean("FileFolderService");
|
fileFolderService = (FileFolderService)applicationContext.getBean("FileFolderService");
|
||||||
dictionaryService = serviceRegistry.getDictionaryService();
|
dictionaryService = serviceRegistry.getDictionaryService();
|
||||||
namespaceService = serviceRegistry.getNamespaceService();
|
namespaceService = serviceRegistry.getNamespaceService();
|
||||||
authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent");
|
authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
|
||||||
|
|
||||||
dbNodeService = (DbNodeServiceImpl)ctx.getBean("dbNodeService");
|
dbNodeService = (DbNodeServiceImpl)applicationContext.getBean("dbNodeService");
|
||||||
dbNodeService.setEnableTimestampPropagation(false);
|
dbNodeService.setEnableTimestampPropagation(false);
|
||||||
|
|
||||||
authenticationComponent.setSystemUserAsCurrentUser();
|
authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
@@ -129,6 +125,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
rootNodeRef = nodeService.getRootNode(storeRef);
|
rootNodeRef = nodeService.getRootNode(storeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAclChangeSetLimits()
|
public void testAclChangeSetLimits()
|
||||||
{
|
{
|
||||||
List<AclChangeSet> aclChangeSets = getAclChangeSets(null, null, null, null, 50);
|
List<AclChangeSet> aclChangeSets = getAclChangeSets(null, null, null, null, 50);
|
||||||
@@ -148,6 +145,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
// This test is no longer valid as we may or may include shared acls not linked to defining ones
|
// This test is no longer valid as we may or may include shared acls not linked to defining ones
|
||||||
// If they are not linked to a node they will be counted wring ...
|
// If they are not linked to a node they will be counted wring ...
|
||||||
|
|
||||||
|
// @Test
|
||||||
// public void testGetAcls_Simple()
|
// public void testGetAcls_Simple()
|
||||||
// {
|
// {
|
||||||
// List<AclChangeSet> cs = getAclChangeSets(null, null, null, null, 50);
|
// List<AclChangeSet> cs = getAclChangeSets(null, null, null, null, 50);
|
||||||
@@ -170,6 +168,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
// assertEquals("ACL count should have matched", totalAcls, totalAclsCheck);
|
// assertEquals("ACL count should have matched", totalAcls, totalAclsCheck);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetNodeMetaData()
|
public void testGetNodeMetaData()
|
||||||
{
|
{
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
@@ -283,6 +282,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
return transactionService.getRetryingTransactionHelper().doInTransaction(callback, true);
|
return transactionService.getRetryingTransactionHelper().doInTransaction(callback, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetTransactionLimits()
|
public void testGetTransactionLimits()
|
||||||
{
|
{
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
@@ -341,6 +341,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
assertEquals(0, txns.size());
|
assertEquals(0, txns.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetNodeMetaDataExludesResidualProperties()
|
public void testGetNodeMetaDataExludesResidualProperties()
|
||||||
{
|
{
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
@@ -365,6 +366,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetNodeMetaData100Nodes()
|
public void testGetNodeMetaData100Nodes()
|
||||||
{
|
{
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
@@ -394,6 +396,8 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
// assertEquals("Unxpected number of nodes", 3, bt.getSuccessCount());
|
// assertEquals("Unxpected number of nodes", 3, bt.getSuccessCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Category(PerformanceTests.class)
|
||||||
|
@Test
|
||||||
public void testNodeMetaDataManyNodes() throws Exception
|
public void testNodeMetaDataManyNodes() throws Exception
|
||||||
{
|
{
|
||||||
long fromCommitTime = System.currentTimeMillis();
|
long fromCommitTime = System.currentTimeMillis();
|
||||||
@@ -451,6 +455,8 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
getNodeMetaData(nodeMetaDataParams, null, st);
|
getNodeMetaData(nodeMetaDataParams, null, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Category(PerformanceTests.class)
|
||||||
|
@Test
|
||||||
public void testNodeMetaDataCache() throws Exception
|
public void testNodeMetaDataCache() throws Exception
|
||||||
{
|
{
|
||||||
long fromCommitTime = System.currentTimeMillis();
|
long fromCommitTime = System.currentTimeMillis();
|
||||||
@@ -481,6 +487,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
getNodeMetaData(nodeMetaDataParams, filter, st);
|
getNodeMetaData(nodeMetaDataParams, filter, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testNodeMetaDataNullPropertyValue() throws Exception
|
public void testNodeMetaDataNullPropertyValue() throws Exception
|
||||||
{
|
{
|
||||||
long fromCommitTime = System.currentTimeMillis();
|
long fromCommitTime = System.currentTimeMillis();
|
||||||
@@ -503,6 +510,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
getNodeMetaData(nodeMetaDataParams, null, st);
|
getNodeMetaData(nodeMetaDataParams, null, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFilters()
|
public void testFilters()
|
||||||
{
|
{
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
@@ -525,6 +533,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
getNodeMetaData(nodeMetaDataParams, null, st);
|
getNodeMetaData(nodeMetaDataParams, null, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testModelDiffs()
|
public void testModelDiffs()
|
||||||
{
|
{
|
||||||
Collection<QName> allModels = dictionaryService.getAllModels();
|
Collection<QName> allModels = dictionaryService.getAllModels();
|
||||||
@@ -765,14 +774,14 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
|
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
solrTrackingComponent.getNodesMetadata(params, filter, bt);
|
solrTrackingComponent.getNodesMetadata(params, filter, bt);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}, true, true);
|
}, true, true);
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
|
|
||||||
bt.runNodeMetaDataChecks(params.getMaxResults());
|
bt.runNodeMetaDataChecks(params.getMaxResults());
|
||||||
@@ -811,7 +820,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
||||||
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
this.txnHelper = txnHelper;
|
this.txnHelper = txnHelper;
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
this.rootNodeRef = rootNodeRef;
|
this.rootNodeRef = rootNodeRef;
|
||||||
@@ -827,7 +836,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
this.doNodeChecks = doNodeChecks;
|
this.doNodeChecks = doNodeChecks;
|
||||||
this.doMetaDataChecks = doMetaDataChecks;
|
this.doMetaDataChecks = doMetaDataChecks;
|
||||||
this.doChecks = doNodeChecks || doMetaDataChecks;
|
this.doChecks = doNodeChecks || doMetaDataChecks;
|
||||||
}
|
}
|
||||||
|
|
||||||
void runNodeChecks(int maxResults)
|
void runNodeChecks(int maxResults)
|
||||||
{
|
{
|
||||||
@@ -1025,7 +1034,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
if (expectPaths)
|
if (expectPaths)
|
||||||
{
|
{
|
||||||
// Check QName paths
|
// Check QName paths
|
||||||
// TODO: Check paths
|
// TODO: Check paths
|
||||||
// Check name paths
|
// Check name paths
|
||||||
Collection<Collection<String>> namePaths = nodeMetaData.getNamePaths();
|
Collection<Collection<String>> namePaths = nodeMetaData.getNamePaths();
|
||||||
if (nodeService.getProperty(nodeRef, ContentModel.PROP_NAME) == null)
|
if (nodeService.getProperty(nodeRef, ContentModel.PROP_NAME) == null)
|
||||||
@@ -1137,9 +1146,9 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
||||||
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpectedNumNodes()
|
public int getExpectedNumNodes()
|
||||||
{
|
{
|
||||||
@@ -1151,7 +1160,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
ArrayList<Long> txs = new ArrayList<Long>(2);
|
ArrayList<Long> txs = new ArrayList<Long>(2);
|
||||||
|
|
||||||
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
||||||
{
|
{
|
||||||
public Long execute() throws Throwable
|
public Long execute() throws Throwable
|
||||||
{
|
{
|
||||||
PropertyMap props = new PropertyMap();
|
PropertyMap props = new PropertyMap();
|
||||||
@@ -1168,10 +1177,10 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
|
|
||||||
return nodeDAO.getNodeRefStatus(content1).getDbTxnId();
|
return nodeDAO.getNodeRefStatus(content1).getDbTxnId();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
||||||
{
|
{
|
||||||
public Long execute() throws Throwable
|
public Long execute() throws Throwable
|
||||||
{
|
{
|
||||||
FileInfo contentInfo = fileFolderService.create(container, "Content2", ContentModel.TYPE_CONTENT);
|
FileInfo contentInfo = fileFolderService.create(container, "Content2", ContentModel.TYPE_CONTENT);
|
||||||
@@ -1181,7 +1190,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
|
|
||||||
return nodeDAO.getNodeRefStatus(content1).getDbTxnId();
|
return nodeDAO.getNodeRefStatus(content1).getDbTxnId();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setExpectedNodeStatus(container, NodeStatus.UPDATED);
|
setExpectedNodeStatus(container, NodeStatus.UPDATED);
|
||||||
setExpectedNodeStatus(content1, NodeStatus.DELETED);
|
setExpectedNodeStatus(content1, NodeStatus.DELETED);
|
||||||
@@ -1200,9 +1209,9 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
||||||
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpectedNumNodes()
|
public int getExpectedNumNodes()
|
||||||
{
|
{
|
||||||
@@ -1214,7 +1223,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
ArrayList<Long> txs = new ArrayList<Long>(2);
|
ArrayList<Long> txs = new ArrayList<Long>(2);
|
||||||
|
|
||||||
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
||||||
{
|
{
|
||||||
public Long execute() throws Throwable
|
public Long execute() throws Throwable
|
||||||
{
|
{
|
||||||
PropertyMap props = new PropertyMap();
|
PropertyMap props = new PropertyMap();
|
||||||
@@ -1235,10 +1244,10 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
|
|
||||||
return nodeDAO.getNodeRefStatus(content1).getDbTxnId();
|
return nodeDAO.getNodeRefStatus(content1).getDbTxnId();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
||||||
{
|
{
|
||||||
public Long execute() throws Throwable
|
public Long execute() throws Throwable
|
||||||
{
|
{
|
||||||
FileInfo contentInfo = fileFolderService.create(container, "Content2", ContentModel.TYPE_CONTENT);
|
FileInfo contentInfo = fileFolderService.create(container, "Content2", ContentModel.TYPE_CONTENT);
|
||||||
@@ -1249,7 +1258,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
|
|
||||||
return nodeDAO.getNodeRefStatus(content1).getDbTxnId();
|
return nodeDAO.getNodeRefStatus(content1).getDbTxnId();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setExpectedNodeStatus(container, NodeStatus.UPDATED);
|
setExpectedNodeStatus(container, NodeStatus.UPDATED);
|
||||||
setExpectedNodeStatus(content1, NodeStatus.DELETED);
|
setExpectedNodeStatus(content1, NodeStatus.DELETED);
|
||||||
@@ -1265,9 +1274,9 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
||||||
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpectedNumNodes()
|
public int getExpectedNumNodes()
|
||||||
{
|
{
|
||||||
@@ -1279,7 +1288,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
ArrayList<Long> txs = new ArrayList<Long>(2);
|
ArrayList<Long> txs = new ArrayList<Long>(2);
|
||||||
|
|
||||||
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
||||||
{
|
{
|
||||||
public Long execute() throws Throwable
|
public Long execute() throws Throwable
|
||||||
{
|
{
|
||||||
PropertyMap props = new PropertyMap();
|
PropertyMap props = new PropertyMap();
|
||||||
@@ -1302,7 +1311,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
|
|
||||||
return nodeDAO.getNodeRefStatus(container).getDbTxnId();
|
return nodeDAO.getNodeRefStatus(container).getDbTxnId();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
return txs;
|
return txs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1315,9 +1324,9 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
||||||
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpectedNumNodes()
|
public int getExpectedNumNodes()
|
||||||
{
|
{
|
||||||
@@ -1329,7 +1338,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
ArrayList<Long> txs = new ArrayList<Long>(2);
|
ArrayList<Long> txs = new ArrayList<Long>(2);
|
||||||
|
|
||||||
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
||||||
{
|
{
|
||||||
public Long execute() throws Throwable
|
public Long execute() throws Throwable
|
||||||
{
|
{
|
||||||
PropertyMap props = new PropertyMap();
|
PropertyMap props = new PropertyMap();
|
||||||
@@ -1358,7 +1367,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
|
|
||||||
return nodeDAO.getNodeRefStatus(container).getDbTxnId();
|
return nodeDAO.getNodeRefStatus(container).getDbTxnId();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
return txs;
|
return txs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1372,9 +1381,9 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
||||||
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpectedNumNodes()
|
public int getExpectedNumNodes()
|
||||||
{
|
{
|
||||||
@@ -1386,12 +1395,12 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
ArrayList<Long> txs = new ArrayList<Long>(2);
|
ArrayList<Long> txs = new ArrayList<Long>(2);
|
||||||
|
|
||||||
final String titles[] =
|
final String titles[] =
|
||||||
{
|
|
||||||
"caf\u00E9", "\u00E7edilla", "\u00E0\u00E1\u00E2\u00E3", "\u00EC\u00ED\u00EE\u00EF", "\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6",
|
|
||||||
"caf\u00E9", "\u00E7edilla", "\u00E0\u00E1\u00E2\u00E3", "\u00EC\u00ED\u00EE\u00EF", "\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6"
|
|
||||||
};
|
|
||||||
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
|
||||||
{
|
{
|
||||||
|
"caf\u00E9", "\u00E7edilla", "\u00E0\u00E1\u00E2\u00E3", "\u00EC\u00ED\u00EE\u00EF", "\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6",
|
||||||
|
"caf\u00E9", "\u00E7edilla", "\u00E0\u00E1\u00E2\u00E3", "\u00EC\u00ED\u00EE\u00EF", "\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6"
|
||||||
|
};
|
||||||
|
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
||||||
|
{
|
||||||
public Long execute() throws Throwable
|
public Long execute() throws Throwable
|
||||||
{
|
{
|
||||||
PropertyMap props = new PropertyMap();
|
PropertyMap props = new PropertyMap();
|
||||||
@@ -1426,7 +1435,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
|
|
||||||
return nodeDAO.getNodeRefStatus(container).getDbTxnId();
|
return nodeDAO.getNodeRefStatus(container).getDbTxnId();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return txs;
|
return txs;
|
||||||
}
|
}
|
||||||
@@ -1441,9 +1450,9 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
RetryingTransactionHelper txnHelper, FileFolderService fileFolderService,
|
||||||
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService,rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService,rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpectedNumNodes()
|
public int getExpectedNumNodes()
|
||||||
{
|
{
|
||||||
@@ -1455,7 +1464,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
ArrayList<Long> txs = new ArrayList<Long>(2);
|
ArrayList<Long> txs = new ArrayList<Long>(2);
|
||||||
|
|
||||||
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
|
||||||
{
|
{
|
||||||
public Long execute() throws Throwable
|
public Long execute() throws Throwable
|
||||||
{
|
{
|
||||||
PropertyMap props = new PropertyMap();
|
PropertyMap props = new PropertyMap();
|
||||||
@@ -1474,7 +1483,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
|
|
||||||
return nodeDAO.getNodeRefStatus(container).getDbTxnId();
|
return nodeDAO.getNodeRefStatus(container).getDbTxnId();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setExpectedNodeStatus(container, NodeStatus.UPDATED);
|
setExpectedNodeStatus(container, NodeStatus.UPDATED);
|
||||||
setExpectedNodeStatus(content, NodeStatus.UPDATED);
|
setExpectedNodeStatus(content, NodeStatus.UPDATED);
|
||||||
|
@@ -63,8 +63,7 @@ import org.alfresco.service.cmr.tagging.TagScope;
|
|||||||
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.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
@@ -77,18 +76,13 @@ import org.junit.Before;
|
|||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
import org.mockito.runners.MockitoJUnitRunner;
|
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tagging service implementation unit test
|
* Tagging service implementation unit test
|
||||||
*
|
*
|
||||||
@@ -96,14 +90,9 @@ import static org.junit.Assert.*;
|
|||||||
* @author Nick Burch
|
* @author Nick Burch
|
||||||
*/
|
*/
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
@Category({OwnJVMTestsCategory.class, LuceneTests.class})
|
public class TaggingServiceImplTest extends BaseSpringTest
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
|
||||||
public class TaggingServiceImplTest
|
|
||||||
{
|
{
|
||||||
private static ConfigurableApplicationContext ctx =
|
private static final Log logger = LogFactory.getLog(TaggingServiceImplTest.class);
|
||||||
(ConfigurableApplicationContext)ApplicationContextHelper.getApplicationContext();
|
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(TaggingServiceImplTest.class);
|
|
||||||
|
|
||||||
/** Services */
|
/** Services */
|
||||||
private TaggingServiceImpl taggingService;
|
private TaggingServiceImpl taggingService;
|
||||||
@@ -159,36 +148,36 @@ public class TaggingServiceImplTest
|
|||||||
{
|
{
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"There should not be any transactions when starting test: " +
|
"There should not be any transactions when starting test: " +
|
||||||
AlfrescoTransactionSupport.getTransactionId() + " started at " +
|
AlfrescoTransactionSupport.getTransactionId() + " started at " +
|
||||||
new Date(AlfrescoTransactionSupport.getTransactionStartTime()));
|
new Date(AlfrescoTransactionSupport.getTransactionStartTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get services
|
// Get services
|
||||||
this.taggingService = (TaggingServiceImpl)ctx.getBean("taggingService");
|
this.taggingService = (TaggingServiceImpl)applicationContext.getBean("taggingService");
|
||||||
this.nodeService = (NodeService) ctx.getBean("NodeService");
|
this.nodeService = (NodeService) applicationContext.getBean("NodeService");
|
||||||
this.fileFolderService = (FileFolderService) ctx.getBean("FileFolderService");
|
this.fileFolderService = (FileFolderService) applicationContext.getBean("FileFolderService");
|
||||||
this.copyService = (CopyService) ctx.getBean("CopyService");
|
this.copyService = (CopyService) applicationContext.getBean("CopyService");
|
||||||
this.checkOutCheckInService = (CheckOutCheckInService) ctx.getBean("CheckoutCheckinService");
|
this.checkOutCheckInService = (CheckOutCheckInService) applicationContext.getBean("CheckoutCheckinService");
|
||||||
this.actionService = (ActionService)ctx.getBean("ActionService");
|
this.actionService = (ActionService)applicationContext.getBean("ActionService");
|
||||||
this.transactionService = (TransactionService)ctx.getBean("transactionComponent");
|
this.transactionService = (TransactionService)applicationContext.getBean("transactionComponent");
|
||||||
this.siteService = ctx.getBean("SiteService", SiteService.class);
|
this.siteService = applicationContext.getBean("SiteService", SiteService.class);
|
||||||
//MNT-10807 : Auditing does not take into account audit.filter.alfresco-access.transaction.user
|
//MNT-10807 : Auditing does not take into account audit.filter.alfresco-access.transaction.user
|
||||||
UserAuditFilter userAuditFilter = new UserAuditFilter();
|
UserAuditFilter userAuditFilter = new UserAuditFilter();
|
||||||
userAuditFilter.setUserFilterPattern("System;.*");
|
userAuditFilter.setUserFilterPattern("System;.*");
|
||||||
userAuditFilter.afterPropertiesSet();
|
userAuditFilter.afterPropertiesSet();
|
||||||
AuditComponent auditComponent = (AuditComponent) ctx.getBean("auditComponent");
|
AuditComponent auditComponent = (AuditComponent) applicationContext.getBean("auditComponent");
|
||||||
auditComponent.setUserAuditFilter(userAuditFilter);
|
auditComponent.setUserAuditFilter(userAuditFilter);
|
||||||
AuditServiceImpl auditServiceImpl = (AuditServiceImpl) ctx.getBean("auditService");
|
AuditServiceImpl auditServiceImpl = (AuditServiceImpl) applicationContext.getBean("auditService");
|
||||||
auditServiceImpl.setAuditComponent(auditComponent);
|
auditServiceImpl.setAuditComponent(auditComponent);
|
||||||
this.auditService = (AuditService)ctx.getBean("auditService");
|
this.auditService = (AuditService)applicationContext.getBean("auditService");
|
||||||
this.scriptService = (ScriptService)ctx.getBean("scriptService");
|
this.scriptService = (ScriptService)applicationContext.getBean("scriptService");
|
||||||
this.actionTrackingService = (ActionTrackingService)ctx.getBean("actionTrackingService");
|
this.actionTrackingService = (ActionTrackingService)applicationContext.getBean("actionTrackingService");
|
||||||
this.authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent");
|
this.authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
|
||||||
|
|
||||||
this.personService = (PersonService)ctx.getBean("PersonService");
|
this.personService = (PersonService)applicationContext.getBean("PersonService");
|
||||||
this.permissionService = (PermissionService)ctx.getBean("PermissionService");
|
this.permissionService = (PermissionService)applicationContext.getBean("PermissionService");
|
||||||
this.authenticationService = (MutableAuthenticationService)ctx.getBean("authenticationService");
|
this.authenticationService = (MutableAuthenticationService)applicationContext.getBean("authenticationService");
|
||||||
this.nodeRefPropInterceptor = (NodeRefPropertyMethodInterceptor)ctx.getBean("nodeRefPropertyInterceptor");
|
this.nodeRefPropInterceptor = (NodeRefPropertyMethodInterceptor)applicationContext.getBean("nodeRefPropertyInterceptor");
|
||||||
|
|
||||||
if (init == false)
|
if (init == false)
|
||||||
{
|
{
|
||||||
@@ -212,10 +201,10 @@ public class TaggingServiceImplTest
|
|||||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "categoryRoot"),
|
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "categoryRoot"),
|
||||||
ContentModel.TYPE_CATEGORYROOT).getChildRef();
|
ContentModel.TYPE_CATEGORYROOT).getChildRef();
|
||||||
nodeService.createNode(
|
nodeService.createNode(
|
||||||
catRoot,
|
catRoot,
|
||||||
ContentModel.ASSOC_CATEGORIES,
|
ContentModel.ASSOC_CATEGORIES,
|
||||||
ContentModel.ASPECT_TAGGABLE,
|
ContentModel.ASPECT_TAGGABLE,
|
||||||
ContentModel.TYPE_CATEGORY).getChildRef();
|
ContentModel.TYPE_CATEGORY).getChildRef();
|
||||||
|
|
||||||
init = true;
|
init = true;
|
||||||
return null;
|
return null;
|
||||||
@@ -225,15 +214,15 @@ public class TaggingServiceImplTest
|
|||||||
|
|
||||||
// We want to know when tagging actions have finished running
|
// We want to know when tagging actions have finished running
|
||||||
asyncOccurs = new AsyncOccurs();
|
asyncOccurs = new AsyncOccurs();
|
||||||
((PolicyComponent)ctx.getBean("policyComponent")).bindClassBehaviour(
|
((PolicyComponent)applicationContext.getBean("policyComponent")).bindClassBehaviour(
|
||||||
AsynchronousActionExecutionQueuePolicies.OnAsyncActionExecute.QNAME,
|
AsynchronousActionExecutionQueuePolicies.OnAsyncActionExecute.QNAME,
|
||||||
ActionModel.TYPE_ACTION,
|
ActionModel.TYPE_ACTION,
|
||||||
new JavaBehaviour(asyncOccurs, "onAsyncActionExecute", NotificationFrequency.EVERY_EVENT)
|
new JavaBehaviour(asyncOccurs, "onAsyncActionExecute", NotificationFrequency.EVERY_EVENT)
|
||||||
);
|
);
|
||||||
|
|
||||||
// We do want action tracking whenever the tag scope updater runs
|
// We do want action tracking whenever the tag scope updater runs
|
||||||
UpdateTagScopesActionExecuter updateTagsAction =
|
UpdateTagScopesActionExecuter updateTagsAction =
|
||||||
(UpdateTagScopesActionExecuter)ctx.getBean("update-tagscope");
|
(UpdateTagScopesActionExecuter)applicationContext.getBean("update-tagscope");
|
||||||
updateTagsAction.setTrackStatus(true);
|
updateTagsAction.setTrackStatus(true);
|
||||||
|
|
||||||
// Create the folders and documents to be tagged
|
// Create the folders and documents to be tagged
|
||||||
@@ -318,22 +307,22 @@ public class TaggingServiceImplTest
|
|||||||
NodeRef[] nodes = new NodeRef[] { subDocument, subFolder, document, folder };
|
NodeRef[] nodes = new NodeRef[] { subDocument, subFolder, document, folder };
|
||||||
for(NodeRef nodeRef : nodes)
|
for(NodeRef nodeRef : nodes)
|
||||||
{
|
{
|
||||||
if(taggingService.isTagScope(nodeRef))
|
if(taggingService.isTagScope(nodeRef))
|
||||||
{
|
{
|
||||||
taggingService.removeTagScope(nodeRef);
|
taggingService.removeTagScope(nodeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the sample nodes
|
// Remove the sample nodes
|
||||||
for(NodeRef nodeRef : nodes)
|
for(NodeRef nodeRef : nodes)
|
||||||
{
|
{
|
||||||
nodeService.deleteNode(nodeRef);
|
nodeService.deleteNode(nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tidy up the audit component, now all the nodes have gone
|
// Tidy up the audit component, now all the nodes have gone
|
||||||
auditService.clearAudit(
|
auditService.clearAudit(
|
||||||
TaggingServiceImpl.TAGGING_AUDIT_APPLICATION_NAME,
|
TaggingServiceImpl.TAGGING_AUDIT_APPLICATION_NAME,
|
||||||
0l, System.currentTimeMillis()+1
|
0l, System.currentTimeMillis()+1
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -343,7 +332,7 @@ public class TaggingServiceImplTest
|
|||||||
@Test
|
@Test
|
||||||
@Category({RedundantTests.class,LuceneTests.class})
|
@Category({RedundantTests.class,LuceneTests.class})
|
||||||
public void test1TagCRUD()
|
public void test1TagCRUD()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>(){
|
this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>(){
|
||||||
|
|
||||||
@@ -429,7 +418,7 @@ public class TaggingServiceImplTest
|
|||||||
@Test
|
@Test
|
||||||
@Category({RedundantTests.class,LuceneTests.class})
|
@Category({RedundantTests.class,LuceneTests.class})
|
||||||
public void test2AddRemoveTag()
|
public void test2AddRemoveTag()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>(){
|
this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>(){
|
||||||
|
|
||||||
@@ -493,7 +482,7 @@ public class TaggingServiceImplTest
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test3TagScopeFindAddRemove()
|
public void test3TagScopeFindAddRemove()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>(){
|
this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>(){
|
||||||
|
|
||||||
@@ -553,7 +542,7 @@ public class TaggingServiceImplTest
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test4TagScope()
|
public void test4TagScope()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>(){
|
this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>(){
|
||||||
|
|
||||||
@@ -627,12 +616,12 @@ public class TaggingServiceImplTest
|
|||||||
|
|
||||||
// Check that the tag scopes got populated
|
// Check that the tag scopes got populated
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Wrong tags on sub folder: " + ts1.getTags(),
|
"Wrong tags on sub folder: " + ts1.getTags(),
|
||||||
3, ts1.getTags().size()
|
3, ts1.getTags().size()
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Wrong tags on main folder: " + ts2.getTags(),
|
"Wrong tags on main folder: " + ts2.getTags(),
|
||||||
3, ts2.getTags().size()
|
3, ts2.getTags().size()
|
||||||
);
|
);
|
||||||
|
|
||||||
// check the order and count of the tagscopes
|
// check the order and count of the tagscopes
|
||||||
@@ -733,7 +722,7 @@ public class TaggingServiceImplTest
|
|||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -805,34 +794,34 @@ public class TaggingServiceImplTest
|
|||||||
@Override
|
@Override
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
TagScopePropertyMethodInterceptor.setEnabled(Boolean.TRUE);
|
TagScopePropertyMethodInterceptor.setEnabled(Boolean.TRUE);
|
||||||
|
|
||||||
Serializable summaryObj = nodeService.getProperty(folder, ContentModel.PROP_TAGSCOPE_SUMMARY);
|
Serializable summaryObj = nodeService.getProperty(folder, ContentModel.PROP_TAGSCOPE_SUMMARY);
|
||||||
assertTrue("TagScopeSummary value on main folder is not of correct class: " + summaryObj.getClass().getName(),
|
assertTrue("TagScopeSummary value on main folder is not of correct class: " + summaryObj.getClass().getName(),
|
||||||
List.class.isAssignableFrom(summaryObj.getClass()));
|
List.class.isAssignableFrom(summaryObj.getClass()));
|
||||||
assertEquals(3, ((List)summaryObj).size());
|
assertEquals(3, ((List)summaryObj).size());
|
||||||
|
|
||||||
//Check that the next call for the same summary comes from the cache
|
//Check that the next call for the same summary comes from the cache
|
||||||
Serializable summaryObj2 = nodeService.getProperty(folder, ContentModel.PROP_TAGSCOPE_SUMMARY);
|
Serializable summaryObj2 = nodeService.getProperty(folder, ContentModel.PROP_TAGSCOPE_SUMMARY);
|
||||||
assertTrue("TagScopeSummary value on main folder did not come from the cache",
|
assertTrue("TagScopeSummary value on main folder did not come from the cache",
|
||||||
summaryObj == summaryObj2);
|
summaryObj == summaryObj2);
|
||||||
|
|
||||||
Map<QName,Serializable> props = nodeService.getProperties(subFolder);
|
Map<QName,Serializable> props = nodeService.getProperties(subFolder);
|
||||||
assertTrue("Properties of subfolder do not include tagScopeSummary", props.containsKey(ContentModel.PROP_TAGSCOPE_SUMMARY));
|
assertTrue("Properties of subfolder do not include tagScopeSummary", props.containsKey(ContentModel.PROP_TAGSCOPE_SUMMARY));
|
||||||
summaryObj = props.get(ContentModel.PROP_TAGSCOPE_SUMMARY);
|
summaryObj = props.get(ContentModel.PROP_TAGSCOPE_SUMMARY);
|
||||||
assertTrue("TagScopeSummary value on subfolder is not of correct class: " + summaryObj.getClass().getName(),
|
assertTrue("TagScopeSummary value on subfolder is not of correct class: " + summaryObj.getClass().getName(),
|
||||||
List.class.isAssignableFrom(summaryObj.getClass()));
|
List.class.isAssignableFrom(summaryObj.getClass()));
|
||||||
assertEquals(3, ((List)summaryObj).size());
|
assertEquals(3, ((List)summaryObj).size());
|
||||||
|
|
||||||
TagScopePropertyMethodInterceptor.setEnabled(Boolean.FALSE);
|
TagScopePropertyMethodInterceptor.setEnabled(Boolean.FALSE);
|
||||||
|
|
||||||
summaryObj = nodeService.getProperty(folder, ContentModel.PROP_TAGSCOPE_SUMMARY);
|
summaryObj = nodeService.getProperty(folder, ContentModel.PROP_TAGSCOPE_SUMMARY);
|
||||||
assertNull("TagScopeSummary value on main folder should be null: " + summaryObj,
|
assertNull("TagScopeSummary value on main folder should be null: " + summaryObj,
|
||||||
summaryObj);
|
summaryObj);
|
||||||
|
|
||||||
props = nodeService.getProperties(subFolder);
|
props = nodeService.getProperties(subFolder);
|
||||||
assertFalse("Properties of subfolder should not contain tagScopeProperty", props.containsKey(ContentModel.PROP_TAGSCOPE_SUMMARY));
|
assertFalse("Properties of subfolder should not contain tagScopeProperty", props.containsKey(ContentModel.PROP_TAGSCOPE_SUMMARY));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -840,7 +829,7 @@ public class TaggingServiceImplTest
|
|||||||
@Test
|
@Test
|
||||||
@Category({RedundantTests.class,LuceneTests.class})
|
@Category({RedundantTests.class,LuceneTests.class})
|
||||||
public void test6TagScopeRefresh()
|
public void test6TagScopeRefresh()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
|
this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
|
||||||
{
|
{
|
||||||
@@ -896,7 +885,7 @@ public class TaggingServiceImplTest
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test7TagScopeSetUpdate()
|
public void test7TagScopeSetUpdate()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
asyncOccurs.awaitExecution(new RetryingTransactionCallback<Void>()
|
asyncOccurs.awaitExecution(new RetryingTransactionCallback<Void>()
|
||||||
{
|
{
|
||||||
@@ -1165,12 +1154,12 @@ public class TaggingServiceImplTest
|
|||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Unexpected tags " + taggingService.findTagScope(testData.container1).getTags(),
|
"Unexpected tags " + taggingService.findTagScope(testData.container1).getTags(),
|
||||||
2, taggingService.findTagScope(testData.container1).getTags().size()
|
2, taggingService.findTagScope(testData.container1).getTags().size()
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Unexpected tags " + taggingService.findTagScope(testData.container2).getTags(),
|
"Unexpected tags " + taggingService.findTagScope(testData.container2).getTags(),
|
||||||
0, taggingService.findTagScope(testData.container2).getTags().size()
|
0, taggingService.findTagScope(testData.container2).getTags().size()
|
||||||
);
|
);
|
||||||
|
|
||||||
assertEquals(1, taggingService.findTagScope(testData.container1).getTag("foo1").getCount());
|
assertEquals(1, taggingService.findTagScope(testData.container1).getTag("foo1").getCount());
|
||||||
@@ -1263,11 +1252,11 @@ public class TaggingServiceImplTest
|
|||||||
taggedDocProps.put(ContentModel.PROP_NAME, "CopyDoc");
|
taggedDocProps.put(ContentModel.PROP_NAME, "CopyDoc");
|
||||||
assertEquals(0, nodeService.getChildAssocs(testData.container2).size());
|
assertEquals(0, nodeService.getChildAssocs(testData.container2).size());
|
||||||
testData.taggedDoc2 = nodeService.createNode(
|
testData.taggedDoc2 = nodeService.createNode(
|
||||||
testData.container2,
|
testData.container2,
|
||||||
ContentModel.ASSOC_CONTAINS,
|
ContentModel.ASSOC_CONTAINS,
|
||||||
ContentModel.ASPECT_TAGGABLE,
|
ContentModel.ASPECT_TAGGABLE,
|
||||||
ContentModel.TYPE_CONTENT,
|
ContentModel.TYPE_CONTENT,
|
||||||
taggedDocProps).getChildRef();
|
taggedDocProps).getChildRef();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1315,10 +1304,10 @@ public class TaggingServiceImplTest
|
|||||||
// Copy the folder to another container
|
// Copy the folder to another container
|
||||||
// Does a proper, recursing copy
|
// Does a proper, recursing copy
|
||||||
testData.taggedFolder2 = copyService.copy(
|
testData.taggedFolder2 = copyService.copy(
|
||||||
testData.taggedFolder, testData.container2,
|
testData.taggedFolder, testData.container2,
|
||||||
ContentModel.ASSOC_CONTAINS,
|
ContentModel.ASSOC_CONTAINS,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
true);
|
true);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1370,8 +1359,8 @@ public class TaggingServiceImplTest
|
|||||||
|
|
||||||
// Move the document to another container
|
// Move the document to another container
|
||||||
testData.taggedDoc = nodeService.moveNode(testData.taggedDoc, testData.container2,
|
testData.taggedDoc = nodeService.moveNode(testData.taggedDoc, testData.container2,
|
||||||
ContentModel.ASSOC_CONTAINS,
|
ContentModel.ASSOC_CONTAINS,
|
||||||
ContentModel.ASPECT_TAGGABLE).getChildRef();
|
ContentModel.ASPECT_TAGGABLE).getChildRef();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1511,75 +1500,75 @@ public class TaggingServiceImplTest
|
|||||||
@Override
|
@Override
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
// Create a user
|
// Create a user
|
||||||
if(authenticationService.authenticationExists(USER_1))
|
if(authenticationService.authenticationExists(USER_1))
|
||||||
authenticationService.deleteAuthentication(USER_1);
|
authenticationService.deleteAuthentication(USER_1);
|
||||||
if(personService.personExists(USER_1))
|
if(personService.personExists(USER_1))
|
||||||
personService.deletePerson(USER_1);
|
personService.deletePerson(USER_1);
|
||||||
|
|
||||||
authenticationService.createAuthentication(USER_1, "PWD".toCharArray());
|
authenticationService.createAuthentication(USER_1, "PWD".toCharArray());
|
||||||
PropertyMap personProperties = new PropertyMap();
|
PropertyMap personProperties = new PropertyMap();
|
||||||
personProperties.put(ContentModel.PROP_USERNAME, USER_1);
|
personProperties.put(ContentModel.PROP_USERNAME, USER_1);
|
||||||
personProperties.put(ContentModel.PROP_AUTHORITY_DISPLAY_NAME, "title" + USER_1);
|
personProperties.put(ContentModel.PROP_AUTHORITY_DISPLAY_NAME, "title" + USER_1);
|
||||||
personProperties.put(ContentModel.PROP_FIRSTNAME, "firstName");
|
personProperties.put(ContentModel.PROP_FIRSTNAME, "firstName");
|
||||||
personProperties.put(ContentModel.PROP_LASTNAME, "lastName");
|
personProperties.put(ContentModel.PROP_LASTNAME, "lastName");
|
||||||
personProperties.put(ContentModel.PROP_EMAIL, USER_1+"@example.com");
|
personProperties.put(ContentModel.PROP_EMAIL, USER_1+"@example.com");
|
||||||
personProperties.put(ContentModel.PROP_JOBTITLE, "jobTitle");
|
personProperties.put(ContentModel.PROP_JOBTITLE, "jobTitle");
|
||||||
personService.createPerson(personProperties);
|
personService.createPerson(personProperties);
|
||||||
|
|
||||||
|
|
||||||
// Give that user permissions on the tagging category root, so
|
// Give that user permissions on the tagging category root, so
|
||||||
// they're allowed to add new tags
|
// they're allowed to add new tags
|
||||||
NodeRef tn = taggingService.createTag(folder.getStoreRef(), "Testing");
|
NodeRef tn = taggingService.createTag(folder.getStoreRef(), "Testing");
|
||||||
NodeRef tr = nodeService.getPrimaryParent(tn).getParentRef();
|
NodeRef tr = nodeService.getPrimaryParent(tn).getParentRef();
|
||||||
permissionService.setPermission(tr, USER_1, PermissionService.EDITOR, true);
|
permissionService.setPermission(tr, USER_1, PermissionService.EDITOR, true);
|
||||||
permissionService.setPermission(tr, USER_1, PermissionService.CONTRIBUTOR, true);
|
permissionService.setPermission(tr, USER_1, PermissionService.CONTRIBUTOR, true);
|
||||||
|
|
||||||
|
|
||||||
// Create a folder with a tag scope on it + auditable aspect
|
// Create a folder with a tag scope on it + auditable aspect
|
||||||
// User can read but not write
|
// User can read but not write
|
||||||
authenticationComponent.setSystemUserAsCurrentUser();
|
authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
testData.auditableFolder = nodeService.createNode(
|
testData.auditableFolder = nodeService.createNode(
|
||||||
folder, ContentModel.ASSOC_CONTAINS,
|
folder, ContentModel.ASSOC_CONTAINS,
|
||||||
QName.createQName("Folder"), ContentModel.TYPE_FOLDER
|
QName.createQName("Folder"), ContentModel.TYPE_FOLDER
|
||||||
).getChildRef();
|
).getChildRef();
|
||||||
nodeService.addAspect(testData.auditableFolder, ContentModel.ASPECT_AUDITABLE, null);
|
nodeService.addAspect(testData.auditableFolder, ContentModel.ASPECT_AUDITABLE, null);
|
||||||
taggingService.addTagScope(testData.auditableFolder);
|
taggingService.addTagScope(testData.auditableFolder);
|
||||||
permissionService.setPermission(testData.auditableFolder, USER_1, PermissionService.CONSUMER, true);
|
permissionService.setPermission(testData.auditableFolder, USER_1, PermissionService.CONSUMER, true);
|
||||||
|
|
||||||
// Auditable checks
|
// Auditable checks
|
||||||
assertEquals("System", nodeService.getProperty(testData.auditableFolder, ContentModel.PROP_CREATOR));
|
assertEquals("System", nodeService.getProperty(testData.auditableFolder, ContentModel.PROP_CREATOR));
|
||||||
assertEquals("System", nodeService.getProperty(testData.auditableFolder, ContentModel.PROP_MODIFIER));
|
assertEquals("System", nodeService.getProperty(testData.auditableFolder, ContentModel.PROP_MODIFIER));
|
||||||
|
|
||||||
|
|
||||||
// Create a node without tags, which the user
|
// Create a node without tags, which the user
|
||||||
// can write to
|
// can write to
|
||||||
testData.taggedNode = nodeService.createNode(
|
testData.taggedNode = nodeService.createNode(
|
||||||
testData.auditableFolder, ContentModel.ASSOC_CONTAINS,
|
testData.auditableFolder, ContentModel.ASSOC_CONTAINS,
|
||||||
QName.createQName("Tagged"), ContentModel.TYPE_CONTENT
|
QName.createQName("Tagged"), ContentModel.TYPE_CONTENT
|
||||||
).getChildRef();
|
).getChildRef();
|
||||||
permissionService.setPermission(testData.taggedNode, USER_1, PermissionService.EDITOR, true);
|
permissionService.setPermission(testData.taggedNode, USER_1, PermissionService.EDITOR, true);
|
||||||
|
|
||||||
|
|
||||||
// Tag the node as the user
|
// Tag the node as the user
|
||||||
authenticationComponent.setCurrentUser(USER_1);
|
authenticationComponent.setCurrentUser(USER_1);
|
||||||
assertEquals(0, taggingService.getTags(testData.taggedNode).size());
|
assertEquals(0, taggingService.getTags(testData.taggedNode).size());
|
||||||
|
|
||||||
nodeService.setProperty(testData.taggedNode, ContentModel.PROP_TITLE, "To ensure we're allowed to write");
|
nodeService.setProperty(testData.taggedNode, ContentModel.PROP_TITLE, "To ensure we're allowed to write");
|
||||||
|
|
||||||
taggingService.addTag(testData.taggedNode, TAG_1);
|
taggingService.addTag(testData.taggedNode, TAG_1);
|
||||||
taggingService.addTag(testData.taggedNode, TAG_2);
|
taggingService.addTag(testData.taggedNode, TAG_2);
|
||||||
assertEquals(2, taggingService.getTags(testData.taggedNode).size());
|
assertEquals(2, taggingService.getTags(testData.taggedNode).size());
|
||||||
|
|
||||||
|
|
||||||
// Ensure the folder tag scope got the update
|
// Ensure the folder tag scope got the update
|
||||||
TagScope ts = taggingService.findTagScope(testData.taggedNode);
|
TagScope ts = taggingService.findTagScope(testData.taggedNode);
|
||||||
assertEquals(testData.auditableFolder, ts.getNodeRef());
|
assertEquals(testData.auditableFolder, ts.getNodeRef());
|
||||||
assertEquals(0, ts.getTags().size());
|
assertEquals(0, ts.getTags().size());
|
||||||
|
|
||||||
assertEquals("System", nodeService.getProperty(testData.auditableFolder, ContentModel.PROP_CREATOR));
|
assertEquals("System", nodeService.getProperty(testData.auditableFolder, ContentModel.PROP_CREATOR));
|
||||||
assertEquals("System", nodeService.getProperty(ts.getNodeRef(), ContentModel.PROP_MODIFIER));
|
assertEquals("System", nodeService.getProperty(ts.getNodeRef(), ContentModel.PROP_MODIFIER));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Due to timestamp propagation, we need to start a new transaction to get the current folder modified date
|
// Due to timestamp propagation, we need to start a new transaction to get the current folder modified date
|
||||||
@@ -1597,22 +1586,22 @@ public class TaggingServiceImplTest
|
|||||||
@Override
|
@Override
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
TagScope ts = taggingService.findTagScope(testData.taggedNode);
|
TagScope ts = taggingService.findTagScope(testData.taggedNode);
|
||||||
assertEquals(testData.auditableFolder, ts.getNodeRef());
|
assertEquals(testData.auditableFolder, ts.getNodeRef());
|
||||||
assertEquals(2, ts.getTags().size());
|
assertEquals(2, ts.getTags().size());
|
||||||
assertEquals(1, ts.getTag(TAG_1).getCount());
|
assertEquals(1, ts.getTag(TAG_1).getCount());
|
||||||
assertEquals(1, ts.getTag(TAG_2).getCount());
|
assertEquals(1, ts.getTag(TAG_2).getCount());
|
||||||
|
|
||||||
// Ensure the auditable flags on the folder are unchanged
|
// Ensure the auditable flags on the folder are unchanged
|
||||||
assertEquals("System", nodeService.getProperty(testData.auditableFolder, ContentModel.PROP_CREATOR));
|
assertEquals("System", nodeService.getProperty(testData.auditableFolder, ContentModel.PROP_CREATOR));
|
||||||
assertEquals("System", nodeService.getProperty(ts.getNodeRef(), ContentModel.PROP_MODIFIER));
|
assertEquals("System", nodeService.getProperty(ts.getNodeRef(), ContentModel.PROP_MODIFIER));
|
||||||
assertEquals(testData.origModified.getTime(), ((Date)nodeService.getProperty(testData.auditableFolder, ContentModel.PROP_MODIFIED)).getTime());
|
assertEquals(testData.origModified.getTime(), ((Date)nodeService.getProperty(testData.auditableFolder, ContentModel.PROP_MODIFIED)).getTime());
|
||||||
|
|
||||||
// Tidy up
|
// Tidy up
|
||||||
authenticationComponent.setSystemUserAsCurrentUser();
|
authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
authenticationService.deleteAuthentication(USER_1);
|
authenticationService.deleteAuthentication(USER_1);
|
||||||
personService.deletePerson(USER_1);
|
personService.deletePerson(USER_1);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1627,18 +1616,18 @@ public class TaggingServiceImplTest
|
|||||||
@Override
|
@Override
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
Map<String, Object> model = new HashMap<String, Object>(0);
|
Map<String, Object> model = new HashMap<String, Object>(0);
|
||||||
model.put("folder", folder);
|
model.put("folder", folder);
|
||||||
model.put("subFolder", subFolder);
|
model.put("subFolder", subFolder);
|
||||||
model.put("document", document);
|
model.put("document", document);
|
||||||
model.put("subDocument", subDocument);
|
model.put("subDocument", subDocument);
|
||||||
model.put("tagScopeTest", false);
|
model.put("tagScopeTest", false);
|
||||||
|
|
||||||
ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/tagging/script/test_taggingService.js");
|
ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/tagging/script/test_taggingService.js");
|
||||||
scriptService.executeScript(location, model);
|
scriptService.executeScript(location, model);
|
||||||
|
|
||||||
// Let the script run
|
// Let the script run
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1760,7 +1749,7 @@ public class TaggingServiceImplTest
|
|||||||
@Test
|
@Test
|
||||||
public void test93OnStartupJob() throws Exception
|
public void test93OnStartupJob() throws Exception
|
||||||
{
|
{
|
||||||
final UpdateTagScopesActionExecuter updateTagsAction = (UpdateTagScopesActionExecuter) ctx
|
final UpdateTagScopesActionExecuter updateTagsAction = (UpdateTagScopesActionExecuter) applicationContext
|
||||||
.getBean("update-tagscope");
|
.getBean("update-tagscope");
|
||||||
class TestData
|
class TestData
|
||||||
{
|
{
|
||||||
@@ -1805,12 +1794,12 @@ public class TaggingServiceImplTest
|
|||||||
TagScope ts1 = taggingService.findTagScope(folder);
|
TagScope ts1 = taggingService.findTagScope(folder);
|
||||||
TagScope ts2 = taggingService.findTagScope(subFolder);
|
TagScope ts2 = taggingService.findTagScope(subFolder);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Wrong tags on folder tagscope: " + ts1.getTags(),
|
"Wrong tags on folder tagscope: " + ts1.getTags(),
|
||||||
0, ts1.getTags().size()
|
0, ts1.getTags().size()
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Wrong tags on folder tagscope: " + ts1.getTags(),
|
"Wrong tags on folder tagscope: " + ts1.getTags(),
|
||||||
0, ts2.getTags().size()
|
0, ts2.getTags().size()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -1869,12 +1858,12 @@ public class TaggingServiceImplTest
|
|||||||
TagScope ts1 = taggingService.findTagScope(folder);
|
TagScope ts1 = taggingService.findTagScope(folder);
|
||||||
TagScope ts2 = taggingService.findTagScope(subFolder);
|
TagScope ts2 = taggingService.findTagScope(subFolder);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Wrong tags on folder tagscope: " + ts1.getTags(),
|
"Wrong tags on folder tagscope: " + ts1.getTags(),
|
||||||
3, ts1.getTags().size()
|
3, ts1.getTags().size()
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Wrong tags on folder tagscope: " + ts1.getTags(),
|
"Wrong tags on folder tagscope: " + ts1.getTags(),
|
||||||
2, ts2.getTags().size()
|
2, ts2.getTags().size()
|
||||||
);
|
);
|
||||||
|
|
||||||
assertEquals(4, ts1.getTag(TAG_1).getCount());
|
assertEquals(4, ts1.getTag(TAG_1).getCount());
|
||||||
@@ -1935,7 +1924,7 @@ public class TaggingServiceImplTest
|
|||||||
logger.debug(Thread.currentThread() + " - About to start tagging for " + tag);
|
logger.debug(Thread.currentThread() + " - About to start tagging for " + tag);
|
||||||
|
|
||||||
// Do the updates
|
// Do the updates
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
||||||
RetryingTransactionCallback<Void> txnCallback = new RetryingTransactionCallback<Void>()
|
RetryingTransactionCallback<Void> txnCallback = new RetryingTransactionCallback<Void>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -1961,7 +1950,7 @@ public class TaggingServiceImplTest
|
|||||||
// Wait briefly for thing to catch up, before we
|
// Wait briefly for thing to catch up, before we
|
||||||
// declare ourselves to be done
|
// declare ourselves to be done
|
||||||
try {
|
try {
|
||||||
Thread.sleep(150);
|
Thread.sleep(150);
|
||||||
} catch (InterruptedException e) {}
|
} catch (InterruptedException e) {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1995,32 +1984,32 @@ public class TaggingServiceImplTest
|
|||||||
// shows none of them running either
|
// shows none of them running either
|
||||||
for (int i = 0; i < 600; i++)
|
for (int i = 0; i < 600; i++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(asyncOccurs.wantedActionsCount < tags.length)
|
if(asyncOccurs.wantedActionsCount < tags.length)
|
||||||
{
|
{
|
||||||
if(i%50 == 0)
|
if(i%50 == 0)
|
||||||
{
|
{
|
||||||
logger.info("Done " + asyncOccurs.wantedActionsCount + " of " + tags.length);
|
logger.info("Done " + asyncOccurs.wantedActionsCount + " of " + tags.length);
|
||||||
}
|
}
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (actionTrackingService.getAllExecutingActions().size() > 0)
|
if (actionTrackingService.getAllExecutingActions().size() > 0)
|
||||||
{
|
{
|
||||||
if(i%50 == 0)
|
if(i%50 == 0)
|
||||||
{
|
{
|
||||||
List<ExecutionSummary> actions = actionTrackingService.getAllExecutingActions();
|
List<ExecutionSummary> actions = actionTrackingService.getAllExecutingActions();
|
||||||
logger.info("Waiting on " + actions.size() + " actions: " + actions);
|
logger.info("Waiting on " + actions.size() + " actions: " + actions);
|
||||||
}
|
}
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra sleep just to be sure things are quiet before we continue
|
// Extra sleep just to be sure things are quiet before we continue
|
||||||
@@ -2035,100 +2024,100 @@ public class TaggingServiceImplTest
|
|||||||
@Override
|
@Override
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
TagScope ts1 = taggingService.findTagScope(folder);
|
TagScope ts1 = taggingService.findTagScope(folder);
|
||||||
TagScope ts2 = taggingService.findTagScope(subFolder);
|
TagScope ts2 = taggingService.findTagScope(subFolder);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Wrong tags on folder tagscope: " + ts1.getTags(),
|
"Wrong tags on folder tagscope: " + ts1.getTags(),
|
||||||
tags.length, ts1.getTags().size()
|
tags.length, ts1.getTags().size()
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Wrong tags on subfolder tagscope: " + ts2.getTags(),
|
"Wrong tags on subfolder tagscope: " + ts2.getTags(),
|
||||||
tags.length, ts2.getTags().size()
|
tags.length, ts2.getTags().size()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Each tag should crop up 3 times on the folder
|
// Each tag should crop up 3 times on the folder
|
||||||
// and twice for the subfolder
|
// and twice for the subfolder
|
||||||
for (String tag : tags)
|
for (String tag : tags)
|
||||||
{
|
{
|
||||||
assertEquals(3, ts1.getTag(tag.toLowerCase()).getCount());
|
assertEquals(3, ts1.getTag(tag.toLowerCase()).getCount());
|
||||||
assertEquals(2, ts2.getTag(tag.toLowerCase()).getCount());
|
assertEquals(2, ts2.getTag(tag.toLowerCase()).getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
// All done
|
// All done
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class AsyncOccurs implements OnAsyncActionExecute {
|
public class AsyncOccurs implements OnAsyncActionExecute {
|
||||||
private Object waitForExecutionLock = new Object();
|
private Object waitForExecutionLock = new Object();
|
||||||
private static final long waitTime = 3500;
|
private static final long waitTime = 3500;
|
||||||
private static final String ACTION_TYPE = UpdateTagScopesActionExecuter.NAME;
|
private static final String ACTION_TYPE = UpdateTagScopesActionExecuter.NAME;
|
||||||
|
|
||||||
private int wantedActionsCount = 0;
|
private int wantedActionsCount = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAsyncActionExecute(Action action, NodeRef actionedUponNodeRef)
|
public void onAsyncActionExecute(Action action, NodeRef actionedUponNodeRef)
|
||||||
{
|
{
|
||||||
if(action.getActionDefinitionName().equals(ACTION_TYPE))
|
if(action.getActionDefinitionName().equals(ACTION_TYPE))
|
||||||
{
|
|
||||||
wantedActionsCount++;
|
|
||||||
synchronized (waitForExecutionLock) {
|
|
||||||
try {
|
|
||||||
waitForExecutionLock.notify();
|
|
||||||
} catch(IllegalMonitorStateException e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println("Ignoring unexpected async action:" + action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> T awaitExecution(RetryingTransactionCallback<T> callback) throws Exception
|
|
||||||
{
|
|
||||||
T returnVal = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
|
||||||
|
|
||||||
synchronized (waitForExecutionLock) {
|
|
||||||
|
|
||||||
// Always wait 100ms
|
|
||||||
waitForExecutionLock.wait(100);
|
|
||||||
|
|
||||||
// If there are actions if the required type
|
|
||||||
// currently running, keep waiting longer for
|
|
||||||
// them to finish
|
|
||||||
if(actionTrackingService.getExecutingActions(ACTION_TYPE).size() > 0)
|
|
||||||
{
|
{
|
||||||
long now = System.currentTimeMillis();
|
wantedActionsCount++;
|
||||||
waitForExecutionLock.wait(waitTime);
|
synchronized (waitForExecutionLock) {
|
||||||
|
try {
|
||||||
if(System.currentTimeMillis() - now >= waitTime)
|
waitForExecutionLock.notify();
|
||||||
{
|
} catch(IllegalMonitorStateException e) {}
|
||||||
System.err.println("Warning - trigger wasn't received");
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
System.out.println("Ignoring unexpected async action:" + action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If there are any more actions of the same type,
|
public <T> T awaitExecution(RetryingTransactionCallback<T> callback) throws Exception
|
||||||
// then wait for them to finish too
|
{
|
||||||
for(int i=0; i<100; i++)
|
T returnVal = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||||
{
|
|
||||||
if( actionTrackingService.getExecutingActions(ACTION_TYPE).size() == 0 )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch(InterruptedException e) {}
|
|
||||||
}
|
|
||||||
if (actionTrackingService.getExecutingActions(ACTION_TYPE).size() > 0)
|
|
||||||
{
|
|
||||||
System.err.println("Warning - not all actions finished");
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnVal;
|
synchronized (waitForExecutionLock) {
|
||||||
}
|
|
||||||
|
// Always wait 100ms
|
||||||
|
waitForExecutionLock.wait(100);
|
||||||
|
|
||||||
|
// If there are actions if the required type
|
||||||
|
// currently running, keep waiting longer for
|
||||||
|
// them to finish
|
||||||
|
if(actionTrackingService.getExecutingActions(ACTION_TYPE).size() > 0)
|
||||||
|
{
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
waitForExecutionLock.wait(waitTime);
|
||||||
|
|
||||||
|
if(System.currentTimeMillis() - now >= waitTime)
|
||||||
|
{
|
||||||
|
System.err.println("Warning - trigger wasn't received");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there are any more actions of the same type,
|
||||||
|
// then wait for them to finish too
|
||||||
|
for(int i=0; i<100; i++)
|
||||||
|
{
|
||||||
|
if( actionTrackingService.getExecutingActions(ACTION_TYPE).size() == 0 )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch(InterruptedException e) {}
|
||||||
|
}
|
||||||
|
if (actionTrackingService.getExecutingActions(ACTION_TYPE).size() > 0)
|
||||||
|
{
|
||||||
|
System.err.println("Warning - not all actions finished");
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2192,7 +2181,7 @@ public class TaggingServiceImplTest
|
|||||||
nodeService.deleteNode(folder2);
|
nodeService.deleteNode(folder2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2289,8 +2278,8 @@ public class TaggingServiceImplTest
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
taggingService.changeTag(storeRef, null, null);
|
taggingService.changeTag(storeRef, null, null);
|
||||||
fail("Should throw exception");
|
fail("Should throw exception");
|
||||||
}
|
}
|
||||||
catch (TaggingException tae)
|
catch (TaggingException tae)
|
||||||
{
|
{
|
||||||
@@ -2490,7 +2479,7 @@ public class TaggingServiceImplTest
|
|||||||
|
|
||||||
// STEP5 start job taggingStartupJobDetail
|
// STEP5 start job taggingStartupJobDetail
|
||||||
// Fire off the quartz bean, this time it can really work
|
// Fire off the quartz bean, this time it can really work
|
||||||
final UpdateTagScopesActionExecuter updateTagsAction = (UpdateTagScopesActionExecuter) ctx.getBean("update-tagscope");
|
final UpdateTagScopesActionExecuter updateTagsAction = (UpdateTagScopesActionExecuter) applicationContext.getBean("update-tagscope");
|
||||||
UpdateTagScopesQuartzJob job = new UpdateTagScopesQuartzJob();
|
UpdateTagScopesQuartzJob job = new UpdateTagScopesQuartzJob();
|
||||||
job.execute(actionService, updateTagsAction);
|
job.execute(actionService, updateTagsAction);
|
||||||
|
|
||||||
|
@@ -31,8 +31,6 @@ import java.io.StringWriter;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.dictionary.DictionaryComponent;
|
import org.alfresco.repo.dictionary.DictionaryComponent;
|
||||||
import org.alfresco.repo.dictionary.DictionaryDAO;
|
import org.alfresco.repo.dictionary.DictionaryDAO;
|
||||||
@@ -41,7 +39,6 @@ import org.alfresco.repo.node.BaseNodeServiceTest;
|
|||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
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;
|
||||||
@@ -50,20 +47,18 @@ import org.alfresco.service.cmr.repository.TemplateService;
|
|||||||
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.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.junit.After;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.Before;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.junit.Test;
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Kevin Roast
|
* @author Kevin Roast
|
||||||
*/
|
*/
|
||||||
@Category(OwnJVMTestsCategory.class)
|
public class TemplateServiceImplTest extends BaseSpringTest
|
||||||
public class TemplateServiceImplTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private static final String TEMPLATE_1 = "org/alfresco/repo/template/test_template1.ftl";
|
private static final String TEMPLATE_1 = "org/alfresco/repo/template/test_template1.ftl";
|
||||||
private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
private NodeRef root_node;
|
private NodeRef root_node;
|
||||||
|
|
||||||
private TemplateService templateService;
|
private TemplateService templateService;
|
||||||
@@ -72,22 +67,18 @@ public class TemplateServiceImplTest extends TestCase
|
|||||||
private ServiceRegistry serviceRegistry;
|
private ServiceRegistry serviceRegistry;
|
||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
|
|
||||||
/*
|
@Before
|
||||||
* @see junit.framework.TestCase#setUp()
|
public void setUp() throws Exception
|
||||||
*/
|
|
||||||
protected void setUp() throws Exception
|
|
||||||
{
|
{
|
||||||
super.setUp();
|
transactionService = (TransactionService)applicationContext.getBean("transactionComponent");
|
||||||
|
nodeService = (NodeService)applicationContext.getBean("nodeService");
|
||||||
|
templateService = (TemplateService)applicationContext.getBean("templateService");
|
||||||
|
serviceRegistry = (ServiceRegistry)applicationContext.getBean("ServiceRegistry");
|
||||||
|
|
||||||
transactionService = (TransactionService)ctx.getBean("transactionComponent");
|
this.authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
|
||||||
nodeService = (NodeService)ctx.getBean("nodeService");
|
|
||||||
templateService = (TemplateService)ctx.getBean("templateService");
|
|
||||||
serviceRegistry = (ServiceRegistry)ctx.getBean("ServiceRegistry");
|
|
||||||
|
|
||||||
this.authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent");
|
|
||||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
this.authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
|
|
||||||
DictionaryDAO dictionaryDao = (DictionaryDAO)ctx.getBean("dictionaryDAO");
|
DictionaryDAO dictionaryDao = (DictionaryDAO)applicationContext.getBean("dictionaryDAO");
|
||||||
|
|
||||||
// load the system model
|
// load the system model
|
||||||
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
|
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
|
||||||
@@ -104,7 +95,7 @@ public class TemplateServiceImplTest extends TestCase
|
|||||||
|
|
||||||
DictionaryComponent dictionary = new DictionaryComponent();
|
DictionaryComponent dictionary = new DictionaryComponent();
|
||||||
dictionary.setDictionaryDAO(dictionaryDao);
|
dictionary.setDictionaryDAO(dictionaryDao);
|
||||||
BaseNodeServiceTest.loadModel(ctx);
|
BaseNodeServiceTest.loadModel(applicationContext);
|
||||||
|
|
||||||
transactionService.getRetryingTransactionHelper().doInTransaction(
|
transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||||
new RetryingTransactionCallback<Object>()
|
new RetryingTransactionCallback<Object>()
|
||||||
@@ -117,21 +108,21 @@ public class TemplateServiceImplTest extends TestCase
|
|||||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(11);
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(11);
|
||||||
properties.put(ContentModel.PROP_NAME, (Serializable) "subFolder");
|
properties.put(ContentModel.PROP_NAME, (Serializable) "subFolder");
|
||||||
NodeRef subFolderRef = nodeService.createNode(
|
NodeRef subFolderRef = nodeService.createNode(
|
||||||
root_node,
|
root_node,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,QName.createValidLocalName("subFolder")),
|
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,QName.createValidLocalName("subFolder")),
|
||||||
ContentModel.TYPE_FOLDER,
|
ContentModel.TYPE_FOLDER,
|
||||||
properties).getChildRef();
|
properties).getChildRef();
|
||||||
properties.put(ContentModel.PROP_NAME, (Serializable) "subSubFolder");
|
properties.put(ContentModel.PROP_NAME, (Serializable) "subSubFolder");
|
||||||
NodeRef subSubFolderRef =nodeService.createNode(
|
NodeRef subSubFolderRef =nodeService.createNode(
|
||||||
subFolderRef,
|
subFolderRef,
|
||||||
ContentModel.ASSOC_CONTAINS,
|
ContentModel.ASSOC_CONTAINS,
|
||||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,QName.createValidLocalName("subSubFolder")),
|
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,QName.createValidLocalName("subSubFolder")),
|
||||||
ContentModel.TYPE_FOLDER,
|
ContentModel.TYPE_FOLDER,
|
||||||
properties).getChildRef();
|
properties).getChildRef();
|
||||||
properties.put(ContentModel.PROP_NAME, (Serializable) "subSubSubFolder");
|
properties.put(ContentModel.PROP_NAME, (Serializable) "subSubSubFolder");
|
||||||
nodeService.createNode(
|
nodeService.createNode(
|
||||||
subSubFolderRef,
|
subSubFolderRef,
|
||||||
ContentModel.ASSOC_CONTAINS,
|
ContentModel.ASSOC_CONTAINS,
|
||||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,QName.createValidLocalName("subSubSubFolder")),
|
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,QName.createValidLocalName("subSubSubFolder")),
|
||||||
ContentModel.TYPE_FOLDER,
|
ContentModel.TYPE_FOLDER,
|
||||||
@@ -142,39 +133,40 @@ public class TemplateServiceImplTest extends TestCase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@After
|
||||||
protected void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
authenticationComponent.clearCurrentSecurityContext();
|
authenticationComponent.clearCurrentSecurityContext();
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testTemplates()
|
public void testTemplates()
|
||||||
{
|
{
|
||||||
transactionService.getRetryingTransactionHelper().doInTransaction(
|
transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||||
new RetryingTransactionCallback<Object>()
|
new RetryingTransactionCallback<Object>()
|
||||||
{
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public Object execute() throws Exception
|
|
||||||
{
|
{
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Object execute() throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
// check the default template engine exists
|
// check the default template engine exists
|
||||||
assertNotNull(templateService.getTemplateProcessor("freemarker"));
|
assertNotNull(templateService.getTemplateProcessor("freemarker"));
|
||||||
Map model = createTemplateModel(root_node);
|
Map model = createTemplateModel(root_node);
|
||||||
|
|
||||||
// execute on test template
|
// execute on test template
|
||||||
String output = templateService.processTemplate("freemarker", TEMPLATE_1, model);
|
String output = templateService.processTemplate("freemarker", TEMPLATE_1, model);
|
||||||
|
|
||||||
// check template contains the expected output
|
// check template contains the expected output
|
||||||
assertTrue("Cannot find root-node-id", (output.indexOf(root_node.getId()) != -1) );
|
assertTrue("Cannot find root-node-id", (output.indexOf(root_node.getId()) != -1) );
|
||||||
assertTrue("Cannot resolve subFolder properly", (output.indexOf("root.childByNamePath[\"subFolder\"].name=subFolder") != -1) );
|
assertTrue("Cannot resolve subFolder properly", (output.indexOf("root.childByNamePath[\"subFolder\"].name=subFolder") != -1) );
|
||||||
assertTrue("Cannot resolve subSubFolder properly", (output.indexOf("root.childByNamePath[\"subFolder/subSubFolder\"].name=subSubFolder") != -1) );
|
assertTrue("Cannot resolve subSubFolder properly", (output.indexOf("root.childByNamePath[\"subFolder/subSubFolder\"].name=subSubFolder") != -1) );
|
||||||
assertTrue("Cannot resolve subSubSubFolder properly", (output.indexOf("root.childByNamePath[\"subFolder/subSubFolder/subSubSubFolder\"].name=subSubSubFolder") != -1) );
|
assertTrue("Cannot resolve subSubSubFolder properly", (output.indexOf("root.childByNamePath[\"subFolder/subSubFolder/subSubSubFolder\"].name=subSubSubFolder") != -1) );
|
||||||
assertTrue("Cannot resolve subSubSubFolder with enhancement properly", (output.indexOf("root.childByNamePath[\"subFolder\"].childByNamePath[\"subSubFolder/subSubSubFolder\"].name=subSubSubFolder") != -1) );
|
assertTrue("Cannot resolve subSubSubFolder with enhancement properly", (output.indexOf("root.childByNamePath[\"subFolder\"].childByNamePath[\"subSubFolder/subSubSubFolder\"].name=subSubSubFolder") != -1) );
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map createTemplateModel(NodeRef root)
|
private Map createTemplateModel(NodeRef root)
|
||||||
@@ -185,11 +177,13 @@ public class TemplateServiceImplTest extends TestCase
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetTemplateProcessor()
|
public void testGetTemplateProcessor()
|
||||||
{
|
{
|
||||||
assertNotNull(templateService.getTemplateProcessor(null));
|
assertNotNull(templateService.getTemplateProcessor(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testProcessTemplate()
|
public void testProcessTemplate()
|
||||||
{
|
{
|
||||||
Map model = createTemplateModel(root_node);
|
Map model = createTemplateModel(root_node);
|
||||||
|
@@ -25,8 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.tenant;
|
package org.alfresco.repo.tenant;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -49,12 +47,11 @@ 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.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A test for MultiTServiceImpl class.
|
* A test for MultiTServiceImpl class.
|
||||||
@@ -62,9 +59,8 @@ import org.springframework.context.ApplicationContext;
|
|||||||
* @author alex.mukha
|
* @author alex.mukha
|
||||||
* @since 4.2.3
|
* @since 4.2.3
|
||||||
*/
|
*/
|
||||||
public class MultiTServiceImplTest
|
public class MultiTServiceImplTest extends BaseSpringTest
|
||||||
{
|
{
|
||||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
private MultiTServiceImpl multiTServiceImpl;
|
private MultiTServiceImpl multiTServiceImpl;
|
||||||
private TenantAdminService tenantAdminService;
|
private TenantAdminService tenantAdminService;
|
||||||
private PersonService personService;
|
private PersonService personService;
|
||||||
@@ -112,15 +108,15 @@ public class MultiTServiceImplTest
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
multiTServiceImpl = ctx.getBean("tenantService", MultiTServiceImpl.class);
|
multiTServiceImpl = applicationContext.getBean("tenantService", MultiTServiceImpl.class);
|
||||||
tenantAdminService = ctx.getBean("tenantAdminService", TenantAdminService.class);
|
tenantAdminService = applicationContext.getBean("tenantAdminService", TenantAdminService.class);
|
||||||
personService = ctx.getBean("PersonService", PersonService.class);
|
personService = applicationContext.getBean("PersonService", PersonService.class);
|
||||||
tenantService = ctx.getBean("tenantService", TenantService.class);
|
tenantService = applicationContext.getBean("tenantService", TenantService.class);
|
||||||
authenticationService = ctx.getBean("AuthenticationService", MutableAuthenticationService.class);
|
authenticationService = applicationContext.getBean("AuthenticationService", MutableAuthenticationService.class);
|
||||||
transactionService = ctx.getBean("TransactionService", TransactionService.class);
|
transactionService = applicationContext.getBean("TransactionService", TransactionService.class);
|
||||||
nodeService = ctx.getBean("NodeService", NodeService.class);
|
nodeService = applicationContext.getBean("NodeService", NodeService.class);
|
||||||
searchService = ctx.getBean("SearchService", SearchService.class);
|
searchService = applicationContext.getBean("SearchService", SearchService.class);
|
||||||
namespaceService = ctx.getBean("NamespaceService", NamespaceService.class);
|
namespaceService = applicationContext.getBean("NamespaceService", NamespaceService.class);
|
||||||
|
|
||||||
DOMAIN = GUID.generate();
|
DOMAIN = GUID.generate();
|
||||||
USER1 = GUID.generate();
|
USER1 = GUID.generate();
|
||||||
@@ -163,21 +159,21 @@ public class MultiTServiceImplTest
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// Create a user with a plain user name without a domain
|
// Create a user with a plain user name without a domain
|
||||||
NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
|
NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
|
||||||
assertNotNull("The user was not created.", userNodeRef);
|
assertNotNull("The user was not created.", userNodeRef);
|
||||||
assertFalse("The user is not from a tenant, but was reported otherwise.", multiTServiceImpl.isTenantUser(USER1));
|
assertFalse("The user is not from a tenant, but was reported otherwise.", multiTServiceImpl.isTenantUser(USER1));
|
||||||
|
|
||||||
// Create a user with a name as an email, but not from tenant
|
// Create a user with a name as an email, but not from tenant
|
||||||
userNodeRef = createUser(USER2_WITH_DOMAIN, TenantService.DEFAULT_DOMAIN, PASS);
|
userNodeRef = createUser(USER2_WITH_DOMAIN, TenantService.DEFAULT_DOMAIN, PASS);
|
||||||
assertNotNull("The user was not created.", userNodeRef);
|
assertNotNull("The user was not created.", userNodeRef);
|
||||||
assertFalse("The user is not from a tenant, but was reported otherwise.", multiTServiceImpl.isTenantUser(USER2_WITH_DOMAIN));
|
assertFalse("The user is not from a tenant, but was reported otherwise.", multiTServiceImpl.isTenantUser(USER2_WITH_DOMAIN));
|
||||||
|
|
||||||
// Create a tenant and a user in it
|
// Create a tenant and a user in it
|
||||||
createTenant(DOMAIN);
|
createTenant(DOMAIN);
|
||||||
userNodeRef = createUser(USER3, DOMAIN, PASS);
|
userNodeRef = createUser(USER3, DOMAIN, PASS);
|
||||||
assertNotNull("The user was not created.", userNodeRef);
|
assertNotNull("The user was not created.", userNodeRef);
|
||||||
assertTrue("The user is from a tenant, but was reported otherwise.", multiTServiceImpl.isTenantUser(USER3 + MultiTServiceImpl.SEPARATOR + DOMAIN));
|
assertTrue("The user is from a tenant, but was reported otherwise.", multiTServiceImpl.isTenantUser(USER3 + MultiTServiceImpl.SEPARATOR + DOMAIN));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -193,43 +189,43 @@ public class MultiTServiceImplTest
|
|||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
|
|
||||||
// Test a tenant user
|
// Test a tenant user
|
||||||
createTenant(DOMAIN);
|
createTenant(DOMAIN);
|
||||||
NodeRef userNodeRef = createUser(USER1, DOMAIN, PASS);
|
NodeRef userNodeRef = createUser(USER1, DOMAIN, PASS);
|
||||||
assertNotNull("The user was not created.", userNodeRef);
|
assertNotNull("The user was not created.", userNodeRef);
|
||||||
|
|
||||||
TenantRunAsWork<String> work = new TenantRunAsWork<String>()
|
TenantRunAsWork<String> work = new TenantRunAsWork<String>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String doWork() throws Exception
|
public String doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getCurrentUserDomain();
|
return tenantService.getCurrentUserDomain();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
String result = TenantUtil.runAsUserTenant(work, USER1, DOMAIN);
|
String result = TenantUtil.runAsUserTenant(work, USER1, DOMAIN);
|
||||||
assertEquals("The domains do not match.", DOMAIN, result);
|
assertEquals("The domains do not match.", DOMAIN, result);
|
||||||
|
|
||||||
// Test a default user
|
// Test a default user
|
||||||
userNodeRef = createUser(USER2, TenantService.DEFAULT_DOMAIN, PASS);
|
userNodeRef = createUser(USER2, TenantService.DEFAULT_DOMAIN, PASS);
|
||||||
assertNotNull("The user was not created.", userNodeRef);
|
assertNotNull("The user was not created.", userNodeRef);
|
||||||
|
|
||||||
work = new TenantRunAsWork<String>()
|
work = new TenantRunAsWork<String>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String doWork() throws Exception
|
public String doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getCurrentUserDomain();
|
return tenantService.getCurrentUserDomain();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
result = TenantUtil.runAsUserTenant(work, USER2, TenantService.DEFAULT_DOMAIN);
|
result = TenantUtil.runAsUserTenant(work, USER2, TenantService.DEFAULT_DOMAIN);
|
||||||
assertEquals("The domains do not match.", TenantService.DEFAULT_DOMAIN, result);
|
assertEquals("The domains do not match.", TenantService.DEFAULT_DOMAIN, result);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
transactionService.getRetryingTransactionHelper().doInTransaction(work);
|
transactionService.getRetryingTransactionHelper().doInTransaction(work);
|
||||||
assertEquals("fred", multiTServiceImpl.getMultiTenantDomainName("@fred@bloggs"));
|
assertEquals("fred", multiTServiceImpl.getMultiTenantDomainName("@fred@bloggs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -241,120 +237,120 @@ public class MultiTServiceImplTest
|
|||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
|
|
||||||
NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
|
NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
|
||||||
assertNotNull("The user was not created.", userNodeRef);
|
assertNotNull("The user was not created.", userNodeRef);
|
||||||
TenantRunAsWork<NodeRef> work1 = new TenantRunAsWork<NodeRef>()
|
TenantRunAsWork<NodeRef> work1 = new TenantRunAsWork<NodeRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public NodeRef doWork() throws Exception
|
public NodeRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getName(NODE_REF);
|
return tenantService.getName(NODE_REF);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
NodeRef result = TenantUtil.runAsUserTenant(work1, USER1, TenantService.DEFAULT_DOMAIN);
|
NodeRef result = TenantUtil.runAsUserTenant(work1, USER1, TenantService.DEFAULT_DOMAIN);
|
||||||
assertEquals("The NodeRef should contain domain.", NODE_REF, result);
|
assertEquals("The NodeRef should contain domain.", NODE_REF, result);
|
||||||
|
|
||||||
createTenant(DOMAIN);
|
createTenant(DOMAIN);
|
||||||
userNodeRef = createUser(USER2, DOMAIN, PASS);
|
userNodeRef = createUser(USER2, DOMAIN, PASS);
|
||||||
assertNotNull("The user was not created.", userNodeRef);
|
assertNotNull("The user was not created.", userNodeRef);
|
||||||
work1 = new TenantRunAsWork<NodeRef>()
|
work1 = new TenantRunAsWork<NodeRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public NodeRef doWork() throws Exception
|
public NodeRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getName(NODE_REF);
|
return tenantService.getName(NODE_REF);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
result = TenantUtil.runAsUserTenant(work1, USER2, DOMAIN);
|
result = TenantUtil.runAsUserTenant(work1, USER2, DOMAIN);
|
||||||
assertEquals("The NodeRef should contain domain.", TENANT_NODE_REF, result);
|
assertEquals("The NodeRef should contain domain.", TENANT_NODE_REF, result);
|
||||||
|
|
||||||
work1 = new TenantRunAsWork<NodeRef>()
|
work1 = new TenantRunAsWork<NodeRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public NodeRef doWork() throws Exception
|
public NodeRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getName(TENANT_NODE_REF, NODE_REF);
|
return tenantService.getName(TENANT_NODE_REF, NODE_REF);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
result = TenantUtil.runAsUserTenant(work1, USER2, DOMAIN);
|
result = TenantUtil.runAsUserTenant(work1, USER2, DOMAIN);
|
||||||
assertEquals("The NodeRef should contain domain.", TENANT_NODE_REF, result);
|
assertEquals("The NodeRef should contain domain.", TENANT_NODE_REF, result);
|
||||||
|
|
||||||
TenantRunAsWork<StoreRef> work2 = new TenantRunAsWork<StoreRef>()
|
TenantRunAsWork<StoreRef> work2 = new TenantRunAsWork<StoreRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public StoreRef doWork() throws Exception
|
public StoreRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getName(STORE_REF);
|
return tenantService.getName(STORE_REF);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
StoreRef result2 = TenantUtil.runAsUserTenant(work2, USER2, DOMAIN);
|
StoreRef result2 = TenantUtil.runAsUserTenant(work2, USER2, DOMAIN);
|
||||||
assertEquals("The StoreRef should contain domain.", TENANT_STORE_REF, result2);
|
assertEquals("The StoreRef should contain domain.", TENANT_STORE_REF, result2);
|
||||||
|
|
||||||
TenantRunAsWork<ChildAssociationRef> work3 = new TenantRunAsWork<ChildAssociationRef>()
|
TenantRunAsWork<ChildAssociationRef> work3 = new TenantRunAsWork<ChildAssociationRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public ChildAssociationRef doWork() throws Exception
|
public ChildAssociationRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getName(childAssocRef);
|
return tenantService.getName(childAssocRef);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ChildAssociationRef result3 = TenantUtil.runAsUserTenant(work3, USER2, DOMAIN);
|
ChildAssociationRef result3 = TenantUtil.runAsUserTenant(work3, USER2, DOMAIN);
|
||||||
assertEquals("The ChildAssociationRef should contain domain.", tenantChildAssocRef, result3);
|
assertEquals("The ChildAssociationRef should contain domain.", tenantChildAssocRef, result3);
|
||||||
|
|
||||||
TenantRunAsWork<AssociationRef> work4 = new TenantRunAsWork<AssociationRef>()
|
TenantRunAsWork<AssociationRef> work4 = new TenantRunAsWork<AssociationRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public AssociationRef doWork() throws Exception
|
public AssociationRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getName(assocRef);
|
return tenantService.getName(assocRef);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
AssociationRef result4 = TenantUtil.runAsUserTenant(work4, USER2, DOMAIN);
|
AssociationRef result4 = TenantUtil.runAsUserTenant(work4, USER2, DOMAIN);
|
||||||
assertEquals("The AssociationRef should contain domain.", tenantAssocRef, result4);
|
assertEquals("The AssociationRef should contain domain.", tenantAssocRef, result4);
|
||||||
|
|
||||||
TenantRunAsWork<StoreRef> work5 = new TenantRunAsWork<StoreRef>()
|
TenantRunAsWork<StoreRef> work5 = new TenantRunAsWork<StoreRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public StoreRef doWork() throws Exception
|
public StoreRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getName(USER2_WITH_DOMAIN, STORE_REF);
|
return tenantService.getName(USER2_WITH_DOMAIN, STORE_REF);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
StoreRef result5 = TenantUtil.runAsUserTenant(work5, USER2, DOMAIN);
|
StoreRef result5 = TenantUtil.runAsUserTenant(work5, USER2, DOMAIN);
|
||||||
assertEquals("The StoreRef should contain domain.", TENANT_STORE_REF, result5);
|
assertEquals("The StoreRef should contain domain.", TENANT_STORE_REF, result5);
|
||||||
|
|
||||||
TenantRunAsWork<QName> work6 = new TenantRunAsWork<QName>()
|
TenantRunAsWork<QName> work6 = new TenantRunAsWork<QName>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public QName doWork() throws Exception
|
public QName doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getName(QNAME);
|
return tenantService.getName(QNAME);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
QName result6 = TenantUtil.runAsUserTenant(work6, USER2, DOMAIN);
|
QName result6 = TenantUtil.runAsUserTenant(work6, USER2, DOMAIN);
|
||||||
assertEquals("The QName should contain domain.", TENANT_QNAME, result6);
|
assertEquals("The QName should contain domain.", TENANT_QNAME, result6);
|
||||||
|
|
||||||
TenantRunAsWork<QName> work7 = new TenantRunAsWork<QName>()
|
TenantRunAsWork<QName> work7 = new TenantRunAsWork<QName>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public QName doWork() throws Exception
|
public QName doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getName(TENANT_NODE_REF, QNAME);
|
return tenantService.getName(TENANT_NODE_REF, QNAME);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
QName result7 = TenantUtil.runAsUserTenant(work7, USER2, DOMAIN);
|
QName result7 = TenantUtil.runAsUserTenant(work7, USER2, DOMAIN);
|
||||||
assertEquals("The QName should contain domain.", TENANT_QNAME, result7);
|
assertEquals("The QName should contain domain.", TENANT_QNAME, result7);
|
||||||
|
|
||||||
TenantRunAsWork<String> work8 = new TenantRunAsWork<String>()
|
TenantRunAsWork<String> work8 = new TenantRunAsWork<String>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String doWork() throws Exception
|
public String doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getName(STRING);
|
return tenantService.getName(STRING);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
String result8 = TenantUtil.runAsUserTenant(work8, USER2, DOMAIN);
|
String result8 = TenantUtil.runAsUserTenant(work8, USER2, DOMAIN);
|
||||||
assertEquals("The String should contain domain.", TENANT_STRING, result8);
|
assertEquals("The String should contain domain.", TENANT_STRING, result8);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -388,7 +384,7 @@ public class MultiTServiceImplTest
|
|||||||
}
|
}
|
||||||
catch (AlfrescoRuntimeException are)
|
catch (AlfrescoRuntimeException are)
|
||||||
{
|
{
|
||||||
are.getMessage().contains("Invalid base username");
|
are.getMessage().contains("Invalid base username");
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -411,109 +407,109 @@ public class MultiTServiceImplTest
|
|||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
|
|
||||||
NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
|
NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
|
||||||
assertNotNull("The user was not created.", userNodeRef);
|
assertNotNull("The user was not created.", userNodeRef);
|
||||||
TenantRunAsWork<NodeRef> work1 = new TenantRunAsWork<NodeRef>()
|
TenantRunAsWork<NodeRef> work1 = new TenantRunAsWork<NodeRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public NodeRef doWork() throws Exception
|
public NodeRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getBaseName(NODE_REF);
|
return tenantService.getBaseName(NODE_REF);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
NodeRef result = TenantUtil.runAsUserTenant(work1, USER1, TenantService.DEFAULT_DOMAIN);
|
NodeRef result = TenantUtil.runAsUserTenant(work1, USER1, TenantService.DEFAULT_DOMAIN);
|
||||||
assertEquals("The NodeRef should not contain domain.", NODE_REF, result);
|
assertEquals("The NodeRef should not contain domain.", NODE_REF, result);
|
||||||
|
|
||||||
createTenant(DOMAIN);
|
createTenant(DOMAIN);
|
||||||
userNodeRef = createUser(USER2, DOMAIN, PASS);
|
userNodeRef = createUser(USER2, DOMAIN, PASS);
|
||||||
assertNotNull("The user was not created.", userNodeRef);
|
assertNotNull("The user was not created.", userNodeRef);
|
||||||
work1 = new TenantRunAsWork<NodeRef>()
|
work1 = new TenantRunAsWork<NodeRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public NodeRef doWork() throws Exception
|
public NodeRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getBaseName(TENANT_NODE_REF);
|
return tenantService.getBaseName(TENANT_NODE_REF);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
result = TenantUtil.runAsUserTenant(work1, USER2, DOMAIN);
|
result = TenantUtil.runAsUserTenant(work1, USER2, DOMAIN);
|
||||||
assertEquals("The NodeRef should not contain domain.", NODE_REF, result);
|
assertEquals("The NodeRef should not contain domain.", NODE_REF, result);
|
||||||
|
|
||||||
work1 = new TenantRunAsWork<NodeRef>()
|
work1 = new TenantRunAsWork<NodeRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public NodeRef doWork() throws Exception
|
public NodeRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getBaseName(TENANT_NODE_REF, true);
|
return tenantService.getBaseName(TENANT_NODE_REF, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
result = TenantUtil.runAsUserTenant(work1, USER1, TenantService.DEFAULT_DOMAIN);
|
result = TenantUtil.runAsUserTenant(work1, USER1, TenantService.DEFAULT_DOMAIN);
|
||||||
assertEquals("The NodeRef should not contain domain.", NODE_REF, result);
|
assertEquals("The NodeRef should not contain domain.", NODE_REF, result);
|
||||||
|
|
||||||
work1 = new TenantRunAsWork<NodeRef>()
|
work1 = new TenantRunAsWork<NodeRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public NodeRef doWork() throws Exception
|
public NodeRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getBaseName(TENANT_NODE_REF, false);
|
return tenantService.getBaseName(TENANT_NODE_REF, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
result = TenantUtil.runAsUserTenant(work1, USER1, TenantService.DEFAULT_DOMAIN);
|
result = TenantUtil.runAsUserTenant(work1, USER1, TenantService.DEFAULT_DOMAIN);
|
||||||
assertEquals("The NodeRef should contain domain.", TENANT_NODE_REF, result);
|
assertEquals("The NodeRef should contain domain.", TENANT_NODE_REF, result);
|
||||||
|
|
||||||
TenantRunAsWork<StoreRef> work2 = new TenantRunAsWork<StoreRef>()
|
TenantRunAsWork<StoreRef> work2 = new TenantRunAsWork<StoreRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public StoreRef doWork() throws Exception
|
public StoreRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getBaseName(TENANT_STORE_REF);
|
return tenantService.getBaseName(TENANT_STORE_REF);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
StoreRef result2 = TenantUtil.runAsUserTenant(work2, USER2, DOMAIN);
|
StoreRef result2 = TenantUtil.runAsUserTenant(work2, USER2, DOMAIN);
|
||||||
assertEquals("The StoreRef should not contain domain.", STORE_REF, result2);
|
assertEquals("The StoreRef should not contain domain.", STORE_REF, result2);
|
||||||
|
|
||||||
TenantRunAsWork<ChildAssociationRef> work3 = new TenantRunAsWork<ChildAssociationRef>()
|
TenantRunAsWork<ChildAssociationRef> work3 = new TenantRunAsWork<ChildAssociationRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public ChildAssociationRef doWork() throws Exception
|
public ChildAssociationRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getBaseName(tenantChildAssocRef);
|
return tenantService.getBaseName(tenantChildAssocRef);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ChildAssociationRef result3 = TenantUtil.runAsUserTenant(work3, USER2, DOMAIN);
|
ChildAssociationRef result3 = TenantUtil.runAsUserTenant(work3, USER2, DOMAIN);
|
||||||
assertEquals("The ChildAssociationRef not should contain domain.", childAssocRef, result3);
|
assertEquals("The ChildAssociationRef not should contain domain.", childAssocRef, result3);
|
||||||
|
|
||||||
TenantRunAsWork<AssociationRef> work4 = new TenantRunAsWork<AssociationRef>()
|
TenantRunAsWork<AssociationRef> work4 = new TenantRunAsWork<AssociationRef>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public AssociationRef doWork() throws Exception
|
public AssociationRef doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getBaseName(tenantAssocRef);
|
return tenantService.getBaseName(tenantAssocRef);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
AssociationRef result4 = TenantUtil.runAsUserTenant(work4, USER2, DOMAIN);
|
AssociationRef result4 = TenantUtil.runAsUserTenant(work4, USER2, DOMAIN);
|
||||||
assertEquals("The AssociationRef should not contain domain.", assocRef, result4);
|
assertEquals("The AssociationRef should not contain domain.", assocRef, result4);
|
||||||
|
|
||||||
TenantRunAsWork<QName> work5 = new TenantRunAsWork<QName>()
|
TenantRunAsWork<QName> work5 = new TenantRunAsWork<QName>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public QName doWork() throws Exception
|
public QName doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getBaseName(TENANT_QNAME, false);
|
return tenantService.getBaseName(TENANT_QNAME, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
QName result5 = TenantUtil.runAsUserTenant(work5, USER2, DOMAIN);
|
QName result5 = TenantUtil.runAsUserTenant(work5, USER2, DOMAIN);
|
||||||
assertEquals("The QName should not contain domain.", QNAME, result5);
|
assertEquals("The QName should not contain domain.", QNAME, result5);
|
||||||
|
|
||||||
TenantRunAsWork<String> work6 = new TenantRunAsWork<String>()
|
TenantRunAsWork<String> work6 = new TenantRunAsWork<String>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String doWork() throws Exception
|
public String doWork() throws Exception
|
||||||
{
|
{
|
||||||
return tenantService.getBaseName(TENANT_STRING);
|
return tenantService.getBaseName(TENANT_STRING);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
String result6 = TenantUtil.runAsUserTenant(work6, USER2, DOMAIN);
|
String result6 = TenantUtil.runAsUserTenant(work6, USER2, DOMAIN);
|
||||||
assertEquals("The String should not contain domain.", STRING, result6);
|
assertEquals("The String should not contain domain.", STRING, result6);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -529,39 +525,39 @@ public class MultiTServiceImplTest
|
|||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
|
|
||||||
String nonExistentDomain = "nonExistentDomain";
|
String nonExistentDomain = "nonExistentDomain";
|
||||||
createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
|
createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
|
||||||
createTenant(DOMAIN);
|
createTenant(DOMAIN);
|
||||||
createUser(USER2, DOMAIN, PASS);
|
createUser(USER2, DOMAIN, PASS);
|
||||||
createUser(USER3, nonExistentDomain, PASS);
|
createUser(USER3, nonExistentDomain, PASS);
|
||||||
String username3WithDomain = USER3 + TenantService.SEPARATOR + nonExistentDomain;
|
String username3WithDomain = USER3 + TenantService.SEPARATOR + nonExistentDomain;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
checkDomainUserWork(USER1, TenantService.DEFAULT_DOMAIN, USER1);
|
checkDomainUserWork(USER1, TenantService.DEFAULT_DOMAIN, USER1);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
fail("The user is not from domain and is not a tenant.");
|
fail("The user is not from domain and is not a tenant.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
checkDomainUserWork(USER2_WITH_DOMAIN, DOMAIN, USER2);
|
checkDomainUserWork(USER2_WITH_DOMAIN, DOMAIN, USER2);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
fail("The user is from domain and is a tenant.");
|
fail("The user is from domain and is a tenant.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
checkDomainUserWork(username3WithDomain, DOMAIN, USER2);
|
checkDomainUserWork(username3WithDomain, DOMAIN, USER2);
|
||||||
fail("The user is not from this domain.");
|
fail("The user is not from this domain.");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// Expected
|
// Expected
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -623,16 +619,16 @@ public class MultiTServiceImplTest
|
|||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
|
|
||||||
NodeRef rootNodeRefDefault = nodeService.getRootNode(DEFAULT_STORE);
|
NodeRef rootNodeRefDefault = nodeService.getRootNode(DEFAULT_STORE);
|
||||||
NodeRef rootNodeRef = new NodeRef(DEFAULT_STORE, IDENTIFIER);
|
NodeRef rootNodeRef = new NodeRef(DEFAULT_STORE, IDENTIFIER);
|
||||||
NodeRef nodeRef = tenantService.getRootNode(nodeService, searchService, namespaceService, ROOT_PATH, rootNodeRef);
|
NodeRef nodeRef = tenantService.getRootNode(nodeService, searchService, namespaceService, ROOT_PATH, rootNodeRef);
|
||||||
assertEquals("The reported rootNodeRef for the default domain is not correct.", rootNodeRefDefault, nodeRef);
|
assertEquals("The reported rootNodeRef for the default domain is not correct.", rootNodeRefDefault, nodeRef);
|
||||||
|
|
||||||
createTenant(DOMAIN);
|
createTenant(DOMAIN);
|
||||||
rootNodeRefDefault = nodeService.getRootNode(TENANT_STORE);
|
rootNodeRefDefault = nodeService.getRootNode(TENANT_STORE);
|
||||||
rootNodeRef = new NodeRef(TENANT_STORE, IDENTIFIER);
|
rootNodeRef = new NodeRef(TENANT_STORE, IDENTIFIER);
|
||||||
nodeRef = tenantService.getRootNode(nodeService, searchService, namespaceService, ROOT_PATH, rootNodeRef);
|
nodeRef = tenantService.getRootNode(nodeService, searchService, namespaceService, ROOT_PATH, rootNodeRef);
|
||||||
assertEquals("The reported rootNodeRef for the tenant domain is not correct.", rootNodeRefDefault, nodeRef);
|
assertEquals("The reported rootNodeRef for the tenant domain is not correct.", rootNodeRefDefault, nodeRef);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -651,11 +647,11 @@ public class MultiTServiceImplTest
|
|||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
|
|
||||||
boolean result = tenantService.isTenantName(STRING);
|
boolean result = tenantService.isTenantName(STRING);
|
||||||
assertFalse("The string was reported as domain, but it is not", result);
|
assertFalse("The string was reported as domain, but it is not", result);
|
||||||
|
|
||||||
result = tenantService.isTenantName(STRING_WITH_EXISTENT_DOMAIN);
|
result = tenantService.isTenantName(STRING_WITH_EXISTENT_DOMAIN);
|
||||||
assertTrue("The string was not reported as domain.", result);
|
assertTrue("The string was not reported as domain.", result);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -697,37 +693,37 @@ public class MultiTServiceImplTest
|
|||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
|
|
||||||
createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
|
createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
|
||||||
String result = getDomainWork(STRING, TenantService.DEFAULT_DOMAIN, USER1, false);
|
String result = getDomainWork(STRING, TenantService.DEFAULT_DOMAIN, USER1, false);
|
||||||
assertEquals("The domain should be reported as default.", TenantService.DEFAULT_DOMAIN, result);
|
assertEquals("The domain should be reported as default.", TenantService.DEFAULT_DOMAIN, result);
|
||||||
|
|
||||||
createUser(USER2, DOMAIN, PASS);
|
createUser(USER2, DOMAIN, PASS);
|
||||||
result = getDomainWork(STRING, TenantService.DEFAULT_DOMAIN, USER2, false);
|
result = getDomainWork(STRING, TenantService.DEFAULT_DOMAIN, USER2, false);
|
||||||
assertEquals("The domain should be reported as default as the tenant was not created yet.", TenantService.DEFAULT_DOMAIN, result);
|
assertEquals("The domain should be reported as default as the tenant was not created yet.", TenantService.DEFAULT_DOMAIN, result);
|
||||||
|
|
||||||
createTenant(DOMAIN);
|
createTenant(DOMAIN);
|
||||||
result = getDomainWork(STRING_WITH_EXISTENT_DOMAIN, DOMAIN, USER2, false);
|
result = getDomainWork(STRING_WITH_EXISTENT_DOMAIN, DOMAIN, USER2, false);
|
||||||
assertEquals("The USER2 domain should be reported as " + DOMAIN, DOMAIN, result);
|
assertEquals("The USER2 domain should be reported as " + DOMAIN, DOMAIN, result);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
result = getDomainWork(STRING_WITH_EXISTENT_DOMAIN, TenantService.DEFAULT_DOMAIN, USER1, true);
|
result = getDomainWork(STRING_WITH_EXISTENT_DOMAIN, TenantService.DEFAULT_DOMAIN, USER1, true);
|
||||||
assertEquals("The domain should be reported as " + DOMAIN, DOMAIN, result);
|
assertEquals("The domain should be reported as " + DOMAIN, DOMAIN, result);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
fail("An exception should not be thrown.");
|
fail("An exception should not be thrown.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
result = getDomainWork(STRING_WITH_NONEXITENT_DOMAIN, DOMAIN, USER2, true);
|
result = getDomainWork(STRING_WITH_NONEXITENT_DOMAIN, DOMAIN, USER2, true);
|
||||||
fail("An exception should be thrown as the domains do not match.");
|
fail("An exception should be thrown as the domains do not match.");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// Expected
|
// Expected
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -765,18 +761,18 @@ public class MultiTServiceImplTest
|
|||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
|
|
||||||
String result = tenantService.getUserDomain(USER1);
|
String result = tenantService.getUserDomain(USER1);
|
||||||
assertEquals("The user domain should be the default one for a non tenant user without a tenant in name.", TenantService.DEFAULT_DOMAIN, result);
|
assertEquals("The user domain should be the default one for a non tenant user without a tenant in name.", TenantService.DEFAULT_DOMAIN, result);
|
||||||
|
|
||||||
result = tenantService.getUserDomain(USER2_WITH_DOMAIN);
|
result = tenantService.getUserDomain(USER2_WITH_DOMAIN);
|
||||||
assertEquals("The user domain should be the default one for a user with email like name if multi tenancy is not enabled.", TenantService.DEFAULT_DOMAIN, result);
|
assertEquals("The user domain should be the default one for a user with email like name if multi tenancy is not enabled.", TenantService.DEFAULT_DOMAIN, result);
|
||||||
|
|
||||||
createTenant(DOMAIN);
|
createTenant(DOMAIN);
|
||||||
result = tenantService.getUserDomain(USER2_WITH_DOMAIN);
|
result = tenantService.getUserDomain(USER2_WITH_DOMAIN);
|
||||||
assertEquals("The user domain should be of the USER2 is " + DOMAIN + ", but was reported as " + result, DOMAIN, result);
|
assertEquals("The user domain should be of the USER2 is " + DOMAIN + ", but was reported as " + result, DOMAIN, result);
|
||||||
|
|
||||||
result = tenantService.getUserDomain(USER1);
|
result = tenantService.getUserDomain(USER1);
|
||||||
assertTrue("The user domain should be the default one (empty string) for a non tenant user without a tenant in name.", result.equals(TenantService.DEFAULT_DOMAIN));
|
assertTrue("The user domain should be the default one (empty string) for a non tenant user without a tenant in name.", result.equals(TenantService.DEFAULT_DOMAIN));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -920,7 +916,7 @@ public class MultiTServiceImplTest
|
|||||||
// TODO: WARNING: HACK for ALF-19155: MT deleteTenant does not work
|
// TODO: WARNING: HACK for ALF-19155: MT deleteTenant does not work
|
||||||
// PersonService prevents 'guest' authorities from being deleted
|
// PersonService prevents 'guest' authorities from being deleted
|
||||||
{
|
{
|
||||||
BehaviourFilter behaviourFilter = (BehaviourFilter) ctx.getBean("policyBehaviourFilter");
|
BehaviourFilter behaviourFilter = (BehaviourFilter) applicationContext.getBean("policyBehaviourFilter");
|
||||||
behaviourFilter.disableBehaviour(ContentModel.TYPE_PERSON);
|
behaviourFilter.disableBehaviour(ContentModel.TYPE_PERSON);
|
||||||
behaviourFilter.disableBehaviour(ContentModel.ASPECT_UNDELETABLE);
|
behaviourFilter.disableBehaviour(ContentModel.ASPECT_UNDELETABLE);
|
||||||
}
|
}
|
||||||
|
@@ -31,40 +31,35 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.junit.Before;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.Test;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests integration between our <tt>UserTransaction</tt> implementation and
|
* Tests integration between our <tt>UserTransaction</tt> implementation and
|
||||||
* our <tt>TransactionManager</tt>.
|
* our <tt>TransactionManager</tt>.
|
||||||
*
|
*
|
||||||
* @see org.alfresco.repo.transaction.AlfrescoTransactionManager
|
|
||||||
* @see org.alfresco.util.transaction.SpringAwareUserTransaction
|
* @see org.alfresco.util.transaction.SpringAwareUserTransaction
|
||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
@Category(OwnJVMTestsCategory.class)
|
public class AlfrescoTransactionSupportTest extends BaseSpringTest
|
||||||
public class AlfrescoTransactionSupportTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
|
|
||||||
private ServiceRegistry serviceRegistry;
|
private ServiceRegistry serviceRegistry;
|
||||||
TransactionService transactionService;
|
TransactionService transactionService;
|
||||||
|
|
||||||
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
transactionService = serviceRegistry.getTransactionService();
|
transactionService = serviceRegistry.getTransactionService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testTransactionId() throws Exception
|
public void testTransactionId() throws Exception
|
||||||
{
|
{
|
||||||
// get a user transaction
|
// get a user transaction
|
||||||
@@ -127,6 +122,7 @@ public class AlfrescoTransactionSupportTest extends TestCase
|
|||||||
assertNull("Thread shouldn't have a txn ID after rollback", AlfrescoTransactionSupport.getTransactionId());
|
assertNull("Thread shouldn't have a txn ID after rollback", AlfrescoTransactionSupport.getTransactionId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testListener() throws Exception
|
public void testListener() throws Exception
|
||||||
{
|
{
|
||||||
final List<String> strings = new ArrayList<String>(1);
|
final List<String> strings = new ArrayList<String>(1);
|
||||||
@@ -175,6 +171,7 @@ public class AlfrescoTransactionSupportTest extends TestCase
|
|||||||
assertTrue("afterCommit not called on listener", strings.contains("afterCommit"));
|
assertTrue("afterCommit not called on listener", strings.contains("afterCommit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testListenerNew() throws Exception
|
public void testListenerNew() throws Exception
|
||||||
{
|
{
|
||||||
final List<String> strings = new ArrayList<String>(1);
|
final List<String> strings = new ArrayList<String>(1);
|
||||||
@@ -223,6 +220,7 @@ public class AlfrescoTransactionSupportTest extends TestCase
|
|||||||
* the transaction in the pre-commit callback. This is caused by the listener set being
|
* the transaction in the pre-commit callback. This is caused by the listener set being
|
||||||
* modified during calls to the listeners.
|
* modified during calls to the listeners.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testPreCommitListenerBinding() throws Exception
|
public void testPreCommitListenerBinding() throws Exception
|
||||||
{
|
{
|
||||||
final String beforeCommit = "beforeCommit";
|
final String beforeCommit = "beforeCommit";
|
||||||
@@ -291,6 +289,7 @@ public class AlfrescoTransactionSupportTest extends TestCase
|
|||||||
assertTrue("Expected callbacks not all processed: " + testList, testList.size() == 0);
|
assertTrue("Expected callbacks not all processed: " + testList, testList.size() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testReadWriteStateRetrieval() throws Exception
|
public void testReadWriteStateRetrieval() throws Exception
|
||||||
{
|
{
|
||||||
final TxnReadState[] postCommitReadState = new TxnReadState[1];
|
final TxnReadState[] postCommitReadState = new TxnReadState[1];
|
||||||
@@ -348,6 +347,7 @@ public class AlfrescoTransactionSupportTest extends TestCase
|
|||||||
assertEquals("Expected 'no transaction'", TxnReadState.TXN_NONE, postCommitReadState[0]);
|
assertEquals("Expected 'no transaction'", TxnReadState.TXN_NONE, postCommitReadState[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testResourceHelper() throws Exception
|
public void testResourceHelper() throws Exception
|
||||||
{
|
{
|
||||||
// start a transaction
|
// start a transaction
|
||||||
|
@@ -37,7 +37,6 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.transaction.Status;
|
import javax.transaction.Status;
|
||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
import junit.framework.TestCase;
|
|
||||||
import org.alfresco.error.ExceptionStackUtil;
|
import org.alfresco.error.ExceptionStackUtil;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.domain.dialect.Dialect;
|
import org.alfresco.repo.domain.dialect.Dialect;
|
||||||
@@ -55,15 +54,16 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
|||||||
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.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.alfresco.util.transaction.TransactionListenerAdapter;
|
import org.alfresco.util.transaction.TransactionListenerAdapter;
|
||||||
import org.apache.commons.lang.mutable.MutableInt;
|
import org.apache.commons.lang.mutable.MutableInt;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.After;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
import org.springframework.dao.ConcurrencyFailureException;
|
import org.springframework.dao.ConcurrencyFailureException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,15 +75,12 @@ import org.springframework.dao.ConcurrencyFailureException;
|
|||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
@Category(OwnJVMTestsCategory.class)
|
public class RetryingTransactionHelperTest extends BaseSpringTest
|
||||||
public class RetryingTransactionHelperTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private static Log logger = LogFactory.getLog("org.alfresco.repo.transaction.RetryingTransactionHelperTest");
|
private static Log logger = LogFactory.getLog("org.alfresco.repo.transaction.RetryingTransactionHelperTest");
|
||||||
|
|
||||||
private static final QName PROP_CHECK_VALUE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "check_value");
|
private static final QName PROP_CHECK_VALUE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "check_value");
|
||||||
|
|
||||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
|
|
||||||
private ServiceRegistry serviceRegistry;
|
private ServiceRegistry serviceRegistry;
|
||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
private TransactionService transactionService;
|
private TransactionService transactionService;
|
||||||
@@ -95,13 +92,13 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
private NodeRef rootNodeRef;
|
private NodeRef rootNodeRef;
|
||||||
private NodeRef workingNodeRef;
|
private NodeRef workingNodeRef;
|
||||||
|
|
||||||
@Override
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
dialect = (Dialect) ctx.getBean("dialect");
|
dialect = (Dialect) applicationContext.getBean("dialect");
|
||||||
|
|
||||||
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
|
authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
|
||||||
transactionService = serviceRegistry.getTransactionService();
|
transactionService = serviceRegistry.getTransactionService();
|
||||||
nodeService = serviceRegistry.getNodeService();
|
nodeService = serviceRegistry.getNodeService();
|
||||||
txnHelper = transactionService.getRetryingTransactionHelper();
|
txnHelper = transactionService.getRetryingTransactionHelper();
|
||||||
@@ -111,22 +108,23 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
|
|
||||||
StoreRef storeRef = nodeService.createStore(
|
StoreRef storeRef = nodeService.createStore(
|
||||||
StoreRef.PROTOCOL_WORKSPACE,
|
StoreRef.PROTOCOL_WORKSPACE,
|
||||||
"test-" + getName() + "-" + System.currentTimeMillis());
|
"test-" + System.currentTimeMillis());
|
||||||
rootNodeRef = nodeService.getRootNode(storeRef);
|
rootNodeRef = nodeService.getRootNode(storeRef);
|
||||||
// Create a node to work on
|
// Create a node to work on
|
||||||
workingNodeRef = nodeService.createNode(
|
workingNodeRef = nodeService.createNode(
|
||||||
rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, getName()),
|
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, GUID.generate()),
|
||||||
ContentModel.TYPE_CMOBJECT).getChildRef();
|
ContentModel.TYPE_CMOBJECT).getChildRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@After
|
||||||
public void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
try { authenticationComponent.clearCurrentSecurityContext(); } catch (Throwable e) {}
|
try { authenticationComponent.clearCurrentSecurityContext(); } catch (Throwable e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSetUp() throws Exception
|
public void testSetUp() throws Exception
|
||||||
{
|
{
|
||||||
assertNotNull(rootNodeRef);
|
assertNotNull(rootNodeRef);
|
||||||
@@ -177,6 +175,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Check that it works without complications.
|
* Check that it works without complications.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testSuccessNoRetry()
|
public void testSuccessNoRetry()
|
||||||
{
|
{
|
||||||
long beforeValue = getCheckValue();
|
long beforeValue = getCheckValue();
|
||||||
@@ -198,6 +197,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
* This also checks that any mischievous attempts to manipulate the transaction
|
* This also checks that any mischievous attempts to manipulate the transaction
|
||||||
* (other than setRollback) are detected.
|
* (other than setRollback) are detected.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testUserTransactionStatus()
|
public void testUserTransactionStatus()
|
||||||
{
|
{
|
||||||
UserTransaction txnBefore = RetryingTransactionHelper.getActiveUserTransaction();
|
UserTransaction txnBefore = RetryingTransactionHelper.getActiveUserTransaction();
|
||||||
@@ -251,6 +251,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Check that the retries happening for simple concurrency exceptions
|
* Check that the retries happening for simple concurrency exceptions
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testSuccessWithRetry()
|
public void testSuccessWithRetry()
|
||||||
{
|
{
|
||||||
RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>()
|
RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>()
|
||||||
@@ -278,6 +279,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Checks that a non-retrying exception is passed out and that the transaction is rolled back.
|
* Checks that a non-retrying exception is passed out and that the transaction is rolled back.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testNonRetryingFailure()
|
public void testNonRetryingFailure()
|
||||||
{
|
{
|
||||||
RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>()
|
RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>()
|
||||||
@@ -312,6 +314,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
* absorbed and that another isn't generated, but that the transaction was rolled back
|
* absorbed and that another isn't generated, but that the transaction was rolled back
|
||||||
* properly.
|
* properly.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testNonRetryingSilentRollback()
|
public void testNonRetryingSilentRollback()
|
||||||
{
|
{
|
||||||
RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>()
|
RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>()
|
||||||
@@ -338,6 +341,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Checks nesting of two transactions with <code>requiresNew == false</code>
|
* Checks nesting of two transactions with <code>requiresNew == false</code>
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testNestedWithPropagation()
|
public void testNestedWithPropagation()
|
||||||
{
|
{
|
||||||
RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>()
|
RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>()
|
||||||
@@ -366,6 +370,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Checks nesting of two transactions with <code>requiresNew == true</code>
|
* Checks nesting of two transactions with <code>requiresNew == true</code>
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testNestedWithoutPropagation()
|
public void testNestedWithoutPropagation()
|
||||||
{
|
{
|
||||||
RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>()
|
RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>()
|
||||||
@@ -397,6 +402,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
* <p/>
|
* <p/>
|
||||||
* Note: skip test for non-MySQL
|
* Note: skip test for non-MySQL
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testNestedWithoutPropagationConcurrentUntilFailureMySQL() throws InterruptedException
|
public void testNestedWithoutPropagationConcurrentUntilFailureMySQL() throws InterruptedException
|
||||||
{
|
{
|
||||||
final RetryingTransactionHelper txnHelperForTest = transactionService.getRetryingTransactionHelper();
|
final RetryingTransactionHelper txnHelperForTest = transactionService.getRetryingTransactionHelper();
|
||||||
@@ -441,6 +447,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testConcurrencyRetryingNoFailure() throws InterruptedException
|
public void testConcurrencyRetryingNoFailure() throws InterruptedException
|
||||||
{
|
{
|
||||||
Thread t1 = new Thread(new ConcurrentTransaction(5000));
|
Thread t1 = new Thread(new ConcurrentTransaction(5000));
|
||||||
@@ -497,6 +504,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testZeroAndNegativeRetries()
|
public void testZeroAndNegativeRetries()
|
||||||
{
|
{
|
||||||
final MutableInt callCount = new MutableInt(0);
|
final MutableInt callCount = new MutableInt(0);
|
||||||
@@ -536,6 +544,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
|
@Test
|
||||||
public void testTimeLimit()
|
public void testTimeLimit()
|
||||||
{
|
{
|
||||||
final RetryingTransactionHelper txnHelper = new RetryingTransactionHelper();
|
final RetryingTransactionHelper txnHelper = new RetryingTransactionHelper();
|
||||||
@@ -557,6 +566,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testALF_17631()
|
public void testALF_17631()
|
||||||
{
|
{
|
||||||
final MutableInt callCount = new MutableInt(0);
|
final MutableInt callCount = new MutableInt(0);
|
||||||
@@ -598,6 +608,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testForceWritable() throws Exception
|
public void testForceWritable() throws Exception
|
||||||
{
|
{
|
||||||
authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
||||||
@@ -670,6 +681,7 @@ public class RetryingTransactionHelperTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testStartNewTransaction() throws Exception
|
public void testStartNewTransaction() throws Exception
|
||||||
{
|
{
|
||||||
// MNT-10096
|
// MNT-10096
|
||||||
|
@@ -29,24 +29,19 @@ import java.util.Random;
|
|||||||
|
|
||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.junit.Before;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.Test;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.transaction.TransactionAwareSingleton
|
* @see org.alfresco.repo.transaction.TransactionAwareSingleton
|
||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
@Category(OwnJVMTestsCategory.class)
|
public class TransactionAwareSingletonTest extends BaseSpringTest
|
||||||
public class TransactionAwareSingletonTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
private static Random rand = new Random();
|
private static Random rand = new Random();
|
||||||
|
|
||||||
/** the instance to test */
|
/** the instance to test */
|
||||||
@@ -56,11 +51,13 @@ public class TransactionAwareSingletonTest extends TestCase
|
|||||||
|
|
||||||
private TransactionService transactionService;
|
private TransactionService transactionService;
|
||||||
|
|
||||||
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
transactionService = (TransactionService) ctx.getBean("transactionComponent");
|
transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCommit() throws Throwable
|
public void testCommit() throws Throwable
|
||||||
{
|
{
|
||||||
UserTransaction txn = transactionService.getUserTransaction();
|
UserTransaction txn = transactionService.getUserTransaction();
|
||||||
@@ -84,6 +81,7 @@ public class TransactionAwareSingletonTest extends TestCase
|
|||||||
check(INTEGER_ONE, false);
|
check(INTEGER_ONE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRollback() throws Throwable
|
public void testRollback() throws Throwable
|
||||||
{
|
{
|
||||||
UserTransaction txn = transactionService.getUserTransaction();
|
UserTransaction txn = transactionService.getUserTransaction();
|
||||||
@@ -108,6 +106,7 @@ public class TransactionAwareSingletonTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final int THREAD_COUNT = 20;
|
private static final int THREAD_COUNT = 20;
|
||||||
|
@Test
|
||||||
public void testThreadsCommit() throws Throwable
|
public void testThreadsCommit() throws Throwable
|
||||||
{
|
{
|
||||||
TestThread[] threads = new TestThread[THREAD_COUNT];
|
TestThread[] threads = new TestThread[THREAD_COUNT];
|
||||||
@@ -133,6 +132,7 @@ public class TransactionAwareSingletonTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
public void testThreadsRollback() throws Throwable
|
public void testThreadsRollback() throws Throwable
|
||||||
{
|
{
|
||||||
TestThread[] threads = new TestThread[THREAD_COUNT];
|
TestThread[] threads = new TestThread[THREAD_COUNT];
|
||||||
|
@@ -47,7 +47,10 @@ 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.test_category.OwnJVMTestsCategory;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||||
@@ -60,11 +63,8 @@ import org.springframework.transaction.PlatformTransactionManager;
|
|||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
@Category(OwnJVMTestsCategory.class)
|
public class TransactionServiceImplTest extends BaseSpringTest
|
||||||
public class TransactionServiceImplTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
|
||||||
|
|
||||||
private PlatformTransactionManager transactionManager;
|
private PlatformTransactionManager transactionManager;
|
||||||
private TransactionServiceImpl transactionService;
|
private TransactionServiceImpl transactionService;
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
@@ -76,20 +76,22 @@ public class TransactionServiceImplTest extends TestCase
|
|||||||
|
|
||||||
private Dialect dialect;
|
private Dialect dialect;
|
||||||
|
|
||||||
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
transactionManager = (PlatformTransactionManager) ctx.getBean("transactionManager");
|
transactionManager = (PlatformTransactionManager) applicationContext.getBean("transactionManager");
|
||||||
transactionService = new TransactionServiceImpl();
|
transactionService = new TransactionServiceImpl();
|
||||||
transactionService.setTransactionManager(transactionManager);
|
transactionService.setTransactionManager(transactionManager);
|
||||||
transactionService.setAllowWrite(true, vetoName);
|
transactionService.setAllowWrite(true, vetoName);
|
||||||
|
|
||||||
nodeService = (NodeService) ctx.getBean("dbNodeService");
|
nodeService = (NodeService) applicationContext.getBean("dbNodeService");
|
||||||
authenticationService = (MutableAuthenticationService) ctx.getBean("AuthenticationService");
|
authenticationService = (MutableAuthenticationService) applicationContext.getBean("AuthenticationService");
|
||||||
personService = (PersonService) ctx.getBean("PersonService");
|
personService = (PersonService) applicationContext.getBean("PersonService");
|
||||||
|
|
||||||
dialect = (Dialect) ctx.getBean("dialect");
|
dialect = (Dialect) applicationContext.getBean("dialect");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testPropagatingTxn() throws Exception
|
public void testPropagatingTxn() throws Exception
|
||||||
{
|
{
|
||||||
// start a transaction
|
// start a transaction
|
||||||
@@ -124,6 +126,7 @@ public class TransactionServiceImplTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testNonPropagatingTxn() throws Exception
|
public void testNonPropagatingTxn() throws Exception
|
||||||
{
|
{
|
||||||
// start a transaction
|
// start a transaction
|
||||||
@@ -146,6 +149,7 @@ public class TransactionServiceImplTest extends TestCase
|
|||||||
txnOuter.commit();
|
txnOuter.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testReadOnlyTxn() throws Exception
|
public void testReadOnlyTxn() throws Exception
|
||||||
{
|
{
|
||||||
// start a read-only transaction
|
// start a read-only transaction
|
||||||
@@ -218,6 +222,7 @@ public class TransactionServiceImplTest extends TestCase
|
|||||||
* Test the write veto
|
* Test the write veto
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testReadOnlyVetoTxn() throws Exception
|
public void testReadOnlyVetoTxn() throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -254,6 +259,7 @@ public class TransactionServiceImplTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetRetryingTransactionHelper()
|
public void testGetRetryingTransactionHelper()
|
||||||
{
|
{
|
||||||
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
@@ -268,7 +274,7 @@ public class TransactionServiceImplTest extends TestCase
|
|||||||
assertFalse("Retriers must be new instances",
|
assertFalse("Retriers must be new instances",
|
||||||
transactionService.getRetryingTransactionHelper() == transactionService.getRetryingTransactionHelper());
|
transactionService.getRetryingTransactionHelper() == transactionService.getRetryingTransactionHelper());
|
||||||
// The same must apply when using the ServiceRegistry (ALF-18718)
|
// The same must apply when using the ServiceRegistry (ALF-18718)
|
||||||
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
ServiceRegistry serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
assertFalse("Retriers must be new instance when retrieved from ServiceRegistry",
|
assertFalse("Retriers must be new instance when retrieved from ServiceRegistry",
|
||||||
serviceRegistry.getRetryingTransactionHelper() == serviceRegistry.getRetryingTransactionHelper());
|
serviceRegistry.getRetryingTransactionHelper() == serviceRegistry.getRetryingTransactionHelper());
|
||||||
|
|
||||||
@@ -300,7 +306,7 @@ public class TransactionServiceImplTest extends TestCase
|
|||||||
private void createUser(String userName)
|
private void createUser(String userName)
|
||||||
{
|
{
|
||||||
// login as system user to create test user
|
// login as system user to create test user
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
||||||
// if user with given user name doesn't already exist then create user
|
// if user with given user name doesn't already exist then create user
|
||||||
if (!this.authenticationService.authenticationExists(userName))
|
if (!this.authenticationService.authenticationExists(userName))
|
||||||
{
|
{
|
||||||
@@ -322,6 +328,7 @@ public class TransactionServiceImplTest extends TestCase
|
|||||||
AuthenticationUtil.clearCurrentSecurityContext();
|
AuthenticationUtil.clearCurrentSecurityContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSystemUserHasWritePermissionsInReadOnlyMode()
|
public void testSystemUserHasWritePermissionsInReadOnlyMode()
|
||||||
{
|
{
|
||||||
createUser(USER_ALFRESCO);
|
createUser(USER_ALFRESCO);
|
||||||
|
Reference in New Issue
Block a user