antelder    2002/06/10 03:23:06

  Modified:    java/test/async AsyncTest.java
               java/test wsif.test.properties
               java/src/org/apache/wsif/providers/soap/apachesoap
                        WSIFOperation_ApacheSOAP.java
               java/test/addressbook AddressBookTest.java
               java/src/org/apache/wsif/providers/soap/apacheaxis
                        WSIFOperation_ApacheAxis.java
               java/test/util WSIFTestRunner.java
               java/src/org/apache/wsif WSIFConstants.java
  Removed:     java/test/async AsyncAddressBookTest.java Stockquote.wsdl
                        AddressBook.wsdl
  Log:
  async operations and testcases to get JMS replyto from context
  
  Revision  Changes    Path
  1.4       +28 -15    xml-axis-wsif/java/test/async/AsyncTest.java
  
  Index: AsyncTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/async/AsyncTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AsyncTest.java    7 Jun 2002 10:57:12 -0000       1.3
  +++ AsyncTest.java    10 Jun 2002 10:23:05 -0000      1.4
  @@ -66,11 +66,13 @@
   import junit.textui.TestRunner;
   import org.apache.wsif.WSIFCorrelationId;
   import org.apache.wsif.WSIFMessage;
  +import org.apache.wsif.WSIFConstants;
   import org.apache.wsif.WSIFOperation;
   import org.apache.wsif.WSIFPort;
   import org.apache.wsif.WSIFService;
   import org.apache.wsif.WSIFServiceFactory;
   import org.apache.wsif.WSIFServiceImpl;
  +import org.apache.wsif.util.WSIFDefaultMessage;
   import org.apache.wsif.util.WSIFDefaultCorrelationService;
   import org.apache.wsif.util.WSIFCorrelationServiceLocator;
   import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis;
  @@ -84,7 +86,8 @@
    */
   public class AsyncTest extends TestCase {
       String wsdlLocation =
  -        TestUtilities.getWsdlPath("java\\test\\async") + "Stockquote.wsdl";
  +        TestUtilities.getWsdlPath("java\\samples\\stockquote\\wsifservice")
  +            + "Stockquote.wsdl";
   
       public AsyncTest(String name) {
           super(name);
  @@ -92,8 +95,6 @@
   
       public static void main(String[] args) {
           junit.textui.TestRunner.run(suite());
  -        //((WSIFDefaultCorrelationService)WSIFCorrelationServiceLocator.
  -        //   getCorrelationService()).shutdown(); 
       }
   
       public static Test suite() {
  @@ -104,18 +105,27 @@
           TestUtilities.setUpExtensionsAndProviders();
       }
   
  -    //public void testDefault       () { doit(null         ,null  ); }
  -    //public void testAxis          () { doit("SOAPPort"   ,"axis"); }
  -    //public void testSoap          () { doit("SOAPPort"   ,"soap"); }
  -    //public void testJava          () { doit("JavaPort"   ,"java"); }
  -    public void testSoapJms       () { if (TestUtilities.areWeTesting("jms")) 
doit("SOAPJMSPort","soap"); }
  +    public void testSoapJms() { 
  +     if (TestUtilities.areWeTesting("jms")) 
  +                 doit("SOAPJMSPort","soap"); 
  +    }
  +    
       public void testAxisJms() {
           if (TestUtilities.areWeTesting("jms"))
               doit("SOAPJMSPort", "axis");
       }
   
  +    public void testSoapJms() { 
  +     if (TestUtilities.areWeTesting("jms")) 
  +                 doit("SOAPJMSPort","soap"); 
  +    }
  +    
       private void doit(String portName, String protocol) {
   
  +        if ( !TestUtilities.areWeTesting("async") ) {
  +           return;
  +        }
  +      
           try {
               invokeMethod(
                   wsdlLocation,
  @@ -167,8 +177,13 @@
           WSIFService dpf = factory.getService(def, service, portType);
           WSIFPort port = (portName == null) ? dpf.getPort() : dpf.getPort(portName);
   
  -        JMSAsyncListener listener = new JMSAsyncListener( "AsyncReplyTo" );
  +        assertTrue( "port " + portName + " protocol " + protocol + " doesn't 
support async!",
  +                    port.supportsAsync() );
  +
           AsyncResponseHandler quoteHandler = new AsyncResponseHandler(2); // 2 async 
calls
  +        WSIFMessage context = new WSIFDefaultMessage();
  +        context.setObjectPart( WSIFConstants.CONTEXT_JMS_REPLYTO, 
  +                               TestUtilities.getWsifProperty("wsif.async.replytoq") 
);
   
           // First do an async call to get a real quote from the remote service, ie 
slow
           System.out.println(
  @@ -181,13 +196,13 @@
           //input1.setObjectPart( "symbol", "IBM" ); 
           input1.setObjectPart("symbol", "");
           
  -        input1.setObjectPart( "partJmsReplyTo", "AsyncReplyTo" );
  +        operation1.setContext( context );
   
           WSIFCorrelationId id1 =
               operation1.executeRequestResponseAsync(input1, quoteHandler);
           String id = (id1==null)? "null" : id1.getCorrelationId();
           System.out.println("IBM operation  id1=" + id );
  -/*
  +
           // Now do a sync call to get a null -1 quote, ie fast
           System.out.println(
               "Executing synchronous operation for null: " + operationName);
  @@ -205,7 +220,7 @@
           if (!ok || q3 != -1.0F) {
               assertTrue(false);
           }
  -*/
  +
           // Now do an async call to get a null -1 quote, ie fast
           System.out.println(
               "Executing asynchronous operation 2 for null: " + operationName);
  @@ -216,7 +231,7 @@
           WSIFMessage fault2 = operation2.createFaultMessage();
           input2.setObjectPart("symbol", "");
   
  -        input2.setObjectPart( "partJmsReplyTo", "AsyncReplyTo" );
  +        operation2.setContext( context );
   
           WSIFCorrelationId id2 =
               operation2.executeRequestResponseAsync(input2, quoteHandler);
  @@ -252,8 +267,6 @@
           } else {
               assertTrue(false);
           }
  -
  -             listener.stop();
   
           if ("axis".equals(protocol)) {
               WSIFServiceImpl.setDynamicWSIFProvider(
  
  
  
  1.2       +5 -2      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- wsif.test.properties      6 Jun 2002 08:28:54 -0000       1.1
  +++ wsif.test.properties      10 Jun 2002 10:23:05 -0000      1.2
  @@ -5,9 +5,12 @@
   # wsif.path=<root directory of WSIF packages> 
   wsif.path=/wsif
   #
  +# wsif.async.replytoq=<JMS q for async responses>
  +wsif.async.replytoq=AsyncReplyTo
  +#
   # wsif.test.components switches off some areas of unit test so that you can run 
   # whole suite without jms, ejb, remotewsdl (in WsdlLoadingTest) or jndi. By default,
   # all areas are on unless you explicitly turn them off.
  -# wsif.test.components=[ejb=on|off,][jms=on|off,][remotewsdl=on|off,][jndi=on|off]
  -wsif.test.components=ejb=on,jms=on,remotewsdl=on,jndi=on,fix=off
  +# 
wsif.test.components=[ejb=on|off,][jms=on|off,][remotewsdl=on|off,][jndi=on|off,][async=on|off]
  +wsif.test.components=ejb=on,jms=on,remotewsdl=on,jndi=on,fix=off,async=on
   #
  
  
  
  1.2       +23 -0     
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFOperation_ApacheSOAP.java
  
  Index: WSIFOperation_ApacheSOAP.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFOperation_ApacheSOAP.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WSIFOperation_ApacheSOAP.java     6 Jun 2002 08:28:51 -0000       1.1
  +++ WSIFOperation_ApacheSOAP.java     10 Jun 2002 10:23:05 -0000      1.2
  @@ -514,6 +514,8 @@
           call.setTargetObjectURI(getInputNamespace());
           call.setMethodName(getName());
   
  +        setTransportContext( st ); // TODO WSDL props override context???
  + 
           Vector params = new Vector();
           Object partInst;
           for (int i = 0; i < names.length; ++i) {
  @@ -1319,6 +1321,27 @@
           Tr.entry(this);
           Tr.exit(context);
           return context;
  +    }
  +
  +    /**
  +     * This sets up any context property values in the transport
  +     */
  +    private void setTransportContext(SOAPTransport t) {
  +       if ( context == null 
  +       || !(t instanceof SOAPJMSConnection) ) {
  +          return;
  +       }
  +
  +       Object o;
  +       SOAPJMSConnection st = (SOAPJMSConnection) t;
  +
  +       try {
  +          o = context.getObjectPart( WSIFConstants.CONTEXT_JMS_REPLYTO );
  +          if ( o instanceof String ) {
  +             st.setJmsProperty( WSIFConstants.JMS_REPLYTO, (String)o );
  +          }                  
  +       } catch (WSIFException ex) {} // ignore 
  +       
       }
   
       /**
  
  
  
  1.2       +63 -4     xml-axis-wsif/java/test/addressbook/AddressBookTest.java
  
  Index: AddressBookTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/addressbook/AddressBookTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AddressBookTest.java      6 Jun 2002 08:28:54 -0000       1.1
  +++ AddressBookTest.java      10 Jun 2002 10:23:05 -0000      1.2
  @@ -67,10 +67,14 @@
   import org.apache.wsif.WSIFService;
   import org.apache.wsif.WSIFServiceFactory;
   import org.apache.wsif.WSIFServiceImpl;
  +import org.apache.wsif.WSIFConstants;
  +import org.apache.wsif.WSIFCorrelationId;
  +import org.apache.wsif.util.WSIFDefaultMessage;
   import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis;
   import addressbook.wsifservice.AddressBook;
   import addressbook.wsiftypes.Address;
   import addressbook.wsiftypes.Phone;
  +import async.AsyncResponseHandler;
   import util.AddressUtility;
   import util.TestUtilities;
   
  @@ -151,10 +155,10 @@
   
           try {
               WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  -                WSIFService service = factory.getService(wsdlLocation, null, // 
serviceNS
  -                    null, // serviceName
  -                    "http://wsifservice.addressbook/";, // portTypeNS
  -                    "AddressBook"); // portTypeName
  +            WSIFService service = factory.getService(wsdlLocation, null, // 
serviceNS
  +               null, // serviceName
  +               "http://wsifservice.addressbook/";, // portTypeNS
  +               "AddressBook" ); // portTypeName
   
               AddressBook abStub = (AddressBook) service.getStub(portName, 
AddressBook.class);
   
  @@ -166,6 +170,12 @@
   
               Address resp2 = abStub.getAddressFromName(firstName2 + " " + lastName2);
               assertTrue(new AddressUtility(addr2).equals(resp2));
  +            
  +                 if (TestUtilities.areWeTesting("async")) {
  +                     testAsyncOPs( service, portName, name1, addr1 );
  +                     testAsyncOPs( service, portName, firstName2 + " " + lastName2, 
addr2 );
  +                 }
  +            
           } catch (Exception e) {
               System.err.println("AddressBookTest(" + portName + ") caught exception 
" + e);
               e.printStackTrace();
  @@ -281,4 +291,53 @@
               assertTrue(false);
           }
       }
  +
  +    private void testAsyncOPs(WSIFService service, String portName, String name, 
Address addr) {
  +       try {
  +            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", name );
  +
  +            WSIFMessage outmsg = op.createOutputMessage();
  +            WSIFMessage faultMsg = op.createFaultMessage();
  +
  +            WSIFMessage context = new WSIFDefaultMessage();
  +            context.setObjectPart( WSIFConstants.CONTEXT_JMS_REPLYTO, 
  +                                   
TestUtilities.getWsifProperty("wsif.async.replytoq") );
  +            op.setContext( context );
  +
  +            WSIFCorrelationId id = op.executeRequestResponseAsync(inMsg, abHandler);
  +            assertTrue("null correlation id returned from async request!", id != 
null );
  +
  +            int i = 10;
  +            while (i-- > 0 && !abHandler.isDone()) {
  +                System.out.println( "waiting for async responses - " + i );
  +                try {
  +                    Thread.sleep(3000);
  +                } catch (InterruptedException ex) {
  +                }
  +            }
  +            assertTrue("no response from async operation!",i > 0); // no responses 
in time
  +
  +            WSIFMessage[] faults = abHandler.getFaults();
  +            WSIFMessage[] outputs = abHandler.getOutputs();
  +            Address respAddr = (Address) outputs[0].getObjectPart("address");
  +            assertTrue("incorrect address response!", addr.equals(respAddr));
  +
  +       } catch (Exception ex) {
  +               ex.printStackTrace();
  +          assertTrue( "exception making async request!!", false );
  +       }
  +    }
  +    
   }
  
  
  
  1.3       +22 -0     
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java
  
  Index: WSIFOperation_ApacheAxis.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSIFOperation_ApacheAxis.java     7 Jun 2002 08:37:17 -0000       1.2
  +++ WSIFOperation_ApacheAxis.java     10 Jun 2002 10:23:06 -0000      1.3
  @@ -543,6 +543,8 @@
           if (names == null)
               prepare(call);
   
  +        setDestinationContext( dest ); // TODO WSDL props override context???
  +
           ArrayList objects = new ArrayList();
           for (int i = 0; i < names.length; i++) {
               Object obj = wsifmessage.getObjectPart(names[i]);
  @@ -913,6 +915,26 @@
           Tr.entry(this);
           Tr.exit(context);
           return context;
  +    }
  +
  +    /**
  +     * This sets up any context property values in the Destination
  +     */
  +    private void setDestinationContext(WSIFJMSDestination dest) {
  +       if ( context == null 
  +       || dest == null ) {
  +          return;
  +       }
  +
  +       Object o;
  +
  +       try {
  +          o = context.getObjectPart( WSIFConstants.CONTEXT_JMS_REPLYTO );
  +          if ( o instanceof String ) {
  +             dest.setProperty( WSIFConstants.JMS_REPLYTO, (String)o );
  +          }                  
  +       } catch (WSIFException ex) {} // ignore 
  +       
       }
   
       /**
  
  
  
  1.4       +15 -3     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WSIFTestRunner.java       7 Jun 2002 10:57:13 -0000       1.3
  +++ WSIFTestRunner.java       10 Jun 2002 10:23:06 -0000      1.4
  @@ -67,6 +67,7 @@
   import junit.textui.TestRunner;
   import org.apache.wsif.util.jms.JMS2HTTPBridge;
   import org.apache.wsif.util.jms.JMS2HTTPBridgeDestination;
  +import org.apache.wsif.util.jms.JMSAsyncListener;
   import org.apache.wsif.util.WSIFDefaultCorrelationService;
   import org.apache.wsif.util.WSIFCorrelationServiceLocator;
   import providers.ProvidersInitialisationTest;
  @@ -77,7 +78,6 @@
   import zipcode.ZIPCodeTest;
   
   import addressbook.AddressBookTest;
  -import async.AsyncAddressBookTest;
   import async.AsyncTest;
   import headers.HeadersTest;
   import faults.FaultMsgTest;
  @@ -119,6 +119,7 @@
           WSIFTestRunner wtr = null;
           BridgeThread jmsAb = null;
           BridgeThread jmsSq = null;
  +        JMSAsyncListener asyncListener = null; 
   
           if (TestUtilities.areWeTesting("jms")) {
               wtr = new WSIFTestRunner();
  @@ -127,6 +128,14 @@
               jmsAb.start();
               jmsSq.start();
           }
  +     if (TestUtilities.areWeTesting("async")) {
  +        try {
  +              asyncListener = 
  +                 new JMSAsyncListener( 
TestUtilities.getWsifProperty("wsif.async.replytoq") );
  +        } catch (Exception ex) {
  +           ex.printStackTrace();
  +        }
  +     } 
   
           junit.textui.TestRunner.run(suite());
   
  @@ -134,7 +143,11 @@
               jmsAb.interrupt();
           if (jmsSq != null)
               jmsSq.interrupt();
  -        
((WSIFDefaultCorrelationService)WSIFCorrelationServiceLocator.getCorrelationService()).shutdown();
  +     if (TestUtilities.areWeTesting("async")) {
  +           asyncListener.stop();
  +           ((WSIFDefaultCorrelationService)WSIFCorrelationServiceLocator.
  +              getCorrelationService()).shutdown();
  +     }
               
       }
   
  @@ -153,7 +166,6 @@
           
           suite.addTest(new TestSuite(ShoppingCartTest.class));
           suite.addTest(new TestSuite(AsyncTest.class));
  -        suite.addTest(new TestSuite(AsyncAddressBookTest.class));
           suite.addTest(new TestSuite(HeadersTest.class));
           suite.addTest(new TestSuite(FaultMsgTest.class));
           suite.addTest(new TestSuite(StockquoteTest.class));
  
  
  
  1.2       +6 -0      xml-axis-wsif/java/src/org/apache/wsif/WSIFConstants.java
  
  Index: WSIFConstants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/WSIFConstants.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WSIFConstants.java        6 Jun 2002 08:28:48 -0000       1.1
  +++ WSIFConstants.java        10 Jun 2002 10:23:06 -0000      1.2
  @@ -117,6 +117,12 @@
       public static final String CONTEXT_SOAP_HEADERS =
           "org.apache.wsif.soap.RequestHeaders";
   
  +    // WSIF context part name for JMSProperty.JMSReplyTo
  +    public static final String CONTEXT_JMS_REPLYTO = "JMSProperty.JMSReplyTo";
  +
  +    // WSIF JMS Property JMSReplyTo
  +    public static final String JMS_REPLYTO = "JMSReplyTo";
  +
       // SOAP faults WSIFMessage part name for the fault code
       public static final String SOAP_FAULT_MSG_NAME = "org.apache.wsif.soap.fault";
   
  
  
  


Reply via email to