arquillian / arquillian-core

Arquillian provides a component model for integration tests, which includes dependency injection and container life cycle management. Instead of managing a runtime in your test, Arquillian brings your test to the runtime.
http://arquillian.org
Apache License 2.0
369 stars 194 forks source link

Failed to deploy if called in BeforeEach method in junit5 #543

Closed gaol closed 2 months ago

gaol commented 6 months ago
Issue Overview

JDK: 11 Maven: 3.8.6 arquillian: 1.8.0.Final junit: junit5

If deployer.deploy() method is called in BeforeEach method, it failed with:

java.lang.IllegalArgumentException: No deployment scenario in context
    at org.jboss.arquillian.container.test.impl.client.deployment.ClientDeployer.deploy(ClientDeployer.java:62)
    at org.jboss.test.ws.jaxws.cxf.jbws3655.EarSchemaImportTestCase.setup(EarSchemaImportTestCase.java:53)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:728)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.jboss.arquillian.junit5.ArquillianExtension.interceptBeforeEachMethod(ArquillianExtension.java:99)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)

The demo code is like:

   @ArquillianResource
   private Deployer deployer;

   @BeforeEach
   public void setup() throws Exception {
      deployer.deploy(EAR_DEPLOYMENT);
   }

   @Deployment(testable = false, name=EAR_DEPLOYMENT,managed=false)
   public static JavaArchive createDeployment() {
      return ShrinkWrap.create(JavaArchive.class, EAR_DEPLOYMENT);
  }

   @Test
   @RunAsClient
   public void testSchemaImport() {
       // this never called because deploy(EAR_DEPLOYMENT) failed.
  }

but move the deploy() method call to each Test method, all work fine.

petrberan commented 6 months ago

Also can be found here: https://issues.redhat.com/browse/ARQ-2231

Was looking into it but I'll need more time to investigate

petrberan commented 2 months ago

This issue has been fixed by a hotfix from @rhusar in https://github.com/arquillian/arquillian-core/pull/583 so I'm assigning this issue to him either to close it or to track further progress

rhusar commented 2 months ago

Thanks @petrberan, you are right, this should be resolved. Let's close and @gaol could you please report back (with 1.9.0.Final) if this was fixed for you completely? Thanks!

gaol commented 2 months ago

Thanks @rhusar and @petrberan , yes, 1.9.0.Final works for me. :+1: