users@jersey.java.net

[Jersey] Re: Jersey Test Framework

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Tue, 09 Aug 2011 10:31:21 +0200

Hello Robert,

seems like you are trying to use Grizzly 2.x and you have declared
incorrect dependencies..

you should use jersey-test-framework-grizzly2:

        <dependency>
             <groupId>com.sun.jersey.jersey-test-framework</groupId>
             <artifactId>*jersey-test-framework-grizzly2*</artifactId>
             <version>${jersey.version}</version>
             <scope>test</scope>
         </dependency>

and you can get rid of the other dependency (grizzly2 is already
included and there is no need to declare it twice). And if you need it
in your runtime, you should depend on jersey-grizzly2 module (this way
you will be sure that all versions are compatible).

You could want to look at our samples, almost all of them are using test
framework so you should be able to extract working configuration from
there.. see http://download.java.net/maven/2/com/sun/jersey/samples/

Hope it helps.

Regards,
Pavel

On 8/9/11 8:18 AM, Robert Naczinski wrote:
> Hello,
>
> I try to use Jersey-testing framework. It's really cool. My pom.xml has:
> ..
> <dependency>
> <groupId>com.sun.jersey.jersey-test-framework</groupId>
> <artifactId>jersey-test-framework-grizzly</artifactId>
> <version>${jersey.version}</version>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>com.sun.grizzly</groupId>
> <artifactId>grizzly-servlet-webserver</artifactId>
> <version>1.9.8</version>
> </dependency>
> ...
>
> Unfortunately I get when starting the test
> java.lang.NoClassDefFoundError: org.glassfish.grizzly.Grizzly
>
> What am I doing wrong?
>
> My code is:
>
> import org.junit.Test;
>
> import com.sun.jersey.api.client.WebResource;
> import com.sun.jersey.test.framework.JerseyTest;
> import com.sun.jersey.test.framework.spi.container.TestContainerException;
>
> import static org.junit.Assert.*;
>
> public class TestPropertyResource extends JerseyTest {
>
> public TestPropertyResource() throws TestContainerException {
> super("bla.resources.properties");
> }
>
> @Test
> public void testHelloWorld() {
> WebResource webResource = resource();
> String uri =
> "services/property/beispielanwendung.properties?propertyName=property";
> String responseMsg = webResource.path(uri).get(String.class);
> assertEquals("Hello World", responseMsg);
> }
> }
>
>
> Can someone give me a tip.
>
> Robert
>