antelder 2002/06/18 02:28:39
Modified: java/test/util wsiftestjmssetup.bat wsiftestmqsetup.bat
WSIFTestRunner.java
java/test wsif.test.properties
java/src/org/apache/wsif/util/jms
NativeJMSRequestListener.java
java/test/jms NativeJMSTest.java
Log:
Complete the native JMS provider testcases
Revision Changes Path
1.5 +1 -0 xml-axis-wsif/java/test/util/wsiftestjmssetup.bat
Index: wsiftestjmssetup.bat
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/util/wsiftestjmssetup.bat,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- wsiftestjmssetup.bat 14 Jun 2002 14:47:16 -0000 1.4
+++ wsiftestjmssetup.bat 18 Jun 2002 09:28:39 -0000 1.5
@@ -18,6 +18,7 @@
rem this should match the wsif.async.replytoq value in wsif.test.properties
echo def q(AsyncReplyTo) qu(AsyncReplyTo) >> wsiftestjmssetup.scp
+echo def q(AsyncReplyTo2) qu(AsyncReplyTo2) >> wsiftestjmssetup.scp
echo end >> wsiftestjmssetup.scp
1.5 +1 -0 xml-axis-wsif/java/test/util/wsiftestmqsetup.bat
Index: wsiftestmqsetup.bat
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/util/wsiftestmqsetup.bat,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- wsiftestmqsetup.bat 14 Jun 2002 14:47:16 -0000 1.4
+++ wsiftestmqsetup.bat 18 Jun 2002 09:28:39 -0000 1.5
@@ -16,6 +16,7 @@
rem this should match the wsif.async.replytoq value in wsif.test.properties
echo DEFINE QLOCAL('AsyncReplyTo') REPLACE >> wsiftestmqsetup.mqs
+echo DEFINE QLOCAL('AsyncReplyTo2') REPLACE >> wsiftestmqsetup.mqs
echo + Calling runmqsc in batch mode to create objects
@REM w/o queue manger - use system default queuemanager
1.6 +2 -0 xml-axis-wsif/java/test/util/WSIFTestRunner.java
Index: WSIFTestRunner.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/util/WSIFTestRunner.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WSIFTestRunner.java 12 Jun 2002 10:27:25 -0000 1.5
+++ WSIFTestRunner.java 18 Jun 2002 09:28:39 -0000 1.6
@@ -61,6 +61,7 @@
import invocation.DynamicInvokerTest;
import jms.JmsTest;
+import jms.NativeJMSTest;
import jndi.JNDIAddressBookTest;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -166,6 +167,7 @@
suite.addTest(new TestSuite(ShoppingCartTest.class));
suite.addTest(new TestSuite(AsyncTest.class));
+ suite.addTest(new TestSuite(NativeJMSTest.class));
suite.addTest(new TestSuite(HeadersTest.class));
suite.addTest(new TestSuite(FaultMsgTest.class));
suite.addTest(new TestSuite(StockquoteTest.class));
1.5 +1 -0 xml-axis-wsif/java/test/wsif.test.properties
Index: wsif.test.properties
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/wsif.test.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- wsif.test.properties 14 Jun 2002 14:47:16 -0000 1.4
+++ wsif.test.properties 18 Jun 2002 09:28:39 -0000 1.5
@@ -8,6 +8,7 @@
# wsif.async.replytoq value should match the wsiftestjmssetup and wsitestfmqsetup
bat files
# wsif.async.replytoq=<JMS q for async responses>
wsif.async.replytoq=AsyncReplyTo
+wsif.async.replytoq2=AsyncReplyTo2
#
# the nativejms properties should match the wsifjmssetup and wsifmqsetup bat files
wsif.nativejms.requestq=NativeJmsRequestQueue
1.2 +16 -25
xml-axis-wsif/java/src/org/apache/wsif/util/jms/NativeJMSRequestListener.java
Index: NativeJMSRequestListener.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/jms/NativeJMSRequestListener.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NativeJMSRequestListener.java 14 Jun 2002 14:47:16 -0000 1.1
+++ NativeJMSRequestListener.java 18 Jun 2002 09:28:39 -0000 1.2
@@ -174,19 +174,22 @@
private void processResponse(Message msg) {
System.out.println( "NativeJMSRequestListener got msg:" + msg );
try {
- String op = msg.getStringProperty( "WSDL_Operation" );
- if ( "addEntry".equals( op ) ) {
- abAddEntry( (ObjectMessage)msg );
- } else if ( "getAddressFromName".equals( op ) ) {
- Address addr = abGetAddressFromName( (ObjectMessage)msg );
- sendReply( msg, addr );
- } else if ( "getQuote".equals( op ) ) {
- float value = sqGetQuote( (ObjectMessage)msg );
- sendReply( msg, new Float( value ) );
- } else {
- System.err.println( "unknown op=" + op );
- }
+ HashMap hm = (HashMap) ((ObjectMessage)msg).getObject();
+ String name = (String)hm.get( "name" );
+ String symbol = (String)hm.get( "symbol" );
+ Address addr = (Address)hm.get( "address" );
+
+ Object reply = null;
+ if ( symbol != null ) {
+ reply = new Float( sqGetQuote( (ObjectMessage)msg ) );
+ sendReply( msg, reply );
+ } else if ( addr != null && name != null ) {
+ abAddEntry( (ObjectMessage) msg );
+ } else if ( name != null ) {
+ reply = abGetAddressFromName( (ObjectMessage) msg );
+ sendReply( msg, reply );
+ }
} catch (Exception ex) {
ex.printStackTrace();
@@ -215,20 +218,8 @@
private void sendReply(Message msg, Object response) throws Exception {
Message replyMsg = session.createObjectMessage();
((ObjectMessage)replyMsg).setObject((Serializable) response );
- String s = "WSDL_PortType_NS";
- replyMsg.setStringProperty( s, msg.getStringProperty( s ) );
- s = "WSDL_PortType_Local";
- replyMsg.setStringProperty( s, msg.getStringProperty( s ) );
- s = "WSDL_Operation";
- replyMsg.setStringProperty( s, msg.getStringProperty( s ) );
- s = "WSDL_Input";
- replyMsg.setStringProperty( s, msg.getStringProperty( s ) );
- s = "WSDL_Output";
- replyMsg.setStringProperty( s, msg.getStringProperty( s ) );
String replyq =
((Queue)msg.getJMSReplyTo()).getQueueName().substring( 9 );
- String id = msg.getJMSMessageID();
- replyMsg.setJMSCorrelationID( id );
WSIFJMSDestination dest = new WSIFJMSDestination(
new WSIFJMSFinderForJndi(null,
@@ -238,7 +229,7 @@
queueConnectionFactory,
replyq )
);
- dest.send( replyMsg, id );
+ dest.send( replyMsg, msg.getJMSMessageID() );
}
}
1.2 +177 -66 xml-axis-wsif/java/test/jms/NativeJMSTest.java
Index: NativeJMSTest.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/jms/NativeJMSTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NativeJMSTest.java 14 Jun 2002 14:47:16 -0000 1.1
+++ NativeJMSTest.java 18 Jun 2002 09:28:39 -0000 1.2
@@ -76,6 +76,7 @@
import org.apache.wsif.providers.jms.*;
import util.TestUtilities;
+import async.AsyncResponseHandler;
import com.ibm.mq.jms.MQQueueConnectionFactory;
@@ -128,24 +129,26 @@
if ( nativeReqListener != null ) nativeReqListener.stop();
}
- public void testStockQuote() { StockQuote(); }
- //public void testAddressBook() {
- // AddressBook_addEntry();
- // AddressBook_getAddressFromName();
- //}
+ //public void testStockQuote() {
+ // StockQuote();
+ //}
+
+ public void testAddressBook() {
+ AddressBook_addEntry();
+ AddressBook_getAddressFromName();
+ }
/**
* Query Stockquote sample
*/
public void StockQuote() {
- String portType = "Stockquote";
+ String portType = "StockquotePT";
String portName = "NativeJmsPort";
String operationName = "getQuote";
String wsdlLocation =
- TestUtilities.getWsdlPath("java\\samples\\stockquote\\wsifservice")
- + "Stockquote.wsdl";
+ TestUtilities.getWsdlPath("java\\samples\\stockquote\\wsifservice") +
"StockQuote.wsdl";
System.out.println("\n=== StockQuote");
try {
@@ -153,12 +156,12 @@
WSIFService service = factory.getService(wsdlLocation,
null, // serviceNS
null, // serviceName
- null,
-// "http://www.ibm.com/namespace/wsif/samples/stockquote", //
portTypeNS
+ "http://wsifservice.stockquote/", // portTypeNS
portType); // portTypeName
WSIFPort port = service.getPort(portName);
+ // Executing synchronous executeRequestResponseOperation(input, output, fault
)
WSIFOperation operation = port.createOperation(operationName);
WSIFMessage context = new WSIFDefaultMessage();
@@ -173,28 +176,50 @@
WSIFMessage output = operation.createOutputMessage();
WSIFMessage fault = operation.createFaultMessage();
- System.out.println(
- "Executing executeRequestResponseAsync operation put: " + operationName);
+ doSyncOp( operation, input, output, context );
+ float value = ((Float)output.getObjectPart( "quote" )).floatValue();
+ System.out.println("sync stockquote found value = " + value);
+ assertTrue( "doSyncOp stockquote value incorrect!",
+ value == -1.0F );
+
+ // Executing executeRequestResponseAsync(input, handler)
+ operation = port.createOperation(operationName);
+
+ operation.setContext( context );
+
+ input = operation.createInputMessage();
+ input.setName("GetQuoteInput");
+ input.setObjectPart("symbol", "" );
+
+ output = doAsyncOp( operation, input, context );
+ value = ((Float)output.getObjectPart( "quote" )).floatValue();
+ System.out.println("async stockquote found value = " + value);
+ assertTrue( "doAsyncOp stockquote value incorrect!",
+ value == -1.0F );
+
+ // Executing executeRequestResponseAsync(input)
+ operation = port.createOperation(operationName);
+
+ operation.setContext( context );
+
+ input = operation.createInputMessage();
+ input.setName("GetQuoteInput");
+ input.setObjectPart("symbol", "" );
+
+ output = doAsyncOpNoHandler( operation, input, context );
+ value = ((Float)output.getObjectPart( "quote" )).floatValue();
+ System.out.println("async stockquote found value = " + value);
+ assertTrue( "doAsyncOpNoHandler stockquote value incorrect!",
+ value == -1.0F );
- try {
- boolean ok = operation.executeRequestResponseOperation(input, output,
fault );
- System.out.println("Sent req ok=" + ok );
- float value = ((Float)output.getObjectPart( "quote" )).floatValue();
- System.out.println("Found value = " + value);
- assertTrue( value == -1.0F );
- } catch (Exception ex) {
- ex.printStackTrace();
- }
} catch (Exception e) {
- System.err.println("StockQuote (" + portName + ") caught exception " + e);
e.printStackTrace();
- assertTrue(false);
+ assertTrue("exception during stockquote test: " + e.getMessage(), false);
}
-
}
/**
- * AddressBook sample
+ * AddressBook sample - addEntry
*/
public void AddressBook_addEntry() {
@@ -203,8 +228,8 @@
String operationName = "addEntry";
String wsdlLocation =
- TestUtilities.getWsdlPath("java\\samples\\addressbook\\wsifservice")
- + "AddressBook.wsdl";
+ TestUtilities.getWsdlPath("java\\samples\\addressbook\\wsifservice")
+ + "AddressBook.wsdl";
System.out.println("\n=== AddressBook_addEntry");
@@ -213,39 +238,29 @@
WSIFService service = factory.getService(wsdlLocation,
null, // serviceNS
null, // serviceName
- null,
-// "http://www.ibm.com/namespace/wsif/samples/ab", // portTypeNS
+ "http://wsifservice.addressbook/", // portTypeNS
portType); // portTypeName
WSIFPort port = service.getPort(portName);
- /**
- * add address
- */
- // invoke send request
WSIFOperation operation = port.createOperation(operationName);
- WSIFMessage context = new WSIFDefaultMessage();
- context.setObjectPart( WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo",
-
TestUtilities.getWsifProperty("wsif.nativejms.responseq") );
- operation.setContext( context );
-
WSIFMessage input = operation.createInputMessage();
input.setObjectPart("name", name1);
input.setObjectPart("address", addr1);
operation.executeInputOnlyOperation(input);
- System.out.println("Put message.....: '" + name1 + "'");
+
} catch (Exception e) {
- System.err.println("AddressBookTest(" + portName + ") caught exception " + e);
e.printStackTrace();
- assertTrue(false);
+ assertTrue("exception during addressbook addEntry: " + e.getMessage(),
+ false);
}
}
/**
- * AddressBook
+ * AddressBook sample - getAddressFromName
*/
public void AddressBook_getAddressFromName() {
@@ -254,8 +269,8 @@
String operationName = "getAddressFromName";
String wsdlLocation =
- TestUtilities.getWsdlPath("java\\samples\\addressbook\\wsifservice")
- + "AddressBook.wsdl";
+ TestUtilities.getWsdlPath("java\\samples\\addressbook\\wsifservice")
+ + "AddressBook.wsdl";
System.out.println("\n=== AddressBook_getAddressFromName");
@@ -264,12 +279,12 @@
WSIFService service = factory.getService(wsdlLocation,
null, // serviceNS
null, // serviceName
- null,
-// "http://www.ibm.com/namespace/wsif/samples/ab", // portTypeNS
+ "http://wsifservice.addressbook/", // portTypeNS
portType); // portTypeName
WSIFPort port = service.getPort(portName);
+ // Executing synchronous executeRequestResponseOperation(input, output, fault
)
String inputMsgName = "GetAddressFromNameRequest";
String outputMsgName = "GetAddressFromNameResponse";
WSIFOperation operation =
@@ -281,38 +296,134 @@
operation.setContext( context );
WSIFMessage input = operation.createInputMessage();
+ input.setObjectPart("name", name1);
+
WSIFMessage output = operation.createOutputMessage();
WSIFMessage fault = operation.createFaultMessage();
- input.setObjectPart("name", name1);
- System.out.println(
- "Executing executeRequestResponseAsync operation put: "
- + operationName
- + ":"
- + inputMsgName
- + ":"
- + outputMsgName);
-
- Object correlId = null;
- try {
- boolean ok = operation.executeRequestResponseOperation(input, output, fault );
- System.out.println("Sent req ok=" + ok );
+ doSyncOp( operation, input, output, context );
+
Address addressResponse = (Address) output.getObjectPart("address");
System.out.println("Found address = " + addressResponse);
+ assertTrue( "doSyncOp addresses not equal!", addr1.equals(addressResponse) );
- assertTrue( addr1.equals(addressResponse) );
- } catch (Exception ex) {
- ex.printStackTrace();
- }
+ // Executing executeRequestResponseOperation(input, output, fault )
+ operation =
+ port.createOperation(operationName, inputMsgName, outputMsgName);
+
+ operation.setContext( context );
+
+ input = operation.createInputMessage();
+ input.setObjectPart("name", name1);
+
+ output = operation.createOutputMessage();
+
+ output = doAsyncOp( operation, input, context );
+
+ addressResponse = (Address) output.getObjectPart("address");
+ System.out.println("Found address = " + addressResponse);
+ assertTrue( "doAsyncOp addresses not equal!", addr1.equals(addressResponse) );
+
+ // Executing executeRequestResponseAsync(input)
+ operation =
+ port.createOperation(operationName, inputMsgName, outputMsgName);
- System.out.println("output=" + output );
+ operation.setContext( context );
+
+ input = operation.createInputMessage();
+ input.setObjectPart("name", name1);
+
+ output = doAsyncOpNoHandler( operation, input, context );
+ addressResponse = (Address) output.getObjectPart("address");
+ System.out.println("Found address = " + addressResponse);
+ assertTrue( "doAsyncOpNoHandler addresses not equal!",
addr1.equals(addressResponse) );
} catch (Exception e) {
- System.err.println("AddressBook (" + portName + ") caught exception " + e);
e.printStackTrace();
- assertTrue(false);
+ assertTrue("exception during addressbook getAddressFromName test: " +
e.getMessage(), false);
}
+ }
+
+ private void doSyncOp(WSIFOperation op,
+ WSIFMessage input, WSIFMessage output, WSIFMessage
context) {
+ try {
+ op.setContext( context );
+ WSIFMessage fault = op.createFaultMessage();
+ boolean ok = op.executeRequestResponseOperation(input, output, fault );
+ assertTrue( "executeRequestResponseOperation returned false!", ok );
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ assertTrue( "exception executing request: " + ex.getMessage(), false );
+ }
+ }
+
+ private WSIFMessage doAsyncOp(WSIFOperation op, WSIFMessage input, WSIFMessage
context) {
+ AsyncResponseHandler handler = new AsyncResponseHandler(1); // 2 async calls
+ try {
+ context.setObjectPart( WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo",
+
TestUtilities.getWsifProperty("wsif.async.replytoq") );
+ op.setContext( context );
+ WSIFCorrelationId id = op.executeRequestResponseAsync(input, handler);
+ System.out.println( "async operation done, correlation id=" +
id.getCorrelationId() );
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ assertTrue( "exception executing async op: " + ex.getMessage(), false );
+ }
+ int i = 5; // 15 seconds timout
+ while ( i-- > 0 && !handler.isDone() ) {
+ System.out.println( "async requests sent, waiting for responses - " + i );
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException ex) {}
+ }
+ assertTrue( "no response to async operation!", i > 0 ); // no responses in
time
+ return handler.getOutputs()[0];
+ }
+
+ private WSIFMessage doAsyncOpNoHandler(WSIFOperation op, WSIFMessage input,
WSIFMessage context) {
+ WSIFMessage output = null;
+ try {
+ context.setObjectPart( WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo",
+
TestUtilities.getWsifProperty("wsif.async.replytoq2") );
+ context.setObjectPart( "testJMSnoHandler", "true" );
+ op.setContext( context );
+ WSIFCorrelationId id = op.executeRequestResponseAsync( input );
+ System.out.println( "async operation done, correlation id=" +
id.getCorrelationId() );
+ op = null;
+
+ Object jmsResponse = getJMSResponse( id.getCorrelationId() );
+ WSIFCorrelationService cs =
+ WSIFCorrelationServiceLocator.getCorrelationService();
+ Object o;
+ synchronized( cs ) {
+ o = cs.get( id );
+ }
+ if ( o != null && o instanceof WSIFOperation ) {
+ cs.remove( id );
+ op = (WSIFOperation)o;
+ } else {
+ assertTrue( "stored correlation object not as expected: " + o, false );
+ }
+ output = op.createOutputMessage();
+ WSIFMessage fault = op.createFaultMessage();
+ op.processAsyncResponse( jmsResponse, output, fault );
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ assertTrue( "exception executing async op: " + ex.getMessage(), false );
+ }
+ return output;
+ }
+
+ private Message getJMSResponse(String id) throws JMSException {
+ QueueConnectionFactory factory = new MQQueueConnectionFactory();
+ MQQueueConnectionFactory mqfactory = (MQQueueConnectionFactory) factory;
+ QueueConnection connection = factory.createQueueConnection();
+ connection.start();
+ QueueSession session = connection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
+ Queue readQ = session.createQueue(
TestUtilities.getWsifProperty("wsif.async.replytoq2") );
+ QueueReceiver receiver = session.createReceiver( readQ,
"JMSCorrelationID='"+id+"'" );
+ return receiver.receive( WSIFProperties.getAsyncTimeout() );
}
}