-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[312] Initial attempt to allow Arquillian to inject method parameters. #608
Conversation
...iner/src/main/java/org/jboss/arquillian/junit5/container/JUnitJupiterDeploymentAppender.java
Outdated
Show resolved
Hide resolved
junit5/core/src/main/java/org/jboss/arquillian/junit5/ArquillianExtension.java
Outdated
Show resolved
Hide resolved
06053d0
to
d320658
Compare
d4249a9
to
d5402a1
Compare
I've moved this back to a draft as there is an issue. The issues is we need to ensure we get the correct parameters for a |
…ters. The parameters are resolved from TestEnrichers. Signed-off-by: James R. Perkins <jperkins@redhat.com>
It looks like the java.lang.RuntimeException: All Providers for type interface javax.naming.Context returned a null value: [org.jboss.arquillian.container.test.impl.enricher.resource.InitialContextProvider@5792c08c]
at org.jboss.arquillian.test.impl.enricher.resource.ArquillianResourceTestEnricher.lookup(ArquillianResourceTestEnricher.java:126)
at org.jboss.arquillian.test.impl.enricher.resource.ArquillianResourceTestEnricher.resolve(ArquillianResourceTestEnricher.java:99)
at org.jboss.arquillian.junit5.MethodParameterObserver.injectParameters(MethodParameterObserver.java:67)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:90)
at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:128)
at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createBeforeContext(ContainerEventController.java:114)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:116)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:83)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:69)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:106)
at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.before(EventTestRunnerAdaptor.java:115)
at org.jboss.arquillian.junit5.ArquillianExtension.beforeEach(ArquillianExtension.java:63)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) |
Yeah, I'm going to have a look at that now. It's interesting it passes in WildFly, but not Payara. I'll look to see if they override the |
Maybe we should just ignore this test on Payara TBH. In Wildfly the context is initialized in the I don't really see this as a huge deal because there are much better ways to lookup objects these days without the |
…ara. There is an issue with where/when the InitialContext producer is initialized for JUnit 5 ParameterResolvers. Signed-off-by: James R. Perkins <jperkins@redhat.com>
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.PARAMETER) | ||
public @interface Vetoed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about DelegateToJunit, JunitParam or something that indicates it is relying on a Junit ParameterResolver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not a bad idea. Just a way to say "don't let Arquillian attempt to resolve this". I think that makes a lot of sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filed #610 as a follow for this.
Short description of what this resolves:
Allows method parameters which are provided by Arquillian to be injected. The parameters are resolved from
TestEnricher
's.Note that for in-container tests, a
ParameterResolver
outside of Arquillian does not work. In other words, you can't inject a method parameter like@TempDir final Path path
because two resolvers will be found. One being the real resolver, the other being theArquillianExtension
. This seems to be due to the fact that the parameter resolver is executed twice for in-container tests. Once for invoking the test from client and once executing in the container itself.To work around the above, I created a
@Vetoed
annotation which can be set on those parameters to allow Arquillian to ignore them. Note I don't know if using the same name as the CDI annotation is good or not, but I couldn't think of a better name :)Changes proposed in this pull request:
ParameterResolver
for resolved method parameters which Arquillian can provide. For example a@ArquillianResource URI uri
.Fixes #312