Amit Patel
Amit Patel

Reputation: 15985

JAX-RS with Jersey: Testing REST service deployed in weblogic/JBoss

I am trying to test a REST service using Jersey Test Framework with maven. When I run tests with mvn test, it runs them on Grizzly Web Server and gives lots of ClassNotFoundException. The service internally calls EJB and other SOAP services. I am able to resolve few by adding dependency in pom.xml but I feel it is very cumbersome task to resolve dependencies.

If I deploy the service in weblogic and test it with SoapUI, it works fine. No ClassNotFoundException found. Wouldn't it be possible to test the rest API which I used to deploy in weblogic?

I would very appreciate if someone help me to workout.

Thanks, Amit Patel

Upvotes: 0

Views: 1739

Answers (1)

Pavel Bucek
Pavel Bucek

Reputation: 5324

Yes, it is possible - you can use ExternalTestContainer and point it to url where is your app deployed.

You'll need to add dependency:

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

and run your tests like:

mvn test -Djersey.test.containerFactory=com.sun.jersey.test.framework.spi.container.external.ExternalTestContainerFactory -Djersey.test.host=$appBaseUri -Djersey.test.port=$appPort

you can omit "jersey.test.containerFactory" settings if this is only test framework module declared in your pom.

Upvotes: 3

Related Questions