JerseyTest 2.4 and url-pattern
(too old to reply)
Eric Stein
2014-04-23 19:08:15 UTC
Thanks, Paul. I had to put this project on the back burner for a bit, but yes, I think that should work.


From: Paul O'Fallon [mailto:***@ofallonfamily.com]
Sent: Tuesday, April 15, 2014 5:03 PM
To: ***@jersey.java.net
Subject: [Jersey] Re: JerseyTest 2.4 and url-pattern

Hello! In your Jersey Test, do you have a configure() method defined? Can you create a ResourceConfig there and use the "packages" method to specify the package for the resources you want to test?

- Paul

On Tue, Apr 15, 2014 at 9:33 AM, Eric Stein <***@locustec.com<mailto:***@locustec.com>> wrote:
Hm, maybe I should be more clear. I've got a single .jar file containing two packages, .rest.view and .rest.data. Each of them is a separate API. In my web application, I have two servlets, each of which has the url-pattern set to recognize one of those packages. I have integration test suites for both packages. In the past, there wasn't an issue, because all the endpoints were distinct. Now I need the same endpoint in both APIs. That's causing JerseyTest to throw the following exception:

org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by @Consumes and @Produces annotations at Java methods
public Foo com.locustec.view.ViewAPIClass.getX(int,int)
public Bar com.locustec. data.DataAPIClass.getY(int,int,java.lang.String)
at matching regular expression /([^/]+?). These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='***@553abee1']

When I run the webapp, there's no problem getting to the correct resource, because I configured the servlets in web.xml to include the path /data or /view. How do I correctly set up JerseyTest to run the two APIs?


-----Original Message-----
From: Eric Stein
Sent: Tuesday, April 15, 2014 9:00 AM
To: ***@jersey.java.net<mailto:***@jersey.java.net>
Subject: JerseyTest 2.4 and url-pattern

How do I set the url-pattern for an instance of a JerseyTest? I'm running two APIs in the same project, and they share an endpoint. That's blowing up my JerseyTest suite because it doesn't recognize it should be configured as two applications.