Hi The method name of JAXRSServerFactoryBean.setResourceProvider is a bit misleading, but this is how it was named from the start...There're two methods, setProvider(Object) and setProviders(List) which can take the JAXRS providers (body readers, writers, exception mappers, etc). If say JacksonProvider is both a reader and writer then it is still sufficient to register it in a test setup only once, and internally it will be checked and registered as needed...
I have also created https://issues.apache.org/jira/browse/CXF-2607 cheers, Sergey -----Original Message----- From: KARR, DAVID (ATTCINW) [mailto:dk0...@att.com] Sent: Thu 1/7/2010 4:12 PM To: users@cxf.apache.org Subject: Using JAXRSServerFactoryBean for CXF-based unit tests I'm starting to set up the infrastructure so I can write tests that test the URL that I send to a controller and then the XML or JSON response that I get (mostly to test mocked exception handling). I'm using the information I got from <http://aruld.info/cxf-22-in-action-services-design-simplified/> for the basic setup. I'm finding that I'm not certain how to translate the easy Spring configuration into explicit API calls. For instance, here is my Spring jaxrs:server configuration: ----------------- <jaxrs:server name="dynamicContentServer" address="/rest"> <jaxrs:features> <cxf:logging/> </jaxrs:features> <jaxrs:providers> <ref bean="jacksonJsonProvider"/> </jaxrs:providers> <jaxrs:serviceBeans> <ref bean="catalogContent"/> <ref bean="priceListContent"/> <ref bean="marketDataContent"/> </jaxrs:serviceBeans> </jaxrs:server> ----------------- What I have so far in my @BeforeClass method is the following: --------------- JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); CatalogContentController catalogContentController = new CatalogContentController(); sf.setServiceBeans(catalogContentController); sf.getInInterceptors().add(new LoggingInInterceptor()); sf.getOutInterceptors().add(new LoggingOutInterceptor()); --------------- I've only added one of the service beans, but that's ok for now. The following is the "template" that I'm using, from the aforementioned example site: ------------------------- JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(Blogger.class); sf.getInInterceptors().add(new LoggingInInterceptor()); sf.getOutInterceptors().add(new LoggingOutInterceptor()); sf.setResourceProvider(Blogger.class, new SingletonResourceProvider(new BloggerImpl())); sf.setAddress("http://localhost:9000/rest/blog"); Map<Object, Object> mappings = new HashMap<Object, Object>(); mappings.put("xml", "application/xml"); mappings.put("json", "application/json"); sf.setExtensionMappings(mappings); sf.create(); --------------------- I'm now trying to figure out how to set the ResourceProvider. I see that it's not as simple as creating the JacksonJsonProvider and putting it in, as that isn't a "ResourceProvider". In the example, they're using the same class as a resource class and a resource provider, so I don't know how to interpret that.