From b9e4557973fdbe119c015377390e4608ccaa123e Mon Sep 17 00:00:00 2001 From: Tom Page Date: Thu, 15 Apr 2021 11:23:26 +0100 Subject: [PATCH] Add unit test to look for unreferenced test classes. (#368) * Add unit test to look for unreferenced test classes. It's very unusual that we write a test class which should not also be added to a test suite. * Utilise the hierarchy of NonBuildTests markers to help exclude false positives. * Update all omitted tests. Either add the test to AllUnitTestsSuite if it passes and runs quickly, mark the test with the appropriate NonBuildTests interface or mark the class as abstract (if appropriate). Mark one test (RemoteTransformerClientTest) as a NeverRunTest even though it passes because it takes 12 seconds to run and is marked as deprecated. * Mark two Camel tests as 'never run' because they failed on the CI. --- repository/pom.xml | 6 + .../java/org/alfresco/AllUnitTestsSuite.java | 29 ++- .../messaging/camel/CamelComponentsTest.java | 3 + .../messaging/camel/CamelRoutesTest.java | 3 + .../ActionParameterConstraintTest.java | 3 + .../evaluator/HasChildEvaluatorTest.java | 3 + .../action/evaluator/HasTagEvaluatorTest.java | 3 + .../executer/CheckOutActionExecuterTest.java | 3 +- .../ExecuteAllRulesActionExecuterTest.java | 3 +- .../TakeOwnershipActionExecuterTest.java | 53 ++--- ...itionSimpleWorkflowActionExecuterTest.java | 3 +- .../FreeMarkerModelLuceneFunctionTest.java | 3 +- .../impl/AbstractBulkImportTests.java | 2 +- .../repo/content/MimetypeMapContentTest.java | 53 ++--- .../CachingContentStoreSpringTest.java | 53 ++--- .../BucketAwareFileContentStoreTest.java | 3 +- .../VolumeAwareFileContentStoreTest.java | 3 +- .../xml/XmlMetadataExtracterTest.java | 54 ++--- .../AggregatingContentStoreTest.java | 3 +- .../RemoteTransformerClientTest.java | 3 + .../repo/dictionary/DictionaryDAOTest.java | 53 ++--- .../dictionary/DictionaryLoadDAOTest.java | 3 + .../domain/node/NodePropertyHelperTest.java | 53 ++--- .../subscriptions/SubscriptionDAOTest.java | 53 ++--- .../org/alfresco/repo/imap/LoadTester.java | 63 +++--- .../alfresco/repo/imap/RemoteLoadTester.java | 53 ++--- .../FullInvitationServiceImplTests.java | 30 +-- .../repo/node/MetadataEncryptorTests.java | 53 ++--- .../NotificationServiceImplSystemTest.java | 111 +++++----- .../executer/AbstractRenderingEngineTest.java | 3 + ...hronousTransformClientIntegrationTest.java | 3 + .../RenditionEventProcessorTest.java | 3 + .../org/alfresco/repo/rule/BaseRuleTest.java | 2 +- .../impl/querymodel/impl/db/DBQueryTest.java | 3 +- .../script/ScriptAuthorityServiceTest.java | 3 +- .../impl/AbstractPermissionTest.java | 2 +- .../impl/AbstractReadPermissionTest.java | 2 +- .../alfresco/repo/site/CustomRoleTest.java | 3 + .../repo/site/SiteServiceTestHuge.java | 53 ++--- ...AbstractTenantRoutingContentStoreTest.java | 3 +- .../repo/version/VersionableAspectTest.java | 3 +- .../AbstractActivitiComponentTest.java | 3 + .../workflow/activiti/ActivitiSmokeTest.java | 3 + .../workflow/activiti/ActivitiSpringTest.java | 3 + .../activiti/ActivitiTaskComponentTest.java | 53 ++--- .../debug/OutputSpacesStoreSystemTest.java | 49 ++--- .../test/OmittedTestClassFinderUnitTest.java | 191 ++++++++++++++++++ 47 files changed, 727 insertions(+), 419 deletions(-) create mode 100644 repository/src/test/java/org/alfresco/util/test/OmittedTestClassFinderUnitTest.java diff --git a/repository/pom.xml b/repository/pom.xml index e2322d98cf..b3b45cc417 100644 --- a/repository/pom.xml +++ b/repository/pom.xml @@ -865,6 +865,12 @@ ${dependency.awaitility.version} test + + org.reflections + reflections + 0.9.12 + test + diff --git a/repository/src/test/java/org/alfresco/AllUnitTestsSuite.java b/repository/src/test/java/org/alfresco/AllUnitTestsSuite.java index decef229e4..d2cdb9d177 100644 --- a/repository/src/test/java/org/alfresco/AllUnitTestsSuite.java +++ b/repository/src/test/java/org/alfresco/AllUnitTestsSuite.java @@ -43,10 +43,14 @@ import org.junit.runners.Suite; org.alfresco.encryption.KeyStoreKeyProviderTest.class, org.alfresco.filesys.config.ServerConfigurationBeanTest.class, org.alfresco.filesys.repo.rules.ShuffleTest.class, + org.alfresco.opencmis.AlfrescoCmisExceptionInterceptorTest.class, org.alfresco.repo.admin.Log4JHierarchyInitTest.class, org.alfresco.repo.attributes.PropTablesCleanupJobTest.class, + org.alfresco.repo.cache.AbstractCacheFactoryTest.class, org.alfresco.repo.cache.DefaultCacheFactoryTest.class, org.alfresco.repo.cache.DefaultSimpleCacheTest.class, + org.alfresco.repo.cache.InMemoryCacheStatisticsTest.class, + org.alfresco.repo.cache.TransactionStatsTest.class, org.alfresco.repo.cache.lookup.EntityLookupCacheTest.class, org.alfresco.repo.calendar.CalendarHelpersTest.class, org.alfresco.repo.copy.CopyServiceImplUnitTest.class, @@ -56,13 +60,16 @@ import org.junit.runners.Suite; org.alfresco.repo.forms.processor.workflow.WorkflowFormProcessorTest.class, org.alfresco.repo.invitation.site.InviteSenderTest.class, org.alfresco.repo.invitation.site.InviteModeratedSenderTest.class, + org.alfresco.repo.jscript.ScriptSearchTest.class, org.alfresco.repo.lock.LockUtilsTest.class, org.alfresco.repo.lock.mem.LockStoreImplTest.class, + org.alfresco.repo.management.subsystems.CryptodocSwitchableApplicationContextFactoryTest.class, org.alfresco.repo.module.ModuleDetailsImplTest.class, org.alfresco.repo.module.ModuleVersionNumberTest.class, org.alfresco.repo.module.tool.ModuleManagementToolTest.class, org.alfresco.repo.module.tool.WarHelperImplTest.class, org.alfresco.repo.module.tool.ModuleServiceImplTest.class, + org.alfresco.repo.node.integrity.IntegrityEventTest.class, org.alfresco.repo.policy.MTPolicyComponentTest.class, org.alfresco.repo.policy.PolicyComponentTest.class, org.alfresco.repo.rendition.RenditionNodeManagerTest.class, @@ -70,6 +77,7 @@ import org.junit.runners.Suite; org.alfresco.repo.replication.ReplicationServiceImplTest.class, org.alfresco.repo.service.StoreRedirectorProxyFactoryTest.class, org.alfresco.repo.site.RoleComparatorImplTest.class, + org.alfresco.repo.tenant.MultiTAdminServiceImplTest.class, org.alfresco.repo.thumbnail.ThumbnailServiceImplParameterTest.class, org.alfresco.repo.transfer.ContentChunkerImplTest.class, org.alfresco.repo.transfer.HttpClientTransmitterImplTest.class, @@ -110,17 +118,27 @@ import org.junit.runners.Suite; org.alfresco.util.schemacomp.validator.NameValidatorTest.class, org.alfresco.util.schemacomp.validator.SchemaVersionValidatorTest.class, org.alfresco.util.schemacomp.validator.TypeNameOnlyValidatorTest.class, + org.alfresco.util.test.OmittedTestClassFinderUnitTest.class, org.alfresco.util.test.junitrules.TemporaryMockOverrideTest.class, + org.alfresco.repo.search.impl.querymodel.impl.db.DBQueryEngineTest.class, + org.alfresco.repo.search.impl.querymodel.impl.db.NodePermissionAssessorLimitsTest.class, + org.alfresco.repo.search.impl.querymodel.impl.db.NodePermissionAssessorPermissionsTest.class, + org.alfresco.repo.search.impl.solr.DbOrIndexSwitchingQueryLanguageTest.class, org.alfresco.repo.search.impl.solr.SolrQueryHTTPClientTest.class, org.alfresco.repo.search.impl.solr.SolrSQLHttpClientTest.class, org.alfresco.repo.search.impl.solr.SolrStatsResultTest.class, + org.alfresco.repo.search.impl.solr.SolrSQLJSONResultMetadataSetTest.class, org.alfresco.repo.search.impl.solr.facet.SolrFacetComparatorTest.class, org.alfresco.repo.search.impl.solr.facet.FacetQNameUtilsTest.class, org.alfresco.util.BeanExtenderUnitTest.class, org.alfresco.repo.search.impl.solr.SpellCheckDecisionManagerTest.class, org.alfresco.repo.search.impl.solr.SolrStoreMappingWrapperTest.class, + org.alfresco.repo.solr.SOLRTrackingComponentUnitTest.class, org.alfresco.repo.security.authentication.CompositePasswordEncoderTest.class, org.alfresco.repo.security.authentication.PasswordHashingTest.class, + org.alfresco.repo.security.authority.script.ScriptAuthorityService_RegExTest.class, + org.alfresco.repo.security.permissions.PermissionCheckCollectionTest.class, + org.alfresco.repo.security.sync.LDAPUserRegistryTest.class, org.alfresco.traitextender.TraitExtenderIntegrationTest.class, org.alfresco.traitextender.AJExtensionsCompileTest.class, @@ -157,8 +175,12 @@ import org.junit.runners.Suite; org.alfresco.repo.action.ActionConditionImplTest.class, org.alfresco.repo.action.CompositeActionImplTest.class, org.alfresco.repo.action.CompositeActionConditionImplTest.class, + org.alfresco.repo.action.executer.TransformActionExecuterTest.class, org.alfresco.repo.audit.AuditableAnnotationTest.class, org.alfresco.repo.audit.PropertyAuditFilterTest.class, + org.alfresco.repo.audit.access.NodeChangeTest.class, + org.alfresco.repo.content.LimitedStreamCopierTest.class, + org.alfresco.repo.content.filestore.FileIOTest.class, org.alfresco.repo.content.filestore.SpoofedTextContentReaderTest.class, org.alfresco.repo.content.ContentDataTest.class, org.alfresco.service.cmr.repository.TransformationOptionLimitsTest.class, @@ -172,6 +194,7 @@ import org.junit.runners.Suite; org.alfresco.repo.content.caching.ContentCacheImplTest.class, org.alfresco.repo.domain.permissions.FixedAclUpdaterUnitTest.class, org.alfresco.repo.domain.propval.PropertyTypeConverterTest.class, + org.alfresco.repo.domain.schema.script.ScriptBundleExecutorImplTest.class, org.alfresco.repo.search.MLAnaysisModeExpansionTest.class, org.alfresco.repo.search.DocumentNavigatorTest.class, org.alfresco.util.NumericEncodingTest.class, @@ -180,6 +203,7 @@ import org.junit.runners.Suite; org.alfresco.repo.search.impl.parsers.FTSTest.class, org.alfresco.repo.security.authentication.AlfrescoSSLSocketFactoryTest.class, org.alfresco.repo.security.authentication.AuthorizationTest.class, + org.alfresco.repo.security.permissions.PermissionCheckedCollectionTest.class, org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSetTest.class, org.alfresco.repo.security.authentication.ChainingAuthenticationServiceTest.class, org.alfresco.repo.security.authentication.NameBasedUserNameGeneratorTest.class, @@ -187,9 +211,10 @@ import org.junit.runners.Suite; org.alfresco.repo.version.common.VersionHistoryImplTest.class, org.alfresco.repo.version.common.versionlabel.SerialVersionLabelPolicyTest.class, org.alfresco.repo.workflow.activiti.WorklfowObjectFactoryTest.class, + org.alfresco.repo.workflow.activiti.properties.ActivitiPriorityPropertyHandlerTest.class, org.alfresco.repo.workflow.WorkflowSuiteContextShutdownTest.class, org.alfresco.repo.search.LuceneUtilsTest.class, - + org.alfresco.heartbeat.HBDataCollectorServiceImplTest.class, org.alfresco.heartbeat.jobs.LockingJobTest.class, org.alfresco.heartbeat.jobs.QuartzJobSchedulerTest.class, @@ -197,6 +222,7 @@ import org.junit.runners.Suite; org.alfresco.heartbeat.ConfigurationDataCollectorTest.class, org.alfresco.heartbeat.InfoDataCollectorTest.class, org.alfresco.heartbeat.ModelUsageDataCollectorTest.class, + org.alfresco.heartbeat.SessionsUsageDataCollectorTest.class, org.alfresco.heartbeat.SystemUsageDataCollectorTest.class, org.alfresco.util.BeanExtenderUnitTest.class, @@ -204,6 +230,7 @@ import org.junit.runners.Suite; org.alfresco.util.resource.HierarchicalResourceLoaderTest.class, org.alfresco.repo.events.ClientUtilTest.class, org.alfresco.repo.rendition2.RenditionService2Test.class, + org.alfresco.repo.rendition2.TransformationOptionsConverterTest.class, org.alfresco.transform.client.registry.TransformServiceRegistryConfigTest.class, org.alfresco.repo.event2.RepoEvent2UnitSuite.class diff --git a/repository/src/test/java/org/alfresco/messaging/camel/CamelComponentsTest.java b/repository/src/test/java/org/alfresco/messaging/camel/CamelComponentsTest.java index 5cbc6358d3..e1d88a3005 100644 --- a/repository/src/test/java/org/alfresco/messaging/camel/CamelComponentsTest.java +++ b/repository/src/test/java/org/alfresco/messaging/camel/CamelComponentsTest.java @@ -25,10 +25,12 @@ */ package org.alfresco.messaging.camel; +import org.alfresco.util.testing.category.NeverRunsTests; import org.apache.camel.CamelContext; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; @@ -40,6 +42,7 @@ import static org.junit.Assert.assertEquals; * Tests Camel components defined in the application's Spring context */ @RunWith(SpringJUnit4ClassRunner.class) +@Category(NeverRunsTests.class) @ContextConfiguration(locations = "/test-messaging-context.xml") public class CamelComponentsTest { @Autowired diff --git a/repository/src/test/java/org/alfresco/messaging/camel/CamelRoutesTest.java b/repository/src/test/java/org/alfresco/messaging/camel/CamelRoutesTest.java index 57cdd43eaf..a2e915c3be 100644 --- a/repository/src/test/java/org/alfresco/messaging/camel/CamelRoutesTest.java +++ b/repository/src/test/java/org/alfresco/messaging/camel/CamelRoutesTest.java @@ -27,12 +27,14 @@ package org.alfresco.messaging.camel; import static org.junit.Assert.*; +import org.alfresco.util.testing.category.NeverRunsTests; import org.apache.camel.CamelContext; import org.apache.camel.EndpointInject; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.component.mock.MockEndpoint; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; @@ -44,6 +46,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Ray Gauss II */ @RunWith(SpringJUnit4ClassRunner.class) +@Category(NeverRunsTests.class) @ContextConfiguration(locations = "/test-messaging-context.xml") public class CamelRoutesTest { diff --git a/repository/src/test/java/org/alfresco/repo/action/constraint/ActionParameterConstraintTest.java b/repository/src/test/java/org/alfresco/repo/action/constraint/ActionParameterConstraintTest.java index 4d9224c84f..47ab134efc 100644 --- a/repository/src/test/java/org/alfresco/repo/action/constraint/ActionParameterConstraintTest.java +++ b/repository/src/test/java/org/alfresco/repo/action/constraint/ActionParameterConstraintTest.java @@ -32,13 +32,16 @@ import org.alfresco.repo.action.evaluator.compare.ComparePropertyValueOperation; import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.action.ParameterConstraint; import org.alfresco.util.BaseSpringTest; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; +import org.junit.experimental.categories.Category; /** * Action parameter constraint unit test * * @author Roy Wetherall */ +@Category(NeverRunsTests.class) public class ActionParameterConstraintTest extends BaseSpringTest { private static final String COMPARE_OP = "ac-compare-operations"; diff --git a/repository/src/test/java/org/alfresco/repo/action/evaluator/HasChildEvaluatorTest.java b/repository/src/test/java/org/alfresco/repo/action/evaluator/HasChildEvaluatorTest.java index a4cf32644d..acfecf7095 100644 --- a/repository/src/test/java/org/alfresco/repo/action/evaluator/HasChildEvaluatorTest.java +++ b/repository/src/test/java/org/alfresco/repo/action/evaluator/HasChildEvaluatorTest.java @@ -34,7 +34,9 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; +import org.junit.experimental.categories.Category; import org.springframework.transaction.annotation.Transactional; /** @@ -44,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional; * @since 3.4 */ @Transactional +@Category(NeverRunsTests.class) public class HasChildEvaluatorTest extends BaseSpringTest { private NodeService nodeService; diff --git a/repository/src/test/java/org/alfresco/repo/action/evaluator/HasTagEvaluatorTest.java b/repository/src/test/java/org/alfresco/repo/action/evaluator/HasTagEvaluatorTest.java index 0ae69cd9c0..58e98b3634 100644 --- a/repository/src/test/java/org/alfresco/repo/action/evaluator/HasTagEvaluatorTest.java +++ b/repository/src/test/java/org/alfresco/repo/action/evaluator/HasTagEvaluatorTest.java @@ -36,7 +36,9 @@ import org.alfresco.service.cmr.tagging.TaggingService; import org.alfresco.service.namespace.QName; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; +import org.junit.experimental.categories.Category; import org.springframework.transaction.annotation.Transactional; /** @@ -45,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional; * @author Roy Wetherall */ @Transactional +@Category(NeverRunsTests.class) public class HasTagEvaluatorTest extends BaseSpringTest { private NodeService nodeService; diff --git a/repository/src/test/java/org/alfresco/repo/action/executer/CheckOutActionExecuterTest.java b/repository/src/test/java/org/alfresco/repo/action/executer/CheckOutActionExecuterTest.java index c0dbb13824..3c9387a26b 100644 --- a/repository/src/test/java/org/alfresco/repo/action/executer/CheckOutActionExecuterTest.java +++ b/repository/src/test/java/org/alfresco/repo/action/executer/CheckOutActionExecuterTest.java @@ -36,6 +36,7 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; import org.junit.experimental.categories.Category; import org.springframework.transaction.annotation.Transactional; @@ -43,7 +44,7 @@ import org.springframework.transaction.annotation.Transactional; /** * Tests checkout using action executer */ -@Category(BaseSpringTestsCategory.class) +@Category({BaseSpringTestsCategory.class, NeverRunsTests.class}) @Transactional public class CheckOutActionExecuterTest extends BaseSpringTest { diff --git a/repository/src/test/java/org/alfresco/repo/action/executer/ExecuteAllRulesActionExecuterTest.java b/repository/src/test/java/org/alfresco/repo/action/executer/ExecuteAllRulesActionExecuterTest.java index 6471762a73..630fa2b517 100644 --- a/repository/src/test/java/org/alfresco/repo/action/executer/ExecuteAllRulesActionExecuterTest.java +++ b/repository/src/test/java/org/alfresco/repo/action/executer/ExecuteAllRulesActionExecuterTest.java @@ -51,6 +51,7 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; import org.junit.experimental.categories.Category; @@ -68,7 +69,7 @@ import static org.alfresco.repo.rule.RuleModel.ASPECT_IGNORE_INHERITED_RULES; * * @author Roy Wetherall */ -@Category(BaseSpringTestsCategory.class) +@Category({BaseSpringTestsCategory.class, NeverRunsTests.class}) @Transactional public class ExecuteAllRulesActionExecuterTest extends BaseSpringTest { diff --git a/repository/src/test/java/org/alfresco/repo/action/executer/TakeOwnershipActionExecuterTest.java b/repository/src/test/java/org/alfresco/repo/action/executer/TakeOwnershipActionExecuterTest.java index 312c56e39f..3e405b400e 100644 --- a/repository/src/test/java/org/alfresco/repo/action/executer/TakeOwnershipActionExecuterTest.java +++ b/repository/src/test/java/org/alfresco/repo/action/executer/TakeOwnershipActionExecuterTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.executer; import static org.junit.Assert.assertEquals; @@ -43,6 +43,7 @@ import org.alfresco.util.test.junitrules.RunAsFullyAuthenticatedRule; import org.alfresco.util.test.junitrules.TemporaryNodes; import org.alfresco.util.test.junitrules.TemporarySites; import org.alfresco.util.test.junitrules.TemporarySites.TestSiteAndMemberInfo; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; @@ -51,7 +52,7 @@ import org.junit.experimental.categories.Category; import org.junit.rules.RuleChain; /** Tests for {@link TakeOwnershipActionExecuter}. */ -@Category(OwnJVMTestsCategory.class) +@Category({OwnJVMTestsCategory.class, NeverRunsTests.class}) public class TakeOwnershipActionExecuterTest { // Rule to initialise the default Alfresco spring configuration diff --git a/repository/src/test/java/org/alfresco/repo/action/executer/TransitionSimpleWorkflowActionExecuterTest.java b/repository/src/test/java/org/alfresco/repo/action/executer/TransitionSimpleWorkflowActionExecuterTest.java index acf3dfe45e..7072872572 100644 --- a/repository/src/test/java/org/alfresco/repo/action/executer/TransitionSimpleWorkflowActionExecuterTest.java +++ b/repository/src/test/java/org/alfresco/repo/action/executer/TransitionSimpleWorkflowActionExecuterTest.java @@ -38,6 +38,7 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseAlfrescoSpringTest; import org.alfresco.util.GUID; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; import org.junit.experimental.categories.Category; @@ -46,7 +47,7 @@ import org.junit.experimental.categories.Category; * * @author Roy Wetherall */ -@Category(BaseSpringTestsCategory.class) +@Category({BaseSpringTestsCategory.class, NeverRunsTests.class}) public class TransitionSimpleWorkflowActionExecuterTest extends BaseAlfrescoSpringTest { private FileFolderService fileFolderService; diff --git a/repository/src/test/java/org/alfresco/repo/action/scheduled/FreeMarkerModelLuceneFunctionTest.java b/repository/src/test/java/org/alfresco/repo/action/scheduled/FreeMarkerModelLuceneFunctionTest.java index ded4ce210a..18b605c0e5 100644 --- a/repository/src/test/java/org/alfresco/repo/action/scheduled/FreeMarkerModelLuceneFunctionTest.java +++ b/repository/src/test/java/org/alfresco/repo/action/scheduled/FreeMarkerModelLuceneFunctionTest.java @@ -41,6 +41,7 @@ import org.alfresco.service.transaction.TransactionService; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.testing.category.LuceneTests; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; import org.springframework.extensions.surf.util.ISO8601DateFormat; @@ -50,7 +51,7 @@ import org.springframework.extensions.surf.util.ISO8601DateFormat; * * @author Andy Hind */ -@Category({OwnJVMTestsCategory.class, LuceneTests.class}) +@Category({OwnJVMTestsCategory.class, LuceneTests.class, NeverRunsTests.class}) public class FreeMarkerModelLuceneFunctionTest extends TestCase { //private static SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sssZ"); diff --git a/repository/src/test/java/org/alfresco/repo/bulkimport/impl/AbstractBulkImportTests.java b/repository/src/test/java/org/alfresco/repo/bulkimport/impl/AbstractBulkImportTests.java index 9a2338e24c..3ce224a00f 100644 --- a/repository/src/test/java/org/alfresco/repo/bulkimport/impl/AbstractBulkImportTests.java +++ b/repository/src/test/java/org/alfresco/repo/bulkimport/impl/AbstractBulkImportTests.java @@ -77,7 +77,7 @@ import static org.junit.Assert.fail; * @since 4.0 */ @Category(LuceneTests.class) -public class AbstractBulkImportTests +public abstract class AbstractBulkImportTests { protected static ApplicationContext ctx; diff --git a/repository/src/test/java/org/alfresco/repo/content/MimetypeMapContentTest.java b/repository/src/test/java/org/alfresco/repo/content/MimetypeMapContentTest.java index 4fe5b21938..7cd71846fd 100644 --- a/repository/src/test/java/org/alfresco/repo/content/MimetypeMapContentTest.java +++ b/repository/src/test/java/org/alfresco/repo/content/MimetypeMapContentTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.content; import java.io.File; @@ -37,6 +37,7 @@ import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.MimetypeService; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.DataModelTestApplicationContextHelper; +import org.alfresco.util.testing.category.NeverRunsTests; import org.apache.poi.util.IOUtils; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; @@ -47,7 +48,7 @@ import org.springframework.context.ApplicationContext; * @see org.alfresco.repo.content.MimetypeMap * @see org.alfresco.repo.content.MimetypeMapTest */ -@Category(OwnJVMTestsCategory.class) +@Category({OwnJVMTestsCategory.class, NeverRunsTests.class}) public class MimetypeMapContentTest extends TestCase { private static ApplicationContext ctx = DataModelTestApplicationContextHelper.getApplicationContext(); diff --git a/repository/src/test/java/org/alfresco/repo/content/caching/CachingContentStoreSpringTest.java b/repository/src/test/java/org/alfresco/repo/content/caching/CachingContentStoreSpringTest.java index ea573d1704..7d0e38728c 100644 --- a/repository/src/test/java/org/alfresco/repo/content/caching/CachingContentStoreSpringTest.java +++ b/repository/src/test/java/org/alfresco/repo/content/caching/CachingContentStoreSpringTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.content.caching; import static org.junit.Assert.assertEquals; @@ -46,6 +46,7 @@ import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.TempFileProvider; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; import org.junit.experimental.categories.Category; import org.junit.internal.runners.JUnit38ClassRunner; @@ -58,7 +59,7 @@ import org.junit.runner.RunWith; * @author Matt Ward */ @RunWith(JUnit38ClassRunner.class) -@Category(OwnJVMTestsCategory.class) +@Category({OwnJVMTestsCategory.class, NeverRunsTests.class}) public class CachingContentStoreSpringTest extends AbstractWritableContentStoreTest { private CachingContentStore store; diff --git a/repository/src/test/java/org/alfresco/repo/content/filestore/BucketAwareFileContentStoreTest.java b/repository/src/test/java/org/alfresco/repo/content/filestore/BucketAwareFileContentStoreTest.java index 18a3360333..5b9bffebec 100644 --- a/repository/src/test/java/org/alfresco/repo/content/filestore/BucketAwareFileContentStoreTest.java +++ b/repository/src/test/java/org/alfresco/repo/content/filestore/BucketAwareFileContentStoreTest.java @@ -29,6 +29,7 @@ package org.alfresco.repo.content.filestore; import java.io.File; import org.alfresco.test_category.OwnJVMTestsCategory; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -43,7 +44,7 @@ import static org.junit.Assert.assertTrue; * @author Andreea Dragoi * */ -@Category(OwnJVMTestsCategory.class) +@Category({OwnJVMTestsCategory.class, NeverRunsTests.class}) public class BucketAwareFileContentStoreTest extends FileContentStoreTest { private static final int BUCKETS_PER_MINUTE = 20; diff --git a/repository/src/test/java/org/alfresco/repo/content/filestore/VolumeAwareFileContentStoreTest.java b/repository/src/test/java/org/alfresco/repo/content/filestore/VolumeAwareFileContentStoreTest.java index c3677e6a38..185e3779a7 100644 --- a/repository/src/test/java/org/alfresco/repo/content/filestore/VolumeAwareFileContentStoreTest.java +++ b/repository/src/test/java/org/alfresco/repo/content/filestore/VolumeAwareFileContentStoreTest.java @@ -29,6 +29,7 @@ import java.io.File; import java.io.IOException; import org.alfresco.test_category.OwnJVMTestsCategory; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -39,7 +40,7 @@ import static org.junit.Assert.assertTrue; * to route content from a store to a selection of filesystem volumes * @author Andreea Dragoi */ -@Category(OwnJVMTestsCategory.class) +@Category({OwnJVMTestsCategory.class, NeverRunsTests.class}) public class VolumeAwareFileContentStoreTest extends FileContentStoreTest{ private static final String VOLUMES = "volumeA,volumeB,volumeC"; diff --git a/repository/src/test/java/org/alfresco/repo/content/metadata/xml/XmlMetadataExtracterTest.java b/repository/src/test/java/org/alfresco/repo/content/metadata/xml/XmlMetadataExtracterTest.java index 1967bcf802..b76dbbd81b 100644 --- a/repository/src/test/java/org/alfresco/repo/content/metadata/xml/XmlMetadataExtracterTest.java +++ b/repository/src/test/java/org/alfresco/repo/content/metadata/xml/XmlMetadataExtracterTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.content.metadata.xml; import static org.alfresco.repo.content.metadata.AbstractMetadataExtracterTest.QUICK_DESCRIPTION; @@ -33,7 +33,6 @@ import java.io.FileNotFoundException; import java.net.URL; import junit.framework.TestCase; - import org.alfresco.model.ContentModel; import org.alfresco.repo.action.ActionImpl; import org.alfresco.repo.action.executer.ActionExecuter; @@ -59,6 +58,8 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; import org.alfresco.util.PropertyMap; +import org.alfresco.util.testing.category.NeverRunsTests; +import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -69,6 +70,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; * * @author Derek Hulley */ +@Category(NeverRunsTests.class) public class XmlMetadataExtracterTest extends TestCase { private static final String FILE_ALFRESCO_MODEL = "xml-metadata/alfresco-model-sample.xml"; diff --git a/repository/src/test/java/org/alfresco/repo/content/replication/AggregatingContentStoreTest.java b/repository/src/test/java/org/alfresco/repo/content/replication/AggregatingContentStoreTest.java index b98bcd8fe4..ecfaf17823 100644 --- a/repository/src/test/java/org/alfresco/repo/content/replication/AggregatingContentStoreTest.java +++ b/repository/src/test/java/org/alfresco/repo/content/replication/AggregatingContentStoreTest.java @@ -40,6 +40,7 @@ import org.alfresco.service.cmr.repository.DirectAccessUrl; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.GUID; import org.alfresco.util.TempFileProvider; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -69,7 +70,7 @@ import static org.mockito.Mockito.when; * @author Derek Hulley * @author Mark Rogers */ -@Category(OwnJVMTestsCategory.class) +@Category({OwnJVMTestsCategory.class, NeverRunsTests.class}) public class AggregatingContentStoreTest extends AbstractWritableContentStoreTest { private static final String SOME_CONTENT = "The No. 1 Ladies' Detective Agency"; diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/RemoteTransformerClientTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/RemoteTransformerClientTest.java index 93f278ec77..c346ad4007 100644 --- a/repository/src/test/java/org/alfresco/repo/content/transform/RemoteTransformerClientTest.java +++ b/repository/src/test/java/org/alfresco/repo/content/transform/RemoteTransformerClientTest.java @@ -28,6 +28,7 @@ package org.alfresco.repo.content.transform; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.util.Pair; +import org.alfresco.util.testing.category.NeverRunsTests; import org.apache.commons.logging.Log; import org.apache.http.Header; import org.apache.http.HttpEntity; @@ -37,6 +38,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.Spy; @@ -61,6 +63,7 @@ import static org.springframework.test.util.AssertionErrors.assertTrue; * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. */ @Deprecated +@Category(NeverRunsTests.class) public class RemoteTransformerClientTest { public static final int STARTUP_RETRY_PERIOD_SECONDS = 2; diff --git a/repository/src/test/java/org/alfresco/repo/dictionary/DictionaryDAOTest.java b/repository/src/test/java/org/alfresco/repo/dictionary/DictionaryDAOTest.java index 34edce9fa5..2f610e837a 100644 --- a/repository/src/test/java/org/alfresco/repo/dictionary/DictionaryDAOTest.java +++ b/repository/src/test/java/org/alfresco/repo/dictionary/DictionaryDAOTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.dictionary; import static org.junit.Assert.assertNotNull; @@ -45,8 +45,10 @@ import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.QName; import org.alfresco.util.ThreadPoolExecutorFactoryBean; import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.springframework.extensions.surf.util.I18NUtil; /** @@ -54,6 +56,7 @@ import org.springframework.extensions.surf.util.I18NUtil; * @author sglover * */ +@Category(NeverRunsTests.class) public class DictionaryDAOTest { public static final String TEST_RESOURCE_MESSAGES = "alfresco/messages/dictionary-messages"; diff --git a/repository/src/test/java/org/alfresco/repo/dictionary/DictionaryLoadDAOTest.java b/repository/src/test/java/org/alfresco/repo/dictionary/DictionaryLoadDAOTest.java index e0bb533097..358c2b002e 100644 --- a/repository/src/test/java/org/alfresco/repo/dictionary/DictionaryLoadDAOTest.java +++ b/repository/src/test/java/org/alfresco/repo/dictionary/DictionaryLoadDAOTest.java @@ -39,8 +39,10 @@ import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork; import org.alfresco.util.DynamicallySizedThreadPoolExecutor; import org.alfresco.util.TraceableThreadFactory; import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.springframework.extensions.surf.util.I18NUtil; /** @@ -48,6 +50,7 @@ import org.springframework.extensions.surf.util.I18NUtil; * @author sglover * */ +@Category (NeverRunsTests.class) public class DictionaryLoadDAOTest { public static final String TEST_RESOURCE_MESSAGES = "alfresco/messages/dictionary-messages"; diff --git a/repository/src/test/java/org/alfresco/repo/domain/node/NodePropertyHelperTest.java b/repository/src/test/java/org/alfresco/repo/domain/node/NodePropertyHelperTest.java index 81baaca64f..696fa0bee7 100644 --- a/repository/src/test/java/org/alfresco/repo/domain/node/NodePropertyHelperTest.java +++ b/repository/src/test/java/org/alfresco/repo/domain/node/NodePropertyHelperTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.domain.node; import java.io.Serializable; @@ -50,6 +50,8 @@ import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.EqualsHelper; +import org.alfresco.util.testing.category.NeverRunsTests; +import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; /** @@ -60,6 +62,7 @@ import org.springframework.context.ApplicationContext; * @author Derek Hulley * @since 3.4 */ +@Category (NeverRunsTests.class) public class NodePropertyHelperTest extends TestCase { private static final QName QN_BOOLEAN = createQName("boolean"); diff --git a/repository/src/test/java/org/alfresco/repo/domain/subscriptions/SubscriptionDAOTest.java b/repository/src/test/java/org/alfresco/repo/domain/subscriptions/SubscriptionDAOTest.java index 810f468042..f62cb32860 100644 --- a/repository/src/test/java/org/alfresco/repo/domain/subscriptions/SubscriptionDAOTest.java +++ b/repository/src/test/java/org/alfresco/repo/domain/subscriptions/SubscriptionDAOTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.domain.subscriptions; import junit.framework.TestCase; @@ -41,10 +41,11 @@ import org.alfresco.service.cmr.subscriptions.SubscriptionItemTypeEnum; import org.alfresco.service.transaction.TransactionService; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.ApplicationContextHelper; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; -@Category(OwnJVMTestsCategory.class) +@Category({OwnJVMTestsCategory.class, NeverRunsTests.class}) public class SubscriptionDAOTest extends TestCase { private ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); diff --git a/repository/src/test/java/org/alfresco/repo/imap/LoadTester.java b/repository/src/test/java/org/alfresco/repo/imap/LoadTester.java index 0c854e44ab..5c176243bf 100644 --- a/repository/src/test/java/org/alfresco/repo/imap/LoadTester.java +++ b/repository/src/test/java/org/alfresco/repo/imap/LoadTester.java @@ -1,40 +1,40 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.imap; +import javax.mail.Flags; +import javax.transaction.UserTransaction; import java.io.IOException; import java.util.Date; import java.util.LinkedList; import java.util.List; -import javax.mail.Flags; -import javax.transaction.UserTransaction; +import com.icegreen.greenmail.store.SimpleStoredMessage; import junit.framework.TestCase; - import org.alfresco.model.ContentModel; import org.alfresco.repo.importer.ACPImportPackageHandler; import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; @@ -55,13 +55,14 @@ import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.PropertyMap; import org.alfresco.util.config.RepositoryFolderConfigBean; +import org.alfresco.util.testing.category.PerformanceTests; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; import org.springframework.core.io.ClassPathResource; -import com.icegreen.greenmail.store.SimpleStoredMessage; - +@Category(PerformanceTests.class) public class LoadTester extends TestCase { private Log logger = LogFactory.getLog(LoadTester.class); @@ -218,7 +219,7 @@ public class LoadTester extends TestCase private void reauthenticate(String name, String password) { - authenticationService.invalidateTicket(authenticationService.getCurrentTicket()); + authenticationService.invalidateTicket(authenticationService.getCurrentTicket()); authenticationService.clearCurrentSecurityContext(); authenticationService.authenticate(name, password.toCharArray()); } diff --git a/repository/src/test/java/org/alfresco/repo/imap/RemoteLoadTester.java b/repository/src/test/java/org/alfresco/repo/imap/RemoteLoadTester.java index 74d1edf107..6b28a4bd92 100644 --- a/repository/src/test/java/org/alfresco/repo/imap/RemoteLoadTester.java +++ b/repository/src/test/java/org/alfresco/repo/imap/RemoteLoadTester.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.imap; import java.io.BufferedInputStream; @@ -41,11 +41,14 @@ import javax.mail.Store; import javax.mail.internet.MimeMultipart; import junit.framework.TestCase; +import org.alfresco.util.testing.category.PerformanceTests; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.experimental.categories.Category; import com.sun.mail.util.BASE64DecoderStream; +@Category(PerformanceTests.class) public class RemoteLoadTester extends TestCase { diff --git a/repository/src/test/java/org/alfresco/repo/invitation/FullInvitationServiceImplTests.java b/repository/src/test/java/org/alfresco/repo/invitation/FullInvitationServiceImplTests.java index a1062eaae5..4e0941995a 100644 --- a/repository/src/test/java/org/alfresco/repo/invitation/FullInvitationServiceImplTests.java +++ b/repository/src/test/java/org/alfresco/repo/invitation/FullInvitationServiceImplTests.java @@ -23,16 +23,20 @@ * along with Alfresco. If not, see . * #L% */ - -package org.alfresco.repo.invitation; - -/** - * Test InvitationService with both engines enabled. - * - * @author Nick Smith - * @since 4.0 - */ -public class FullInvitationServiceImplTests extends AbstractInvitationServiceImplTest -{ - // See inherited tests. -} + +package org.alfresco.repo.invitation; + +import org.alfresco.util.testing.category.NeverRunsTests; +import org.junit.experimental.categories.Category; + +/** + * Test InvitationService with both engines enabled. + * + * @author Nick Smith + * @since 4.0 + */ +@Category(NeverRunsTests.class) +public class FullInvitationServiceImplTests extends AbstractInvitationServiceImplTest +{ + // See inherited tests. +} diff --git a/repository/src/test/java/org/alfresco/repo/node/MetadataEncryptorTests.java b/repository/src/test/java/org/alfresco/repo/node/MetadataEncryptorTests.java index a6bff944ee..2a512c23c3 100644 --- a/repository/src/test/java/org/alfresco/repo/node/MetadataEncryptorTests.java +++ b/repository/src/test/java/org/alfresco/repo/node/MetadataEncryptorTests.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.node; import java.io.Serializable; @@ -50,11 +50,14 @@ import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.PropertyMap; +import org.alfresco.util.testing.category.NeverRunsTests; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.experimental.categories.Category; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.extensions.surf.util.I18NUtil; +@Category(NeverRunsTests.class) public class MetadataEncryptorTests extends TestCase { private static final String TEST_MODEL = "org/alfresco/repo/node/encrypted_prop_model.xml"; diff --git a/repository/src/test/java/org/alfresco/repo/notification/NotificationServiceImplSystemTest.java b/repository/src/test/java/org/alfresco/repo/notification/NotificationServiceImplSystemTest.java index ec46b173ca..2763438325 100644 --- a/repository/src/test/java/org/alfresco/repo/notification/NotificationServiceImplSystemTest.java +++ b/repository/src/test/java/org/alfresco/repo/notification/NotificationServiceImplSystemTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.notification; import java.io.Serializable; @@ -32,8 +32,8 @@ import java.util.Map; import org.alfresco.model.ContentModel; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.model.Repository; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.notification.NotificationContext; @@ -47,6 +47,7 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseAlfrescoTestCase; import org.alfresco.util.GUID; +import org.alfresco.util.testing.category.NeverRunsTests; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.experimental.categories.Category; @@ -57,7 +58,7 @@ import org.junit.experimental.categories.Category; * @author Roy Wetherall * @since 4.0 */ -@Category(OwnJVMTestsCategory.class) +@Category({OwnJVMTestsCategory.class, NeverRunsTests.class}) public class NotificationServiceImplSystemTest extends BaseAlfrescoTestCase { private static final String FROM_USER = "fromUser" + GUID.generate(); @@ -196,33 +197,33 @@ public class NotificationServiceImplSystemTest extends BaseAlfrescoTestCase protected boolean useSpacesStore() { return true; - } - - public void testSimpleEmailNotificationSystem() - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public Void doWork() - { - NotificationContext context = new NotificationContext(); - - context.setFrom(FROM_EMAIL); - context.addTo(TO_USER1); - context.setSubject(SUBJECT); - context.setBodyTemplate(template.toString()); - - Map templateArgs = new HashMap(1); - templateArgs.put("template", template); - context.setTemplateArgs(templateArgs); - - notificationService.sendNotification(EMailNotificationProvider.NAME, context); - - return null; - } - }); - } - + } + + public void testSimpleEmailNotificationSystem() + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + NotificationContext context = new NotificationContext(); + + context.setFrom(FROM_EMAIL); + context.addTo(TO_USER1); + context.setSubject(SUBJECT); + context.setBodyTemplate(template.toString()); + + Map templateArgs = new HashMap(1); + templateArgs.put("template", template); + context.setTemplateArgs(templateArgs); + + notificationService.sendNotification(EMailNotificationProvider.NAME, context); + + return null; + } + }); + } + public void testTemplateEmailNotification() diff --git a/repository/src/test/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngineTest.java b/repository/src/test/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngineTest.java index 3ab38cea19..bde0ab1f04 100644 --- a/repository/src/test/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngineTest.java +++ b/repository/src/test/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngineTest.java @@ -51,6 +51,8 @@ import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.QName; +import org.alfresco.util.testing.category.NeverRunsTests; +import org.junit.experimental.categories.Category; import org.mockito.ArgumentCaptor; /** @@ -59,6 +61,7 @@ import org.mockito.ArgumentCaptor; * @deprecated We are introducing the new async RenditionService2. */ @Deprecated +@Category(NeverRunsTests.class) public class AbstractRenderingEngineTest extends TestCase { private final NodeRef source = new NodeRef("http://test/sourceId"); diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/LocalSynchronousTransformClientIntegrationTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/LocalSynchronousTransformClientIntegrationTest.java index a5cde83a8f..1997641982 100644 --- a/repository/src/test/java/org/alfresco/repo/rendition2/LocalSynchronousTransformClientIntegrationTest.java +++ b/repository/src/test/java/org/alfresco/repo/rendition2/LocalSynchronousTransformClientIntegrationTest.java @@ -31,10 +31,12 @@ import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; @@ -50,6 +52,7 @@ import static org.alfresco.model.ContentModel.PROP_CONTENT; /** * Integration tests for {@link LocalSynchronousTransformClient} */ +@Category(NeverRunsTests.class) public class LocalSynchronousTransformClientIntegrationTest extends AbstractRenditionIntegrationTest { @Autowired diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/RenditionEventProcessorTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/RenditionEventProcessorTest.java index 802e8c1dd9..6da871da7d 100644 --- a/repository/src/test/java/org/alfresco/repo/rendition2/RenditionEventProcessorTest.java +++ b/repository/src/test/java/org/alfresco/repo/rendition2/RenditionEventProcessorTest.java @@ -32,6 +32,7 @@ import org.alfresco.repo.rawevents.types.OnContentUpdatePolicyEvent; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; +import org.alfresco.util.testing.category.NeverRunsTests; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.Message; @@ -39,6 +40,7 @@ import org.apache.camel.support.DefaultExchange; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.junit.rules.TestName; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; @@ -53,6 +55,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; * * @author Cristian Turlica */ +@Category(NeverRunsTests.class) public class RenditionEventProcessorTest { private RenditionEventProcessor renditionEventProcessor; diff --git a/repository/src/test/java/org/alfresco/repo/rule/BaseRuleTest.java b/repository/src/test/java/org/alfresco/repo/rule/BaseRuleTest.java index d7a1769e86..30229078aa 100644 --- a/repository/src/test/java/org/alfresco/repo/rule/BaseRuleTest.java +++ b/repository/src/test/java/org/alfresco/repo/rule/BaseRuleTest.java @@ -62,7 +62,7 @@ import org.springframework.transaction.annotation.Transactional; * @author Roy Wetherall */ @Transactional -public class BaseRuleTest extends BaseSpringTest +public abstract class BaseRuleTest extends BaseSpringTest { /** * Data used in the tests diff --git a/repository/src/test/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBQueryTest.java b/repository/src/test/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBQueryTest.java index e9c6ae0117..dfb43eadf8 100644 --- a/repository/src/test/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBQueryTest.java +++ b/repository/src/test/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBQueryTest.java @@ -77,6 +77,7 @@ import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.CachingDateFormat; import org.alfresco.util.testing.category.LuceneTests; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -90,7 +91,7 @@ import org.springframework.extensions.surf.util.I18NUtil; * @author Andy * */ -@Category(LuceneTests.class) +@Category({LuceneTests.class, NeverRunsTests.class}) public class DBQueryTest implements DictionaryListener { protected static ApplicationContext ctx = null; diff --git a/repository/src/test/java/org/alfresco/repo/security/authority/script/ScriptAuthorityServiceTest.java b/repository/src/test/java/org/alfresco/repo/security/authority/script/ScriptAuthorityServiceTest.java index ec4178a93e..9f908ee4f0 100644 --- a/repository/src/test/java/org/alfresco/repo/security/authority/script/ScriptAuthorityServiceTest.java +++ b/repository/src/test/java/org/alfresco/repo/security/authority/script/ScriptAuthorityServiceTest.java @@ -59,6 +59,7 @@ import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ScriptPagingDetails; import org.alfresco.util.testing.category.LuceneTests; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; @@ -66,7 +67,7 @@ import org.springframework.context.ApplicationContext; * Tests for the Script wrapper for the Authority Service, * ScriptAuthorityService */ -@Category(LuceneTests.class) +@Category({LuceneTests.class, NeverRunsTests.class}) public class ScriptAuthorityServiceTest extends TestCase { private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); diff --git a/repository/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractPermissionTest.java b/repository/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractPermissionTest.java index c0819c2b54..955c28b8cf 100644 --- a/repository/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractPermissionTest.java +++ b/repository/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractPermissionTest.java @@ -64,7 +64,7 @@ import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.springframework.context.ApplicationContext; -public class AbstractPermissionTest extends TestCase +public abstract class AbstractPermissionTest extends TestCase { protected static final String USER2_LEMUR = "lemur"; diff --git a/repository/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractReadPermissionTest.java b/repository/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractReadPermissionTest.java index f363e6499e..4596828e0f 100644 --- a/repository/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractReadPermissionTest.java +++ b/repository/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractReadPermissionTest.java @@ -70,7 +70,7 @@ import org.springframework.context.ApplicationContext; import junit.framework.TestCase; @Category(LuceneTests.class) -public class AbstractReadPermissionTest extends TestCase +public abstract class AbstractReadPermissionTest extends TestCase { protected static ApplicationContext applicationContext = ApplicationContextHelper.getApplicationContext(); diff --git a/repository/src/test/java/org/alfresco/repo/site/CustomRoleTest.java b/repository/src/test/java/org/alfresco/repo/site/CustomRoleTest.java index 22f49b8017..0d59662c3c 100755 --- a/repository/src/test/java/org/alfresco/repo/site/CustomRoleTest.java +++ b/repository/src/test/java/org/alfresco/repo/site/CustomRoleTest.java @@ -40,7 +40,9 @@ import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.BaseAlfrescoSpringTest; import org.alfresco.util.Pair; import org.alfresco.util.PropertyMap; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Before; +import org.junit.experimental.categories.Category; import org.springframework.test.context.ContextConfiguration; import org.springframework.transaction.annotation.Transactional; @@ -52,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional; @Transactional @ContextConfiguration({"classpath:alfresco/application-context.xml", "classpath:org/alfresco/repo/site/site-custom-context.xml"}) +@Category(NeverRunsTests.class) public class CustomRoleTest extends BaseAlfrescoSpringTest { private static final String USER_ONE = "UserOne_CustomRoleTest"; diff --git a/repository/src/test/java/org/alfresco/repo/site/SiteServiceTestHuge.java b/repository/src/test/java/org/alfresco/repo/site/SiteServiceTestHuge.java index 3a33901e5f..6c9fa746ba 100644 --- a/repository/src/test/java/org/alfresco/repo/site/SiteServiceTestHuge.java +++ b/repository/src/test/java/org/alfresco/repo/site/SiteServiceTestHuge.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.site; import static org.junit.Assert.fail; @@ -47,11 +47,13 @@ import org.alfresco.service.cmr.site.SiteVisibility; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.PropertyMap; +import org.alfresco.util.testing.category.PerformanceTests; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; /** @@ -59,6 +61,7 @@ import org.springframework.context.ApplicationContext; * * @author Alan Davis */ +@Category(PerformanceTests.class) public class SiteServiceTestHuge { private enum Allocation diff --git a/repository/src/test/java/org/alfresco/repo/tenant/AbstractTenantRoutingContentStoreTest.java b/repository/src/test/java/org/alfresco/repo/tenant/AbstractTenantRoutingContentStoreTest.java index 4ad04c9215..137cb1cc8d 100644 --- a/repository/src/test/java/org/alfresco/repo/tenant/AbstractTenantRoutingContentStoreTest.java +++ b/repository/src/test/java/org/alfresco/repo/tenant/AbstractTenantRoutingContentStoreTest.java @@ -55,6 +55,7 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.testing.category.LuceneTests; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; @@ -64,7 +65,7 @@ import org.springframework.context.ApplicationContext; * @author Alfresco * @since 4.2.1 */ -@Category({OwnJVMTestsCategory.class, LuceneTests.class}) +@Category({OwnJVMTestsCategory.class, LuceneTests.class, NeverRunsTests.class}) public class AbstractTenantRoutingContentStoreTest extends TestCase { private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); diff --git a/repository/src/test/java/org/alfresco/repo/version/VersionableAspectTest.java b/repository/src/test/java/org/alfresco/repo/version/VersionableAspectTest.java index 677735df02..5cd00ab385 100644 --- a/repository/src/test/java/org/alfresco/repo/version/VersionableAspectTest.java +++ b/repository/src/test/java/org/alfresco/repo/version/VersionableAspectTest.java @@ -51,13 +51,14 @@ import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.ApplicationContextHelper; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; /** * @author Dmitry Velichkevich */ -@Category(OwnJVMTestsCategory.class) +@Category({OwnJVMTestsCategory.class, NeverRunsTests.class}) public class VersionableAspectTest extends TestCase { public static final String AUTO_VERSION_KEY = "version.store.enableAutoVersioning"; diff --git a/repository/src/test/java/org/alfresco/repo/workflow/activiti/AbstractActivitiComponentTest.java b/repository/src/test/java/org/alfresco/repo/workflow/activiti/AbstractActivitiComponentTest.java index 2c51ec8076..ba764eea3f 100644 --- a/repository/src/test/java/org/alfresco/repo/workflow/activiti/AbstractActivitiComponentTest.java +++ b/repository/src/test/java/org/alfresco/repo/workflow/activiti/AbstractActivitiComponentTest.java @@ -72,8 +72,10 @@ import org.alfresco.service.cmr.workflow.WorkflowDefinition; import org.alfresco.service.cmr.workflow.WorkflowDeployment; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.After; import org.junit.Before; +import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; @@ -93,6 +95,7 @@ import org.springframework.transaction.annotation.Transactional; "classpath:activiti/test-activiti-component-context.xml", "classpath:alfresco/activiti-context.xml"}) @Transactional +@Category(NeverRunsTests.class) public class AbstractActivitiComponentTest { protected static final String TEST_GROUP = "GROUP_testGroup"; diff --git a/repository/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiSmokeTest.java b/repository/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiSmokeTest.java index d6fe1e25a1..ddf69aab03 100644 --- a/repository/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiSmokeTest.java +++ b/repository/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiSmokeTest.java @@ -36,12 +36,15 @@ import org.activiti.engine.RepositoryService; import org.activiti.engine.RuntimeService; import org.activiti.engine.repository.Deployment; import org.activiti.engine.runtime.ProcessInstance; +import org.alfresco.util.testing.category.NeverRunsTests; +import org.junit.experimental.categories.Category; import org.springframework.core.io.ClassPathResource; /** * @author Nick Smith * @since 3.4.e */ +@Category(NeverRunsTests.class) public class ActivitiSmokeTest extends TestCase { public void testDeploy() throws Exception diff --git a/repository/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiSpringTest.java b/repository/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiSpringTest.java index bfc7a5668e..77f03b4729 100644 --- a/repository/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiSpringTest.java +++ b/repository/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiSpringTest.java @@ -48,7 +48,9 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; +import org.alfresco.util.testing.category.NeverRunsTests; import org.apache.commons.lang3.ArrayUtils; +import org.junit.experimental.categories.Category; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -56,6 +58,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; * @author Nick Smith * @since 3.4.e */ +@Category(NeverRunsTests.class) public class ActivitiSpringTest extends TestCase { private static final QName PROP_CHECK_VALUE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "check_value"); diff --git a/repository/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiTaskComponentTest.java b/repository/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiTaskComponentTest.java index 9991861878..9964cf9bff 100644 --- a/repository/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiTaskComponentTest.java +++ b/repository/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiTaskComponentTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.workflow.activiti; @@ -57,15 +57,18 @@ import org.alfresco.service.cmr.workflow.WorkflowTask; import org.alfresco.service.cmr.workflow.WorkflowTaskQuery; import org.alfresco.service.cmr.workflow.WorkflowTaskState; import org.alfresco.service.namespace.QName; +import org.alfresco.util.testing.category.NeverRunsTests; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; /** * @author Nick Smith * @author Frederik Heremans * @since 3.4.e */ +@Category(NeverRunsTests.class) public class ActivitiTaskComponentTest extends AbstractActivitiComponentTest { private WorkflowDefinition workflowDef; diff --git a/repository/src/test/java/org/alfresco/util/debug/OutputSpacesStoreSystemTest.java b/repository/src/test/java/org/alfresco/util/debug/OutputSpacesStoreSystemTest.java index 36b6a00795..b561b104d2 100644 --- a/repository/src/test/java/org/alfresco/util/debug/OutputSpacesStoreSystemTest.java +++ b/repository/src/test/java/org/alfresco/util/debug/OutputSpacesStoreSystemTest.java @@ -23,27 +23,28 @@ * along with Alfresco. If not, see . * #L% */ -package org.alfresco.util.debug; - -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.test_category.BaseSpringTestsCategory; -import org.alfresco.util.BaseSpringTest; -import org.junit.experimental.categories.Category; - -/** - * @author Roy Wetherall - */ -@Category(BaseSpringTestsCategory.class) -public class OutputSpacesStoreSystemTest extends BaseSpringTest -{ - /** - * Dump the contents of the spaces store to standard out - */ - public void testDumpSpacesStore() - { - NodeService nodeService = (NodeService)this.applicationContext.getBean("nodeService"); - StoreRef spacesStore = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); - System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, spacesStore)); - } -} +package org.alfresco.util.debug; + +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.test_category.BaseSpringTestsCategory; +import org.alfresco.util.BaseSpringTest; +import org.alfresco.util.testing.category.NeverRunsTests; +import org.junit.experimental.categories.Category; + +/** + * @author Roy Wetherall + */ +@Category({BaseSpringTestsCategory.class, NeverRunsTests.class}) +public class OutputSpacesStoreSystemTest extends BaseSpringTest +{ + /** + * Dump the contents of the spaces store to standard out + */ + public void testDumpSpacesStore() + { + NodeService nodeService = (NodeService)this.applicationContext.getBean("nodeService"); + StoreRef spacesStore = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); + System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, spacesStore)); + } +} diff --git a/repository/src/test/java/org/alfresco/util/test/OmittedTestClassFinderUnitTest.java b/repository/src/test/java/org/alfresco/util/test/OmittedTestClassFinderUnitTest.java new file mode 100644 index 0000000000..679c58288a --- /dev/null +++ b/repository/src/test/java/org/alfresco/util/test/OmittedTestClassFinderUnitTest.java @@ -0,0 +1,191 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2020 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.util.test; + +import static java.util.Collections.emptySet; +import static java.util.stream.Collectors.toSet; + +import static junit.framework.TestCase.assertEquals; + +import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Stream; + +import com.google.common.collect.Sets; +import com.google.common.collect.Sets.SetView; + +import junit.framework.TestCase; +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.util.testing.category.NonBuildTests; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runners.Suite.SuiteClasses; +import org.reflections.Reflections; +import org.reflections.scanners.MethodAnnotationsScanner; +import org.reflections.scanners.SubTypesScanner; +import org.reflections.scanners.TypeAnnotationsScanner; + +public class OmittedTestClassFinderUnitTest +{ + /** + * Test to look for tests which are unintentionally skipped by our CI. + *

+ * In particular we look for classes that contain @Test methods or extend TestCase and which are not referenced by TestSuites. There + * are a few subtleties to this: + *

    + *
  • alfresco-core and alfresco-data-model don't use test suites, and some @Test methods are executed via inheritance;
  • + *
  • some tests are explicitly marked as NonBuildTests;
  • + *
  • we assume that all test suite classes have names ending in "TestSuite".
  • + *
+ */ + @Test + public void checkTestClassesReferencedInTestSuites() + { + // We assume that all of our tests are in org.alfresco. + Reflections reflections = new Reflections("org.alfresco", new MethodAnnotationsScanner(), new TypeAnnotationsScanner(), new SubTypesScanner()); + + // Find the test classes which are not in test suites. + Set testClasses = getTestClassesOnPath(reflections); + Set classesReferencedByTestSuites = getClassesReferencedByTestSuites(reflections); + SetView unreferencedTests = Sets.difference(testClasses, classesReferencedByTestSuites); + + // Filter out tests which are in Maven modules that don't use test suites (alfresco-core and alfresco-data-model). + // Also filter any test classes contained in test dependencies (*.jar). + Set unreferencedTestClasses = unreferencedTests.stream() + .map(this::classFromCanonicalName) + .filter(clazz -> { + String path = clazz.getProtectionDomain().getCodeSource().getLocation().getPath(); + return !path.endsWith("/data-model/target/test-classes/") + && !path.endsWith("/core/target/test-classes/") + && !path.endsWith(".jar"); + }) + .collect(toSet()); + + System.out.println("Unreferenced test class count: " + unreferencedTestClasses.size()); + unreferencedTestClasses.forEach(System.out::println); + + assertEquals("Found test classes which are not referenced by any test suite.", emptySet(), unreferencedTestClasses); + } + + /** + * Find all test classes. We define a class to be a test class if it contains a Test, Before or After annotation, is not a test suite, + * is not abstract and is not a "non-build" test (e.g. the test class is marked as a performance test). + * @param reflections The Reflections object used to provide information about the classes. + * @return A set of canonical names for the test classes. + */ + private Set getTestClassesOnPath(Reflections reflections) + { + Set classesWithTestAnnotations = Stream.of(Test.class, Before.class, After.class) + .map(annotation -> findClassesWithMethodAnnotation(reflections, annotation)) + .flatMap(Set::stream) + .collect(toSet()); + + Set classesExtendingTestCase = reflections.getSubTypesOf(TestCase.class).stream().map(testClass -> testClass.getCanonicalName()).collect(toSet()); + + return Sets.union(classesWithTestAnnotations, classesExtendingTestCase).stream() + // Exclude test suite classes. + .filter(className -> !className.endsWith("Suite")) + // Exclude abstract classes. + .filter(className -> !Modifier.isAbstract(classFromCanonicalName(className).getModifiers())) + // Exclude test classes which are explicitly marked as "non-build" test classes. + .filter(className -> !markedAsNonBuildTest(classFromCanonicalName(className))) + .collect(toSet()); + } + + /** + * Several tests are intentionally excluded from the build. These are marked with the {@link Category} annotation referencing an + * interface that extends {@link NonBuildTests}. This is useful for e.g. performance testing or to help with debugging. + * @param clazz The test class to check. + * @return true if the test class has been marked with a NonBuildTests category. + */ + private boolean markedAsNonBuildTest(Class clazz) + { + Category category = clazz.getAnnotation(Category.class); + if (category == null) + { + return false; + } + return Arrays.stream(category.value()) + .anyMatch(value -> NonBuildTests.class.isAssignableFrom(value)); + } + + /** + * Get all the test classes referenced from test suites. + * @param reflections The Reflections object used to provide information about the classes. + * @return The set of canonical names of test classes referenced by test suites. + */ + private Set getClassesReferencedByTestSuites(Reflections reflections) + { + Set classesReferencedByTestSuites = new HashSet<>(); + for (Class testSuite : reflections.getTypesAnnotatedWith(SuiteClasses.class)) + { + SuiteClasses testSuiteAnnotation = (SuiteClasses) testSuite.getAnnotation(SuiteClasses.class); + Arrays.stream(testSuiteAnnotation.value()) + .map(testClass -> testClass.getCanonicalName()) + // Exclude nested test suite classes. + .filter(className -> !className.endsWith("Suite")) + .forEach(classesReferencedByTestSuites::add); + } + return classesReferencedByTestSuites; + } + + /** + * Find the names of classes with the given annotation. + * @param reflections The Reflections object used to provide information about the classes. + * @param annotation The class of the annotation to look for. + * @return The set of canonical names of classes containing methods annotated with the annotation. + */ + private Set findClassesWithMethodAnnotation(Reflections reflections, Class annotation) + { + return reflections.getStore() + .get(MethodAnnotationsScanner.class, annotation.getName()) + .stream() + // Get the class name from the method name. + .map(methodName -> methodName.split("\\.[^\\.]+\\(")[0]) + .collect(toSet()); + } + + /** + * Find the Class corresponding to a canonical class name. + * @param name The name of the class. + * @return The Class object. + */ + private Class classFromCanonicalName(String name) + { + try + { + return Class.forName(name, false, getClass().getClassLoader()); + } + catch (ClassNotFoundException e) + { + throw new AlfrescoRuntimeException("Couldn't find test class for name.", e); + } + } +}