diff --git a/tck-dist/pom.xml b/tck-dist/pom.xml index 7e38d5cea..03a72d9c4 100644 --- a/tck-dist/pom.xml +++ b/tck-dist/pom.xml @@ -37,6 +37,7 @@ ${project.version} + ${project.version} true 2.2.4 @@ -49,10 +50,23 @@ + jakarta.data jakarta-data-tck ${jakarta.data.tck.version} + + + + jakarta.servlet + jakarta.servlet-api + ${jakarta.servlet.version} + + + + jakarta.data + jakarta-data-api + ${jakarta.data.api.version} diff --git a/tck/pom.xml b/tck/pom.xml index 0e6cc7f06..72917cdd8 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -84,6 +84,13 @@ provided + + jakarta.enterprise + jakarta.enterprise.cdi-api + ${jakarta.enterprise.cdi.version} + provided + + jakarta.nosql diff --git a/tck/src/main/java/ee/jakarta/tck/data/framework/junit/anno/CDI.java b/tck/src/main/java/ee/jakarta/tck/data/framework/junit/anno/CDI.java new file mode 100644 index 000000000..64e4a4279 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/data/framework/junit/anno/CDI.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ +package ee.jakarta.tck.data.framework.junit.anno; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.junit.jupiter.api.extension.ExtendWith; + +import ee.jakarta.tck.data.framework.junit.extensions.CDIConditionExtension; + +/** + * These are tests that require CDI for testing. + * This annotation will verify that CDI is available. + * If CDI is not available, tests are skipped, otherwise, tests are run. + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@ExtendWith(CDIConditionExtension.class) +public @interface CDI { + +} diff --git a/tck/src/main/java/ee/jakarta/tck/data/framework/junit/extensions/CDIConditionExtension.java b/tck/src/main/java/ee/jakarta/tck/data/framework/junit/extensions/CDIConditionExtension.java new file mode 100644 index 000000000..6d116a77b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/data/framework/junit/extensions/CDIConditionExtension.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ +package ee.jakarta.tck.data.framework.junit.extensions; + +import java.util.logging.Logger; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +import jakarta.enterprise.inject.spi.CDI; + +/** + * Evaluates the availability of CDI to determine if a test class/method is enabled/disabled. + * + * @see ee.jakarta.tck.data.framework.junit.anno.CDI + */ +public class CDIConditionExtension implements ExecutionCondition { + + private static final Logger log = Logger.getLogger(CDIConditionExtension.class.getCanonicalName()); + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + + //We are only verifying CDI when running on a platform so first verify that this condition is running on a platform + if(Boolean.parseBoolean(context.getConfigurationParameter(ArquillianExtension.RUNNING_INSIDE_ARQUILLIAN).orElse("false"))) { + log.info("Inside Jakarta EE Platform, testing CDI provider."); + } else { + log.info("Outside Jakarta EE Platform, waiting to test CDI provider until inside."); + return ConditionEvaluationResult.enabled("Deploying test to container."); + } + + try { + CDI.current(); + return ConditionEvaluationResult.enabled("CDI provider is available"); + } catch (IllegalStateException e) { + return ConditionEvaluationResult.disabled("CDI provider is not available"); + } catch (Throwable t) { + return ConditionEvaluationResult.disabled("CDI provider available state unknown", t.getLocalizedMessage()); + } + } + +} \ No newline at end of file diff --git a/tck/src/main/java/ee/jakarta/tck/data/standalone/entity/EntityTest.java b/tck/src/main/java/ee/jakarta/tck/data/standalone/entity/EntityTests.java similarity index 99% rename from tck/src/main/java/ee/jakarta/tck/data/standalone/entity/EntityTest.java rename to tck/src/main/java/ee/jakarta/tck/data/standalone/entity/EntityTests.java index 345ffd04f..c91cead12 100644 --- a/tck/src/main/java/ee/jakarta/tck/data/standalone/entity/EntityTest.java +++ b/tck/src/main/java/ee/jakarta/tck/data/standalone/entity/EntityTests.java @@ -71,13 +71,13 @@ @Standalone @AnyEntity @ReadOnlyTest -public class EntityTest { +public class EntityTests { - public static final Logger log = Logger.getLogger(EntityTest.class.getCanonicalName()); + public static final Logger log = Logger.getLogger(EntityTests.class.getCanonicalName()); @Deployment public static JavaArchive createDeployment() { - return ShrinkWrap.create(JavaArchive.class).addClasses(EntityTest.class); + return ShrinkWrap.create(JavaArchive.class).addClasses(EntityTests.class); } @Inject diff --git a/tck/src/main/resources/ee/jakarta/tck/data/framework/signature/sig-test-pkg-list.txt b/tck/src/main/resources/ee/jakarta/tck/data/framework/signature/sig-test-pkg-list.txt index 21efb29c6..6434247c6 100644 --- a/tck/src/main/resources/ee/jakarta/tck/data/framework/signature/sig-test-pkg-list.txt +++ b/tck/src/main/resources/ee/jakarta/tck/data/framework/signature/sig-test-pkg-list.txt @@ -24,4 +24,6 @@ jakarta.data jakarta.data.exceptions +jakarta.data.model +jakarta.data.page jakarta.data.repository \ No newline at end of file