Hi
On 27/11/13 18:22, David Karlsen wrote:
Hi.

I´ve looked at
https://cwiki.apache.org/confluence/display/CXF20DOC/JAXRS+Testing#JAXRSTesting-LocalTransportfor
information on howto test JAX-RS services.

I´d like the LocalTransport approach (so I don´t have to configure TCP
ports etc), but I´d like to use springs test support (@ContextConfiguration
etc) and only add the LocalTransport configuration.

I´d also like to reuse the spring context file as it will look when
using/packaging it into a .war, which looks like:

   <jaxrs:server address="/v1">
         <jaxrs:serviceBeans>
             <ref bean="trackService" />
             <ref bean="blobService" />
         </jaxrs:serviceBeans>
         <jaxrs:providers>
             <bean
class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
             <ref bean="serviceExceptionMapper" />
         </jaxrs:providers>
         <jaxrs:properties>
             <entry key="mtom-enabled" value="true" />
         </jaxrs:properties>
     </jaxrs:server>

Is it possible to configure only the LocalTransport stuff in my test, and
inject the configured Server from the context file with spring?

The initialized server in this case will already HTTP Destination attached to it by default, so you can try to parameterize either the address or transportId attribute, for example, you'd have either

<jaxrs:server address="${prefix}/v1">

and default to "" and set to "local://" for tests

or

<jaxrs:server address="/v1" transportId=${transportId}>

default to "http://cxf.apache.org/transports/http"; and set to
"http://cxf.apache.org/transports/local"; for tests.

I've update the wiki to show how to create the clients in the latter case:
https://cwiki.apache.org/confluence/display/CXF20DOC/JAXRS+Testing
(see at the end)

HTH, Sergey


Reply via email to