forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP ArC: fix non-@inherited transitive bindings on @inherited bindings
- Loading branch information
Showing
3 changed files
with
130 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
...test/interceptors/bindings/inherited/transitive/InheritedTransitiveBindingOnBeanTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package io.quarkus.arc.test.interceptors.bindings.inherited.transitive; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.test.ArcTestContainer; | ||
import jakarta.annotation.Priority; | ||
import jakarta.inject.Singleton; | ||
import jakarta.interceptor.AroundInvoke; | ||
import jakarta.interceptor.Interceptor; | ||
import jakarta.interceptor.InterceptorBinding; | ||
import jakarta.interceptor.InvocationContext; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class InheritedTransitiveBindingOnBeanTest { | ||
@RegisterExtension | ||
public ArcTestContainer container = new ArcTestContainer.Builder() | ||
.beanClasses(MyBean.class, FooBinding.class, BarBinding.class, BazBinding.class, FooInterceptor.class, BarInterceptor.class, BazInterceptor.class) | ||
.build(); | ||
|
||
@Test | ||
public void testInterception() { | ||
MyBean bean = Arc.container().instance(MyBean.class).get(); | ||
assertNotNull(bean); | ||
bean.doSomething(); | ||
assertTrue(FooInterceptor.intercepted); | ||
assertFalse(BarInterceptor.intercepted); | ||
assertTrue(BazInterceptor.intercepted); | ||
} | ||
|
||
@FooBinding | ||
@BarBinding | ||
static class MySuperclass { | ||
} | ||
|
||
@Singleton | ||
static class MyBean extends MySuperclass { | ||
void doSomething() { | ||
} | ||
} | ||
|
||
@BazBinding | ||
@Target({ TYPE, METHOD }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@InterceptorBinding | ||
@Inherited | ||
@interface FooBinding { | ||
} | ||
|
||
@Target({ TYPE, METHOD }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@InterceptorBinding | ||
// not @Inherited | ||
@interface BarBinding { | ||
} | ||
|
||
@Target({ TYPE, METHOD }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@InterceptorBinding | ||
// not @Inherited | ||
@interface BazBinding { | ||
} | ||
|
||
@FooBinding | ||
@Interceptor | ||
@Priority(1) | ||
static class FooInterceptor { | ||
static boolean intercepted = false; | ||
|
||
@AroundInvoke | ||
Object intercept(InvocationContext ctx) throws Exception { | ||
intercepted = true; | ||
return ctx.proceed(); | ||
} | ||
} | ||
|
||
@BarBinding | ||
@Interceptor | ||
@Priority(1) | ||
static class BarInterceptor { | ||
static boolean intercepted = false; | ||
|
||
@AroundInvoke | ||
Object intercept(InvocationContext ctx) throws Exception { | ||
intercepted = true; | ||
return ctx.proceed(); | ||
} | ||
} | ||
|
||
@BazBinding | ||
@Interceptor | ||
@Priority(1) | ||
static class BazInterceptor { | ||
static boolean intercepted = false; | ||
|
||
@AroundInvoke | ||
Object intercept(InvocationContext ctx) throws Exception { | ||
intercepted = true; | ||
return ctx.proceed(); | ||
} | ||
} | ||
} |