cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <>
Subject RE: Unit Tests for CXF JSON services
Date Wed, 23 Dec 2009 21:23:07 GMT

Here is the one possible approach :

Typically a test server is launched in another process, but Andy was not
keen on it :-) so he embedded an actual resource class inside
JAXRSLoggingAtomPushSpringTest but I was happy to follow by adding more
resources inside too...
You can use WebClient to test these embedded resources, the
corresponding spring config is here :

see jaxrs:server there.

I'm about to sign off but I'll be happy to provide more info later on
Cheers, Sergey 

-----Original Message-----
From: Nayan Hajratwala [] 
Sent: 23 December 2009 19:10
Subject: Unit Tests for CXF JSON services


I am trying (without much success) to write a unit test against a CXF
service. Note that by Unit Test, I mean no starting up a "dummy" web
server, no network access, etc. I will be using mocks for these parts.

Essentially what I want to do is this:

1) Set up a JSON request, for simplicity:

{ "userId":1 }

2) Invoke the CXF service with that request to:

During this step, i'll be injecting mocks into the service, so it will
always return "Joe Schmoe"

3) Assert that the response comes back in the JSON format of:

{ getUserResponse: { "firstName":"Joe", "lastName":"Schmoe" } }

My problem is that outside of a deployed/running web instance, i'm not
sure how to get step 2 to take in JSON and return JSON.


Nayan Hajratwala

View raw message