users@jersey.java.net

Re: [Jersey] Filter not executing when running a JerseyTest

From: Pavel Bucek <Pavel.Bucek_at_Sun.COM>
Date: Wed, 28 Apr 2010 18:03:45 +0200

one additional note: maven 2.1.0+ does not correctly propagate
properties set via -D, so you need to use version 2.0.9 and prior.

Pavel


Pavel Bucek wrote:
>
> Hello Steve,
>
> unfortunately, you can't currently register servlet and filter class
> concurrently with jersey test framework (setting one will erase the
> other).
>
> What you can do is deploy your application on (for example) embedded
> glassfish and run your tests against it using support for external
> container. Command for executing tests will look like:
>
> jersey version 1.2+:
>
> mvn test
> -Djersey.test.containerFactory=com.sun.jersey.test.framework.spi.container.external.ExternalTestContainerFactory
> -Djersey.test.port=XXX -Djersey.test.host=XXX
>
> jersey version 1.1.5.1-:
>
> mvn test
> -Djersey.test.containerFactory=com.sun.jersey.test.framework.spi.container.external.ExternalTestContainerFactory
> -DJERSEY_HTTP_PORT=XXX -DJERSEY_HOST_NAME=XXX
>
> Regards,
> Pavel
>
>
>
> schong wrote:
>> Hello,
>> I’m having difficulties trying to execute a Filter using the Jersey
>> Test Framework.
>>
>> We’ve got a Maven Project called Customer Registration. This has two
>> modules. A REST module (produces a JAR) and a Web module (produces
>> WAR) .
>> The Web module has a dependency on the REST JAR.
>>
>> In the Web module we’ve got a Filter that is mapped to the Jersey
>> Servlet
>> (in the web.xml) so that any requests have to the Filter first.
>>
>> What I am trying to do is to run tests using a JerseyTest class
>> against the
>> Web module running on a GrizzlyWebServer. The theory is that any
>> requests to
>> our REST service will go to the Filter.
>>
>> My problem is that the GrizzlyWebServer starts up fine and the tests run
>> against it but the Filter is not executed.
>>
>> I ran separate JUnit tests (Apache HttpClient) against a Jetty
>> instance with
>> the same web module (using mvn jetty:run from the command line). The
>> Filter
>> is executed fine.
>>
>> I’d really like to have the tests running as part of my JerseyTest so
>> that
>> we can run the tests as part of our build process.
>>
>> Does anyone have any pointers or suggestions?
>> Thanks, Steve.
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>