-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bean that has a bound interceptor must not declare final methods
- otherwise a deployment exception is thrown - final methods declared on bean classes that require client proxies are ignored though
- Loading branch information
Showing
4 changed files
with
125 additions
and
16 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
45 changes: 45 additions & 0 deletions
45
...sts/src/test/java/io/quarkus/arc/test/clientproxy/finalmethod/FinalMethodIgnoredTest.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,45 @@ | ||
package io.quarkus.arc.test.clientproxy.finalmethod; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.ClientProxy; | ||
import io.quarkus.arc.test.ArcTestContainer; | ||
import java.io.IOException; | ||
import javax.annotation.PostConstruct; | ||
import javax.enterprise.context.ApplicationScoped; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class FinalMethodIgnoredTest { | ||
|
||
@RegisterExtension | ||
public ArcTestContainer container = new ArcTestContainer(Moo.class); | ||
|
||
@Test | ||
public void testProducer() throws IOException { | ||
Moo moo = Arc.container().instance(Moo.class).get(); | ||
assertTrue(moo instanceof ClientProxy); | ||
assertEquals(0, moo.getVal()); | ||
assertEquals(10, ((Moo) ((ClientProxy) moo).arc_contextualInstance()).val); | ||
} | ||
|
||
@ApplicationScoped | ||
static class Moo { | ||
|
||
private int val; | ||
|
||
@PostConstruct | ||
void init() { | ||
this.val = 10; | ||
} | ||
|
||
// will return 0 if invoked upon a client proxy | ||
final int getVal() { | ||
return val; | ||
} | ||
|
||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
...rc/test/java/io/quarkus/arc/test/interceptors/finalmethod/FinalInterceptedMethodTest.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,56 @@ | ||
package io.quarkus.arc.test.interceptors.finalmethod; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import io.quarkus.arc.test.ArcTestContainer; | ||
import io.quarkus.arc.test.interceptors.Simple; | ||
import javax.annotation.Priority; | ||
import javax.enterprise.inject.spi.DeploymentException; | ||
import javax.inject.Singleton; | ||
import javax.interceptor.AroundInvoke; | ||
import javax.interceptor.Interceptor; | ||
import javax.interceptor.InvocationContext; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class FinalInterceptedMethodTest { | ||
|
||
@RegisterExtension | ||
public ArcTestContainer container = ArcTestContainer.builder().beanClasses(Simple.class, SimpleBean.class, | ||
SimpleInterceptor.class).shouldFail().build(); | ||
|
||
@Test | ||
public void testFailure() { | ||
Throwable t = container.getFailure(); | ||
assertNotNull(t); | ||
assertTrue(t instanceof DeploymentException); | ||
assertTrue(t.getMessage().contains("foo")); | ||
assertTrue(t.getMessage().contains("bar")); | ||
} | ||
|
||
@Simple | ||
@Singleton | ||
static class SimpleBean { | ||
|
||
final String foo() { | ||
return "foo"; | ||
} | ||
|
||
final void bar() { | ||
} | ||
|
||
} | ||
|
||
@Simple | ||
@Priority(1) | ||
@Interceptor | ||
static class SimpleInterceptor { | ||
|
||
@AroundInvoke | ||
Object mySuperCoolAroundInvoke(InvocationContext ctx) throws Exception { | ||
return ctx.proceed(); | ||
} | ||
} | ||
|
||
} |