diff --git a/bom/application/pom.xml b/bom/application/pom.xml
index dff2a3a7481c..16b6750564ac 100644
--- a/bom/application/pom.xml
+++ b/bom/application/pom.xml
@@ -1154,6 +1154,19 @@
3.1.9.Final
+
+ org.glassfish.jersey.ext.cdi
+ jersey-cdi1x
+ ${jersey.version}
+
+
+
+ org.glassfish.jersey.ext.cdi
+ jersey-cdi1x-servlet
+ ${jersey.version}
+
+
+
org.glassfish.hk2.external
bean-validator
diff --git a/dotCMS/pom.xml b/dotCMS/pom.xml
index 7792bba84dc7..5cb123e632cd 100644
--- a/dotCMS/pom.xml
+++ b/dotCMS/pom.xml
@@ -1405,6 +1405,17 @@
3.1.9.Final
+
+ org.glassfish.jersey.ext.cdi
+ jersey-cdi1x
+
+
+
+
+ org.glassfish.jersey.ext.cdi
+ jersey-cdi1x-servlet
+
+
org.glassfish.hk2.external
bean-validator
@@ -1429,7 +1440,6 @@
jandex
3.0.5
-
org.apache.tomcat
tomcat-catalina
diff --git a/dotCMS/src/main/java/com/dotcms/analytics/viewtool/AnalyticsTool.java b/dotCMS/src/main/java/com/dotcms/analytics/viewtool/AnalyticsTool.java
index c8c2703c599c..dcad56d98c98 100644
--- a/dotCMS/src/main/java/com/dotcms/analytics/viewtool/AnalyticsTool.java
+++ b/dotCMS/src/main/java/com/dotcms/analytics/viewtool/AnalyticsTool.java
@@ -40,19 +40,11 @@ public AnalyticsTool() {
}
private static ContentAnalyticsAPI getContentAnalyticsAPI() {
- final Optional contentAnalyticsAPI = CDIUtils.getBean(ContentAnalyticsAPI.class);
- if (!contentAnalyticsAPI.isPresent()) {
- throw new DotRuntimeException("Could not instance ContentAnalyticsAPI");
- }
- return contentAnalyticsAPI.get();
+ return CDIUtils.getBeanThrows(ContentAnalyticsAPI.class);
}
private static AnalyticsQueryParser getAnalyticsQueryParser() {
- final Optional queryParserOptional = CDIUtils.getBean(AnalyticsQueryParser.class);
- if (!queryParserOptional.isPresent()) {
- throw new DotRuntimeException("Could not instance AnalyticsQueryParser");
- }
- return queryParserOptional.get();
+ return CDIUtils.getBeanThrows(AnalyticsQueryParser.class);
}
public AnalyticsTool(final ContentAnalyticsAPI contentAnalyticsAPI,
diff --git a/dotCMS/src/main/java/com/dotcms/business/FactoryLocatorProducers.java b/dotCMS/src/main/java/com/dotcms/business/FactoryLocatorProducers.java
deleted file mode 100644
index 0c2d4cf8fe3a..000000000000
--- a/dotCMS/src/main/java/com/dotcms/business/FactoryLocatorProducers.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.dotcms.business;
-
-import com.dotcms.cube.CubeJSClientFactory;
-import com.dotmarketing.business.FactoryLocator;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Produces;
-
-/**
- * This class is useful to include classes are not into the CDI container but
- * wants to be available to be injected.
- * Most of the {@link FactoryLocator} classes will be eventually here.
- * @author jsanca
- */
-@ApplicationScoped
-public class FactoryLocatorProducers {
-
-
- @Produces
- public CubeJSClientFactory getCubeJSClientFactory() {
- return FactoryLocator.getCubeJSClientFactory();
- }
-}
diff --git a/dotCMS/src/main/java/com/dotcms/cdi/CDIUtils.java b/dotCMS/src/main/java/com/dotcms/cdi/CDIUtils.java
index 296b09eeab28..b4dead470d50 100644
--- a/dotCMS/src/main/java/com/dotcms/cdi/CDIUtils.java
+++ b/dotCMS/src/main/java/com/dotcms/cdi/CDIUtils.java
@@ -16,20 +16,34 @@ private CDIUtils() {
}
/**
- * Get a bean from CDI container
+ * Get a bean from CDI container and return an Optional with the bean if found, empty otherwise
* @param clazz the class of the bean
* @return an Optional with the bean if found, empty otherwise
*/
public static Optional getBean(Class clazz) {
+ try {
+ return Optional.of(getBeanThrows(clazz));
+ } catch (Exception e) {
+ // Exception is already logged in getBeanThrows
+ }
+ return Optional.empty();
+ }
+
+
+ /**
+ * Get a bean from CDI container but throw an exception if the bean is not found
+ * @param clazz the class of the bean
+ * @return the bean
+ * @param the type of the bean
+ */
+ public static T getBeanThrows(Class clazz) {
try {
- return Optional.of(CDI.current().select(clazz).get());
+ return CDI.current().select(clazz).get();
} catch (Exception e) {
- Logger.error(CDIUtils.class,
- String.format("Unable to find bean of class [%s] [%s]", clazz, e.getMessage())
- );
+ String errorMessage = String.format("Unable to find bean of class [%s]: %s", clazz, e.getMessage());
+ Logger.error(CDIUtils.class, errorMessage);
+ throw new IllegalStateException(errorMessage, e);
}
- return Optional.empty();
}
-
}
diff --git a/dotCMS/src/main/java/com/dotcms/cube/CubeJSClientFactoryImpl.java b/dotCMS/src/main/java/com/dotcms/cube/CubeJSClientFactoryImpl.java
index c0adf31d92c6..830ca460c8c9 100644
--- a/dotCMS/src/main/java/com/dotcms/cube/CubeJSClientFactoryImpl.java
+++ b/dotCMS/src/main/java/com/dotcms/cube/CubeJSClientFactoryImpl.java
@@ -11,12 +11,14 @@
import com.dotmarketing.exception.DotSecurityException;
import com.google.common.annotations.VisibleForTesting;
import com.liferay.portal.model.User;
+import javax.enterprise.context.ApplicationScoped;
/**
* Factory to create {@link CubeJSClient} instances.
*
* @author vico
*/
+@ApplicationScoped
public class CubeJSClientFactoryImpl implements CubeJSClientFactory {
private static AnalyticsHelper analyticsHelper = AnalyticsHelper.get();
diff --git a/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java b/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java
index d45b26b8b476..a06bb61be3ff 100644
--- a/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java
+++ b/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java
@@ -50,6 +50,7 @@
import java.util.function.Consumer;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
+import javax.inject.Named;
/**
* Manages the processing of jobs in a distributed job queue system. This class is responsible for
@@ -138,7 +139,7 @@ public class JobQueueManagerAPIImpl implements JobQueueManagerAPI {
* - Initializes event handlers for various job state changes.
*/
@Inject
- public JobQueueManagerAPIImpl(JobQueue jobQueue,
+ public JobQueueManagerAPIImpl(@Named("queueProducer") JobQueue jobQueue,
JobQueueConfig jobQueueConfig,
CircuitBreaker circuitBreaker,
RetryStrategy defaultRetryStrategy,
diff --git a/dotCMS/src/main/java/com/dotcms/jobs/business/queue/JobQueueProducer.java b/dotCMS/src/main/java/com/dotcms/jobs/business/queue/JobQueueProducer.java
index 1596e9fb17d6..431b40fc33e5 100644
--- a/dotCMS/src/main/java/com/dotcms/jobs/business/queue/JobQueueProducer.java
+++ b/dotCMS/src/main/java/com/dotcms/jobs/business/queue/JobQueueProducer.java
@@ -3,6 +3,7 @@
import com.dotmarketing.util.Config;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
+import javax.inject.Named;
/**
* This class is responsible for producing the JobQueue implementation used in the application. It
@@ -22,17 +23,16 @@ public class JobQueueProducer {
*
* @return A JobQueue instance
*/
+ @Named("queueProducer")
@Produces
- @ApplicationScoped
public JobQueue produceJobQueue() {
if (JOB_QUEUE_IMPLEMENTATION_TYPE.equals("postgres")) {
return new PostgresJobQueue();
}
- throw new IllegalStateException(
- "Unknown job queue implementation type: " + JOB_QUEUE_IMPLEMENTATION_TYPE
- );
+ throw new IllegalStateException("Unknown job queue implementation type: " + JOB_QUEUE_IMPLEMENTATION_TYPE);
+
}
}
\ No newline at end of file
diff --git a/dotCMS/src/main/java/com/dotcms/jobs/business/queue/PostgresJobQueue.java b/dotCMS/src/main/java/com/dotcms/jobs/business/queue/PostgresJobQueue.java
index 37bb0fa9ac1e..229b7c68111f 100644
--- a/dotCMS/src/main/java/com/dotcms/jobs/business/queue/PostgresJobQueue.java
+++ b/dotCMS/src/main/java/com/dotcms/jobs/business/queue/PostgresJobQueue.java
@@ -53,6 +53,7 @@
* @see Job
* @see JobState
*/
+
public class PostgresJobQueue implements JobQueue {
private static final String CREATE_JOB_QUEUE_QUERY = "INSERT INTO job_queue "
diff --git a/dotCMS/src/main/java/com/dotcms/rest/api/v1/analytics/content/ContentAnalyticsResource.java b/dotCMS/src/main/java/com/dotcms/rest/api/v1/analytics/content/ContentAnalyticsResource.java
index c457e1980834..ca36973aad2c 100644
--- a/dotCMS/src/main/java/com/dotcms/rest/api/v1/analytics/content/ContentAnalyticsResource.java
+++ b/dotCMS/src/main/java/com/dotcms/rest/api/v1/analytics/content/ContentAnalyticsResource.java
@@ -5,13 +5,11 @@
import com.dotcms.analytics.model.ResultSetItem;
import com.dotcms.analytics.track.collectors.WebEventsCollectorServiceFactory;
import com.dotcms.analytics.track.matchers.UserCustomDefinedRequestMatcher;
-import com.dotcms.cdi.CDIUtils;
import com.dotcms.rest.InitDataObject;
import com.dotcms.rest.ResponseEntityStringView;
import com.dotcms.rest.WebResource;
import com.dotcms.rest.annotation.NoCache;
import com.dotcms.util.DotPreconditions;
-import com.dotmarketing.business.APILocator;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.UUIDUtil;
import com.google.common.annotations.VisibleForTesting;
@@ -21,8 +19,11 @@
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
-import org.glassfish.jersey.server.JSONP;
-
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
@@ -31,12 +32,7 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
+import org.glassfish.jersey.server.JSONP;
/**
* Resource class that exposes endpoints to query content analytics data.
@@ -47,6 +43,7 @@
* @author Jose Castro
* @since Sep 13th, 2024
*/
+
@Path("/v1/analytics/content")
@Tag(name = "Content Analytics",
description = "Endpoints that exposes information related to how dotCMS content is accessed and interacted with by users.")
@@ -57,13 +54,7 @@ public class ContentAnalyticsResource {
private final WebResource webResource;
private final ContentAnalyticsAPI contentAnalyticsAPI;
- @SuppressWarnings("unused")
- public ContentAnalyticsResource() {
- this(CDIUtils.getBean(ContentAnalyticsAPI.class).orElseGet(APILocator::getContentAnalyticsAPI));
- }
-
- //@Inject
- @VisibleForTesting
+ @Inject
public ContentAnalyticsResource(final ContentAnalyticsAPI contentAnalyticsAPI) {
this(new WebResource(), contentAnalyticsAPI);
}
diff --git a/dotCMS/src/main/java/com/dotcms/rest/api/v1/job/JobQueueResource.java b/dotCMS/src/main/java/com/dotcms/rest/api/v1/job/JobQueueResource.java
index fc15b93c9714..e3816a015529 100644
--- a/dotCMS/src/main/java/com/dotcms/rest/api/v1/job/JobQueueResource.java
+++ b/dotCMS/src/main/java/com/dotcms/rest/api/v1/job/JobQueueResource.java
@@ -1,6 +1,5 @@
package com.dotcms.rest.api.v1.job;
-import com.dotcms.cdi.CDIUtils;
import com.dotcms.jobs.business.job.Job;
import com.dotcms.jobs.business.job.JobPaginatedResult;
import com.dotcms.rest.ResponseEntityView;
@@ -14,6 +13,7 @@
import java.io.IOException;
import java.util.Map;
import java.util.Set;
+import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.BeanParam;
import javax.ws.rs.Consumes;
@@ -38,8 +38,9 @@ public class JobQueueResource {
private final JobQueueHelper helper;
- public JobQueueResource() {
- this(new WebResource(), CDIUtils.getBean(JobQueueHelper.class).orElseThrow(()->new IllegalStateException("JobQueueHelper Bean not found")));
+ @Inject
+ public JobQueueResource(final JobQueueHelper helper) {
+ this(new WebResource(), helper);
}
@VisibleForTesting
diff --git a/dotCMS/src/main/java/com/dotcms/rest/config/ContainerReloader.java b/dotCMS/src/main/java/com/dotcms/rest/config/ContainerReloader.java
index 969420976ad0..7c5695dfaf7c 100644
--- a/dotCMS/src/main/java/com/dotcms/rest/config/ContainerReloader.java
+++ b/dotCMS/src/main/java/com/dotcms/rest/config/ContainerReloader.java
@@ -9,7 +9,7 @@
import org.glassfish.jersey.server.spi.Container;
/**
- * A new Reloader will get created on each reload there can only be one container at a time
+ * A new Re-loader will get created on each reload there can only be one container at a time
*/
@Provider
@ApplicationScoped
diff --git a/dotCMS/src/main/java/com/dotcms/rest/config/DotRestApplication.java b/dotCMS/src/main/java/com/dotcms/rest/config/DotRestApplication.java
index 38af8db95716..f8163c40798b 100644
--- a/dotCMS/src/main/java/com/dotcms/rest/config/DotRestApplication.java
+++ b/dotCMS/src/main/java/com/dotcms/rest/config/DotRestApplication.java
@@ -4,6 +4,7 @@
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import io.swagger.v3.jaxrs2.integration.resources.AcceptHeaderOpenApiResource;
import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource;
+import org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.servers.Server;
@@ -57,7 +58,7 @@ public DotRestApplication() {
"com.dotcms.rendering.js",
"com.dotcms.ai.rest",
"io.swagger.v3.jaxrs2"
- );
+ ).register(CdiComponentProvider.class);
}
/**
diff --git a/dotCMS/src/main/java/com/dotmarketing/business/APILocator.java b/dotCMS/src/main/java/com/dotmarketing/business/APILocator.java
index 07921109e3fb..2acb7cb49e27 100644
--- a/dotCMS/src/main/java/com/dotmarketing/business/APILocator.java
+++ b/dotCMS/src/main/java/com/dotmarketing/business/APILocator.java
@@ -1443,8 +1443,8 @@ Object create() {
case SYSTEM_API: return new SystemAPIImpl();
case ARTIFICIAL_INTELLIGENCE_API: return new DotAIAPIFacadeImpl();
case ACHECKER_API: return new ACheckerAPIImpl();
- case CONTENT_ANALYTICS_API: CDIUtils.getBean(ContentAnalyticsAPI.class).orElseThrow(() -> new DotRuntimeException("Content Analytics API not found"));
- case JOB_QUEUE_MANAGER_API: return CDIUtils.getBean(JobQueueManagerAPI.class).orElseThrow(() -> new DotRuntimeException("JobQueueManagerAPI not found"));
+ case CONTENT_ANALYTICS_API: return CDIUtils.getBeanThrows(ContentAnalyticsAPI.class);
+ case JOB_QUEUE_MANAGER_API: return CDIUtils.getBeanThrows(JobQueueManagerAPI.class);
}
throw new AssertionError("Unknown API index: " + this);
}
diff --git a/dotCMS/src/main/java/com/dotmarketing/business/FactoryLocator.java b/dotCMS/src/main/java/com/dotmarketing/business/FactoryLocator.java
index cb3d99958d92..7e055bb3e2aa 100644
--- a/dotCMS/src/main/java/com/dotmarketing/business/FactoryLocator.java
+++ b/dotCMS/src/main/java/com/dotmarketing/business/FactoryLocator.java
@@ -271,7 +271,7 @@ public static SystemTableFactory getSystemTableFactory() {
}
public static CubeJSClientFactory getCubeJSClientFactory() {
- return (CubeJSClientFactory) getInstance(FactoryIndex.CUBEJS_CLIENT_FACTORY);
+ return CDIUtils.getBeanThrows(CubeJSClientFactory.class);
}
/**
@@ -289,7 +289,7 @@ public static LanguageVariableFactory getLanguageVariableFactory() {
* @return An instance of the {@link ContentAnalyticsFactory} object.
*/
public static ContentAnalyticsFactory getContentAnalyticsFactory() {
- return (ContentAnalyticsFactory) getInstance(FactoryIndex.CONTENT_ANALYTICS_FACTORY);
+ return CDIUtils.getBeanThrows(ContentAnalyticsFactory.class);
}
/**
@@ -378,9 +378,7 @@ enum FactoryIndex
VARIANT_FACTORY,
EXPERIMENTS_FACTORY,
SYSTEM_TABLE_FACTORY,
- CUBEJS_CLIENT_FACTORY,
LANGUAGE_VARIABLE_FACTORY,
- CONTENT_ANALYTICS_FACTORY,
PORTLET_FACTORY;
Object create() {
@@ -423,9 +421,7 @@ Object create() {
case VARIANT_FACTORY : return new VariantFactoryImpl();
case EXPERIMENTS_FACTORY: return new ExperimentsFactoryImpl();
case SYSTEM_TABLE_FACTORY: return new SystemTableFactoryImpl();
- case CUBEJS_CLIENT_FACTORY: return new CubeJSClientFactoryImpl();
case LANGUAGE_VARIABLE_FACTORY: return new LanguageVariableFactoryImpl();
- case CONTENT_ANALYTICS_FACTORY: CDIUtils.getBean(ContentAnalyticsFactory.class).orElseThrow(() -> new DotRuntimeException("ContentAnalyticsFactory not found"));
case PORTLET_FACTORY: return new PortletFactoryImpl();
}
throw new AssertionError("Unknown Factory Index: " + this);
diff --git a/dotCMS/src/main/resources/META-INF/beans.xml b/dotCMS/src/main/resources/META-INF/beans.xml
new file mode 100644
index 000000000000..55e20058e932
--- /dev/null
+++ b/dotCMS/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/dotCMS/src/main/webapp/WEB-INF/beans.xml b/dotCMS/src/main/webapp/WEB-INF/beans.xml
deleted file mode 100644
index 1675ad7ab74c..000000000000
--- a/dotCMS/src/main/webapp/WEB-INF/beans.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dotCMS/src/test/java/com/dotcms/UnitTestBase.java b/dotCMS/src/test/java/com/dotcms/UnitTestBase.java
index e994d0f1f97a..4c6abfccd7d9 100644
--- a/dotCMS/src/test/java/com/dotcms/UnitTestBase.java
+++ b/dotCMS/src/test/java/com/dotcms/UnitTestBase.java
@@ -12,10 +12,6 @@
import com.liferay.portal.model.Company;
import com.liferay.portal.model.User;
import java.util.TimeZone;
-import org.jboss.weld.bootstrap.api.helpers.RegistrySingletonProvider;
-import org.jboss.weld.environment.se.Weld;
-import org.jboss.weld.environment.se.WeldContainer;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.mockito.Mockito;
@@ -24,8 +20,6 @@ public abstract class UnitTestBase extends BaseMessageResources {
protected static final ContentTypeAPI contentTypeAPI = mock(ContentTypeAPI.class);
protected static final CompanyAPI companyAPI = mock(CompanyAPI.class);
- private static WeldContainer weld;
-
public static class MyAPILocator extends APILocator {
static {
@@ -47,10 +41,6 @@ protected CompanyAPI getCompanyAPIImpl() {
@BeforeClass
public static void prepare () throws DotDataException, DotSecurityException, Exception {
- weld = new Weld().containerId(RegistrySingletonProvider.STATIC_INSTANCE)
- .initialize();
-
- System.out.println("Weld :: " + weld);
Config.initializeConfig();
Config.setProperty("API_LOCATOR_IMPLEMENTATION", MyAPILocator.class.getName());
@@ -64,10 +54,4 @@ public static void prepare () throws DotDataException, DotSecurityException, Exc
Mockito.lenient().when(companyAPI.getDefaultCompany()).thenReturn(company);
}
- @AfterClass
- public static void cleanup() {
- if( null != weld && weld.isRunning() ){
- weld.shutdown();
- }
- }
}
diff --git a/dotCMS/src/test/resources/META-INF/beans.xml b/dotCMS/src/test/resources/META-INF/beans.xml
deleted file mode 100644
index 1675ad7ab74c..000000000000
--- a/dotCMS/src/test/resources/META-INF/beans.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dotcms-integration/src/test/java/com/dotcms/DataProviderWeldRunner.java b/dotcms-integration/src/test/java/com/dotcms/DataProviderWeldRunner.java
new file mode 100644
index 000000000000..ddfe15f5a0af
--- /dev/null
+++ b/dotcms-integration/src/test/java/com/dotcms/DataProviderWeldRunner.java
@@ -0,0 +1,41 @@
+package com.dotcms;
+
+import com.tngtech.java.junit.dataprovider.DataProviderRunner;
+import org.jboss.weld.environment.se.Weld;
+import org.jboss.weld.environment.se.WeldContainer;
+import org.junit.runners.model.InitializationError;
+
+/**
+ * Annotate your JUnit4 test using {@code @DataProviderRunner} class with {@code @RunWith(DataProviderWeldRunner.class)} to run it with Weld container.
+ */
+public class DataProviderWeldRunner extends DataProviderRunner {
+
+ private static final Weld WELD;
+ private static final WeldContainer CONTAINER;
+
+ static {
+ WELD = new Weld("DataProviderWeldRunner");
+ CONTAINER = WELD.initialize();
+ }
+
+ /**
+ * Creates a DataProviderRunner to run supplied {@code clazz}.
+ *
+ * @param clazz the test {@link Class} to run
+ * @throws InitializationError if the test {@link Class} is malformed.
+ */
+ public DataProviderWeldRunner(Class> clazz) throws InitializationError {
+ super(clazz);
+ }
+
+ /**
+ * Create the test instance using Weld container.
+ * @return the test instance
+ * @throws Exception if something goes wrong
+ */
+ @Override
+ protected Object createTest() throws Exception {
+ return CONTAINER.instance().select(getTestClass().getJavaClass()).get();
+ }
+
+}
diff --git a/dotcms-integration/src/test/java/com/dotcms/IntegrationTestBase.java b/dotcms-integration/src/test/java/com/dotcms/IntegrationTestBase.java
index 01fc89e82008..427dee4fd2ea 100644
--- a/dotcms-integration/src/test/java/com/dotcms/IntegrationTestBase.java
+++ b/dotcms-integration/src/test/java/com/dotcms/IntegrationTestBase.java
@@ -31,8 +31,6 @@
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.commons.io.FileUtils;
-import org.jboss.weld.environment.se.Weld;
-import org.jboss.weld.environment.se.WeldContainer;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -56,8 +54,6 @@ public abstract class IntegrationTestBase extends BaseMessageResources {
private final static PrintStream stdout = System.out;
private final static ByteArrayOutputStream output = new ByteArrayOutputStream();
- private static WeldContainer weld;
-
@Rule
public TestName name = new TestName();
@@ -281,15 +277,4 @@ protected T wrapOnReadOnlyConn(final ReturnableDelegate supplier) throw
}
}
- @BeforeClass
- public static void initWeld() {
- weld = new Weld().containerId("IntegrationTestBase").initialize();
- }
-
- @AfterClass
- public static void cleanupWeld() {
- if( null != weld && weld.isRunning() ){
- weld.shutdown();
- }
- }
}
diff --git a/dotcms-integration/src/test/java/com/dotcms/JUnit4WeldRunner.java b/dotcms-integration/src/test/java/com/dotcms/JUnit4WeldRunner.java
new file mode 100644
index 000000000000..cbe54dad21fc
--- /dev/null
+++ b/dotcms-integration/src/test/java/com/dotcms/JUnit4WeldRunner.java
@@ -0,0 +1,40 @@
+package com.dotcms;
+
+import org.jboss.weld.environment.se.Weld;
+import org.jboss.weld.environment.se.WeldContainer;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.InitializationError;
+
+/**
+ * Annotate your JUnit4 test class with {@code @RunWith(JUnit4WeldRunner.class)} to run it with Weld container.
+ */
+public class JUnit4WeldRunner extends BlockJUnit4ClassRunner {
+
+ private static final Weld WELD;
+ private static final WeldContainer CONTAINER;
+
+ static {
+ WELD = new Weld("JUnit4WeldRunner");
+ CONTAINER = WELD.initialize();
+ }
+
+ /**
+ * Creates a DataProviderRunner to run supplied {@code clazz}.
+ *
+ * @param clazz the test {@link Class} to run
+ * @throws InitializationError if the test {@link Class} is malformed.
+ */
+ public JUnit4WeldRunner(Class> clazz) throws InitializationError {
+ super(clazz);
+ }
+
+ /**
+ * Create the test instance using Weld container.
+ * @return the test instance
+ * @throws Exception if something goes wrong
+ */
+ @Override
+ protected Object createTest() throws Exception {
+ return CONTAINER.instance().select(getTestClass().getJavaClass()).get();
+ }
+}
diff --git a/dotcms-integration/src/test/java/com/dotcms/Junit5WeldBaseTest.java b/dotcms-integration/src/test/java/com/dotcms/Junit5WeldBaseTest.java
new file mode 100644
index 000000000000..93a7326368a8
--- /dev/null
+++ b/dotcms-integration/src/test/java/com/dotcms/Junit5WeldBaseTest.java
@@ -0,0 +1,16 @@
+package com.dotcms;
+
+import org.jboss.weld.junit5.WeldInitiator;
+import org.jboss.weld.junit5.WeldSetup;
+
+
+public abstract class Junit5WeldBaseTest {
+
+ @WeldSetup
+ public static WeldInitiator weldInitiator = WeldInitiator.of(
+ WeldInitiator.createWeld()
+ .containerId("Junit5WeldBaseTest")
+ .enableDiscovery()
+ );
+
+}
diff --git a/dotcms-integration/src/test/java/com/dotcms/MainSuite2b.java b/dotcms-integration/src/test/java/com/dotcms/MainSuite2b.java
index af7780c03e6b..7f9cf6bc5622 100644
--- a/dotcms-integration/src/test/java/com/dotcms/MainSuite2b.java
+++ b/dotcms-integration/src/test/java/com/dotcms/MainSuite2b.java
@@ -25,7 +25,9 @@
import com.dotcms.cache.lettuce.DotObjectCodecTest;
import com.dotcms.cache.lettuce.LettuceCacheTest;
import com.dotcms.cache.lettuce.RedisClientTest;
+import com.dotcms.cdi.SimpleDataProviderWeldRunnerInjectionIT;
import com.dotcms.cdi.SimpleInjectionIT;
+import com.dotcms.cdi.SimpleJUnit4InjectionIT;
import com.dotcms.content.business.ObjectMapperTest;
import com.dotcms.content.business.json.ContentletJsonAPITest;
import com.dotcms.content.business.json.LegacyJSONObjectRenderTest;
@@ -109,7 +111,7 @@
import com.dotmarketing.common.db.DBTimeZoneCheckTest;
import com.dotmarketing.filters.AutoLoginFilterTest;
import com.dotmarketing.filters.CMSUrlUtilIntegrationTest;
-import com.dotmarketing.osgi.GenericBundleActivatorTest;
+import com.dotmarketing.osgi.GenericBundleActivatorIntegrationTest;
import com.dotmarketing.portlets.browser.BrowserUtilTest;
import com.dotmarketing.portlets.browser.ajax.BrowserAjaxTest;
import com.dotmarketing.portlets.categories.business.CategoryFactoryTest;
@@ -233,7 +235,7 @@
Task201102UpdateColumnSitelicTableTest.class,
DependencyManagerTest.class,
com.dotcms.rest.api.v1.versionable.VersionableResourceTest.class,
- GenericBundleActivatorTest.class,
+ GenericBundleActivatorIntegrationTest.class,
SAMLHelperTest.class,
PermissionHelperTest.class,
ResetPasswordTokenUtilTest.class,
@@ -392,6 +394,8 @@
JobQueueManagerAPITest.class,
ConfigUtilsTest.class,
SimpleInjectionIT.class,
+ SimpleDataProviderWeldRunnerInjectionIT.class,
+ SimpleJUnit4InjectionIT.class,
LegacyJSONObjectRenderTest.class,
Task241013RemoveFullPathLcColumnFromIdentifierTest.class,
Task241009CreatePostgresJobQueueTablesTest.class,
diff --git a/dotcms-integration/src/test/java/com/dotcms/TestBaseJunit5WeldInitiator.java b/dotcms-integration/src/test/java/com/dotcms/TestBaseJunit5WeldInitiator.java
deleted file mode 100644
index b65843c090dc..000000000000
--- a/dotcms-integration/src/test/java/com/dotcms/TestBaseJunit5WeldInitiator.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.dotcms;
-
-import com.dotcms.jobs.business.api.JobProcessorFactory;
-import com.dotcms.jobs.business.api.JobProcessorScanner;
-import com.dotcms.jobs.business.api.JobQueueConfig;
-import com.dotcms.jobs.business.api.JobQueueConfigProducer;
-import com.dotcms.jobs.business.api.JobQueueManagerAPIImpl;
-import com.dotcms.jobs.business.api.events.EventProducer;
-import com.dotcms.jobs.business.api.events.RealTimeJobMonitor;
-import com.dotcms.jobs.business.error.CircuitBreaker;
-import com.dotcms.jobs.business.error.RetryStrategy;
-import com.dotcms.jobs.business.error.RetryStrategyProducer;
-import com.dotcms.jobs.business.queue.JobQueue;
-import com.dotcms.jobs.business.queue.JobQueueProducer;
-import com.dotcms.rest.api.v1.job.JobQueueHelper;
-import org.jboss.weld.bootstrap.api.helpers.RegistrySingletonProvider;
-import org.jboss.weld.junit5.WeldInitiator;
-import org.jboss.weld.junit5.WeldJunit5Extension;
-import org.jboss.weld.junit5.WeldSetup;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.extension.ExtendWith;
-
-@ExtendWith(WeldJunit5Extension.class)
-public class TestBaseJunit5WeldInitiator {
-
- @WeldSetup
- public static WeldInitiator weld = WeldInitiator.of(
- WeldInitiator.createWeld()
- .containerId(RegistrySingletonProvider.STATIC_INSTANCE)
- .beanClasses(JobQueueManagerAPIImpl.class, JobQueueConfig.class,
- JobQueue.class, RetryStrategy.class, CircuitBreaker.class,
- JobQueueProducer.class, JobQueueConfigProducer.class,
- RetryStrategyProducer.class, RealTimeJobMonitor.class,
- EventProducer.class, JobProcessorFactory.class, JobQueueHelper.class,
- JobProcessorScanner.class
- )
- );
-
- @AfterAll
- public static void tearDown() {
- if (weld != null && weld.isRunning()) {
- weld.shutdown();
- weld = null;
- }
- }
-
-}
diff --git a/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleDataProviderWeldRunnerInjectionIT.java b/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleDataProviderWeldRunnerInjectionIT.java
new file mode 100644
index 000000000000..b6b9bb3f327d
--- /dev/null
+++ b/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleDataProviderWeldRunnerInjectionIT.java
@@ -0,0 +1,51 @@
+package com.dotcms.cdi;
+
+import static org.junit.Assert.assertEquals;
+
+import com.dotcms.DataProviderWeldRunner;
+import com.tngtech.java.junit.dataprovider.DataProvider;
+import com.tngtech.java.junit.dataprovider.UseDataProvider;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Integration test for simple CDI injection using the Runner DataProviderWeldRunner
+ */
+@ApplicationScoped
+@RunWith(DataProviderWeldRunner.class)
+public class SimpleDataProviderWeldRunnerInjectionIT {
+
+ @Inject
+ GreetingBean greetingBean;
+
+ /**
+ * Test that DataProviderWeldRunner can inject a bean and receive a value from a data provider
+ * @param testCase the test case
+ */
+ @UseDataProvider("testCases")
+ @Test
+ public void testInjection(TestCase testCase) {
+ assertEquals("lol", testCase.getValue());
+ assertEquals ("Hello World", greetingBean.greet());
+ }
+
+ @DataProvider
+ public static Object[] testCases() {
+ return new Object[]{
+ new TestCase("lol"),
+ };
+ }
+
+ public static class TestCase {
+ private final String value;
+ public TestCase(String value){
+ this.value = value;
+ }
+ public String getValue(){
+ return value;
+ }
+ }
+
+}
diff --git a/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleInjectionIT.java b/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleInjectionIT.java
index 30e3112da561..a9724435b2fe 100644
--- a/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleInjectionIT.java
+++ b/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleInjectionIT.java
@@ -5,13 +5,19 @@
import static org.junit.Assert.assertTrue;
import com.dotcms.IntegrationTestBase;
+import com.dotcms.JUnit4WeldRunner;
import java.util.Optional;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.spi.CDI;
import org.junit.Test;
+import org.junit.runner.RunWith;
/**
* Integration test for simple CDI injection
*/
-public class SimpleInjectionIT extends IntegrationTestBase {
+@ApplicationScoped
+@RunWith(JUnit4WeldRunner.class)
+public class SimpleInjectionIT {
/**
* Test CDI injection
@@ -20,12 +26,8 @@ public class SimpleInjectionIT extends IntegrationTestBase {
*/
@Test
public void testInjection() {
-
- Optional optional = CDIUtils.getBean(GreetingBean.class);
- assertTrue(optional.isPresent());
- final GreetingBean greetingBean = optional.get();
+ final GreetingBean greetingBean = CDIUtils.getBeanThrows(GreetingBean.class);
assertEquals("Hello World", greetingBean.greet());
-
}
}
diff --git a/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleJUnit4InjectionIT.java b/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleJUnit4InjectionIT.java
new file mode 100644
index 000000000000..007a240a4d6b
--- /dev/null
+++ b/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleJUnit4InjectionIT.java
@@ -0,0 +1,26 @@
+package com.dotcms.cdi;
+
+import static org.junit.Assert.assertEquals;
+
+import com.dotcms.JUnit4WeldRunner;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@ApplicationScoped
+@RunWith(JUnit4WeldRunner.class)
+public class SimpleJUnit4InjectionIT {
+
+ @Inject
+ GreetingBean greetingBean;
+
+ /**
+ * Test CDI injection using the Runner JUnit4WeldRunner
+ */
+ @Test
+ public void testInjection() {
+ final String greet = greetingBean.greet();
+ assertEquals("Hello World", greet);
+ }
+}
diff --git a/dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPICDITest.java b/dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPICDITest.java
index d4e6d85c2865..58a18fd7712a 100644
--- a/dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPICDITest.java
+++ b/dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPICDITest.java
@@ -5,24 +5,25 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
-import com.dotcms.TestBaseJunit5WeldInitiator;
+import com.dotcms.Junit5WeldBaseTest;
import com.dotcms.jobs.business.error.ExponentialBackoffRetryStrategy;
import com.dotcms.jobs.business.queue.JobQueue;
import javax.inject.Inject;
+import org.jboss.weld.junit5.EnableWeld;
import org.junit.jupiter.api.Test;
/**
* Test class for verifying the CDI (Contexts and Dependency Injection) functionality of the
* JobQueueManagerAPI implementation.
*/
-
-public class JobQueueManagerAPICDITest extends TestBaseJunit5WeldInitiator {
+@EnableWeld
+public class JobQueueManagerAPICDITest extends Junit5WeldBaseTest {
@Inject
- private JobQueueManagerAPI jobQueueManagerAPI;
+ JobQueueManagerAPI jobQueueManagerAPI;
@Inject
- private JobQueueManagerAPI jobQueueManagerAPI2;
+ JobQueueManagerAPI jobQueueManagerAPI2;
/**
* Method to test: Multiple injections of JobQueueManagerAPI Given Scenario: Two separate
diff --git a/dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPIIntegrationTest.java b/dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPIIntegrationTest.java
index d9b5f0046be1..210028bdee69 100644
--- a/dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPIIntegrationTest.java
+++ b/dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPIIntegrationTest.java
@@ -13,7 +13,6 @@
import com.dotcms.jobs.business.processor.JobProcessor;
import com.dotcms.jobs.business.processor.ProgressTracker;
import com.dotcms.util.IntegrationTestInitService;
-import com.dotmarketing.business.APILocator;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.util.Logger;
@@ -26,24 +25,33 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import javax.inject.Inject;
import org.awaitility.Awaitility;
+import org.jboss.weld.junit5.EnableWeld;
+import org.jboss.weld.junit5.WeldJunit5Extension;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.api.TestMethodOrder;
+import org.junit.jupiter.api.extension.ExtendWith;
/**
* Integration tests for the JobQueueManagerAPI.
* These tests verify the functionality of the job queue system in a real environment,
* including job creation, processing, cancellation, retrying, and progress tracking.
*/
+@EnableWeld
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class JobQueueManagerAPIIntegrationTest {
+@TestInstance(Lifecycle.PER_CLASS)
+public class JobQueueManagerAPIIntegrationTest extends com.dotcms.Junit5WeldBaseTest {
- private static JobQueueManagerAPI jobQueueManagerAPI;
+ @Inject
+ JobQueueManagerAPI jobQueueManagerAPI;
/**
* Sets up the test environment before all tests are run.
@@ -55,8 +63,6 @@ public class JobQueueManagerAPIIntegrationTest {
static void setUp() throws Exception {
// Initialize the test environment
IntegrationTestInitService.getInstance().init();
-
- jobQueueManagerAPI = APILocator.getJobQueueManagerAPI();
}
/**
@@ -66,7 +72,7 @@ static void setUp() throws Exception {
* @throws Exception if there's an error during cleanup
*/
@AfterAll
- static void cleanUp() throws Exception {
+ void cleanUp() throws Exception {
if(null != jobQueueManagerAPI) {
jobQueueManagerAPI.close();
}
diff --git a/dotcms-integration/src/test/java/com/dotcms/junit/CustomDataProviderRunner.java b/dotcms-integration/src/test/java/com/dotcms/junit/CustomDataProviderRunner.java
index f98199bfd452..4bdf0d2daae8 100644
--- a/dotcms-integration/src/test/java/com/dotcms/junit/CustomDataProviderRunner.java
+++ b/dotcms-integration/src/test/java/com/dotcms/junit/CustomDataProviderRunner.java
@@ -1,23 +1,55 @@
package com.dotcms.junit;
+import com.dotcms.DataProviderWeldRunner;
+import com.dotcms.JUnit4WeldRunner;
import com.dotmarketing.util.Logger;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import com.tngtech.java.junit.dataprovider.internal.DataConverter;
import com.tngtech.java.junit.dataprovider.internal.TestGenerator;
import com.tngtech.java.junit.dataprovider.internal.TestValidator;
+import java.util.Optional;
+import org.jboss.weld.environment.se.Weld;
+import org.jboss.weld.environment.se.WeldContainer;
import org.junit.Ignore;
import org.junit.rules.RunRules;
import org.junit.runner.Description;
+import org.junit.runner.RunWith;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
-
import java.util.List;
public class CustomDataProviderRunner extends DataProviderRunner {
+ // We assume that any test annotated with any of the following runners is meant to be run with Weld
+ static final List> weldRunners = List.of(JUnit4WeldRunner.class, DataProviderWeldRunner.class);
+
+ /**
+ * Check if the given class is annotated with any of the Weld runners
+ * @param clazz the class to check
+ * @return true if the class is annotated with any of the Weld runners
+ */
+ static boolean isWeldRunnerPresent(Class> clazz) {
+ return Optional.ofNullable(clazz.getAnnotation(RunWith.class))
+ .map(RunWith::value)
+ .map(runnerClass -> weldRunners.stream()
+ .anyMatch(weldRunner -> weldRunner.equals(runnerClass)))
+ .orElse(false);
+ }
+
+ private static final Weld WELD;
+ private static final WeldContainer CONTAINER;
+
+ static {
+ WELD = new Weld("CustomDataProviderRunner");
+ CONTAINER = WELD.initialize();
+ }
+
+ private final boolean instantiateWithWeld;
+
public CustomDataProviderRunner(Class> clazz) throws InitializationError {
super(clazz);
+ instantiateWithWeld = isWeldRunnerPresent(clazz);
}
@Override
@@ -61,4 +93,13 @@ public Object invokeExplosively(Object target, Object... params) throws Throwabl
testValidator = new TestValidator(dataConverter);
}
+ @Override
+ protected Object createTest() throws Exception {
+ if (instantiateWithWeld) {
+ final Class> javaClass = getTestClass().getJavaClass();
+ Logger.debug(this, String.format("Instantiating [%s] with Weld", javaClass));
+ return CONTAINER.instance().select(javaClass).get();
+ }
+ return super.createTest();
+ }
}
diff --git a/dotcms-integration/src/test/java/com/dotcms/rest/api/v1/job/JobQueueHelperIntegrationTest.java b/dotcms-integration/src/test/java/com/dotcms/rest/api/v1/job/JobQueueHelperIntegrationTest.java
index 566363fc2ab3..06d6a5856165 100644
--- a/dotcms-integration/src/test/java/com/dotcms/rest/api/v1/job/JobQueueHelperIntegrationTest.java
+++ b/dotcms-integration/src/test/java/com/dotcms/rest/api/v1/job/JobQueueHelperIntegrationTest.java
@@ -5,7 +5,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import com.dotcms.TestBaseJunit5WeldInitiator;
import com.dotcms.jobs.business.job.Job;
import com.dotcms.jobs.business.processor.JobProcessor;
import com.dotmarketing.exception.DoesNotExistException;
@@ -22,6 +21,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
+import org.jboss.weld.junit5.EnableWeld;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -30,7 +30,8 @@
* Helper add functionality to consume JobQueueManagerAPI
* Here we test those functionalities, methods that simply call the JobQueueManagerAPI are not tested
*/
-public class JobQueueHelperIntegrationTest extends TestBaseJunit5WeldInitiator {
+@EnableWeld
+public class JobQueueHelperIntegrationTest extends com.dotcms.Junit5WeldBaseTest {
@Inject
JobQueueHelper jobQueueHelper;
@@ -137,7 +138,7 @@ void testGetStatusInfo() throws DotDataException, JsonProcessingException {
* Given scenario: call cancel Job with an invalid job id
* Expected result: we should get a DoesNotExistException
*/
- @Test
+ @Test
void testCancelNonExistingJob(){
assertThrows(DoesNotExistException.class, () -> {
jobQueueHelper.cancelJob("nonExisting" );
diff --git a/dotcms-integration/src/test/java/com/dotcms/util/IntegrationTestInitService.java b/dotcms-integration/src/test/java/com/dotcms/util/IntegrationTestInitService.java
index 9711a2000a10..5eab72b64c47 100644
--- a/dotcms-integration/src/test/java/com/dotcms/util/IntegrationTestInitService.java
+++ b/dotcms-integration/src/test/java/com/dotcms/util/IntegrationTestInitService.java
@@ -2,22 +2,9 @@
import com.dotcms.business.bytebuddy.ByteBuddyFactory;
import com.dotcms.config.DotInitializationService;
-import com.dotcms.jobs.business.api.JobProcessorFactory;
-import com.dotcms.jobs.business.api.JobProcessorScanner;
-import com.dotcms.jobs.business.api.JobQueueConfig;
-import com.dotcms.jobs.business.api.JobQueueConfigProducer;
-import com.dotcms.jobs.business.api.JobQueueManagerAPIImpl;
-import com.dotcms.jobs.business.api.events.EventProducer;
-import com.dotcms.jobs.business.api.events.RealTimeJobMonitor;
-import com.dotcms.jobs.business.error.CircuitBreaker;
-import com.dotcms.jobs.business.error.RetryStrategy;
-import com.dotcms.jobs.business.error.RetryStrategyProducer;
-import com.dotcms.jobs.business.queue.JobQueue;
-import com.dotcms.jobs.business.queue.JobQueueProducer;
import com.dotcms.repackage.org.apache.struts.Globals;
import com.dotcms.repackage.org.apache.struts.config.ModuleConfig;
import com.dotcms.repackage.org.apache.struts.config.ModuleConfigFactory;
-import com.dotcms.rest.api.v1.job.JobQueueHelper;
import com.dotcms.test.TestUtil;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.business.CacheLocator;
@@ -29,9 +16,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.awaitility.Awaitility;
-import org.jboss.weld.bootstrap.api.helpers.RegistrySingletonProvider;
-import org.jboss.weld.environment.se.Weld;
-import org.jboss.weld.environment.se.WeldContainer;
import org.mockito.Mockito;
/**
@@ -44,8 +28,6 @@ public class IntegrationTestInitService {
private static final AtomicBoolean initCompleted = new AtomicBoolean(false);
- private static WeldContainer weld;
-
static {
SystemProperties.getProperties();
}
@@ -62,23 +44,6 @@ public void init() throws Exception {
try {
if (initCompleted.compareAndSet(false, true)) {
- weld = new Weld().containerId(RegistrySingletonProvider.STATIC_INSTANCE)
- .beanClasses(
- JobQueueManagerAPIImpl.class,
- JobQueueConfig.class,
- JobQueue.class,
- RetryStrategy.class,
- CircuitBreaker.class,
- JobQueueProducer.class,
- JobQueueConfigProducer.class,
- RetryStrategyProducer.class,
- RealTimeJobMonitor.class,
- JobProcessorFactory.class,
- EventProducer.class,
- JobProcessorScanner.class,
- JobQueueHelper.class)
- .initialize();
-
System.setProperty(TestUtil.DOTCMS_INTEGRATION_TEST, TestUtil.DOTCMS_INTEGRATION_TEST);
Awaitility.setDefaultPollInterval(10, TimeUnit.MILLISECONDS);
@@ -105,6 +70,7 @@ public void init() throws Exception {
DotInitializationService.getInstance().initialize();
APILocator.getDotAIAPI().getEmbeddingsAPI().initEmbeddingsTable();
+ Logger.info(this, "Integration Test Init Service initialized");
}
} catch (Exception e) {
Logger.error(this, "Error initializing Integration Test Init Service", e);
diff --git a/dotcms-integration/src/test/java/com/dotmarketing/osgi/GenericBundleActivatorTest.java b/dotcms-integration/src/test/java/com/dotmarketing/osgi/GenericBundleActivatorIntegrationTest.java
similarity index 98%
rename from dotcms-integration/src/test/java/com/dotmarketing/osgi/GenericBundleActivatorTest.java
rename to dotcms-integration/src/test/java/com/dotmarketing/osgi/GenericBundleActivatorIntegrationTest.java
index 2a8af5a199c3..711d2c4a2cc7 100644
--- a/dotcms-integration/src/test/java/com/dotmarketing/osgi/GenericBundleActivatorTest.java
+++ b/dotcms-integration/src/test/java/com/dotmarketing/osgi/GenericBundleActivatorIntegrationTest.java
@@ -5,7 +5,6 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import com.dotcms.LicenseTestUtil;
import com.dotcms.util.IntegrationTestInitService;
import java.lang.reflect.Method;
import java.net.URL;
@@ -23,7 +22,7 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.launch.Framework;
-public class GenericBundleActivatorTest {
+public class GenericBundleActivatorIntegrationTest {
/**
* Sets up OSGI and makes sure the framework has started
diff --git a/dotcms-integration/src/test/java/com/dotmarketing/portlets/contentlet/business/ContentletAPITest.java b/dotcms-integration/src/test/java/com/dotmarketing/portlets/contentlet/business/ContentletAPITest.java
index 73bcc22e18a4..386420475414 100644
--- a/dotcms-integration/src/test/java/com/dotmarketing/portlets/contentlet/business/ContentletAPITest.java
+++ b/dotcms-integration/src/test/java/com/dotmarketing/portlets/contentlet/business/ContentletAPITest.java
@@ -207,7 +207,6 @@ public class ContentletAPITest extends ContentletBaseTest {
@Test
public void testDotAsset_Checkin() throws DotDataException, DotSecurityException, IOException {
-
// 1) creates a dotasset for test
final String variable = "testDotAsset" + System.currentTimeMillis();
final ContentTypeAPI contentTypeAPI = APILocator.getContentTypeAPI(APILocator.systemUser());
diff --git a/dotcms-integration/src/test/resources/META-INF/beans.xml b/dotcms-integration/src/test/resources/META-INF/beans.xml
index 1675ad7ab74c..12fe991ddcca 100644
--- a/dotcms-integration/src/test/resources/META-INF/beans.xml
+++ b/dotcms-integration/src/test/resources/META-INF/beans.xml
@@ -1,7 +1,6 @@
-