Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ArquillianResteasyResource as class attribute #13

Open
lordofthejars opened this issue Jan 7, 2014 · 5 comments
Open

@ArquillianResteasyResource as class attribute #13

lordofthejars opened this issue Jan 7, 2014 · 5 comments

Comments

@lordofthejars
Copy link
Member

@ArquillianResteasyResource annotation is used as method parameter, for example:

@Test
 public void getCustomerById(@ArquillianResteasyResource CustomerResource customerResource)

but in some cases (in my case for integration with cukes on space), it will be useful if we could use @ArquillianResteasyResource as attribute of a class like @ArquillianResource does. Something like:

@ArquillianResteasyResource CustomerResource customerResource

@Test
public void getCustomerById() {}

Currently a NullPointerException is thrown.

@blabno
Copy link
Member

blabno commented Jan 8, 2014

@lordofthejars Thank you for reporting this. Initially I wanted to be able to override resource settings with annotations placed over test method. I'll inspect if there were other obstacles.

What I see that might be problem now is that in single test class we can have several deployments, each test operating on different one. @aslakknutsen is it possible to do injection before each test? Would we know which test method is going to be used so that we would know which deployment we will operate against?

@aslakknutsen
Copy link
Member

@blabno I don't think you have to worry about that. Arquillian Core will activate the correct Deployment context based on the usage of @OperatesOnDeployment on the Test method. What ever is in that context is what you should rely on.

The only time you need to hassle with this is if you want to support cross context/dual injections, where you support @OperatesOnDeployment on the @ArquillianResteasyResource.

If you use @ArquillianResource with some form of Qualifier, you can rely on the OperatesOnDeploymentAwareProvider class to handle the Context switching, if not you'll have to replicate some of the logic in here; https://github.com/arquillian/arquillian-core/blob/master/container/test-impl-base/src/main/java/org/jboss/arquillian/container/test/impl/enricher/resource/OperatesOnDeploymentAwareProvider.java#L69

@blabno
Copy link
Member

blabno commented Jan 8, 2014

@lordofthejars With #14 you reminded me why we allowed @ArquillianResteasyResource only for method params. It's because rest client resources are created using RestEasy Client library and since you might not have that in your server you should mark test as @RunAsClient. But in same test class you might have tests that you want to run NOT in @RunAsClient mode and if you had @ArquillianResteasyResource on anything different than method param then CNFE would be thrown. Let me inspect this later today.

@aslakknutsen
Copy link
Member

@blabno We could support a Dummy impl for use with the InContainer mode that just injects a Empty Proxy which throws an Exception stating something like: Can only be used on client side..

Depending on what you deploy/proxy, you might still get a CNFE, but at least it won't be because something the Extension is missing.

@lordofthejars
Copy link
Member Author

I like the idea of Aslak. The truth is that the reason why it is only supported as method param has sense, but I think that we could relax a bit so can be used in different places too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants