-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@TestTransaction - move logic to the TestTransactionInterceptor class
- add basic support for interceptor's inheritance - other unsupported use cases are described here: quarkusio/quarkus#11942
- Loading branch information
Luca Di Grazia
committed
Sep 4, 2022
1 parent
fb9f66a
commit 60c9755
Showing
9 changed files
with
145 additions
and
47 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
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
17 changes: 17 additions & 0 deletions
17
...ts/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/inheritance/Interceptor1.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,17 @@ | ||
package io.quarkus.arc.test.interceptors.inheritance; | ||
|
||
import javax.interceptor.AroundInvoke; | ||
import javax.interceptor.Interceptor; | ||
import javax.interceptor.InvocationContext; | ||
|
||
@One | ||
@Interceptor | ||
public class Interceptor1 extends OverridenInterceptor { | ||
|
||
@AroundInvoke | ||
@Override | ||
public Object intercept(InvocationContext ctx) throws Exception { | ||
return ctx.proceed() + "1"; | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...ts/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/inheritance/Interceptor2.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,9 @@ | ||
package io.quarkus.arc.test.interceptors.inheritance; | ||
|
||
import javax.interceptor.Interceptor; | ||
|
||
@Two | ||
@Interceptor | ||
public class Interceptor2 extends OverridenInterceptor { | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...src/test/java/io/quarkus/arc/test/interceptors/inheritance/InterceptorSuperclassTest.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,44 @@ | ||
package io.quarkus.arc.test.interceptors.inheritance; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.test.ArcTestContainer; | ||
import javax.enterprise.context.ApplicationScoped; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
/** | ||
* "Around-invoke methods may be defined on interceptor classes and/or the target class and/or super- | ||
* classes of the target class or the interceptor classes. However, only one around-invoke method may be | ||
* defined on a given class." | ||
*/ | ||
public class InterceptorSuperclassTest { | ||
|
||
@RegisterExtension | ||
public ArcTestContainer container = new ArcTestContainer(Interceptor1.class, Interceptor2.class, One.class, Two.class, | ||
OverridenInterceptor.class, Fool.class); | ||
|
||
@Test | ||
public void testInterception() { | ||
Fool fool = Arc.container().instance(Fool.class).get(); | ||
assertEquals("ping1", fool.pingOne()); | ||
assertEquals("pingoverriden", fool.pingTwo()); | ||
} | ||
|
||
@ApplicationScoped | ||
public static class Fool { | ||
|
||
@One | ||
String pingOne() { | ||
return "ping"; | ||
} | ||
|
||
@Two | ||
String pingTwo() { | ||
return "ping"; | ||
} | ||
|
||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...nt-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/inheritance/One.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,18 @@ | ||
package io.quarkus.arc.test.interceptors.inheritance; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
import javax.interceptor.InterceptorBinding; | ||
|
||
@Target({ TYPE, METHOD }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@InterceptorBinding | ||
public @interface One { | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...ests/src/test/java/io/quarkus/arc/test/interceptors/inheritance/OverridenInterceptor.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,12 @@ | ||
package io.quarkus.arc.test.interceptors.inheritance; | ||
|
||
import javax.interceptor.AroundInvoke; | ||
import javax.interceptor.InvocationContext; | ||
|
||
public class OverridenInterceptor { | ||
|
||
@AroundInvoke | ||
public Object intercept(InvocationContext ctx) throws Exception { | ||
return ctx.proceed() + "overriden"; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...nt-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/inheritance/Two.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,18 @@ | ||
package io.quarkus.arc.test.interceptors.inheritance; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
import javax.interceptor.InterceptorBinding; | ||
|
||
@Target({ TYPE, METHOD }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@InterceptorBinding | ||
public @interface Two { | ||
|
||
} |