Skip to content

Commit

Permalink
WELD-2699 Add support for execution of CDI lang model TCKs.
Browse files Browse the repository at this point in the history
  • Loading branch information
manovotn committed Jan 20, 2022
1 parent 3a3855d commit 6466309
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-actions.yml
Expand Up @@ -116,7 +116,7 @@ jobs:
run: |
JBOSS_HOME=`pwd`'/wildfly'
export JBOSS_HOME=`echo $JBOSS_HOME`
mvn clean verify -Dincontainer -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -pl '!jboss-tck-runner,!impl'
mvn clean verify -Dincontainer -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -pl '!jboss-tck-runner'
- name: Prepare failure archive (if maven failed)
if: failure()
shell: bash
Expand Down
74 changes: 74 additions & 0 deletions lang-model-tck/pom.xml
@@ -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>
@@ -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);
}
}
@@ -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);
}
}
16 changes: 16 additions & 0 deletions lang-model-tck/src/test/resources/arquillian.xml
@@ -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>
3 changes: 2 additions & 1 deletion pom.xml
Expand Up @@ -98,13 +98,13 @@

<modules>
<module>impl</module>
<module>weld-lite-extension-translator</module>
<module>modules/ejb</module>
<module>modules/jsf</module>
<module>modules/jta</module>
<module>modules/web</module>
<module>probe</module>
<module>bom</module>
<module>weld-lite-extension-translator</module>
</modules>

<!-- Dependency management. KEEP IN ALPHABETICAL ORDER -->
Expand Down Expand Up @@ -595,6 +595,7 @@
<module>porting-package</module>
<module>tests-common</module>
<module>tests</module>
<module>lang-model-tck</module>
<module>tests-arquillian</module>
<module>inject-tck-runner</module>
</modules>
Expand Down

0 comments on commit 6466309

Please sign in to comment.