Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jakarta TCKs #33638

Merged
merged 8 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import org.jboss.jandex.Indexer;
import org.jboss.logging.Logger;

import io.quarkus.arc.processor.AnnotationsTransformer;
import io.quarkus.arc.processor.BeanArchives;
import io.quarkus.arc.processor.BeanDefiningAnnotation;
import io.quarkus.arc.processor.BeanDeployment;
import io.quarkus.arc.processor.DotNames;
import io.quarkus.arc.runtime.AdditionalBean;
import io.quarkus.deployment.ApplicationArchive;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
Expand All @@ -51,7 +53,8 @@ public BeanArchiveIndexBuildItem build(ArcConfig config, ApplicationArchivesBuil
CustomScopeAnnotationsBuildItem customScopes, List<ExcludeDependencyBuildItem> excludeDependencyBuildItems,
List<BeanArchivePredicateBuildItem> beanArchivePredicates,
List<KnownCompatibleBeanArchiveBuildItem> knownCompatibleBeanArchives,
BuildCompatibleExtensionsBuildItem buildCompatibleExtensions)
BuildCompatibleExtensionsBuildItem buildCompatibleExtensions,
BuildProducer<AnnotationsTransformerBuildItem> annotationsTransformations)
throws Exception {

// First build an index from application archives
Expand All @@ -69,6 +72,20 @@ public BeanArchiveIndexBuildItem build(ArcConfig config, ApplicationArchivesBuil
Set<String> additionalBeansFromExtensions = new HashSet<>();
buildCompatibleExtensions.entrypoint.runDiscovery(applicationIndex, additionalBeansFromExtensions);
additionalBeanClasses.addAll(additionalBeansFromExtensions);
annotationsTransformations.produce(new AnnotationsTransformerBuildItem(new AnnotationsTransformer() {
@Override
public boolean appliesTo(Kind kind) {
return kind == Kind.CLASS;
}

@Override
public void transform(TransformationContext ctx) {
if (additionalBeansFromExtensions.contains(ctx.getTarget().asClass().name().toString())) {
// make all the `@Discovery`-registered classes beans
ctx.transform().add(AdditionalBean.class).done();
}
}
}));

// Build the index for additional beans and generated bean classes
Set<DotName> additionalIndex = new HashSet<>();
Expand Down Expand Up @@ -131,13 +148,22 @@ private IndexView buildApplicationIndex(ArcConfig config, ApplicationArchivesBui
.map(bda -> new BeanDefiningAnnotation(bda.getName(), bda.getDefaultScope()))
.collect(Collectors.toList()), stereotypes);
beanDefiningAnnotations.addAll(customScopes.getCustomScopeNames());
// Also include archives that are not bean archives but contain qualifiers or interceptor bindings
// Also include archives that are not bean archives but contain scopes, qualifiers or interceptor bindings
beanDefiningAnnotations.add(DotNames.SCOPE);
beanDefiningAnnotations.add(DotNames.NORMAL_SCOPE);
beanDefiningAnnotations.add(DotNames.QUALIFIER);
beanDefiningAnnotations.add(DotNames.INTERCEPTOR_BINDING);

boolean rootIsAlwaysBeanArchive = !config.strictCompatibility;
Collection<ApplicationArchive> candidateArchives = applicationArchivesBuildItem.getApplicationArchives();
if (!rootIsAlwaysBeanArchive) {
candidateArchives = new ArrayList<>(candidateArchives);
candidateArchives.add(applicationArchivesBuildItem.getRootArchive());
}

List<IndexView> indexes = new ArrayList<>();

for (ApplicationArchive archive : applicationArchivesBuildItem.getApplicationArchives()) {
for (ApplicationArchive archive : candidateArchives) {
if (isApplicationArchiveExcluded(config, excludeDependencyBuildItems, archive)) {
continue;
}
Expand All @@ -151,7 +177,9 @@ private IndexView buildApplicationIndex(ArcConfig config, ApplicationArchivesBui
indexes.add(index);
}
}
indexes.add(applicationArchivesBuildItem.getRootArchive().getIndex());
if (rootIsAlwaysBeanArchive) {
indexes.add(applicationArchivesBuildItem.getRootArchive().getIndex());
}
return CompositeIndex.create(indexes);
}

Expand Down
2 changes: 1 addition & 1 deletion independent-projects/arc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<!-- TCK versions -->
<version.arquillian>1.7.0.Final</version.arquillian>
<version.atinject-tck>2.0.1</version.atinject-tck>
<version.cdi-tck>4.0.9</version.cdi-tck>
<version.cdi-tck>4.0.10</version.cdi-tck>
<version.junit4>4.13.2</version.junit4>
<!-- Maven plugin versions -->
<version.compiler.plugin>3.11.0</version.compiler.plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ private Object findTest(ArcContainer arc, Class<?> testClass) {
return instance.get();
}

// fallback for generic test classes, whose set of bean types does not contain a `Class`
// but a `ParameterizedType` instead
for (InstanceHandle<Object> handle : arc.listAll(Object.class)) {
if (testClass.equals(handle.getBean().getBeanClass())) {
return handle.get();
if (testClass.getTypeParameters().length > 0) {
// fallback for generic test classes, whose set of bean types does not contain a `Class`
// but a `ParameterizedType` instead
for (InstanceHandle<Object> handle : arc.listAll(Object.class)) {
if (testClass.equals(handle.getBean().getBeanClass())) {
return handle.get();
}
}
}

Expand Down
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.

Original file line number Diff line number Diff line change
Expand Up @@ -20,87 +20,14 @@
</packages>

<classes>
<class name="org.jboss.cdi.tck.tests.implementation.simple.lifecycle.SimpleBeanLifecycleTest">
<methods>
<!-- https://github.com/jakartaee/cdi-tck/pull/452 -->
<exclude name="testBeanCreateInjectsDependenciesAndInvokesInitializerToInstantiateInstance"/>
</methods>
</class>
<class name="org.jboss.cdi.tck.interceptors.tests.contract.lifecycleCallback.LifecycleCallbackInterceptorTest">
<methods>
<!-- https://github.com/jakartaee/cdi-tck/issues/448 -->
<exclude name="testPostConstructInterceptor"/>
<exclude name="testProtectedLifecycleInterceptorMethod"/>
<exclude name="testLifeCycleCallbackInterceptorNotInvokedForMethodLevelInterceptor"/>
<exclude name="testSingleMethodInterposingMultipleLifecycleCallbackEvents"/>
<exclude name="testPackagePrivateLifecycleInterceptorMethod"/>
<exclude name="testPreDestroyInterceptor"/>
<exclude name="testAroundInvokeAndLifeCycleCallbackInterceptorsCanBeDefinedOnTheSameClass"/>
<exclude name="testPrivateLifecycleInterceptorMethod"/>
<exclude name="testPublicLifecycleInterceptorMethod"/>
</methods>
</class>
<class name="org.jboss.cdi.tck.interceptors.tests.contract.invocationContext.InvocationContextTest">
<methods>
<exclude name="testGetTargetMethod"/>
</methods>
</class>
<!-- === exclusions from the canonical exclusion list in the CDI TCK === -->

<!-- https://github.com/jakartaee/cdi-tck/issues/453 -->
<class name="org.jboss.cdi.tck.tests.context.DestroyForSameCreationalContextTest">
<methods>
<!-- https://github.com/jakartaee/cdi-tck/pull/452 -->
<exclude name="testDestroyForSameCreationalContextOnly"/>
</methods>
</class>
<class name="org.jboss.cdi.tck.tests.context.DestroyForSameCreationalContext2Test">
<methods>
<!-- https://github.com/jakartaee/cdi-tck/issues/457 -->
<exclude name="testDestroyForSameCreationalContextOnly"/>
</methods>
</class>
<class name="org.jboss.cdi.tck.tests.interceptors.definition.inheritance.InterceptorBindingInheritanceTest">
<methods>
<exclude name="testInterceptorBindingDirectlyInheritedFromManagedBean"/>
<exclude name="testInterceptorBindingIndirectlyInheritedFromManagedBean"/>
</methods>
</class>
<class name="org.jboss.cdi.tck.tests.lookup.injectionpoint.InjectionPointTest">
<methods>
<!-- https://github.com/jakartaee/cdi-tck/issues/459 -->
<exclude name="testApiTypeInjectionPoint"/>
<exclude name="testGetBindingTypes"/>
<exclude name="testGetMemberField"/>
<exclude name="testGetMemberMethod"/>
<exclude name="testNullInjectionPointInjectedIntoNonInjectedObject"/>
<exclude name="testCurrentBinding"/>
<exclude name="testDependentScope"/>
<exclude name="testGetAnnotatedParameter"/>
<exclude name="testGetType"/>
<exclude name="testIsTransient"/>
<exclude name="testGetAnnotatedField"/>
<exclude name="testGetMemberConstructor"/>
<exclude name="testGetBean"/>
</methods>
</class>
<class name="org.jboss.cdi.tck.tests.interceptors.definition.InterceptorDefinitionTest">
<methods>
<!-- https://github.com/jakartaee/cdi-tck/issues/455 -->
<exclude name="testInterceptorsImplementInterceptorInterface"/>
</methods>
</class>
<class name="org.jboss.cdi.tck.tests.context.dependent.DependentContextTest">
<methods>
<!-- https://github.com/jakartaee/cdi-tck/pull/452 -->
<exclude name="testContextIsActiveDuringInjection"/>
<!-- https://github.com/jakartaee/cdi-tck/issues/454 -->
<exclude name="testDependentScopedInterceptorsAreDependentObjectsOfBean"/>
</methods>
</class>
<class name="org.jboss.cdi.tck.tests.context.GetFromContextualTest">
<methods>
<!-- https://github.com/jakartaee/cdi-tck/pull/452 -->
<exclude name="testGetMayNotCreateNewInstanceUnlessCreationalContextGiven"/>
</methods>
</class>
</classes>
</test>
</suite>
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);
}
}
Loading