Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WELD-2699 Add support for execution of CDI lang model TCKs.
- Loading branch information
Showing
6 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>weld-core-parent</artifactId> | ||
<groupId>org.jboss.weld</groupId> | ||
<version>5.0.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<name>CDI Lite Language Model TCK</name> | ||
<artifactId>lang-model-tck</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>jakarta.enterprise</groupId> | ||
<artifactId>cdi-tck-lang-model</artifactId> | ||
<version>${cdi.tck-4-0.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<!-- we need to depend on the impl to make sure this module is built after weld-lite-extension-translator --> | ||
<dependency> | ||
<groupId>org.jboss.weld</groupId> | ||
<artifactId>weld-lite-extension-translator</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.arquillian.junit</groupId> | ||
<artifactId>arquillian-junit-container</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.weld</groupId> | ||
<artifactId>weld-core-test-common</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>jakarta.enterprise</groupId> | ||
<artifactId>cdi-tck-lang-model</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.arquillian.container</groupId> | ||
<artifactId>arquillian-weld-embedded</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.weld</groupId> | ||
<artifactId>weld-core-impl</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
34 changes: 34 additions & 0 deletions
34
lang-model-tck/src/test/java/org/jboss/weld/lang/model/tck/LangModelExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2021, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.jboss.weld.lang.model.tck; | ||
|
||
import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension; | ||
import jakarta.enterprise.inject.build.compatible.spi.Enhancement; | ||
import jakarta.enterprise.lang.model.declarations.ClassInfo; | ||
import org.jboss.cdi.lang.model.tck.LangModelVerifier; | ||
|
||
public class LangModelExtension implements BuildCompatibleExtension { | ||
|
||
public static int ENHANCEMENT_INVOKED = 0; | ||
|
||
@Enhancement(types = LangModelVerifier.class) | ||
public void run(ClassInfo clazz) { | ||
ENHANCEMENT_INVOKED++; | ||
LangModelVerifier.verify(clazz); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
lang-model-tck/src/test/java/org/jboss/weld/lang/model/tck/LangModelTckTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2021, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.jboss.weld.lang.model.tck; | ||
|
||
import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension; | ||
import jakarta.enterprise.lang.model.declarations.ClassInfo; | ||
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.BeanDiscoveryMode; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.jboss.shrinkwrap.impl.BeansXml; | ||
import org.jboss.weld.tests.util.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* <p> | ||
* Executes CDI TCK for language model used in CDI Lite, current setup requires discovery mode ALL plus adding | ||
* {@link LangModelVerifier} into the deployment to discover it as a bean. Alternatively, this could be added | ||
* synthetically inside {@link LangModelExtension}. | ||
* </p> | ||
* | ||
* <p> | ||
* Actual test happens inside {@link LangModelExtension} by calling {@link LangModelVerifier#verify(ClassInfo)}. | ||
* </p> | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class LangModelTckTest { | ||
|
||
@Deployment | ||
public static Archive<?> deploy() { | ||
return ShrinkWrap.create(WebArchive.class, LangModelTckTest.class.getSimpleName() + ".war") | ||
// beans.xml with discovery mode "all" | ||
.addAsWebInfResource(new BeansXml(BeanDiscoveryMode.ALL), "beans.xml") | ||
.addAsServiceProvider(BuildCompatibleExtension.class, LangModelExtension.class) | ||
// add this class into the deployment so that it's subject to discovery | ||
.addClasses(LangModelVerifier.class); | ||
} | ||
|
||
@Test | ||
public void testLangModel() { | ||
// test is executed in LangModelExtension; here we just assert that the relevant extension method was invoked | ||
Assert.assertTrue(LangModelExtension.ENHANCEMENT_INVOKED == 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<arquillian xmlns="http://jboss.org/schema/arquillian" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> | ||
|
||
<engine> | ||
<!-- Uncomment to export test archives for debug purposes --> | ||
<!-- property name="deploymentExportPath">target/</property --> | ||
</engine> | ||
|
||
<container qualifier="weld" default="true"> | ||
<configuration> | ||
<property name="environment">SE</property> | ||
</configuration> | ||
</container> | ||
</arquillian> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters