Skip to content

Commit

Permalink
Add Jakarta TCKs
Browse files Browse the repository at this point in the history
- AtInject
- CDI (Lite)
- CDI Lang Model
  • Loading branch information
Ladicek committed May 29, 2023
1 parent 364aade commit 7a55f18
Show file tree
Hide file tree
Showing 12 changed files with 483 additions and 1 deletion.
1 change: 1 addition & 0 deletions independent-projects/arc/tcks/cdi-tck-runner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<systemPropertyVariables>
<org.jboss.cdi.tck.cdiLiteMode>true</org.jboss.cdi.tck.cdiLiteMode>
<org.jboss.cdi.tck.libraryDirectory>${project.build.directory}/porting-pkg</org.jboss.cdi.tck.libraryDirectory>
</systemPropertyVariables>
<reuseForks>false</reuseForks>
Expand Down

This file was deleted.

88 changes: 88 additions & 0 deletions tcks/jakarta-atinject/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-tck-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-tck-jakarta-atinjecft</artifactId>
<name>Quarkus - TCK - Jakarta AtInject</name>

<properties>
<atinject-tck.version>2.0.1</atinject-tck.version>
<junit4.version>4.13.2</junit4.version>
</properties>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arquillian</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>

<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-tck</artifactId>
<version>${atinject-tck.version}</version>
<exclusions>
<exclusion>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</exclusion>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit4.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
</dependency>

<!-- Minimal test dependencies to *-deployment artifacts for consistent build order -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<quarkus.arc.remove-unused-beans>false</quarkus.arc.remove-unused-beans>
<quarkus.arc.strict-compatibility>true</quarkus.arc.strict-compatibility>
<quarkus.arc.transform-unproxyable-classes>false</quarkus.arc.transform-unproxyable-classes>
</systemPropertyVariables>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.quarkus.tck.atinject;

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.MetaAnnotations;
import jakarta.enterprise.inject.build.compatible.spi.ScannedClasses;
import jakarta.enterprise.inject.literal.NamedLiteral;

import org.atinject.tck.auto.Convertible;
import org.atinject.tck.auto.Drivers;
import org.atinject.tck.auto.DriversSeat;
import org.atinject.tck.auto.FuelTank;
import org.atinject.tck.auto.Seat;
import org.atinject.tck.auto.Tire;
import org.atinject.tck.auto.V8Engine;
import org.atinject.tck.auto.accessories.Cupholder;
import org.atinject.tck.auto.accessories.SpareTire;

public class AtInjectTckExtension implements BuildCompatibleExtension {
@Discovery
public void discovery(ScannedClasses scan, MetaAnnotations meta) {
scan.add(Convertible.class.getName());
scan.add(DriversSeat.class.getName());
scan.add(FuelTank.class.getName());
scan.add(Seat.class.getName());
scan.add(Tire.class.getName());
scan.add(V8Engine.class.getName());

scan.add(Cupholder.class.getName());
scan.add(SpareTire.class.getName());
}

@Enhancement(types = Convertible.class)
public void convertible(ClassConfig clazz) {
clazz.fields()
.stream()
.filter(it -> "spareTire".equals(it.info().name()))
.forEach(it -> it.addAnnotation(Spare.class));
}

@Enhancement(types = DriversSeat.class)
public void driversSeat(ClassConfig clazz) {
clazz.addAnnotation(Drivers.class);
}

@Enhancement(types = SpareTire.class)
public void spareTire(ClassConfig clazz) {
clazz.addAnnotation(NamedLiteral.of("spare"))
.addAnnotation(Spare.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.quarkus.tck.atinject;

import static org.junit.Assert.assertTrue;

import java.util.Enumeration;

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

import org.atinject.tck.Tck;
import org.atinject.tck.auto.Car;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
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;

import io.quarkus.arc.Arc;

@RunWith(Arquillian.class)
public class AtInjectTest {
@Deployment
public static Archive<?> deployment() {
return ShrinkWrap.create(JavaArchive.class)
.addPackages(true, Tck.class.getPackage())
.addClasses(AtInjectTest.class, AtInjectTckExtension.class, Spare.class)
.addAsServiceProvider(BuildCompatibleExtension.class, AtInjectTckExtension.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}

@Test
public void test() {
Car instance = Arc.container().instance(Car.class).get();

junit.framework.Test test = Tck.testsFor(instance, /* supportsStatic */ false, /* supportsPrivate */ true);
junit.framework.TestResult result = new junit.framework.TestResult();
test.run(result);

// this is ugly and doesn't report failures properly, but I don't see a better way
if (!result.wasSuccessful()) {
int failuresCount = 0;
Enumeration<junit.framework.TestFailure> failures = result.failures();
while (failures.hasMoreElements()) {
System.out.println(failures.nextElement());
failuresCount++;
}

int errorsCount = 0;
Enumeration<junit.framework.TestFailure> errors = result.errors();
while (errors.hasMoreElements()) {
System.out.println(errors.nextElement());
errorsCount++;
}
System.out.println("Total " + failuresCount + " failures and " + errorsCount + " errors");
}

assertTrue(result.wasSuccessful());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.quarkus.tck.atinject;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import jakarta.inject.Qualifier;

@Qualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface Spare {
}
80 changes: 80 additions & 0 deletions tcks/jakarta-cdi-lang-model/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-tck-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-tck-jakarta-cdi-lang-model</artifactId>
<name>Quarkus - TCK - Jakarta CDI Lang Model</name>

<properties>
<cdi-tck.version>4.0.10</cdi-tck.version>
<junit4.version>4.13.2</junit4.version>
</properties>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arquillian</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>

<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>cdi-tck-lang-model</artifactId>
<version>${cdi-tck.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit4.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
</dependency>

<!-- Minimal test dependencies to *-deployment artifacts for consistent build order -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<systemPropertyVariables>
<quarkus.arc.remove-unused-beans>false</quarkus.arc.remove-unused-beans>
<quarkus.arc.strict-compatibility>true</quarkus.arc.strict-compatibility>
<quarkus.arc.transform-unproxyable-classes>false</quarkus.arc.transform-unproxyable-classes>
</systemPropertyVariables>
</systemPropertyVariables>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.quarkus.tck.cdi.lang.model;

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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.quarkus.tck.cdi.lang.model;

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
}
}
Loading

0 comments on commit 7a55f18

Please sign in to comment.