users@jersey.java.net

[Jersey] Re: Jersey 2.0 Test Question

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Fri, 24 Feb 2012 11:09:17 +0100

The things should work as described by Arul. Look at a pom.xml in any
of the new Jersey examples and make sure you have all the dependencies.
And if it still doesn't work, please open a Jira issue and attach your
project to it so that we can have a look.

Marek

On Fri 24 Feb 2012 06:39:31 AM CET, Jason Lee wrote:
> I actually do have that. :| Maybe things will make more sense in the morning. Give it another stare with fresh eyes.
> If that doesn't work, I'll try rebuilding the project step by step. It's a simple POC, so that won't be a big deal.
>
> On 2/23/12 6:10 PM, Arul Dhesiaseelan wrote:
>> I suspect you may be missing provider bundle. Did you include the test framework providers artifact in your POM?
>>
>> <dependency>
>> <groupId>org.glassfish.jersey.test-framework.providers</groupId>
>> <artifactId>jersey-test-framework-provider-bundle</artifactId>
>> <version>2.0-m01</version>
>> <type>pom</type>
>> <scope>test</scope>
>> </dependency>
>>
>> It looks like you need to add this artifact in addition to your test container. I used grizzly along with the above
>> artifact and it worked.
>>
>> -Arul
>>
>> On Thu, Feb 23, 2012 at 1:16 PM, Jason Lee <jason.d.lee_at_oracle.com <mailto:jason.d.lee_at_oracle.com>> wrote:
>>
>> I'm trying to migrate a very simple test to Jersey 2.0 and having a bit of a problem, namely, the test container
>> is not seeing my resource. Here's the resource source, more or less:
>>
>> @Path("foo")
>> public class MyResource {
>>
>> @GET
>> @Produces("text/plain")
>> public String argh() {
>> return "argh!";
>> }
>> // ...
>> }
>>
>> And here's my test:
>>
>> public class ServiceTest extends JerseyTest {
>> protected static final String MIME_TYPE = MediaType.APPLICATION_JSON;
>> @Override
>> protected Application configure() {
>> enable(TestProperties.LOG_TRAFFIC);
>> ResourceConfig resourceConfig = ResourceConfig.builder().addClasses(MyResource.class).build();
>>
>> return Application.builder(resourceConfig).build();
>> }
>> @Test
>> public void simpleTest() {
>> Response response = target().path("foo").request("text/plain").get();
>> assertEquals(200, response.getStatus());
>> }
>> }
>>
>> The request always returns a 404. I'm looking at examples/helloworld/.../HelloWorldTest.java, and as far as I
>> can tell, I'm doing exactly what it's doing (that test runs just fine), but my resource is never found.
>>
>> Any ideas what I might be doing wrong?
>>
>> --
>> Jason Lee
>> Senior Member of Technical Staff
>> GlassFish Team
>>
>> Oracle Corporation
>> Phone +1 405-216-3193 <tel:%2B1%20405-216-3193>
>> Blog http://blogs.steeplesoft.com
>>
>>
>>
>>
>> --
>> http://aruld.info
>> http://twitter.com/aruld
>>
>>
>
>
> --
> Jason Lee
> Senior Member of Technical Staff
> GlassFish Team
>
> Oracle Corporation
> Phone +1 405-216-3193
> Blog http://blogs.steeplesoft.com