Arquillian Warp and CDI in Inspection


#1

Hi currently I am developing a test and I want to use Arquillian Warp. Currently I am using Arquillian 1.1.7, latest Warp and Managed Apache TomEE 1.7.1. The test is as simple as:

@RunWith(Arquillian.class)
@WarpTest
public class RestUploadTest {
    
    @Deployment
    public static final WebArchive deployment() {
    	return ShrinkWrap
                .create(WebArchive.class)
                .addClasses(BoundedInputStream.class, IOUtil.class,
                    P12Resource.class, TemporaryFolder.class)
                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
                .addAsLibraries(
                    Maven.resolver().loadPomFromFile("pom.xml")
                        .resolve("org.glassfish:javax.json")
                        .withTransitivity().as(JavaArchive.class));
    }
   
    @ArquillianResource
    URL baseUrl;
    
    @Test
    @RunAsClient
    public void shouldUploadContent() {
	Warp.initiate(() -> {
  
            URI endpoint = UriBuilder.fromPath(baseUrl.toExternalForm())
                .path(P12Resource.class).path("chunkedUpload").build();
            given().request().body("This is a test file.".getBytes())
                .post(endpoint).then().assertThat()
                .body("uploadId", notNullValue()).and()
                .body("offset", notNullValue());

	}).inspect(new Inspection() {
                private static final long serialVersionUID = 1L;
    			
                @Inject
                TemporaryFolder temporaryFolder;
    			
                @AfterServlet
                public void assertCreatedFile() {
                    System.out.println(temporaryFolder.getRoot());
            }

	});
    
    }
    
}

The problem is that temporaryFolder is not injected and its value is null.
Note that TemporaryFolder is a class that I have developed and injected correctly on my business class (EJB).

Probably I am doing something wrong but I can’t see exactly what.


#2

I’m not 100% sure how this works for TomEE Managed, but for TomEE Embedded I believe they don’t rely on the normal CDI Enricher, but rather somewhere threat the whole TestClass as a Bean. If this behavior is done outside of the TestEnricher SPI in Core then this won’t be called when Warp tries to Enrich the Inspection.


#3

Thanks, yes with embedded I have had a lot of problems so I decided to go to managed/remote. I am going to ask to TomEE forum.


#4

Almost there, I receive this exception:

org.jboss.arquillian.warp.impl.client.execution.WarpSynchronizationException: The Warp failed to observe requests or match them with response.

There were no requests matched by observer [null]

If Warp enriched a wrong request, use observe(…) method to select appropriate request which should be enriched instead.
Otherwise check the server-side log and enable Arquillian debugging mode on both, test and server VM by passing -Darquillian.debug=true.

at org.jboss.arquillian.warp.impl.client.execution.SynchronizationPoint.awaitResponses(SynchronizationPoint.java:155)
at org.jboss.arquillian.warp.impl.client.execution.DefaultExecutionSynchronizer.waitForResponse(DefaultExecutionSynchronizer.java:60)
at 

Do you think it may me something related with TomEE? I mean do I need to set an observer as mandatory?


#5

We are running in an strange problem, same project with same pom and arquilian.xml works on Romain machine but not in mine. https://github.com/Scytl/restguide/tree/master/sources/rest-chunk

Can anyone test it in his computer? We suspect something related with snapshots but not sure.


#6

Hi alex, “works on my machine”.

C:\projetos\restguide\sources\rest-chunk>mvn -version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 12:22:22-0300)
Maven home: C:\apache-maven-3.1.1
Java version: 1.8.0_40, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_40\jre
Default locale: pt_BR, platform encoding: Cp1252
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "dos"
C:\projetos\restguide\sources\rest-chunk>mvn clean test

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.561s
[INFO] Finished at: Wed Mar 25 17:55:58 BRT 2015
[INFO] Final Memory: 33M/282M
[INFO] ------------------------------------------------------------------------

#7

Thank you so much, oh what’s happening on my machine :frowning: well doesn’t matter probably it is something related with maven.

Thanks for your time.
Alex.


#8

have you tried to run mvn -U clean package?


#9

Hi it was a problem with my company proxy :frowning: no worries :smile:


#10

Can we mark it as solved then? :slight_smile: