From 72706b652f52eccc0ff3cbc9f3c2ec01138d380b Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Tue, 7 Mar 2023 12:28:50 +0100 Subject: [PATCH] ArC: add Lang Model TCK runner --- .../arc/lang-model-tck-runner/pom.xml | 49 +++++++++++++++++++ .../arc/tck/LangModelTckExtension.java | 23 +++++++++ .../io/quarkus/arc/tck/LangModelTest.java | 31 ++++++++++++ independent-projects/arc/pom.xml | 1 + 4 files changed, 104 insertions(+) create mode 100644 independent-projects/arc/lang-model-tck-runner/pom.xml create mode 100644 independent-projects/arc/lang-model-tck-runner/src/test/java/io/quarkus/arc/tck/LangModelTckExtension.java create mode 100644 independent-projects/arc/lang-model-tck-runner/src/test/java/io/quarkus/arc/tck/LangModelTest.java diff --git a/independent-projects/arc/lang-model-tck-runner/pom.xml b/independent-projects/arc/lang-model-tck-runner/pom.xml new file mode 100644 index 00000000000000..12e4ffcf821563 --- /dev/null +++ b/independent-projects/arc/lang-model-tck-runner/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + + io.quarkus.arc + arc-parent + 999-SNAPSHOT + + + arc-lang-model-tck-runner + ArC - Lang Model TCK Runner + + + + + org.jboss.arquillian + arquillian-bom + ${version.arquillian} + pom + import + + + + + + + io.quarkus.arc + arc-arquillian + + + jakarta.enterprise + cdi-tck-lang-model + ${version.cdi-tck} + + + junit + junit + ${version.junit4} + + + org.jboss.arquillian.junit + arquillian-junit-container + + + + diff --git a/independent-projects/arc/lang-model-tck-runner/src/test/java/io/quarkus/arc/tck/LangModelTckExtension.java b/independent-projects/arc/lang-model-tck-runner/src/test/java/io/quarkus/arc/tck/LangModelTckExtension.java new file mode 100644 index 00000000000000..65cb300e57df54 --- /dev/null +++ b/independent-projects/arc/lang-model-tck-runner/src/test/java/io/quarkus/arc/tck/LangModelTckExtension.java @@ -0,0 +1,23 @@ +package io.quarkus.arc.tck; + +import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension; +import jakarta.enterprise.inject.build.compatible.spi.Discovery; +import jakarta.enterprise.inject.build.compatible.spi.Enhancement; +import jakarta.enterprise.inject.build.compatible.spi.ScannedClasses; +import jakarta.enterprise.lang.model.declarations.ClassInfo; + +import org.jboss.cdi.lang.model.tck.LangModelVerifier; + +public class LangModelTckExtension implements BuildCompatibleExtension { + @Discovery + public void addClass(ScannedClasses scan) { + // `LangModelVerifier` has no bean defining annotation + // and isn't discovered in annotated discovery + scan.add(LangModelVerifier.class.getName()); + } + + @Enhancement(types = LangModelVerifier.class) + public void run(ClassInfo clazz) { + LangModelVerifier.verify(clazz); + } +} diff --git a/independent-projects/arc/lang-model-tck-runner/src/test/java/io/quarkus/arc/tck/LangModelTest.java b/independent-projects/arc/lang-model-tck-runner/src/test/java/io/quarkus/arc/tck/LangModelTest.java new file mode 100644 index 00000000000000..8396e8c7ae335f --- /dev/null +++ b/independent-projects/arc/lang-model-tck-runner/src/test/java/io/quarkus/arc/tck/LangModelTest.java @@ -0,0 +1,31 @@ +package io.quarkus.arc.tck; + +import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.cdi.lang.model.tck.LangModelVerifier; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(Arquillian.class) +public class LangModelTest { + @Deployment + public static Archive deployment() { + return ShrinkWrap.create(JavaArchive.class) + .addPackage(LangModelVerifier.class.getPackage()) + .addClasses(LangModelTest.class, LangModelTckExtension.class) + .addAsServiceProvider(BuildCompatibleExtension.class, LangModelTckExtension.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void test() { + // the test itself runs in LangModelTckExtension + // and if it fails, deployment fails + } +} diff --git a/independent-projects/arc/pom.xml b/independent-projects/arc/pom.xml index 78e5cc037b318f..def6ade66fc5bd 100644 --- a/independent-projects/arc/pom.xml +++ b/independent-projects/arc/pom.xml @@ -73,6 +73,7 @@ atinject-tck-runner cdi-tck-porting-pkg cdi-tck-runner + lang-model-tck-runner