Hi Sergey, thanks for the response. It seems it had to do something with the way how I setup the server.
When using RuntimeDelegate delegate = RuntimeDelegate.getInstance(); JAXRSServerFactoryBean sf = delegate.createEndpoint(new HippoWebServicesApplication(), JAXRSServerFactoryBean.class); it does seem to work. Thanks so far. Jeroen On Mon, Mar 3, 2014 at 11:22 PM, Sergey Beryozkin <[email protected]>wrote: > Hi > > I'm not sure right now, may be 2.6.x specific. > Can you please giev a try with CXF 2.7.10, I can check 2.6.14-SNAPSHOT > tomorrow > > Thanks, Sergey > > On 03/03/14 21:38, Jeroen Reijn wrote: > >> Hi all, >> >> today I was trying to create tests my JAX-RS services created with CXF >> 2.6.13. I wanted to use the local transport mechanism for this, but it >> seems I'm running into issues I can't really explain. >> >> I created a new test class based on the local transport example provided >> by >> the wiki[1] >> >> In essence what I do is create a server: >> >> private static void startServer() throws Exception { >> List<Object> providers = new ArrayList<Object>(); >> providers.add(JacksonJaxbJsonProvider.class); >> >> JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); >> sf.setResourceClasses(SystemResource.class); >> sf.setProviders(providers); >> sf.setAddress(ENDPOINT_ADDRESS); >> sf.getInInterceptors().add(new LoggingInInterceptor()); >> sf.getOutInterceptors().add(new LoggingOutInterceptor()); >> >> server = sf.create(); >> } >> >> >> Where I specify the JacksonJaxbJsonProvider as an additional provider. >> >> Now in my actual test I try to use the WebClient like this: >> >> @Test >> public void testGetSystemInfo() { >> WebClient client = WebClient.create(ENDPOINT_ADDRESS); >> >> client.accept(MediaType.APPLICATION_JSON).type( >> MediaType.APPLICATION_JSON); >> >> WebClient.getConfig(client).getRequestContext().put( >> LocalConduit.DIRECT_DISPATCH, >> Boolean.TRUE); >> final Response response = client >> .path("v1/system/jvm") >> .accept(MediaType.APPLICATION_JSON) >> .type(MediaType.APPLICATION_JSON) >> .get(Response.class); >> >> assertTrue(response.getStatus() == Response.Status.OK. >> getStatusCode()); >> } >> >> So far so good. >> >> Now when I try this test it fails, with the message: >> >> "No message body writer has been found for response class LinkedHashMap". >> Somehow it seems not to map to my JacksonJaxbJsonProvider.class, which >> does >> work when doing this via the browser. >> >> While debugging the problem a bit I noticed that when I run from my >> browser >> I get the following debug statements: >> >> 03.03.2014 20:49:19 DEBUG http-8080-1 >> [JAXRSInInterceptor.processRequest:228] Request path is: /v1/system/jvm >> 03.03.2014 20:49:19 DEBUG http-8080-1 >> [JAXRSInInterceptor.processRequest:229] Request HTTP method is: GET >> 03.03.2014 20:49:19 DEBUG http-8080-1 >> [JAXRSInInterceptor.processRequest:230] Request contentType is: */* >> 03.03.2014 20:49:19 DEBUG http-8080-1 >> [JAXRSInInterceptor.processRequest:231] Accept contentType is: >> application/json >> 03.03.2014 20:49:19 DEBUG http-8080-1 >> [JAXRSInInterceptor.processRequest:233] Found operation: getMemoryInfo >> Now if I run this with the local transport I get the following output. >> >> 03.03.2014 22:20:46 DEBUG main [JAXRSInInterceptor.processRequest:231] >> Request path is: /v1/system/jvm >> 03.03.2014 22:20:46 DEBUG main [JAXRSInInterceptor.processRequest:232] >> Request HTTP method is: GET >> 03.03.2014 22:20:46 DEBUG main [JAXRSInInterceptor.processRequest:233] >> Request contentType is: application/json >> 03.03.2014 22:20:46 DEBUG main [JAXRSInInterceptor.processRequest:234] >> Accept contentType is: null >> 03.03.2014 22:20:46 DEBUG main [JAXRSInInterceptor.processRequest:236] >> Found operation: getMemoryInfo >> >> It seems there is something wrong with the Accept contentType somehow. >> >> Does somebody have any clues or pointers into which direction I should >> take >> a look? >> >> [1]https://cwiki.apache.org/confluence/display/CXF20DOC/JAXRS+Testing >> >> > > -- > Sergey Beryozkin > > Talend Community Coders > http://coders.talend.com/ > > Blog: http://sberyozkin.blogspot.com > -- Jeroen Reijn Hippo Amsterdam - Oosteinde 11, 1017 WT Amsterdam Boston - 101 Main Street, Cambridge, MA 02142 US +1 877 414 4776 (toll free) Europe +31(0)20 522 4466 www.onehippo.com http://about.me/jeroenreijn
