Interesting approach, but i'm really looking for a way to do it without having to start up the server (in or out of process).
I may end up giving this a try failing something else. On Dec 23, 2009, at 4:23 PM, Sergey Beryozkin wrote: > Hi > > Here is the one possible approach : > http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/o > rg/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushSpringTest.java > > 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 : > > http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resour > ces/jaxrs_logging_atompush/WEB-INF/beans.xml > > 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 [mailto:[email protected]] > Sent: 23 December 2009 19:10 > To: [email protected] > Subject: Unit Tests for CXF JSON services > > Folks, > > 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: > > /services/getUser > > 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. > > Suggestions? > > --- > Nayan Hajratwala > http://agileshrugged.com > http://twitter.com/nhajratw > 734.658.6032 > >
