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 an...@apache.org on 2002/10/15 14:13:11 UTC
cvs commit: xml-axis-wsif/java/test/jms Timeouts.wsdl JMSTimeoutTest.java
antelder 2002/10/15 05:13:11
Added: java/test/jms Timeouts.wsdl JMSTimeoutTest.java
Log:
testcase for specifying timouts to be specified for each operation request
Revision Changes Path
1.1 xml-axis-wsif/java/test/jms/Timeouts.wsdl
Index: Timeouts.wsdl
===================================================================
<?xml version="1.0" ?>
<definitions targetNamespace="http://wsifservice.addressbook/"
xmlns:tns="http://wsifservice.addressbook/"
xmlns:typens="http://wsiftypes.addressbook/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:format="http://schemas.xmlsoap.org/wsdl/formatbinding/"
xmlns:java="http://schemas.xmlsoap.org/wsdl/java/"
xmlns:jms="http://schemas.xmlsoap.org/wsdl/jms/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<!-- type defs -->
<types>
<xsd:schema
targetNamespace="http://wsiftypes.addressbook/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<xsd:complexType name="phone">
<xsd:element name="areaCode" type="xsd:int"/>
<xsd:element name="exchange" type="xsd:string"/>
<xsd:element name="number" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="address">
<xsd:element name="streetNum" type="xsd:int"/>
<xsd:element name="streetName" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="state" type="xsd:string"/>
<xsd:element name="zip" type="xsd:int"/>
<xsd:element name="phoneNumber" type="typens:phone"/>
</xsd:complexType>
</xsd:schema>
</types>
<!-- message declns -->
<message name="AddEntryWholeNameRequestMessage">
<part name="name" type="xsd:string"/>
<part name="address" type="typens:address"/>
</message>
<message name="AddEntryFirstAndLastNamesRequestMessage">
<part name="firstName" type="xsd:string"/>
<part name="lastName" type="xsd:string"/>
<part name="address" type="typens:address"/>
</message>
<message name="GetAddressFromNameRequestMessage">
<part name="name" type="xsd:string"/>
</message>
<message name="GetAddressFromNameResponseMessage">
<part name="address" type="typens:address"/>
</message>
<!-- port type declns -->
<portType name="AddressBook">
<operation name="addEntry">
<input name="AddEntryWholeNameRequest" message="tns:AddEntryWholeNameRequestMessage"/>
</operation>
<operation name="addEntry">
<input name="AddEntryFirstAndLastNamesRequest" message="tns:AddEntryFirstAndLastNamesRequestMessage"/>
</operation>
<operation name="getAddressFromName">
<input name="GetAddressFromNameRequest" message="tns:GetAddressFromNameRequestMessage"/>
<output name="GetAddressFromNameResponse" message="tns:GetAddressFromNameResponseMessage"/>
</operation>
</portType>
<!-- binding declns -->
<binding name="SOAPJmsBinding1" type="tns:AddressBook">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/jms"/>
<operation name="addEntry">
<soap:operation soapAction=""/>
<input name="AddEntryWholeNameRequest">
<soap:body use="encoded"
namespace="http://wsifservice.addressbook/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
</operation>
<operation name="addEntry">
<soap:operation soapAction=""/>
<input name="AddEntryFirstAndLastNamesRequest">
<soap:body use="encoded"
namespace="http://wsifservice.addressbook/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
</operation>
<operation name="getAddressFromName">
<soap:operation soapAction=""/>
<input name="GetAddressFromNameRequest">
<soap:body use="encoded"
namespace="http://wsifservice.addressbook/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
<jms:propertyValue name="wsif.syncrequest.timeout" type="xsd:string" value="7000"/>
<jms:propertyValue name="wsif.asyncrequest.timeout" type="xsd:string" value="11000"/>
</input>
<output name="GetAddressFromNameResponse">
<soap:body use="encoded"
namespace="http://wsifservice.addressbook/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<binding name="SOAPJmsBinding2" type="tns:AddressBook">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/jms"/>
<operation name="addEntry">
<soap:operation soapAction=""/>
<input name="AddEntryWholeNameRequest">
<soap:body use="encoded"
namespace="http://wsifservice.addressbook/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
</operation>
<operation name="addEntry">
<soap:operation soapAction=""/>
<input name="AddEntryFirstAndLastNamesRequest">
<soap:body use="encoded"
namespace="http://wsifservice.addressbook/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
</operation>
<operation name="getAddressFromName">
<soap:operation soapAction=""/>
<input name="GetAddressFromNameRequest">
<soap:body use="encoded"
namespace="http://wsifservice.addressbook/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
<jms:property name="wsif.syncrequest.timeout" part="syncTimeout"/>
<jms:property name="wsif.asyncrequest.timeout" part="asyncTimeout"/>
</input>
<output name="GetAddressFromNameResponse">
<soap:body use="encoded"
namespace="http://wsifservice.addressbook/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<binding name="SOAPJmsBinding3" type="tns:AddressBook">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/jms"/>
<operation name="addEntry">
<soap:operation soapAction=""/>
<input name="AddEntryWholeNameRequest">
<soap:body use="encoded"
namespace="http://wsifservice.addressbook/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
</operation>
<operation name="addEntry">
<soap:operation soapAction=""/>
<input name="AddEntryFirstAndLastNamesRequest">
<soap:body use="encoded"
namespace="http://wsifservice.addressbook/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
</operation>
<operation name="getAddressFromName">
<soap:operation soapAction=""/>
<input name="GetAddressFromNameRequest">
<soap:body use="encoded"
namespace="http://wsifservice.addressbook/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output name="GetAddressFromNameResponse">
<soap:body use="encoded"
namespace="http://wsifservice.addressbook/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<binding name="NativeJmsBinding1" type="tns:AddressBook">
<jms:binding type="ObjectMessage"/>
<format:typeMapping encoding="Java" style="Java">
<format:typeMap typeName="typens:address" formatType="com.ibm.www.namespace.wsif.samples.ab.types.Address" />
<format:typeMap typeName="xsd:string" formatType="java.lang.String" />
</format:typeMapping>
<operation name="addEntry">
<input name="AddEntryWholeNameRequest">
<jms:input parts="name address"/>
</input>
</operation>
<operation name="addEntry">
<input name="AddEntryFirstAndLastNamesRequest"/>
</operation>
<operation name="getAddressFromName">
<input name="GetAddressFromNameRequest">
<jms:propertyValue name="wsif.syncrequest.timeout" type="xsd:string" value="7000"/>
<jms:propertyValue name="wsif.asyncrequest.timeout" type="xsd:string" value="11000"/>
</input>
<output name="GetAddressFromNameResponse"/>
</operation>
</binding>
<binding name="NativeJmsBinding2" type="tns:AddressBook">
<jms:binding type="ObjectMessage"/>
<format:typeMapping encoding="Java" style="Java">
<format:typeMap typeName="typens:address" formatType="com.ibm.www.namespace.wsif.samples.ab.types.Address" />
<format:typeMap typeName="xsd:string" formatType="java.lang.String" />
</format:typeMapping>
<operation name="addEntry">
<input name="AddEntryWholeNameRequest">
<jms:input parts="name address"/>
</input>
</operation>
<operation name="addEntry">
<input name="AddEntryFirstAndLastNamesRequest"/>
</operation>
<operation name="getAddressFromName">
<input name="GetAddressFromNameRequest">
<jms:property name="wsif.syncrequest.timeout" part="syncTimeout"/>
<jms:property name="wsif.asyncrequest.timeout" part="asyncTimeout"/>
</input>
<output name="GetAddressFromNameResponse"/>
</operation>
</binding>
<binding name="NativeJmsBinding3" type="tns:AddressBook">
<jms:binding type="ObjectMessage"/>
<format:typeMapping encoding="Java" style="Java">
<format:typeMap typeName="typens:address" formatType="com.ibm.www.namespace.wsif.samples.ab.types.Address" />
<format:typeMap typeName="xsd:string" formatType="java.lang.String" />
</format:typeMapping>
<operation name="addEntry">
<input name="AddEntryWholeNameRequest">
<jms:input parts="name address"/>
</input>
</operation>
<operation name="addEntry">
<input name="AddEntryFirstAndLastNamesRequest"/>
</operation>
<operation name="getAddressFromName">
<input name="GetAddressFromNameRequest"/>
<output name="GetAddressFromNameResponse"/>
</operation>
</binding>
<!-- service decln -->
<service name="AddressBookService">
<!-- jms:propertyValue timeouts -->
<port name="SOAPJMSPort1" binding="tns:SOAPJmsBinding1">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file:///JNDI-Directory">
</jms:address>
</port>
<!-- jms:property timeouts -->
<port name="SOAPJMSPort2" binding="tns:SOAPJmsBinding2">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file:///JNDI-Directory">
</jms:address>
</port>
<!-- context timeouts -->
<port name="SOAPJMSPort3" binding="tns:SOAPJmsBinding3">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file:///JNDI-Directory">
</jms:address>
</port>
<!-- wsif.properties timeouts -->
<port name="SOAPJMSPort4" binding="tns:SOAPJmsBinding3">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file:///JNDI-Directory">
</jms:address>
</port>
<!-- jms:address jms:propertyValue -->
<port name="SOAPJMSPort5" binding="tns:SOAPJmsBinding3">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file:///JNDI-Directory">
<jms:propertyValue name="wsif.syncrequest.timeout" type="xsd:string" value="25000"/>
<jms:propertyValue name="wsif.asyncrequest.timeout" type="xsd:string" value="27000"/>
</jms:address>
</port>
<!-- context overiders jms:property -->
<port name="SOAPJMSPort6" binding="tns:SOAPJmsBinding2">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file:///JNDI-Directory">
<jms:propertyValue name="wsif.syncrequest.timeout" type="xsd:string" value="99000"/>
<jms:propertyValue name="wsif.asyncrequest.timeout" type="xsd:string" value="99000"/>
</jms:address>
</port>
<port name="NativeJmsPort1" binding="tns:NativeJmsBinding1">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file:///JNDI-Directory">
</jms:address>
</port>
<port name="NativeJmsPort2" binding="tns:NativeJmsBinding2">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file:///JNDI-Directory">
</jms:address>
</port>
<port name="NativeJmsPort3" binding="tns:NativeJmsBinding3">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file:///JNDI-Directory">
</jms:address>
</port>
<port name="NativeJmsPort4" binding="tns:NativeJmsBinding3">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file:///JNDI-Directory">
</jms:address>
</port>
<port name="NativeJmsPort5" binding="tns:NativeJmsBinding3">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file:///JNDI-Directory">
<jms:propertyValue name="wsif.syncrequest.timeout" type="xsd:string" value="25000"/>
<jms:propertyValue name="wsif.asyncrequest.timeout" type="xsd:string" value="27000"/>
</jms:address>
</port>
<port name="NativeJmsPort6" binding="tns:NativeJmsBinding2">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file:///JNDI-Directory">
<jms:propertyValue name="wsif.syncrequest.timeout" type="xsd:string" value="99000"/>
<jms:propertyValue name="wsif.asyncrequest.timeout" type="xsd:string" value="99000"/>
</jms:address>
</port>
</service>
</definitions>
1.1 xml-axis-wsif/java/test/jms/JMSTimeoutTest.java
Index: JMSTimeoutTest.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package jms;
import java.text.DateFormat;
import java.util.Date;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.wsif.WSIFConstants;
import org.apache.wsif.WSIFCorrelationId;
import org.apache.wsif.WSIFException;
import org.apache.wsif.WSIFMessage;
import org.apache.wsif.WSIFOperation;
import org.apache.wsif.WSIFPort;
import org.apache.wsif.WSIFService;
import org.apache.wsif.WSIFServiceFactory;
import org.apache.wsif.util.WSIFProperties;
import util.AddressUtility;
import util.TestUtilities;
import addressbook.wsifservice.AddressBook;
import addressbook.wsiftypes.Address;
import addressbook.wsiftypes.Phone;
import async.AsyncResponseHandler;
/**
* Junit test to test out the JMS sync and async timeouts.
* This doesn't work so well yet and you have to run each test
* manually and check the timeout is correct. the only way to
* do this for async ops is to add a system.out.println to the
* correlation service to show what timeout value its using.
*
* @author <a href="mailto:ant.elder@uk.ibm.com">Ant Elder</a>
*/
public class JMSTimeoutTest extends TestCase {
String wsdlLocation =
TestUtilities.getWsdlPath("java\\test\\jms") + "Timeouts.wsdl";
private static final long sps1 = 7000;
private static final long spa1 = 11000;
private static final long sps2 = 12000;
private static final long spa2 = 14000;
private static final long sps3 = 15000;
private static final long spa3 = 18000;
private static final long sps4 = 3000; // wsif.properties
private static final long spa4 = 10000; // wsif.properties
private static final long sps5 = 25000;
private static final long spa5 = 27000;
private static final long sps6 = 15000;
private static final long spa6 = 18000;
public JMSTimeoutTest(String name) {
super(name);
}
public static void main(String[] args) {
// TestUtilities.startListeners(); <***** don't listen so it times out
junit.textui.TestRunner.run(suite());
// TestUtilities.stopListeners();
}
public static Test suite() {
return new TestSuite(JMSTimeoutTest.class);
}
public void setUp() {
TestUtilities.setUpExtensionsAndProviders();
}
// public void testDynamicAxisJms1() {
// doitDyn("SOAPJMSPort1", "soap");
// }
//xxx public void testDynamicAxisJms2() {
// doitDyn("SOAPJMSPort2", "soap");
// }
// public void testDynamicAxisJms3() {
// doitDyn("SOAPJMSPort3", "soap");
// }
// public void testDynamicAxisJms4() {
// doitDyn("SOAPJMSPort4", "soap");
// }
// public void testDynamicAxisJms5() {
// doitDyn("SOAPJMSPort5", "soap");
// }
// public void testDynamicAxisJms6() {
// doitDyn("SOAPJMSPort6", "soap");
// }
// public void testDynamicAxisJms1() {
// testAsyncOPs("SOAPJMSPort1", "soap");
// }
// public void testDynamicAxisJms2() {
// testAsyncOPs("SOAPJMSPort2", "soap");
// }
// public void testDynamicAxisJms3() {
// testAsyncOPs("SOAPJMSPort3", "soap");
// }
// public void testDynamicAxisJms4() {
// testAsyncOPs("SOAPJMSPort4", "soap");
// }
// public void testDynamicAxisJms5() {
// testAsyncOPs("SOAPJMSPort5", "soap");
// }
// public void testDynamicAxisJms6() {
// testAsyncOPs("SOAPJMSPort6", "soap");
// }
// public void testDynamicAxisJms1() {
// doitDyn("SOAPJMSPort1", "axis");
// }
// public void testDynamicAxisJms2() {
// doitDyn("SOAPJMSPort2", "axis");
// }
// public void testDynamicAxisJms3() {
// doitDyn("SOAPJMSPort3", "axis");
// }
// public void testDynamicAxisJms4() {
// doitDyn("SOAPJMSPort4", "axis");
// }
// public void testDynamicAxisJms5() {
// doitDyn("SOAPJMSPort5", "axis");
// }
// public void testDynamicAxisJms6() {
// doitDyn("SOAPJMSPort6", "axis");
// }
// public void testDynamicAxisJms1() {
// testAsyncOPs("SOAPJMSPort1", "axis");
// }
// public void testDynamicAxisJms2() {
// testAsyncOPs("SOAPJMSPort2", "axis");
// }
// public void testDynamicAxisJms3() {
// testAsyncOPs("SOAPJMSPort3", "axis");
// }
// public void testDynamicAxisJms4() {
// testAsyncOPs("SOAPJMSPort4", "axis");
// }
// public void testDynamicAxisJms5() {
// testAsyncOPs("SOAPJMSPort5", "axis");
// }
public void testDynamicAxisJms6() {
testAsyncOPs("SOAPJMSPort6", "axis");
}
// public void testDynamicNativeJms() {
// doitDyn("NativeJmsPort1", "" );
// }
// public void testDynamicNativeJms() {
// doitDyn("NativeJmsPort2", "" );
// }
// public void testDynamicNativeJms() {
// doitDyn("NativeJmsPort3", "" );
// }
// public void testDynamicNativeJms() {
// doitDyn("NativeJmsPort4", "" );
// }
// public void testDynamicNativeJms() {
// doitDyn("NativeJmsPort5", "" );
// }
// public void testDynamicNativeJms() {
// doitDyn("NativeJmsPort6", "" );
// }
//public void testDynamicNativeJms() {
// testAsyncOPs("NativeJmsPort1", "");
//}
// public void testDynamicNativeJms() {
// testAsyncOPs("NativeJmsPort2", "" );
// }
// public void testDynamicNativeJms() {
// testAsyncOPs("NativeJmsPort3", "" );
// }
// public void testDynamicNativeJms() {
// testAsyncOPs("NativeJmsPort4", "" );
// }
// public void testDynamicNativeJms() {
// testAsyncOPs("NativeJmsPort5", "" );
// }
// public void testDynamicNativeJms() {
// testAsyncOPs("NativeJmsPort6", "" );
// }
private void doitDyn(String portName, String protocol) {
if (portName.toUpperCase().indexOf("JMS") != -1
&& !TestUtilities.areWeTesting("jms"))
return;
TestUtilities.setProviderForProtocol(protocol);
try {
WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
WSIFService service =
factory.getService(
wsdlLocation,
null,
null,
"http://wsifservice.addressbook/",
"AddressBook");
service.mapType(
new javax.xml.namespace.QName(
"http://wsiftypes.addressbook/",
"address"),
Class.forName("addressbook.wsiftypes.Address"));
service.mapType(
new javax.xml.namespace.QName(
"http://wsiftypes.addressbook/",
"phone"),
Class.forName("addressbook.wsiftypes.Phone"));
WSIFPort port = service.getPort(portName);
WSIFOperation operation =
port.createOperation("getAddressFromName");
// Create the messages
WSIFMessage inputMessage = operation.createInputMessage();
WSIFMessage outputMessage = operation.createOutputMessage();
WSIFMessage faultMessage = operation.createFaultMessage();
// Set the name to find in the addressbook
String nameToLookup = "Chris P. Bacon";
inputMessage.setObjectPart("name", nameToLookup);
if ("SOAPJMSPort2".equals(portName)
|| "NativeJmsPort2".equals(portName)) {
inputMessage.setObjectPart("syncTimeout", "" + sps2);
}
if ("SOAPJMSPort3".equals(portName)
|| "NativeJmsPort3".equals(portName)
|| "SOAPJMSPort6".equals(portName)
|| "NativeJmsPort6".equals(portName)) {
WSIFMessage context = operation.getContext();
context.setObjectPart(
WSIFConstants.WSIF_PROP_SYNC_TIMEOUT,
"" + sps3);
operation.setContext(context);
}
// Execute the operation
Date first = new Date();
boolean operationSucceeded =
operation.executeRequestResponseOperation(
inputMessage,
outputMessage,
faultMessage);
if (operationSucceeded) {
assertTrue("it didn't timeout!!", false);
} else {
Date second = new Date();
DateFormat df = DateFormat.getDateTimeInstance();
long diff = second.getTime() - first.getTime();
System.out.println("diff=" + diff);
// assertTrue("lookup op failed!!", false);
}
} catch (Exception e) {
e.printStackTrace();
assertTrue("exception running tests-" + e.getMessage(), false);
}
}
private void testAsyncOPs(String portName, String protocol) {
if (portName.toUpperCase().indexOf("JMS") != -1
&& !TestUtilities.areWeTesting("jms"))
return;
TestUtilities.setProviderForProtocol(protocol);
try {
WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
WSIFService service =
factory.getService(
wsdlLocation,
null,
null,
"http://wsifservice.addressbook/",
"AddressBook");
service.mapType(
new javax.xml.namespace.QName(
"http://wsiftypes.addressbook/",
"address"),
Class.forName("addressbook.wsiftypes.Address"));
service.mapType(
new javax.xml.namespace.QName(
"http://wsiftypes.addressbook/",
"phone"),
Class.forName("addressbook.wsiftypes.Phone"));
WSIFPort port =
(portName == null)
? service.getPort()
: service.getPort(portName);
if (!port.supportsAsync()) {
return;
}
WSIFOperation op = port.createOperation("getAddressFromName");
AsyncResponseHandler abHandler = new AsyncResponseHandler(1);
// 1 async call
WSIFMessage inMsg = op.createInputMessage();
inMsg.setObjectPart("name", "fred");
WSIFMessage outmsg = op.createOutputMessage();
WSIFMessage faultMsg = op.createFaultMessage();
WSIFMessage context = op.getContext();
context.setObjectPart(
WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo",
TestUtilities.getWsifProperty("wsif.async.replytoq"));
if ("SOAPJMSPort2".equals(portName)
|| "NativeJmsPort2".equals(portName)) {
inMsg.setObjectPart("asyncTimeout", "" + spa2);
}
if ("SOAPJMSPort3".equals(portName)
|| "NativeJmsPort3".equals(portName)
|| "SOAPJMSPort6".equals(portName)
|| "NativeJmsPort6".equals(portName)) {
context.setObjectPart(
WSIFConstants.WSIF_PROP_ASYNC_TIMEOUT,
"" + spa3);
}
op.setContext(context);
WSIFCorrelationId id =
op.executeRequestResponseAsync(inMsg, abHandler);
assertTrue(
"null correlation id returned from async request!",
id != null);
int i = 30;
while (i-- > 0 && !abHandler.isDone()) {
System.out.println("waiting for async responses - " + i);
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
}
}
} catch (Exception ex) {
ex.printStackTrace();
assertTrue("exception making async request!!", false);
}
}
/*
Date first = new Date();
try {
stub.addEntry(name, addr, deliveryMode);
} catch (WSIFException we) {
System.out.println("Caught expected " + we);
caught = true;
}
assertTrue(caught);
Date second = new Date();
DateFormat df = DateFormat.getDateTimeInstance();
System.out.println("first date was " + df.format(first));
System.out.println("second date was " + df.format(second));
// getTime() returns milliseconds.
long firstTime = first.getTime();
long secondTime = second.getTime();
System.out.println("first time was " + firstTime);
System.out.println("second time was " + secondTime);
long timeout = WSIFProperties.getSyncTimeout();
assertTrue(firstTime<secondTime);
assertTrue((secondTime-firstTime)>timeout);
assertTrue((secondTime-firstTime)<(timeout*2));
*/
}