<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technotrance, Illusions and Perspectives &#187; apache-cxf</title>
	<atom:link href="http://myblog.shriharisc.com/tag/apache-cxf/feed/" rel="self" type="application/rss+xml" />
	<link>http://myblog.shriharisc.com</link>
	<description>A dose of everyday bruises with Java/JEE</description>
	<lastBuildDate>Mon, 02 Aug 2010 17:45:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Unit testing CXF webservice endpoints using Spring-Test and TestNG</title>
		<link>http://myblog.shriharisc.com/2009/10/09/unit-testing-cxf-webservice-endpoints-using-spring-test-and-testng/</link>
		<comments>http://myblog.shriharisc.com/2009/10/09/unit-testing-cxf-webservice-endpoints-using-spring-test-and-testng/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 16:05:44 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[jee-light]]></category>
		<category><![CDATA[apache-cxf]]></category>
		<category><![CDATA[spring-test]]></category>
		<category><![CDATA[testng]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=127</guid>
		<description><![CDATA[The Spring IOC feature of configurational wiring of POJOs to control and achieve network of business logic frees developers of writing any boilerplate code and eventually of bugs. I would like to explain one such facility with regard to establishing an unit testing infrastructure for writing unit test cases for JAXWS specific web service endpoints [...]]]></description>
			<content:encoded><![CDATA[<p>The Spring IOC feature of configurational wiring of POJOs to control and achieve network of business logic frees developers of writing any boilerplate code and eventually of bugs. I would like to explain one such facility with regard to establishing an unit testing infrastructure for writing unit test cases for JAXWS specific web service endpoints (CXF) using Spring-test module and TestNG unit testing framework.</p>
<p>Lets take a simple example of a web service endpoint exposing a functionality to query a book price, given the ISBN number, given a maven project. This write-up just concentrates on establishing a web service unit testing framework. Following are sequence of steps one could follow to achieve the required infrastructure setup.</p>
<p>1) Change ${basedir}/pom.xml include adding spring-test dependency, and TestNG dependency, with maven-surefire-plugin configuration (assuming CXF dependencies are already present)</p>
<pre class="brush: xml">
&lt;dependency&gt;
 &lt;groupId&gt;org.springframework&lt;/groupId&gt;
 &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
 &lt;version&gt;2.5.6&lt;/version&gt;
 &lt;/dependency&gt;
&lt;dependency&gt;
 &lt;groupId&gt;org.testng&lt;/groupId&gt;
 &lt;artifactId&gt;testng&lt;/artifactId&gt;
 &lt;version&gt;5.9&lt;/version&gt;
 &lt;classfier&gt;jdk15&lt;/classifier&gt;
 &lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
</pre>
<p>2) Add a Spring configuration file (service-test.xml) under ${basedir}/src/test/resources. The CXF&#8217;s JaxWSProxyFactoryBean can be wired to to create a service proxy. Below is the snippet of the configuration file.</p>
<pre class="brush: xml">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xmlns:cxf=&quot;http://cxf.apache.org/core&quot;
xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                    http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd&quot;&gt;&lt;/span&gt;&lt;/pre&gt;
    &lt;import resource=&quot;classpath:META-INF/cxf/cxf.xml&quot; /&gt;
     &lt;import resource=&quot;classpath:META-INF/cxf/cxf-extension-soap.xml&quot; /&gt;
     &lt;import resource=&quot;classpath:META-INF/cxf/cxf-extension-http.xml&quot; /&gt;

     &lt;!-- Required to load the service endpoint uris --&gt;
     &lt;bean id=&quot;propConfig&quot; class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;&gt;
         &lt;property name=&quot;locations&quot;&gt;
            &lt;list&gt;
               &lt;value&gt;classpath:service-test.properties&lt;/value&gt;
             &lt;/list&gt;
         &lt;/property&gt;
     &lt;/bean&gt;

     &lt;bean id=&quot;proxyFactory&quot; class=&quot;org.apache.cxf.jaxws.JaxWsProxyFactoryBean&quot;&gt;
         &lt;property name=&quot;serviceClass&quot; value=&quot;com.schtech.service.endpoint.store.BookPriceService&quot;/&gt;
         &lt;property name=&quot;address&quot; value=&quot;${bookstore.service.endpoint.url}&quot;/&gt;
         &lt;property name=&quot;bus&quot; ref=&quot;cxf&quot; /&gt;
    &lt;/bean&gt;

     &lt;bean id=&quot;serviceClient&quot; class=&quot;com.schtech.service.endpoint.store.BookPriceService&quot; factory-bean=&quot;proxyFactory&quot;
        factory-method=&quot;create&quot;/&gt;
&lt;/beans&gt;
</pre>
<p>3) Implement the TestNG test case to test web service. Here three things have to be noted: (1) ContextConfiguration annotation helps us load<br />
the configuration file. (2) The test case extends AbstractTestNGSpringContextTests to load the context configuration and autowire the service<br />
bean. (3) Autowire annotation on the service endpoint interface initializes with proxy factory created service proxy instance.</p>
<pre class="brush: java">
@ContextConfiguration(locations = {&quot;classpath:service-context.xml&quot;})
public class BookCatalogTest extends AbstractTestNGSpringContextTests
 { @Autowired
   private BookPriceService serviceClient;

   @Test
   public void testBookPrice()
   { String isbn = &quot;978-3-16-148410-0,&quot;;
     Double price  = serviceClient.findBookPrice(isbn);
     assertNotNull(price);
   }
}
</pre>
<p>The infrastructure is ready to be used to test other service endpoints hosted elsewhere. Running mvn test at the ${basedir} prompt would unit test the service endpoints.</p>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/10/09/unit-testing-cxf-webservice-endpoints-using-spring-test-and-testng/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chaining Apache CXF, JackRabbit using SpringModules</title>
		<link>http://myblog.shriharisc.com/2009/09/11/chaining-apache-cxf-jackrabbit-using-springmodules/</link>
		<comments>http://myblog.shriharisc.com/2009/09/11/chaining-apache-cxf-jackrabbit-using-springmodules/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 17:54:52 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[jee-light]]></category>
		<category><![CDATA[apache-cxf]]></category>
		<category><![CDATA[apache-jackrabbit]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[springmodules]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=103</guid>
		<description><![CDATA[Apache CXF integration with Spring and SpringModules support for Apache JackRabbit provides a nice combination for chaining command of actions to be delegated across layers of the enterprise application tiers . Here is a quick tip as how to do this. A more detailed tutorial has been hosted at http://bit.ly/TmmJx
1) Web application configuration (/WEB-INF/web.xml) snippet [...]]]></description>
			<content:encoded><![CDATA[<p>Apache CXF integration with Spring and SpringModules support for Apache JackRabbit provides a nice combination for chaining command of actions to be delegated across layers of the enterprise application tiers . Here is a quick tip as how to do this. A more detailed tutorial has been hosted at <a rel="http://bit.ly/plugins/iframe?hashUrl=http%3A%2F%2Fbit.ly%2FTmmJx" href="http://bit.ly/TmmJx" target="_blank">http://bit.ly/TmmJx</a></p>
<p>1) Web application configuration (/WEB-INF/web.xml) snippet (as specified below) loads Apache CXF configuration (classpath:cxf.xml) and delegates to CXF container</p>
<pre class="brush: xml">
&lt;context-param&gt;
 &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
 &lt;param-value&gt;classpath:cxf.xml&lt;/param-value&gt;
 &lt;/context-param&gt;

 &lt;servlet&gt;
 &lt;servlet-name&gt;CXFServlet&lt;/servlet-name&gt;
 &lt;servlet-class&gt;org.apache.cxf.transport.servlet.CXFServlet&lt;/servlet-class&gt;
 &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
 &lt;/servlet&gt;

 &lt;servlet-mapping&gt;
 &lt;servlet-name&gt;CXFServlet&lt;/servlet-name&gt;
 &lt;url-pattern&gt;/service/*&lt;/url-pattern&gt;
 &lt;/servlet-mapping&gt;
</pre>
<p>2) Apache CXF&#8217;s configuration (cxf.xml) loads the Spring context configuration</p>
<pre class="brush: xml">
 &lt;import resource=&quot;classpath:META-INF/cxf/cxf.xml&quot; /&gt;
 &lt;import resource=&quot;classpath:META-INF/cxf/cxf-extension-soap.xml&quot; /&gt;
 &lt;import resource=&quot;classpath:META-INF/cxf/cxf-servlet.xml&quot; /&gt;
 &lt;import resource=&quot;classpath:jcrcontext.xml&quot;/&gt;
</pre>
<p>where the SpringModules JCRContext configuration loads the JackRabbit&#8217;s RepositoryFactoryBean</p>
<pre class="brush: xml">
&lt;bean id=&quot;repository&quot; class=&quot;org.springmodules.jcr.jackrabbit.RepositoryFactoryBean&quot;&gt;
  &lt;property name=&quot;configuration&quot; value=&quot;classpath:repository.xml&quot;/&gt;
  &lt;property name=&quot;homeDir&quot; ref=&quot;./target/myrepository&quot;/&gt;
 &lt;/bean&gt;

 &lt;bean id=&quot;sessionFactory&quot;  class=&quot;org.springmodules.jcr.jackrabbit.JackrabbitSessionFactory&quot;&gt;
  &lt;property name=&quot;repository&quot; ref=&quot;repository&quot; /&gt;
  &lt;property name=&quot;credentials&quot; ref=&quot;simpleCredentials&quot;/&gt;
 &lt;/bean&gt;

 &lt;bean id=&quot;jcrTemplate&quot; class=&quot;org.springmodules.jcr.JcrTemplate&quot;&gt;
  &lt;property name=&quot;sessionFactory&quot; ref=&quot;sessionFactory&quot; /&gt;
  &lt;property name=&quot;allowCreate&quot; value=&quot;true&quot; /&gt;
 &lt;/bean&gt;

 &lt;bean id=&quot;simpleCredentials&quot; class=&quot;javax.jcr.SimpleCredentials&quot;&gt;
  &lt;constructor-arg index=&quot;0&quot; value=&quot;bogus&quot;/&gt;
  &lt;constructor-arg index=&quot;1&quot;&gt;
   &lt;bean factory-bean=&quot;password&quot; factory-method=&quot;toCharArray&quot;/&gt;
  &lt;/constructor-arg&gt;
 &lt;/bean&gt;

 &lt;bean id=&quot;password&quot;  class=&quot;java.lang.String&quot;&gt;
  &lt;constructor-arg index=&quot;0&quot; value=&quot;pass&quot;/&gt;
 &lt;/bean&gt;
</pre>
<p>This chaining can be extended to any depth and a myriad range of implementation stacks could be acheived, if a container (Spring, Seam, Guice) offer support for seamless intra-container configuration and component resolution.</p>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/09/11/chaining-apache-cxf-jackrabbit-using-springmodules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Establishing a webservice unit test infrastructure using Unitils on Apache CXF and Hibernate</title>
		<link>http://myblog.shriharisc.com/2009/07/16/establishing-a-webservice-unit-test-infrastructure-using-unitils-on-apache-cxf/</link>
		<comments>http://myblog.shriharisc.com/2009/07/16/establishing-a-webservice-unit-test-infrastructure-using-unitils-on-apache-cxf/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 12:38:23 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[jee-light]]></category>
		<category><![CDATA[apache-cxf]]></category>
		<category><![CDATA[unitils]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=72</guid>
		<description><![CDATA[Unitils is most preferred Spring based unit testing framework for unit testing DAOs and persistence layers. However using the power of inherent Spring support it has, added with flexible flavors on JUnit or TestNG, it could be extended to implement Web-services testing infrastructure such as Apache CXF which has persistence layer access through DAO layer, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://unitils.org/summary.html">Unitils</a> is most preferred Spring based unit testing framework for unit testing DAOs and persistence layers. However using the power of inherent Spring support it has, added with flexible flavors on JUnit or TestNG, it could be extended to implement Web-services testing infrastructure such as <a href="http://cxf.apache.org/">Apache CXF</a> which has persistence layer access through DAO layer, that gets rid of loads of boilerplate code we got to ensure, before a proxy gets initialized.</p>
<p>This quick tip addresses how to put in place a unit testing infrastructure, so that unit testing Apache CXF web-services becomes a easy task. We assume we would use TestNG flavor of Unitils for our understanding, using JUnit is equivalently similar, and Maven based POM.</p>
<p>1) Include the Unitils dependency with TestNG in ${basedir}/pom.xml as given below.</p>
<pre class="brush: xml">
&lt;dependency&gt;
 &lt;groupId&gt;org.unitils&lt;/groupId&gt;
 &lt;artifactId&gt;unitils&lt;/artifactId&gt;
 &lt;version&gt;2.3&lt;/version&gt;
 &lt;/dependency&gt;

 &lt;dependency&gt;
 &lt;groupId&gt;org.testng&lt;/groupId&gt;
 &lt;artifactId&gt;testng&lt;/artifactId&gt;
 &lt;version&gt;5.8&lt;/version&gt;
 &lt;classifier&gt;jdk15&lt;/classifier&gt;
 &lt;scope&gt;test&lt;/scope&gt;
 &lt;/dependency&gt;
</pre>
<p>2) Add a Spring configuration file under ${basedir}/src/test/resources, say as client-test-config.xml and add the JAXWSProxyFactoryBean wiring so as to obtain a proxy object of the service exposed on a specific WSDL url.</p>
<pre class="brush: xml">
&lt;beans&gt;
   &lt;bean id=&quot;propConfig&quot; class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;&gt;
     &lt;property name=&quot;systemPropertiesMode&quot; value=&quot;2&quot;/&gt;
     &lt;property name=&quot;location&quot; value=&quot;classpath:mytest.properties&quot;/&gt;
   &lt;/bean&gt;

   &lt;bean id=&quot;wsclient&quot;  class=&quot;mypackage.MyServiceInterface&quot; factory-bean=&quot;wsFactory&quot; factory-method=&quot;create&quot;/&gt;

   &lt;bean id=&quot;wsFactory&quot; class=&quot;org.apache.cxf.jaxws.JaxWsProxyFactoryBean&quot;&gt;
      &lt;property name=&quot;serviceClass&quot; value=&quot;mypackage.MyServiceInterface&quot;/&gt;
      &lt;property name=&quot;address&quot; value=&quot;${myservice.wsdl.url}&quot;/&gt;
   &lt;/bean&gt;
&lt;/beans&gt;
</pre>
<p>3) Define a unit test-case using the Spring configuration file, to inject the proxy service bean, and invoke/unit test methods on the exposed service.</p>
<pre class="brush: java">
public class MyServiceTest extends UnitilsTestNG
{   @SpringApplicationContext
    public ConfigurableApplicationContext createApplicationContext()
    {  return new ClassPathXmlApplicationContext(&quot;client-test-config.xml&quot;);
    }

    @SpringBean(&quot;wsclient&quot;)
     private MyServiceInterface myService;&lt;/span&gt;
      //All your unit test methods annotated with @Test here&lt;/span&gt;
}
</pre>
<p>Thats it!. Your webservice unit test infrastructure for Apache CXF on Unitils is ready for adding test cases.</p>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/07/16/establishing-a-webservice-unit-test-infrastructure-using-unitils-on-apache-cxf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
