1 Reply Latest reply on Dec 6, 2017 9:52 AM by med.amd

    Arquillian read test file at runtime

    med.amd

      Hi,

      I would like to read a test file and send it on a JMS queue within a test methode.

      I used the solution described here to add files to the war test. But when I try to read file in the test methode I get FileNotFoundException.

       

      File file = new File("fileName");

       

      What is the path used to retreive files?

      As a workaround I'm using addAsWebInfResource in the deployment creation method : .addAsWebInfResource("src/main/webapp/fileName","classes/fileName") And InputStream stream = getClass().getResourceAsStream("/fileName"); in the test method to retreive file.

        • 1. Re: Arquillian read test file at runtime
          med.amd

          Update :

          The workaround works intermittently :

          I get randomly this error :

           

          Caused by: java.lang.reflect.InvocationTargetException

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

              at java.lang.reflect.Method.invoke(Method.java:606)

              at org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDeploymentScenarioGenerator.invoke(AnnotationDeploymentScenarioGenerator.java:156)

          java.lang.IllegalArgumentException: src/main/webapp/fileName not found in classloader sun.misc.Launcher$AppClassLoader@46c6c084

          at org.jboss.shrinkwrap.api.asset.ClassLoaderAsset.<init>(ClassLoaderAsset.java:70)

              at org.jboss.shrinkwrap.api.asset.ClassLoaderAsset.<init>(ClassLoaderAsset.java:45)

              at org.jboss.shrinkwrap.impl.base.container.WebContainerBase.addAsWebInfResource(WebContainerBase.java:380)

              at com.vermeg.arq.AgoraArquillianTest.createTestDeployment(AgoraArquillianTest.java:39)