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

small improvements in Build Compatible Extensions and Language Model TCKs #501

Merged
merged 1 commit into from
Nov 27, 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
@@ -0,0 +1,16 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.registration;

import jakarta.annotation.Priority;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.Interceptor;
import jakarta.interceptor.InvocationContext;

@MyInterceptorBinding
@Interceptor
@Priority(1)
public class MyInterceptor {
@AroundInvoke
public Object intercept(InvocationContext ctx) throws Exception {
return ctx.proceed();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.jboss.cdi.tck.tests.build.compatible.extensions.registration;

import jakarta.interceptor.InterceptorBinding;

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

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@InterceptorBinding
public @interface MyInterceptorBinding {
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class RegistrationExtension implements BuildCompatibleExtension {
private final AtomicInteger beanCounter = new AtomicInteger();
private final AtomicInteger beanMyQualifierCounter = new AtomicInteger();
private final AtomicInteger observerCounter = new AtomicInteger();
private final AtomicInteger interceptorCounter = new AtomicInteger();

@Registration(types = MyService.class)
public void beans(BeanInfo bean) {
Expand All @@ -31,6 +32,14 @@ public void observers(ObserverInfo observer, Types types) {
}
}

@Registration(types = MyInterceptor.class)
public void interceptors(BeanInfo interceptor, Messages msg) {
if (!interceptor.isInterceptor()) {
msg.error("Interceptor expected", interceptor);
}
interceptorCounter.incrementAndGet();
}

@Validation
public void test(Messages msg) {
if (beanCounter.get() != 2) {
Expand All @@ -44,5 +53,9 @@ public void test(Messages msg) {
if (observerCounter.get() != 1) {
msg.error("Should see 1 observer declared in class that implements MyService");
}

if (interceptorCounter.get() != 1) {
msg.error("Should see 1 interceptor of type MyInterceptor");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.jboss.cdi.lang.model.tck;

import jakarta.enterprise.lang.model.declarations.ClassInfo;

public class JavaLangObjectMethods /*extends Object*/ {
public static class Verifier {
public static void verify(ClassInfo clazz) {
assert clazz.methods().isEmpty();

ClassInfo javaLangObject = clazz.superClassDeclaration();
assert !javaLangObject.methods().isEmpty();
assert LangModelUtils.collectMethods(javaLangObject, "toString").size() == 1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class LangModelVerifier {
InheritedFields inheritedFields;
InheritedAnnotations inheritedAnnotations;

JavaLangObjectMethods javaLangObjectMethods;

PrimitiveTypes primitiveTypes;
BridgeMethods bridgeMethods;
RepeatableAnnotations repeatableAnnotations;
Expand Down Expand Up @@ -79,6 +81,8 @@ public static void verify(ClassInfo clazz) {
InheritedFields.Verifier.verify(LangModelUtils.classOfField(clazz, "inheritedFields"));
InheritedAnnotations.verify(LangModelUtils.classOfField(clazz, "inheritedAnnotations"));

JavaLangObjectMethods.Verifier.verify(LangModelUtils.classOfField(clazz, "javaLangObjectMethods"));

PrimitiveTypes.verify(LangModelUtils.classOfField(clazz, "primitiveTypes"));
BridgeMethods.verify(LangModelUtils.classOfField(clazz, "bridgeMethods"));
RepeatableAnnotations.verify(LangModelUtils.classOfField(clazz, "repeatableAnnotations"));
Expand Down