Skip to content

Commit

Permalink
Merge pull request #24888 from avpinchuk/cdi-model-tck
Browse files Browse the repository at this point in the history
Enable CDI Lang Model TCK
  • Loading branch information
avpinchuk authored Apr 12, 2024
2 parents cdf3310 + fbb8be6 commit 03daeb8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 109 deletions.
62 changes: 6 additions & 56 deletions appserver/tests/tck/cdi/cdi-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,14 @@
<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>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
Expand All @@ -84,57 +70,19 @@
<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.
-->
Expand All @@ -143,7 +91,6 @@
<artifactId>arquillian-glassfish-server-managed</artifactId>
<version>1.4</version>
</dependency>

</dependencies>


Expand Down Expand Up @@ -211,6 +158,9 @@
<glassfish.home>${glassfish.root}/glassfish7</glassfish.home>
<glassfish.enableAssertions>:org.jboss.cdi...</glassfish.enableAssertions>
</systemPropertyVariables>
<includes>
<include>CDILangModelTCKRunner.java</include>
</includes>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation. All rights reserved.
* Copyright (c) 2022, 2024 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
Expand All @@ -15,28 +15,29 @@
*/
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 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.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
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;
import static java.lang.System.Logger.Level.INFO;
import static org.glassfish.tck.cdi.lang.model.LangModelVerifierBuildCompatibleExtension.langModelVerifierBuildCompatibleExtensionPassed;
import static org.junit.Assert.assertTrue;

@RunWith(Arquillian.class)
public class CDILangModelTCKRunner {

private static final System.Logger LOG = System.getLogger(CDILangModelTCKRunner.class.getName());

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

// The package we are testing
.addPackage(LangModelVerifier.class.getPackage())
Expand All @@ -45,17 +46,11 @@ public static WebArchive deploy() {
.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(EmptyAsset.INSTANCE, "beans.xml");

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

System.out.println(archive.toString(true));
LOG.log(INFO, archive.toString(true));

return archive;

}

@Test
Expand Down

This file was deleted.

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

import org.jboss.cdi.lang.model.tck.LangModelVerifier;

import jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension;
import jakarta.enterprise.inject.build.compatible.spi.ClassConfig;
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 org.jboss.cdi.lang.model.tck.LangModelVerifier;

public class LangModelVerifierBuildCompatibleExtension implements BuildCompatibleExtension {

public static boolean langModelVerifierBuildCompatibleExtensionCalled;
public static boolean langModelVerifierBuildCompatibleExtensionPassed;

@Discovery
public void discovery(ScannedClasses scannedClasses) {
scannedClasses.add(LangModelVerifier.class.getName());
}

@Enhancement(types = LangModelVerifier.class)
public void configure(ClassConfig classConfig) {
langModelVerifierBuildCompatibleExtensionCalled = true;
LangModelVerifier.verify(classConfig.info());
// If there's an error, the verify() method will throw an exception
langModelVerifierBuildCompatibleExtensionPassed = true;
}

}

0 comments on commit 03daeb8

Please sign in to comment.