You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ds...@apache.org on 2006/04/26 11:53:14 UTC

svn commit: r397161 - in /webservices/axis2/trunk/java/modules/jibx: ./ test-resources/repo/conf/ test-resources/wsdl/ test/org/apache/axis2/jibx/

Author: dsosnoski
Date: Wed Apr 26 02:53:12 2006
New Revision: 397161

URL: http://svn.apache.org/viewcvs?rev=397161&view=rev
Log:
Full unit test for JiBX data binding.

Added:
    webservices/axis2/trunk/java/modules/jibx/test-resources/repo/conf/axis2.xml
    webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Echo.java
    webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/UtilServer.java
Modified:
    webservices/axis2/trunk/java/modules/jibx/project.xml
    webservices/axis2/trunk/java/modules/jibx/test-resources/wsdl/customer-echo.wsdl
    webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Customer.java
    webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Person.java
    webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Test.java

Modified: webservices/axis2/trunk/java/modules/jibx/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jibx/project.xml?rev=397161&r1=397160&r2=397161&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/project.xml (original)
+++ webservices/axis2/trunk/java/modules/jibx/project.xml Wed Apr 26 02:53:12 2006
@@ -1,143 +1,170 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- -->
-<project>
-    <pomVersion>3</pomVersion>
-    <extend>../../etc/project.xml</extend>
-
-    <name>Apache Axis 2.0 - JiBX Data Binding</name>
-    <id>axis2-jibx</id>
-    <groupId>axis2</groupId>
-    <description>JiBX data binding support for Axis 2.0</description>
-
-    <dependencies>
-       <dependency>
-            <groupId>ws-commons</groupId>
-            <artifactId>axiom-api</artifactId>
-            <version>${axiom.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>ws-commons</groupId>
-            <artifactId>axiom-impl</artifactId>
-            <version>${axiom.version}</version>
-        </dependency>
-       <dependency>
-            <groupId>ws-commons</groupId>
-            <artifactId>XmlSchema</artifactId>
-            <version>${XmlSchema.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>ws-commons</groupId>
-            <artifactId>policy</artifactId>
-            <version>${policy.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>axis2</groupId>
-            <artifactId>axis2-common</artifactId>
-            <version>${pom.currentVersion}</version>
-        </dependency>
-        <dependency>
-            <groupId>axis2</groupId>
-            <artifactId>axis2-codegen</artifactId>
-            <version>${pom.currentVersion}</version>
-        </dependency>
-        <dependency>
-            <groupId>axis2</groupId>
-            <artifactId>axis2-core</artifactId>
-            <version>${pom.currentVersion}</version>
-        </dependency>
-	  <dependency>
-            <groupId>axis2</groupId>
-            <artifactId>axis2-java2wsdl</artifactId>
-            <version>${pom.currentVersion}</version>
-        </dependency>
-        <dependency>
-            <groupId>axis</groupId>
-            <artifactId>axis-wsdl4j</artifactId>
-            <version>${axis.wsdl4j.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-
-        <!-- external JARs -->
-        <dependency>
-            <groupId>ant</groupId>
-            <artifactId>ant</artifactId>
-            <version>${ant.version}</version>
-            <type>jar</type>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-            <version>${commons.logging.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-            <version>${log4j.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-            <url>http://dist.codehaus.org/stax/jars/</url>
-        </dependency>
-        <dependency>
-            <groupId>${stax.impl.groupid}</groupId>
-            <artifactId>${stax.impl.artifactid}</artifactId>
-            <version>${stax.impl.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>stax</groupId>
-            <artifactId>stax-api</artifactId>
-            <version>${stax.api.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>jibx</groupId>
-            <artifactId>jibx-bind</artifactId>
-            <version>${jibx.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>jibx</groupId>
-            <artifactId>jibx-run</artifactId>
-            <version>${jibx.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-    </dependencies>
-    <build/>
-    <reports/>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+<project>
+    <pomVersion>3</pomVersion>
+    <extend>../../etc/project.xml</extend>
+
+    <name>Apache Axis 2.0 - JiBX Data Binding</name>
+    <id>axis2-jibx</id>
+    <groupId>axis2</groupId>
+    <description>JiBX data binding support for Axis 2.0</description>
+
+    <dependencies>
+       <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>axiom-api</artifactId>
+            <version>${axiom.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>axiom-impl</artifactId>
+            <version>${axiom.version}</version>
+        </dependency>
+       <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>XmlSchema</artifactId>
+            <version>${XmlSchema.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>policy</artifactId>
+            <version>${policy.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2-common</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2-codegen</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2-core</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>axis</groupId>
+            <artifactId>axis-wsdl4j</artifactId>
+            <version>${axis.wsdl4j.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+
+        <!-- external JARs -->
+        <dependency>
+            <groupId>ant</groupId>
+            <artifactId>ant</artifactId>
+            <version>${ant.version}</version>
+            <type>jar</type>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>${commons.logging.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>bcel</groupId>
+            <artifactId>bcel</artifactId>
+            <version>${bcel.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>${log4j.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+            <url>http://dist.codehaus.org/stax/jars/</url>
+        </dependency>
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>${commons.httpclient.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>${commons.codec.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>${stax.impl.groupid}</groupId>
+            <artifactId>${stax.impl.artifactid}</artifactId>
+            <version>${stax.impl.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>stax</groupId>
+            <artifactId>stax-api</artifactId>
+            <version>${stax.api.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>jibx</groupId>
+            <artifactId>jibx-bind</artifactId>
+            <version>${jibx.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>jibx</groupId>
+            <artifactId>jibx-run</artifactId>
+            <version>${jibx.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+    </dependencies>
+    <build/>
+    <reports/>
+</project>

Added: webservices/axis2/trunk/java/modules/jibx/test-resources/repo/conf/axis2.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jibx/test-resources/repo/conf/axis2.xml?rev=397161&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/test-resources/repo/conf/axis2.xml (added)
+++ webservices/axis2/trunk/java/modules/jibx/test-resources/repo/conf/axis2.xml Wed Apr 26 02:53:12 2006
@@ -0,0 +1,198 @@
+<axisconfig name="AxisJava2.0">
+    <!-- ================================================= -->
+    <!-- Parameters -->
+    <!-- ================================================= -->
+    <parameter name="hotdeployment" locked="false">true</parameter>
+    <parameter name="hotupdate" locked="false">false</parameter>
+    <parameter name="enableMTOM" locked="false">false</parameter>
+    <parameter name="sendStacktraceDetailsWithFaults" locked="false">true</parameter>
+
+    <!-- Uncomment this to enable REST support -->
+    <!--    <parameter name="enableREST" locked="false">true</parameter>-->
+
+
+    <parameter name="userName" locked="false">admin</parameter>
+    <parameter name="password" locked="false">axis2</parameter>
+
+    <!-- If you have a frontend host which exposes this webservice using a different public URL  -->
+    <!-- use this parameter to override autodetected url -->
+    <!--<parameter name="httpFrontendHostUrl" locked="false">https://someotherhost/context</parameter>-->
+
+
+    <!--    The way of adding listener to the system-->
+    <!--    <listener class="org.apache.axis2.ObserverIMPL">-->
+    <!--        <parameter name="RSS_URL" locked="false">http://127.0.0.1/rss</parameter>-->
+    <!--    </listener>-->
+
+    <!-- ================================================= -->
+    <!-- Message Receivers -->
+    <!-- ================================================= -->
+    <!--This is the Deafult Message Receiver for the system , if you want to have MessageReceivers for -->
+    <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+    <!--any operation -->
+    <!--Note : You can ovride this for particular service by adding the same element with your requirement-->
+    <messageReceivers>
+        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+                         class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+                         class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+    </messageReceivers>
+    <!-- ================================================= -->
+    <!-- Transport Ins -->
+    <!-- ================================================= -->
+    <transportReceiver name="http"
+                       class="org.apache.axis2.transport.http.SimpleHTTPServer">
+        <parameter name="port" locked="false">6060</parameter>
+        <!--If you want to give your own host address for EPR generation-->
+        <!--uncommet following paramter , and set as you required.-->
+        <!--<parameter name="hostname" locked="false">http://myApp.com/ws</parameter>-->
+    </transportReceiver>
+
+    <!--Uncomment if you want to have SMTP transport support-->
+    <!--<transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener">-->
+    <!--<parameter name="transport.mail.pop3.host" locked="false">127.0.0.1</parameter>-->
+    <!--<parameter name="transport.mail.pop3.user" locked="false">axis2</parameter>-->
+    <!--<parameter name="transport.mail.pop3.password" locked="false">axis2</parameter>-->
+    <!--<parameter name="transport.mail.pop3.port" locked="false">110</parameter>-->
+    <!--<parameter name="transport.mail.replyToAddress" locked="false">axis2@127.0.0.1</parameter>-->
+    <!--</transportReceiver>-->
+
+    <transportReceiver name="tcp"
+                       class="org.apache.axis2.transport.tcp.TCPServer">
+        <parameter name="port" locked="false">6060</parameter>
+        <!--If you want to give your own host address for EPR generation-->
+        <!--uncommet following paramter , and set as you required.-->
+        <!--<parameter name="hostname" locked="false">tcp://myApp.com/ws</parameter>-->
+    </transportReceiver>
+
+    <!--Uncomment this if you want JMS transport support-->
+    <!--<transportReceiver name="jms" class="org.apache.axis2.transport.jms.SimpleJMSListener">-->
+    <!--<parameter name="transport.jms.Destination" locked="false">dynamicQueues/FOO</parameter>-->
+    <!--<parameter name="java.naming.factory.initial" locked="false">-->
+    <!--org.activemq.jndi.ActiveMQInitialContextFactory</parameter>-->
+    <!--<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>-->
+    <!--</transportReceiver>-->
+
+    <!-- ================================================= -->
+    <!-- Transport Outs -->
+    <!-- ================================================= -->
+
+    <transportSender name="tcp"
+                     class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+    <transportSender name="local"
+                     class="org.apache.axis2.transport.local.LocalTransportSender"/>
+    <transportSender name="jms"
+                     class="org.apache.axis2.transport.jms.JMSSender"/>
+    <transportSender name="http"
+                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+        <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+        <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+    </transportSender>
+    <transportSender name="https"
+                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+        <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+        <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+    </transportSender>
+
+    <!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+   <transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
+       <parameter name="transport.mail.smtp.host" locked="false">127.0.0.1</parameter>
+       <parameter name="transport.mail.smtp.user" locked="false">axis2</parameter>
+       <parameter name="transport.mail.smtp.password" locked="false">axis2</parameter>
+       <parameter name="transport.mail.smtp.port" locked="false">25</parameter>
+   </transportSender>
+   -->
+
+    <!-- ================================================= -->
+    <!-- Global Modules  -->
+    <!-- ================================================= -->
+    <!-- Comment this to disable Addressing -->
+<!--    <module ref="addressing"/>  -->
+
+    <!--Configuring module , providing parameters for modules whether they refer or not-->
+    <!--<moduleConfig name="addressing">-->
+    <!--<parameter name="addressingPara" locked="false">N/A</parameter>-->
+    <!--</moduleConfig>-->
+
+    <!-- ================================================= -->
+    <!-- Phases  -->
+    <!-- ================================================= -->
+    <phaseOrder type="inflow">
+        <!--  System pre defined phases       -->
+         <phase name="Transport">
+            <handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+            <handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+        </phase>
+        <phase name="Security"/>
+        <phase name="PreDispatch"/>
+        <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+            <handler name="AddressingBasedDispatcher"
+                     class="org.apache.axis2.engine.AddressingBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+
+            <handler name="SOAPMessageBodyBasedDispatcher"
+                     class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+            <handler name="InstanceDispatcher"
+                     class="org.apache.axis2.engine.InstanceDispatcher">
+                <order phase="PostDispatch"/>
+            </handler>
+        </phase>
+        <!--  System pre defined phases       -->
+        <!--   After Postdispatch phase module author or or service author can add any phase he want      -->
+        <phase name="OperationInPhase"/>
+    </phaseOrder>
+    <phaseOrder type="outflow">
+        <!--      user can add his own phases to this area  -->
+        <phase name="OperationOutPhase"/>
+        <!--system predefined phase-->
+        <!--these phase will run irrespective of the service-->
+        <phase name="PolicyDetermination"/>
+        <phase name="MessageOut"/>
+    </phaseOrder>
+    <phaseOrder type="INfaultflow">
+        <phase name="PreDispatch"/>
+        <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+            <handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+
+            <handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+
+            <handler name="AddressingBasedDispatcher"
+                     class="org.apache.axis2.engine.AddressingBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+
+            <handler name="SOAPMessageBodyBasedDispatcher"
+                     class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+                <order phase="Dispatch"/>
+            </handler>
+            <handler name="InstanceDispatcher"
+                     class="org.apache.axis2.engine.InstanceDispatcher">
+                <order phase="PostDispatch"/>
+            </handler>
+        </phase>
+        <!--      user can add his own phases to this area  -->
+        <phase name="OperationInFaultPhase"/>
+    </phaseOrder>
+    <phaseOrder type="Outfaultflow">
+        <!--      user can add his own phases to this area  -->
+        <phase name="OperationOutFaultPhase"/>
+        <phase name="PolicyDetermination"/>
+        <phase name="MessageOut"/>
+    </phaseOrder>
+</axisconfig>
+

Modified: webservices/axis2/trunk/java/modules/jibx/test-resources/wsdl/customer-echo.wsdl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jibx/test-resources/wsdl/customer-echo.wsdl?rev=397161&r1=397160&r2=397161&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/test-resources/wsdl/customer-echo.wsdl (original)
+++ webservices/axis2/trunk/java/modules/jibx/test-resources/wsdl/customer-echo.wsdl Wed Apr 26 02:53:12 2006
@@ -28,7 +28,7 @@
   </portType>
 
   <binding name="EchoCustomerBinding" type="tns:EchoCustomer">
-    <soap:binding style="doc" transport="http://schemas.xmlsoap.org/soap/http"/>
+    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
     <operation name="echo">
       <soap:operation soapAction="echo"/>
       <input>
@@ -42,7 +42,7 @@
 
   <service name="EchoCustomerService">
     <port name="EchoCustomerPort" binding="tns:EchoCustomerBinding">
-      <soap:address location="http://localhost:8800/EchoCustomerService"/>
+      <soap:address location="http://127.0.0.1:5555/axis2/services/EchoCustomerService"/>
     </port>
   </service>
   

Modified: webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Customer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Customer.java?rev=397161&r1=397160&r2=397161&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Customer.java (original)
+++ webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Customer.java Wed Apr 26 02:53:12 2006
@@ -23,4 +23,26 @@
     public String state;
     public Integer zip;
     public String phone;
+    
+    public Customer() {}
+    
+    public Customer(String city, Person person, String phone, String state, String street, Integer zip) {
+        this.city = city;
+        this.person = person;
+        this.phone = phone;
+        this.state = state;
+        this.street = street;
+        this.zip = zip;
+    }
+    
+    public boolean equals(Object obj) {
+        if (obj instanceof Customer) {
+            Customer cust = (Customer)obj;
+            return person.equals(cust.person) && street.equals(cust.street) &&
+                city.equals(cust.city) && state.equals(cust.state) &&
+                zip.equals(cust.zip) && phone.equals(cust.phone);
+        } else {
+            return false;
+        }
+    }
 }

Added: webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Echo.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Echo.java?rev=397161&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Echo.java (added)
+++ webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Echo.java Wed Apr 26 02:53:12 2006
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.jibx;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class Echo {
+
+    private Log log = LogFactory.getLog(getClass());
+    
+    public Echo() {
+    }
+
+    public OMElement echo(OMElement omEle) {
+        return omEle;
+    }
+}
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Person.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Person.java?rev=397161&r1=397160&r2=397161&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Person.java (original)
+++ webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Person.java Wed Apr 26 02:53:12 2006
@@ -20,4 +20,23 @@
     public int customerNumber;
     public String firstName;
     public String lastName;
+    
+    public Person() {}
+    
+    public Person(int number, String name, String name2) {
+        customerNumber = number;
+        firstName = name;
+        lastName = name2;
+    }
+    
+    public boolean equals(Object obj) {
+        if (obj instanceof Person) {
+            Person person = (Person)obj;
+            return customerNumber == person.customerNumber &&
+                firstName.equals(person.firstName) &&
+                lastName.equals(person.lastName);
+        } else {
+            return false;
+        }
+    }
 }

Modified: webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Test.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Test.java?rev=397161&r1=397160&r2=397161&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Test.java (original)
+++ webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/Test.java Wed Apr 26 02:53:12 2006
@@ -19,11 +19,17 @@
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.xml.namespace.QName;
+
 import junit.framework.TestCase;
 
+import org.apache.axis2.description.AxisService;
 import org.apache.axis2.wsdl.codegen.CodeGenerationEngine;
 import org.apache.axis2.wsdl.codegen.CodeGenerationException;
 import org.apache.axis2.wsdl.codegen.extension.JiBXExtension;
@@ -33,8 +39,12 @@
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Target;
+import org.apache.tools.ant.taskdefs.Java;
 import org.apache.tools.ant.taskdefs.Javac;
 import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Commandline.Argument;
+import org.apache.axis2.util.Utils;
+import org.jibx.binding.Compile;
 import org.jibx.runtime.BindingDirectory;
 import org.jibx.runtime.IBindingFactory;
 import org.jibx.runtime.IMarshallingContext;
@@ -48,15 +58,24 @@
  */
 public class Test extends TestCase
 {
-    public static final String OUTPUT_LOCATION_BASE = "target/gen";
-    public static final String OUTPUT_LOCATION_PREFIX = "/test";
-    private static int folderCount = 0;
-    public static final String WSDL_BASE_DIR = "test-resources/wsdl/";
-    public static final String BINDING_BASE_DIR = "test-resources/binding/";
-    public static final String CLASSES_DIR = "/target/classes/";
-    private String[] moduleNames={"xml","common","core"};
+    private static final String TEST_CLASSES_DIR = "target/test-classes";
+    private static final String OUTPUT_LOCATION_BASE = "target/gen";
+    private static final String OUTPUT_LOCATION_PREFIX = "/test";
+    private static final String WSDL_BASE_DIR = "test-resources/wsdl/";
+    private static final String BINDING_BASE_DIR = "test-resources/binding/";
+    public static final String REPOSITORY_DIR = "test-resources/repo/";
+    private static final String CLASSES_DIR = "/target/classes/";
+    private static final String[] moduleNames= {"common", "core"};
     private static final String MODULE_PATH_PREFIX = "../modules/";
     private static final String COMPILE_TARGET_NAME = "compile";
+    private static final String BIND_TARGET_NAME = "bind";
+    private static final String STUB_CLASS =
+        "org.apache.axis2.EchoCustomerServiceStub";
+
+    public static final QName serviceName = new QName("EchoCustomerService");
+    public static final QName operationName = new QName("echo");
+    
+    private AxisService service;
 
 
     /**
@@ -71,6 +90,10 @@
         }else{
             outputFile.mkdir();
         }
+        service = Utils.createSimpleService(serviceName,
+            Echo.class.getName(), operationName);
+        UtilServer.start(REPOSITORY_DIR);
+        UtilServer.deployService(service);
     }
 
     /**
@@ -98,10 +121,12 @@
      * @throws Exception
      */
     protected void tearDown() throws Exception {
-        File outputFile = new File(OUTPUT_LOCATION_BASE);
+        UtilServer.unDeployService(serviceName);
+        UtilServer.stop();
+/*        File outputFile = new File(OUTPUT_LOCATION_BASE);
         if (outputFile.exists() && outputFile.isDirectory()){
             deleteDir(outputFile);
-        }
+        }   */
     }
 
     /**
@@ -130,16 +155,6 @@
             new CommandLineOption(CommandLineOptionConstants.WSDL2JavaConstants.OUTPUT_LOCATION_OPTION,
             new String[] {outdir}));
         
-        // server side option is on
-        optionMap.put(CommandLineOptionConstants.WSDL2JavaConstants.SERVER_SIDE_CODE_OPTION,
-            new CommandLineOption(CommandLineOptionConstants.WSDL2JavaConstants.SERVER_SIDE_CODE_OPTION,
-            new String[0]));
-        
-        // descriptor option is on
-        optionMap.put(CommandLineOptionConstants.WSDL2JavaConstants.GENERATE_SERVICE_DESCRIPTION_OPTION,
-            new CommandLineOption(CommandLineOptionConstants.WSDL2JavaConstants.GENERATE_SERVICE_DESCRIPTION_OPTION,
-            new String[0]));
-        
          // db is JiBX
          optionMap.put(CommandLineOptionConstants.WSDL2JavaConstants.DATA_BINDING_TYPE_OPTION,
             new CommandLineOption(CommandLineOptionConstants.WSDL2JavaConstants.DATA_BINDING_TYPE_OPTION,
@@ -166,7 +181,7 @@
      * 
      * @param outdir
      */
-    private void compile(String outdir) {
+    private void compile(String outdir) throws Exception {
         
         //using the ant javac task for compilation
         Javac javaCompiler = new Javac();
@@ -194,6 +209,7 @@
         File outputLocationFile = new File(classdir);
         outputLocationFile.mkdir();
         Path classPath = new Path(codeGenProject, classdir) ;
+        classPath.add(new Path(codeGenProject, TEST_CLASSES_DIR));
         classPath.addExisting(classPath.concatSystemClasspath(), false);
         for (int i = 0; i < moduleNames.length; i++) {
             classPath.add(new Path(codeGenProject,
@@ -209,58 +225,66 @@
         //output the classes into the output dir as well
         javaCompiler.setDestdir(outputLocationFile);
         javaCompiler.setVerbose(true);
-        try {
-            codeGenProject.executeTarget(COMPILE_TARGET_NAME);
-        } catch (BuildException e) {
-            fail();
-        }
+        javaCompiler.execute();
+//        codeGenProject.executeTarget(COMPILE_TARGET_NAME);
+    }
+
+    /**
+     * Bind the data classes.
+     * 
+     * @param datadir
+     * @param binding
+     */
+    private void bind(String datadir, String binding) throws Exception {
+        
+        // define ant java task for binding compiler
+        Java java = new Java();
+        Project codeGenProject = new Project();
+        Target compileTarget = new Target();
+        compileTarget.setName(BIND_TARGET_NAME);
+        compileTarget.addTask(java);
+        codeGenProject.addTarget(compileTarget);
+        codeGenProject.setSystemProperties();
+        java.setProject(codeGenProject);
+        java.setFork(true);
+        java.setClassname("org.jibx.binding.Compile");
+
+        // set classpath to include generated classes
+        Path classPath = new Path(codeGenProject, datadir) ;
+        classPath.addExisting(classPath.concatSystemClasspath(), false);
+        java.setClasspath(classPath);
+        
+        // add binding definition as argument
+        Argument arg = java.createArg();
+        arg.setValue(binding);
 
+        // execute the binding compiler
+        java.execute();
     }
     
-    public void testRunCustomer() throws Exception {
+    public void testBuildAndRun() throws Exception {
+        
+        // start by generating and compiling the Axis2 interface code
         String outdir =
-            OUTPUT_LOCATION_BASE + OUTPUT_LOCATION_PREFIX + folderCount++;
+            OUTPUT_LOCATION_BASE + OUTPUT_LOCATION_PREFIX;
         codeGenerate(WSDL_BASE_DIR + "customer-echo.wsdl",
             BINDING_BASE_DIR + "customer-binding.xml", outdir);
         compile(outdir);
+        
+        // execute the JiBX binding compiler
+        bind(outdir + "/classes", BINDING_BASE_DIR + "customer-binding.xml");
+        
+        // finish by testing a roundtrip call to the echo server
+        File classesdir = new File(outdir + "/classes");
+        URLClassLoader loader = new URLClassLoader(new URL[] {classesdir.toURL()});
+        Class stub = loader.loadClass(STUB_CLASS);
+        Object inst = stub.newInstance();
+        Person person = new Person(42, "John", "Smith");
+        Customer customer = new Customer("Redmond", person, "+14258858080",
+            "WA", "14619 NE 80th Pl.", new Integer(98052));
+        Method method = stub.getMethod("echo", new Class[] {Customer.class});
+        Object result = method.invoke(inst, new Object[] {customer});
+        assertEquals("Result object does not match request object",
+            customer, result);
     }
-    
-    /**
-     * Unmarshal the sample document from a file, then marshal it back out to
-     * another file.
-     */
-/*	public static void main(String[] args) {
-        if (args.length < 2) {
-            System.out.println("Usage: java -cp ... " +
-                "org.jibx.starter.Test in-file out-file");
-            System.exit(0);
-        }
-		try {
-			
-            // note that you can use multiple bindings with the same class, in
-            //  which case you need to use the getFactory() call that takes the
-            //  binding name as the first parameter
-            IBindingFactory bfact = BindingDirectory.getFactory(Customer.class);
-            
-            // unmarshal customer information from file
-            IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
-            FileInputStream in = new FileInputStream(args[0]);
-            Customer customer = (Customer)uctx.unmarshalDocument(in, null);
-            
-            // you can add code here to alter the unmarshalled customer
-            
-			// marshal object back out to file (with nice indentation, as UTF-8)
-			IMarshallingContext mctx = bfact.createMarshallingContext();
-			mctx.setIndent(2);
-			FileOutputStream out = new FileOutputStream(args[1]);
-			mctx.marshalDocument(customer, "UTF-8", null, out);
-			
-		} catch (FileNotFoundException e) {
-			e.printStackTrace();
-            System.exit(1);
-		} catch (JiBXException e) {
-			e.printStackTrace();
-            System.exit(1);
-		}
-	}    */
 }

Added: webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/UtilServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/UtilServer.java?rev=397161&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/UtilServer.java (added)
+++ webservices/axis2/trunk/java/modules/jibx/test/org/apache/axis2/jibx/UtilServer.java Wed Apr 26 02:53:12 2006
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.jibx;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+
+public class UtilServer {
+    private static int count = 0;
+
+    private static SimpleHTTPServer receiver;
+
+    public static final int TESTING_PORT = 5555;
+
+    public static final String FAILURE_MESSAGE = "Intentional Failure";
+
+
+    public static synchronized void deployService(AxisService service)
+            throws AxisFault {
+        receiver.getConfigurationContext().getAxisConfiguration().addService(
+                service);
+    }
+
+    public static synchronized void unDeployService(QName service)
+            throws AxisFault {
+        receiver.getConfigurationContext().getAxisConfiguration()
+                .removeService(service.getLocalPart());
+    }
+
+    public static synchronized void start(String repository) throws Exception {
+        if (count == 0) {
+            ConfigurationContext er = getNewConfigurationContext(repository);
+
+            receiver = new SimpleHTTPServer(er, TESTING_PORT);
+
+            try {
+                receiver.start();
+                System.out.print("Server started on port "
+                        + TESTING_PORT + ".....");
+            } finally {
+
+            }
+
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException e1) {
+                throw new AxisFault("Thread interuptted", e1);
+            }
+
+        }
+        count++;
+    }
+
+     public static synchronized void start(String repository , String axis2xml) throws Exception {
+        if (count == 0) {
+            ConfigurationContext er = getNewConfigurationContext(repository,axis2xml);
+
+            receiver = new SimpleHTTPServer(er, TESTING_PORT);
+
+            try {
+                receiver.start();
+                System.out.print("Server started on port "
+                        + TESTING_PORT + ".....");
+            } finally {
+
+            }
+
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException e1) {
+                throw new AxisFault("Thread interuptted", e1);
+            }
+
+        }
+        count++;
+    }
+
+    public static ConfigurationContext getNewConfigurationContext(
+            String repository) throws Exception {
+        File file = new File(repository);
+        if (!file.exists()) {
+            throw new Exception("repository directory "
+                    + file.getAbsolutePath() + " does not exists");
+        }
+        return ConfigurationContextFactory.createConfigurationContextFromFileSystem(file.getAbsolutePath(),
+                file.getAbsolutePath() + "/conf/axis2.xml");
+    }
+
+      public static ConfigurationContext getNewConfigurationContext(
+            String repository , String axis2xml) throws Exception {
+        File file = new File(repository);
+        if (!file.exists()) {
+            throw new Exception("repository directory "
+                    + file.getAbsolutePath() + " does not exists");
+        }
+        return ConfigurationContextFactory.createConfigurationContextFromFileSystem(file.getAbsolutePath(),
+                axis2xml);
+    }
+
+    public static synchronized void stop() throws AxisFault {
+        if (count == 1) {
+            receiver.stop();
+            while (receiver.isRunning()) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e1) {
+                }
+            }
+            count = 0;
+            // tp.doStop();
+            System.out.print("Server stopped .....");
+        } else {
+            count--;
+        }
+        ListenerManager listenerManager =
+                receiver.getConfigurationContext().getListenerManager();
+        if (listenerManager != null) {
+            listenerManager.stop();
+        }
+    }
+
+    public static ConfigurationContext getConfigurationContext() {
+        return receiver.getConfigurationContext();
+    }
+
+}