Apologies you are right I just tried removing it and don't need it! Makes things even simpler!
Many thanks and sorry for confusing! Sent from a mobile device > On 1 Dec 2013, at 17:37, Andrei Shakirin <[email protected]> wrote: > > Just out of curiosity: do you really need to define LocalTransportFactory > bean? > Doesn't that work for you just with configurable local address "local://abcd > " or do you have some special reason to redefine LocalTransportFactory? > > Regards, > Andrei. > >> -----Original Message----- >> From: Mandy Warren [mailto:[email protected]] >> Sent: Samstag, 30. November 2013 20:14 >> To: [email protected] >> Subject: Re: LocalTransport for integration testing >> >> Just adding a few more comments as we have exactly this setup with our >> projects. We're using Maven and have a spring file (main- >> applicationContext.xml)under src/main/resources defining the jaxrs bean >> with the property placeholder as Sergey has specified. This references a >> properties file with the actual address defined. >> >> We've then got another Spring file (IntegrationTestsAppContext.xml) under >> src/integrationtest/resources which also has a property placeholder, pointing >> to another properties file with the local: address specified. This Spring >> file >> imports the main Spring file (so we get all the jaxrs bean detail): >> >> <import >> resource="classpath:conf/spring/main-applicationContext.xml" /> >> >> and specifies this bean to enable local transport (we don't want this for >> live >> hence defining it in the integration test spring config). >> >> <bean class="org.apache.cxf.transport.local.LocalTransportFactory" >> lazy-init="false"> >> <property name="transportIds"> >> <list> >> <value>http://cxf.apache.org/transports/local</value> >> </list> >> </property> >> </bean> >> >> We then run our tests as follows:- >> >> @RunWith(SpringJUnit4ClassRunner.class) >> @ContextConfiguration({ >> "classpath:conf/spring/IntegrationTestsAppContext.xml" }) >> @DirtiesContext(classMode = >> DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) >> public class MyIntegrationTests { >> // Must match the overridden local endpoint.address >> private final static String ENDPOINT_ADDRESS = "local://abcd"; >> >> @Test >> public void testStuff() throwsException { >> WebClient client = WebClient.create(ENDPOINT_ADDRESS); >> WebClient.getConfig(client).getRequestContext() >> .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE); >> >> Response response = client >> .path("v1/some/path/to/your/service") >> .type(MediaType.APPLICATION_XML) >> .accept(MediaType.APPLICATION_XML) >> .matrix("date", "2013-11-30") >> .get(Response.class); >> >> // do some asserts on the response >> >> } >> >> CXF makes it very nice and easy! >> >> Hope this helps >> >> Mandy >> >> Sent from a mobile device >> >>>> On 28 Nov 2013, at 10:59, Sergey Beryozkin <[email protected]> >>> wrote: >>> >>> Hi >>>> On 27/11/13 18:22, David Karlsen wrote: >>>> Hi. >>>> >>>> I´ve looked at >> https://cwiki.apache.org/confluence/display/CXF20DOC/JAXRS+Testing#JA >>>> XRSTesting-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 >>> >>>
