Skip to content

Commit

Permalink
Merge pull request #24040 from arjantijms/cdi_tck_lang_model
Browse files Browse the repository at this point in the history
Add execution of the CDI Lang Model TCK
  • Loading branch information
arjantijms authored Jul 8, 2022
2 parents 341fc3b + 356e21d commit 815122c
Show file tree
Hide file tree
Showing 15 changed files with 977 additions and 543 deletions.
571 changes: 571 additions & 0 deletions appserver/tests/tck/cdi/cdi-full/pom.xml

Large diffs are not rendered by default.

261 changes: 261 additions & 0 deletions appserver/tests/tck/cdi/cdi-model/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation. All rights reserved.
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
-->
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.glassfish.main.tests.tck</groupId>
<artifactId>glassfish-external-tck-cdi-parent</artifactId>
<version>7.0.0-SNAPSHOT</version>
</parent>

<artifactId>glassfish-external-tck-cdi-model</artifactId>

<name>CDI TCK Model runner 4.0 for Weld (GlassFish)</name>
<description>Aggregates dependencies and runs the CDI TCK (both standalone and on GlassFish)</description>

<properties>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<cdi.tck-4-0.version>4.0.5</cdi.tck-4-0.version>

<!-- This matches the htmlunit version in TCK -->
<htmlunit.version>2.50.0</htmlunit.version>
<excluded.groups>se</excluded.groups>

<glassfish.version>${project.version}</glassfish.version>
<glassfish.root>${project.build.directory}</glassfish.root>
<glassfish.home>${glassfish.root}/glassfish7</glassfish.home>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>cdi-tck-lang-model</artifactId>
<version>${cdi.tck-4-0.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-lite-extension-translator</artifactId>
<version>${weld.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-test-common</artifactId>
<version>${weld.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-impl</artifactId>
<version>${weld.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-lite-extension-translator</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.7.0.Alpha10</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-test-common</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-impl</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>cdi-tck-lang-model</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jboss.weld.module</groupId>
<artifactId>weld-web</artifactId>
<version>${weld.version}</version>
</dependency>


<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>cdi-tck-api</artifactId>
<version>${cdi.tck-4-0.version}</version>
<exclusions>
<exclusion>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>test</scope>
</dependency>

<!--
The Arquillian connector that starts GlassFish and deploys archives to it.
-->
<dependency>
<groupId>org.omnifaces.arquillian</groupId>
<artifactId>arquillian-glassfish-server-managed</artifactId>
<version>1.2</version>
</dependency>

</dependencies>


<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<!-- Disable annotation processor for test sources -->
<testCompilerArgument>-proc:none</testCompilerArgument>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependency/lib</outputDirectory>
<archive>
<manifest>
<addClasspath>false</addClasspath>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>unpack-glassfish</id>
<phase>test-compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<markersDirectory>${glassfish.root}/dependency-maven-plugin-markers</markersDirectory>
<artifactItems>
<artifactItem>
<groupId>org.glassfish.main.distributions</groupId>
<artifactId>${glassfish-artifact-id}</artifactId>
<version>${glassfish.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${glassfish.root}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx768m</argLine>
<forkMode>once</forkMode>
<!-- System Properties -->
<systemPropertyVariables>
<glassfish.home>${glassfish.root}/glassfish7</glassfish.home>
<glassfish.enableAssertions>:org.jboss.cdi...</glassfish.enableAssertions>
</systemPropertyVariables>
</configuration>
</plugin>


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M7</version>
<executions>
<execution>
<id>generate-test-report</id>
<phase>verify</phase>
<goals>
<goal>report-only</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${project.build.directory}/surefire-reports</outputDirectory>
<outputName>test-report</outputName>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>javaee-full</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<glassfish-artifact-id>glassfish</glassfish-artifact-id>
</properties>
</profile>
<profile>
<id>webprofile</id>
<properties>
<glassfish-artifact-id>web</glassfish-artifact-id>
</properties>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation. All rights reserved.
*
* 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 org.glassfish.tck.cdi.lang.model;

import static org.glassfish.tck.cdi.lang.model.LangModelVerifierBuildCompatibleExtension.langModelVerifierBuildCompatibleExtensionPassed;
import static org.jboss.shrinkwrap.api.BeanDiscoveryMode.ALL;
import static org.junit.Assert.assertTrue;

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.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.impl.BeansXml;
import org.junit.Test;
import org.junit.runner.RunWith;

import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension;
import jakarta.enterprise.inject.spi.Extension;

@RunWith(Arquillian.class)
public class CDILangModelTCKRunner {

@Deployment
public static WebArchive deploy() {
WebArchive archive= ShrinkWrap.create(WebArchive.class)

// The package we are testing
.addPackage(LangModelVerifier.class.getPackage())

// The build compatible extension that starts the test
.addClass(LangModelVerifierBuildCompatibleExtension.class)
.addAsServiceProvider(BuildCompatibleExtension.class, LangModelVerifierBuildCompatibleExtension.class)

// The cleanup extension that vetoes all classes that we're testing, since they are only
// meant for the lang model verifier and shouldn't be processed afterwards.
.addClass(CleanupExtension.class)
.addAsServiceProvider(Extension.class, CleanupExtension.class)

.addAsWebInfResource(new BeansXml(ALL), "beans.xml");

System.out.println(archive.toString(true));

return archive;

}

@Test
public void testCDILangModel() {
// If the extension has been called, and no exception was thrown
assertTrue(langModelVerifierBuildCompatibleExtensionPassed);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation. All rights reserved.
*
* 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 org.glassfish.tck.cdi.lang.model;

import jakarta.annotation.Priority;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.spi.Extension;
import jakarta.enterprise.inject.spi.ProcessAnnotatedType;

public class CleanupExtension implements Extension {

public void enhancement(@Priority(Integer.MAX_VALUE) @Observes ProcessAnnotatedType<?> pat) {
if (LangModelVerifierBuildCompatibleExtension.langModelVerifierBuildCompatibleExtensionCalled &&
pat.getAnnotatedType().getJavaClass().getName().startsWith("org.jboss.cdi.lang.model.tck")) {
pat.veto();
}
}
}
Loading

0 comments on commit 815122c

Please sign in to comment.