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 ga...@apache.org on 2005/01/12 00:31:06 UTC
cvs commit: ws-axis/java/test/wsdl/choice ChoiceService.wsdl ChoiceServiceSoapImpl.java ChoiceServiceTestCase.java build.xml server-deploy.wsdd
gawor 2005/01/11 15:31:06
Added: java/test/wsdl/choice ChoiceService.wsdl
ChoiceServiceSoapImpl.java
ChoiceServiceTestCase.java build.xml
server-deploy.wsdd
Log:
added choice tests
Revision Changes Path
1.1 ws-axis/java/test/wsdl/choice/ChoiceService.wsdl
Index: ChoiceService.wsdl
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<definitions
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://tempuri.org/"
targetNamespace="http://tempuri.org/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<s:schema elementFormDefault="qualified"
xmlns:tns="http://tempuri.org/"
targetNamespace="http://tempuri.org/">
<s:import namespace="http://www.w3.org/2001/XMLSchema" />
<xsd:complexType name="BaseFaultType">
<xsd:sequence>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FaultType">
<xsd:complexContent>
<xsd:extension base="s0:BaseFaultType">
<xsd:sequence>
<xsd:element name="command" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="StagingFaultType">
<xsd:complexContent>
<xsd:extension base="s0:FaultType">
<xsd:sequence>
<xsd:element name="attribute" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="SetResourceProperties">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="a" type="xsd:string"/>
<xsd:element name="b" type="xsd:int"/>
<xsd:element name="c" type="xsd:dateTime"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="FaultPropertyType">
<xsd:choice>
<xsd:element name="fault1" type="s0:FaultType"/>
<xsd:element name="fault2" type="s0:StagingFaultType"/>
<xsd:element ref="tns:SetResourceProperties"/>
</xsd:choice>
</xsd:complexType>
<s:element name="Record1">
<s:complexType>
<s:sequence>
<s:element name="elem" type="s0:FaultPropertyType"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="Record2">
<s:complexType>
<s:sequence>
<s:element name="elem" type="s0:FaultPropertyType"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</types>
<message name="Record1SoapIn">
<part name="parameters" element="s0:Record1" />
</message>
<message name="Record2SoapOut">
<part name="parameters" element="s0:Record2" />
</message>
<portType name="ChoiceServiceSoap">
<operation name="get">
<input message="s0:Record1SoapIn" />
<output message="s0:Record2SoapOut" />
</operation>
</portType>
<binding name="ChoiceServiceSoap" type="s0:ChoiceServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<operation name="get">
<soap:operation soapAction="http://tempuri.org/get" style="document" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="ChoiceService">
<port name="ChoiceServiceSoap" binding="s0:ChoiceServiceSoap">
<soap:address location="http://localhost:8080/axis/services/ChoiceServiceSoap" />
</port>
</service>
</definitions>
1.1 ws-axis/java/test/wsdl/choice/ChoiceServiceSoapImpl.java
Index: ChoiceServiceSoapImpl.java
===================================================================
/*
* Copyright 2002-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.
*/
package test.wsdl.choice;
public class ChoiceServiceSoapImpl implements test.wsdl.choice.ChoiceServiceSoap {
public test.wsdl.choice.Record2 get(test.wsdl.choice.Record1 parameters) throws java.rmi.RemoteException {
Record2 r = new Record2();
r.setElem(parameters.getElem());
return r;
}
}
1.1 ws-axis/java/test/wsdl/choice/ChoiceServiceTestCase.java
Index: ChoiceServiceTestCase.java
===================================================================
/*
* Copyright 2002-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.
*/
package test.wsdl.choice;
import java.util.Date;
import java.util.Calendar;
import org.apache.axis.types.URI;
import org.apache.axis.encoding.ser.CalendarSerializer;
import junit.framework.TestCase;
import junit.framework.AssertionFailedError;
import org.apache.axis.client.AdminClient;
import org.apache.axis.components.logger.LogFactory;
import org.apache.axis.message.MessageElement;
import org.apache.axis.message.Text;
import org.apache.axis.utils.Options;
import org.apache.commons.logging.Log;
import org.apache.log4j.Logger;
import javax.xml.namespace.QName;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Calendar;
public class ChoiceServiceTestCase extends TestCase {
public ChoiceServiceTestCase(String name) {
super(name);
}
public void testSerialization() throws Exception {
ChoiceServiceSoap binding;
try {
ChoiceServiceLocator locator = new ChoiceServiceLocator();
binding = locator.getChoiceServiceSoap();
deployServer();
}
catch (javax.xml.rpc.ServiceException jre) {
throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
}
catch (Exception e) {
throw new AssertionFailedError("Binding initialization Exception caught: " + e);
}
assertTrue("binding is null", binding != null);
FaultPropertyType fp1;
FaultPropertyType fp2;
Record1 r1;
Record2 r2;
// test 1
FaultType f1 = new FaultType();
f1.setDescription("foo");
f1.setCommand("bar");
fp1 = new FaultPropertyType();
fp1.setFault1(f1);
r1 = new Record1();
r1.setElem(fp1);
r2 = binding.get(r1);
assertTrue(r2 != null);
fp2 = r2.getElem();
assertTrue(fp2 != null);
assertTrue(fp2.getFault1() != null);
assertTrue(fp2.getFault1() instanceof FaultType);
assertEquals("foo",
((FaultType)fp2.getFault1()).getDescription());
assertEquals("bar",
((FaultType)fp2.getFault1()).getCommand());
// test 2
StagingFaultType f2 = new StagingFaultType();
f2.setDescription("foo1");
f2.setCommand("bar1");
f2.setAttribute("moo");
fp1 = new FaultPropertyType();
fp1.setFault2(f2);
r1 = new Record1();
r1.setElem(fp1);
r2 = binding.get(r1);
assertTrue(r2 != null);
fp2 = r2.getElem();
assertTrue(fp2 != null);
assertTrue(fp2.getFault2() != null);
assertTrue(fp2.getFault2() instanceof StagingFaultType);
assertEquals("foo1",
((FaultType)fp2.getFault2()).getDescription());
assertEquals("bar1",
((FaultType)fp2.getFault2()).getCommand());
assertEquals("moo",
((StagingFaultType)fp2.getFault2()).getAttribute());
}
public void testChoiceSerialization() throws Exception {
ChoiceServiceSoap binding;
try {
ChoiceServiceLocator locator = new ChoiceServiceLocator();
binding = locator.getChoiceServiceSoap();
deployServer();
}
catch (javax.xml.rpc.ServiceException jre) {
throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
}
catch (Exception e) {
throw new AssertionFailedError("Binding initialization Exception caught: " + e);
}
assertTrue("binding is null", binding != null);
FaultPropertyType fp1;
Record1 r1;
Record2 r2;
// serialize f1
FaultType f1 = new FaultType();
f1.setDescription("foo");
f1.setCommand("bar");
fp1 = new FaultPropertyType();
fp1.setFault1(f1);
r1 = new Record1();
r1.setElem(fp1);
r2 = binding.get(r1);
assertTrue(r2 != null);
// serialize f2
StagingFaultType f2 = new StagingFaultType();
f2.setDescription("foo1");
f2.setCommand("bar1");
f2.setAttribute("moo");
fp1 = new FaultPropertyType();
fp1.setFault2(f2);
r1 = new Record1();
r1.setElem(fp1);
r2 = binding.get(r1);
assertTrue(r2 != null);
}
private void deployServer() {
final String INPUT_FILE = "server-deploy.wsdd";
InputStream is = getClass().getResourceAsStream(INPUT_FILE);
if (is == null) {
// try current directory
try {
is = new FileInputStream(INPUT_FILE);
} catch (FileNotFoundException e) {
is = null;
}
}
assertNotNull("Unable to find " + INPUT_FILE + ". Make sure it is on the classpath or in the current directory.", is);
AdminClient admin = new AdminClient();
try {
Options opts = new Options( null );
opts.setDefaultURL("http://localhost:8080/axis/services/AdminService");
admin.process(opts, is);
} catch (Exception e) {
assertTrue("Unable to deploy " + INPUT_FILE + ". ERROR: " + e, false);
}
}
}
1.1 ws-axis/java/test/wsdl/choice/build.xml
Index: build.xml
===================================================================
<?xml version="1.0" ?>
<!DOCTYPE project [
<!ENTITY properties SYSTEM "file:../../../xmls/properties.xml">
<!ENTITY paths SYSTEM "file:../../../xmls/path_refs.xml">
<!ENTITY taskdefs SYSTEM "file:../../../xmls/taskdefs.xml">
<!ENTITY taskdefs_post_compile SYSTEM "file:../../../xmls/taskdefs_post_compile.xml">
<!ENTITY targets SYSTEM "file:../../../xmls/targets.xml">
]>
<!-- ===================================================================
<description>
Test/Sample Component file for Axis
Notes:
This is a build file for use with the Jakarta Ant build tool.
Prerequisites:
jakarta-ant from http://jakarta.apache.org
Build Instructions:
To compile
ant compile
To execute
ant run
Author:
Brook Richan brichan@sandlot.com
Copyright:
Copyright (c) 2003 Apache Software Foundation.
</description>
==================================================================== -->
<project default="compile">
<property name="axis.home" location="../../.." />
<property name="componentName" value="test/wsdl/choice" />
&properties;
&paths;
&taskdefs;
&taskdefs_post_compile;
&targets;
<target name="clean">
<echo message="Removing ${build.dir}/classes/${componentName} and ${build.dir}/work/${componentName}" />
<delete dir="${build.dir}/classes/${componentName}"/>
<delete dir="${build.dir}/work/${componentName}"/>
</target>
<target name="copy" depends="setenv"/>
<target name="compile" depends="copy">
<echo message="Compiling test.wsdl.choice"/>
<wsdl2java url="${axis.home}/test/wsdl/choice/ChoiceService.wsdl"
output="${axis.home}/build/work"
serverSide="no"
noWrapped="true"
testcase="no">
<mapping namespace="http://tempuri.org/" package="test.wsdl.choice"/>
</wsdl2java>
<copy todir="${build.dir}/work/test/wsdl/choice" overwrite="yes">
<fileset dir="${axis.home}/test/wsdl/choice">
<include name="*.java"/>
</fileset>
</copy>
<javac srcdir="${build.dir}/work" destdir="${build.dest}" nowarn="${nowarn}" source="${source}" fork="${javac.fork}"
debug="${debug}">
<classpath refid="classpath" />
<include name="test/wsdl/choice/**/*.java" />
</javac>
<copy todir="${build.dir}/classes/test/wsdl/choice" overwrite="yes">
<fileset dir="${axis.home}/test/wsdl/choice">
<include name="server-deploy.wsdd"/>
</fileset>
</copy>
</target>
<target name="run" >
<antcall target="execute-Component" />
</target>
</project>
1.1 ws-axis/java/test/wsdl/choice/server-deploy.wsdd
Index: server-deploy.wsdd
===================================================================
<!-- Use this file to deploy some handlers/chains and services -->
<!-- Two ways to do this: -->
<!-- java org.apache.axis.client.AdminClient deploy.wsdd -->
<!-- after the axis server is running -->
<!-- or -->
<!-- java org.apache.axis.utils.Admin client|server deploy.wsdd -->
<!-- from the same directory that the Axis engine runs -->
<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<!-- Services from ChoiceService WSDL service -->
<service name="ChoiceServiceSoap" provider="java:RPC" style="document" use="literal">
<parameter name="wsdlTargetNamespace" value="http://tempuri.org/"/>
<parameter name="wsdlServiceElement" value="ChoiceService"/>
<parameter name="wsdlServicePort" value="ChoiceServiceSoap"/>
<parameter name="className" value="test.wsdl.choice.ChoiceServiceSoapImpl"/>
<parameter name="wsdlPortType" value="ChoiceServiceSoap"/>
<operation name="get" qname="get" returnQName="retNS:Record2" xmlns:retNS="http://tempuri.org/" returnType="rtns:>Record2" xmlns:rtns="http://tempuri.org/" soapAction="http://tempuri.org/get" >
<parameter qname="pns:Record1" xmlns:pns="http://tempuri.org/" type="tns:>Record1" xmlns:tns="http://tempuri.org/"/>
</operation>
<parameter name="allowedMethods" value="get"/>
<typeMapping
xmlns:ns="http://tempuri.org/"
qname="ns:BaseFaultType"
type="java:test.wsdl.choice.BaseFaultType"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://tempuri.org/"
qname="ns:>Record1"
type="java:test.wsdl.choice.Record1"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://tempuri.org/"
qname="ns:StagingFaultType"
type="java:test.wsdl.choice.StagingFaultType"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://tempuri.org/"
qname="ns:>Record2"
type="java:test.wsdl.choice.Record2"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://tempuri.org/"
qname="ns:FaultType"
type="java:test.wsdl.choice.FaultType"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://tempuri.org/"
qname="ns:FaultPropertyType"
type="java:test.wsdl.choice.FaultPropertyType"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://tempuri.org/"
qname="ns:>SetResourceProperties"
type="java:test.wsdl.choice.SetResourceProperties"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
</service>
</deployment>