|
From: andrew s. <and...@gm...> - 2013-10-21 14:16:57
|
hi, I'm using RestEasy 3.0.4.Final, with JBoss AS7.1.0, and trying to build an arquillian test following the approach described here: https://gist.github.com/w0mbat/6317015 The test runs, the rest service is called, a reasonable result returned but the test fails because of the getMediaType exception below. I get an exception when I try to return a POJO via a JSON object... but not when I just check the response code. Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 17.185 sec <<< FAILURE! testGetWebDoc(com.ams10961.rest.WebDocServiceRESTTest) Time elapsed: 2.394 sec <<< ERROR! java.lang.NoSuchMethodError: javax.ws.rs.core.Response.getMediaType()Ljavax/ws/rs/core/MediaType; at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(ClientInvocation.java:128) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:425) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.get(ClientInvocationBuilder.java:165) at com.ams10961.rest.WebDocServiceRESTTest.testGetWebDoc(WebDocServiceRESTTest.java:73) Any ideas what this could be? Thanks... Andrew I've tried later versions of the JBoss BOM (up to 1.0.7.FinaL), and other versions of RestEasy (3.0.0, 3.0.2) The Test @Test @RunAsClient public void testGetWebDoc(@ArquillianResource URL base) throws Exception { javax.ws.rs.client.Client client = ClientBuilder.newClient(); WebTarget restRoot = client.target(base.toURI() + "rest"); WebTarget webDocRestRoot = restRoot.path("/webdoc"); WebDoc response = webDocRestRoot .queryParam( "url", "http://news.bbc.co.uk") .request(MediaType.APPLICATION_JSON).get(WebDoc.class); client.close(); assertNotNull(response); } The Service @GET @Produces(MediaType.APPLICATION_JSON) public WebDoc fetch(@QueryParam("url") String url) { logger.info("url: >"+url+"<"); WebDoc webDoc = null; try { webDoc = webDocFetchService.fetchWebDoc(url); // persist the WebDoc webDocService.save(webDoc); return webDoc; } catch (WebDocFetchException e) { throw new WebApplicationException( Response.Status.INTERNAL_SERVER_ERROR); } catch (WebDocParseException e) { throw new WebApplicationException( Response.Status.INTERNAL_SERVER_ERROR); } } When I change the client to the following (i.e. just return a response)I get no exception Response response = restRoot .path("/webdoc") .queryParam( "url", "http://news.bbc.co.uk") .request(MediaType.APPLICATION_JSON) .get(); Some relevant highlights from the pom.xml file. <!-- Define the version of the JBoss BOMs we want to import. The JBoss BOMs specify tested stacks. --> <version.org.jboss.bom>1.0.4. Final</version.org.jboss.bom> <dependencyManagement> <dependencies> <dependency> <groupId>org.jboss.bom</groupId> <artifactId>jboss-javaee-6.0-with-tools</artifactId> <version>${version.org.jboss.bom}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.jboss.bom</groupId> <artifactId>jboss-javaee-6.0-with-hibernate</artifactId> <version>${version.org.jboss.bom}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependency> <groupId>org.jboss.spec.javax.ws.rs</groupId> <artifactId>jboss-jaxrs-api_1.1_spec</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-client</artifactId> <version>3.0.4.Final</version> </dependency> java version "1.6.0_27" OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.2) OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mod |