Skip to content

OperateOnDeployment annotation causes method parameter injection to fail #810

@robertpatrick

Description

@robertpatrick

We are porting https://github.com/arquillian/arquillian-container-wls to work with modern versions of WebLogic Server 15.1.x so that we can run the Jakarta EE 11 TCKs. We have been stuck with a failing test class that looks like the attached file.

WebLogicMultipleDeploymentsTest.java

Both tests in this file fail with:

[ERROR] org.jboss.arquillian.container.wls.managed_15_1_x.WebLogicMultipleDeploymentsTest.assertFirstWarDeployed(URL) -- Time elapsed: 0.001 s <<< ERROR!
java.lang.RuntimeException: All Providers for type class java.net.URL returned a null value: [org.jboss.arquillian.container.test.impl.enricher.resource.URLResourceProvider@233352da]
	at org.jboss.arquillian.test.impl.enricher.resource.ArquillianResourceTestEnricher.lookup(ArquillianResourceTestEnricher.java:125)
	at org.jboss.arquillian.test.impl.enricher.resource.ArquillianResourceTestEnricher.resolve(ArquillianResourceTestEnricher.java:98)
	at org.jboss.arquillian.junit5.MethodParameterObserver.injectParameters(MethodParameterObserver.java:93)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:85)
	at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:102)
	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:89)
	at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:115)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:85)
	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:94)
	at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:82)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:85)
	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:94)
	at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:68)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:85)
	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:94)
	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:133)
	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:105)
	at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.fireCustomLifecycle(EventTestRunnerAdaptor.java:158)
	at org.jboss.arquillian.junit5.ArquillianExtension.beforeTestExecution(ArquillianExtension.java:116)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

If we switch the comments in the file to use member variable injection, the tests pass. We have spent a considerable amount of time analyzing why the tests using both @OperateOnDeployment with method argument injection of the URL always fail--even though the ProtocolMetadata contains the correct information. One of our engineers spent several days digging into this came to the following conclusion:

I've spent enough time debugging and believe I understand that it's an issue with Arquillian and there isn't anything (that i can think of) to resolve it in the test. For resolving @ArquillianResource annotation for URL types,  Arquillian gets ProtocolMetaData information from the deployment context.

  • For single deployments, The deployment context is always set on the thread for each test execution.
  • For multiple deployments, Arqullian sets the deployment context (based on the @OperateOnDeployment annotation) on the thread but only for @ArquillianResource annotation for URL’s declared as class fields.  This is why the class fields declaration always works and has the appropriate context path for each deployment. Arquillian is not setting the deployment context on the thread for @ArquillianResource URL declared as method parameters, hence the URL isn’t resolved because it can’t find the any ProtocolMetaData.

Looks like we can only use the member variable declaration of @ArquillianResource URL  for the multiple deployment tests due to what appears to be an Arquillian bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions