whitlock    2002/10/10 07:51:44

  Modified:    java/src/org/apache/wsif/wsdl/extensions/jms
                        JMSFaultPropertySerializer.java
                        JMSFaultProperty.java JMSPropertySerializer.java
               java/test/jms JmsFaultTest.java JmsFault.wsdl
               java/src/org/apache/wsif/providers/jms JMSFormatter.java
                        WSIFOperation_Jms.java
               java/test/util TestUtilities.java
               java/src/org/apache/wsif/util/jms WSIFJMSDestination.java
                        WSIFJMSProperties.java
               java/test/async AsyncTests.java
               java/test/org/apache/wsif/util/jms
                        NativeJMSRequestListener.java
  Log:
  Fix NativeJms faults, fault properties and output properties
  
  Revision  Changes    Path
  1.2       +12 -0     
xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSFaultPropertySerializer.java
  
  Index: JMSFaultPropertySerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSFaultPropertySerializer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JMSFaultPropertySerializer.java   7 Oct 2002 15:25:51 -0000       1.1
  +++ JMSFaultPropertySerializer.java   10 Oct 2002 14:51:43 -0000      1.2
  @@ -133,6 +133,13 @@
                   pw);
           }
   
  +        if (jmsFaultProperty.getPart() != null) {
  +            DOMUtils.printAttribute(
  +                JMSConstants.ATTR_PART,
  +                jmsFaultProperty.getPart(),
  +                pw);
  +        }
  +
           Boolean required = extension.getRequired();
           if (required != null) {
               DOMUtils.printQualifiedAttribute(
  @@ -204,6 +211,11 @@
           String value = DOMUtils.getAttribute(el, JMSConstants.ATTR_VALUE);
           if (value != null) {
               jmsFaultProperty.setValue(value);
  +        }
  +
  +        String part = DOMUtils.getAttribute(el, JMSConstants.ATTR_PART);
  +        if (part != null) {
  +            jmsFaultProperty.setPart(part);
           }
   
           Trc.exit(jmsFaultProperty);
  
  
  
  1.2       +18 -0     
xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSFaultProperty.java
  
  Index: JMSFaultProperty.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSFaultProperty.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JMSFaultProperty.java     7 Oct 2002 15:25:51 -0000       1.1
  +++ JMSFaultProperty.java     10 Oct 2002 14:51:43 -0000      1.2
  @@ -77,6 +77,7 @@
       protected String fieldName;
       protected QName fieldType;
       protected String fieldValue;
  +    protected String fieldPart;
   
       /**
        * @see ExtensibilityElement#setElementType(QName)
  @@ -154,6 +155,22 @@
           this.fieldValue = value;
       }
   
  +    /**
  +     * Gets the Part
  +     * @return Returns a String
  +     */
  +    public String getPart() {
  +        return fieldPart;
  +    }
  +    
  +    /**
  +     * Sets the Part
  +     * @param fieldPart The Part to set
  +     */
  +    public void setPart(String part) {
  +        this.fieldPart = part;
  +    }
  +
       public String toString() {
           StringBuffer strBuf = new StringBuffer(super.toString());
   
  @@ -163,6 +180,7 @@
           strBuf.append("\nname=" + fieldName);
           strBuf.append("\ntype=" + fieldType);
           strBuf.append("\nvalue=" + fieldValue);
  +        strBuf.append("\npart=" + fieldPart);
           return strBuf.toString();
       }
   }
  
  
  
  1.4       +13 -0     
xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSPropertySerializer.java
  
  Index: JMSPropertySerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSPropertySerializer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JMSPropertySerializer.java        19 Jul 2002 15:46:28 -0000      1.3
  +++ JMSPropertySerializer.java        10 Oct 2002 14:51:43 -0000      1.4
  @@ -158,6 +158,19 @@
               javax.wsdl.BindingOutput.class,
               JMSConstants.Q_ELEM_JMS_PROPERTY,
               JMSProperty.class);
  +
  +        registry.registerSerializer(
  +            javax.wsdl.BindingFault.class,
  +            JMSConstants.Q_ELEM_JMS_PROPERTY,
  +            this);
  +        registry.registerDeserializer(
  +            javax.wsdl.BindingFault.class,
  +            JMSConstants.Q_ELEM_JMS_PROPERTY,
  +            this);
  +        registry.mapExtensionTypes(
  +            javax.wsdl.BindingFault.class,
  +            JMSConstants.Q_ELEM_JMS_PROPERTY,
  +            JMSProperty.class);
           Trc.exit();
       }
   
  
  
  
  1.3       +177 -16   xml-axis-wsif/java/test/jms/JmsFaultTest.java
  
  Index: JmsFaultTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/jms/JmsFaultTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JmsFaultTest.java 9 Oct 2002 11:52:11 -0000       1.2
  +++ JmsFaultTest.java 10 Oct 2002 14:51:43 -0000      1.3
  @@ -63,6 +63,8 @@
   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;
  @@ -78,6 +80,9 @@
   public class JmsFaultTest extends TestCase {
       String wsdlLocation = TestUtilities.getWsdlPath("java\\test\\jms") + 
"jmsfault.wsdl";
   
  +    private static final boolean ASYNC = true;
  +    private static final boolean SYNC = true;
  +
       public JmsFaultTest(String name) {
           super(name);
       }
  @@ -96,35 +101,152 @@
           TestUtilities.setUpExtensionsAndProviders();
       }
   
  -    public void testNoFault() {
  -        doit("throwSimple", 0, false, null, null);
  +    public void testNoFaultSync() {
  +        doit("throwSimple", 0, false, null, null, SYNC);
  +    }
  +
  +    public void testSimpleSync() {
  +        doit(
  +            "throwSimple",
  +            1,
  +            false,
  +            new String[] { "faultText" },
  +            new Object[] { "A Simple Fault" }, SYNC);
  +    }
  +
  +    public void testIntsSync() {
  +        doit(
  +            "throwSimple",
  +            2,
  +            false,
  +            new String[] { "faultInt1", "faultInt2", "faultInt3" },
  +            new Object[] { new Integer(1), new Integer(2), new Integer(3)}, SYNC);
  +    }
  +
  +    public void testTwoIntsSync() {
  +        doit(
  +            "throwSimple",
  +            3,
  +            false,
  +            new String[] { "faultInt1", "faultInt2" },
  +            new Object[] { new Integer(1), new Integer(2) }, SYNC);
  +    }
  +
  +    public void testEmptyJmsFaultSync() {
  +        doit(
  +            "throwSimple",
  +            2,
  +            false,
  +            new String[] { "faultInt1", "faultInt2", "faultInt3" },
  +            new Object[] { new Integer(1), new Integer(2), new Integer(3)}, SYNC);
  +    }
  +
  +    public void testIndicIntSync() {
  +        doit(
  +            "throwIndicInt",
  +            4,
  +            false,
  +            new String[] { "faultText" },
  +            new Object[] { "A Simple Fault" }, SYNC);
  +    }
  +
  +    public void testNoFaultAltSync() {
  +        doit("throwSimple", 5, false, null, null, SYNC);
  +    }
  +
  +    public void testFaultIndicPropSync() {
  +        doit(
  +            "throwProperties",
  +            6,
  +            false,
  +            new String[] { "faultText", "faultIndic" },
  +            new Object[] { "A Fault Indicator", new Byte((byte) - 1)}, SYNC);
  +    }
  +
  +    public void testJmsPropFaultSync() {
  +        doit(
  +            "throwProperties",
  +            7,
  +            false,
  +            new String[] { "faultText", "faultIndic", "faultProp" },
  +            new Object[] {
  +                "Another Property Fault",
  +                new Byte((byte) - 2),
  +                "Another JMS Property" }, SYNC);
  +    }
  +
  +    public void testNoFaultAsync() {
  +        doit("throwSimple", 0, false, null, null, ASYNC);
       }
   
  -    public void testSimple() {
  +    public void testSimpleAsync() {
           doit(
               "throwSimple",
               1,
               false,
               new String[] { "faultText" },
  -            new Object[] { "A Simple Fault" });
  +            new Object[] { "A Simple Fault" }, ASYNC);
       }
   
  -    public void testInts() {
  +    public void testIntsAsync() {
           doit(
               "throwSimple",
               2,
               false,
               new String[] { "faultInt1", "faultInt2", "faultInt3" },
  -            new Object[] { new Integer(1), new Integer(2), new Integer(3)});
  +            new Object[] { new Integer(1), new Integer(2), new Integer(3)}, ASYNC);
       }
   
  -    public void testTwoInts() {
  +    public void testTwoIntsAsync() {
           doit(
               "throwSimple",
               3,
               false,
               new String[] { "faultInt1", "faultInt2" },
  -            new Object[] { new Integer(1), new Integer(2) });
  +            new Object[] { new Integer(1), new Integer(2) }, ASYNC);
  +    }
  +
  +    public void testEmptyJmsFaultAsync() {
  +        doit(
  +            "throwSimple",
  +            2,
  +            false,
  +            new String[] { "faultInt1", "faultInt2", "faultInt3" },
  +            new Object[] { new Integer(1), new Integer(2), new Integer(3)}, ASYNC);
  +    }
  +
  +    public void testIndicIntAsync() {
  +        doit(
  +            "throwIndicInt",
  +            4,
  +            false,
  +            new String[] { "faultText" },
  +            new Object[] { "A Simple Fault" }, ASYNC);
  +    }
  +
  +    public void testNoFaultAltAsync() {
  +        doit("throwSimple", 5, false, null, null, ASYNC);
  +    }
  +
  +    public void testFaultIndicPropAsync() {
  +        doit(
  +            "throwProperties",
  +            6,
  +            false,
  +            new String[] { "faultText", "faultIndic" },
  +            new Object[] { "A Fault Indicator", new Byte((byte) - 1)}, ASYNC);
  +    }
  +
  +    public void testJmsPropFaultAsync() {
  +        doit(
  +            "throwProperties",
  +            7,
  +            false,
  +            new String[] { "faultText", "faultIndic", "faultProp" },
  +            new Object[] {
  +                "Another Property Fault",
  +                new Byte((byte) - 2),
  +                "Another JMS Property" }, ASYNC);
       }
   
       private void doit(
  @@ -132,7 +254,8 @@
           int choice,
           boolean exceptionExpected,
           String[] names,
  -        Object[] parts) {
  +        Object[] parts,
  +        boolean blocks) {
                
           if (!TestUtilities.areWeTesting("jms"))
               return;
  @@ -155,11 +278,40 @@
               WSIFMessage outputMessage = operation.createOutputMessage();
               WSIFMessage faultMessage = operation.createFaultMessage();
   
  -            boolean operationSucceeded =
  -                operation.executeRequestResponseOperation(
  -                    inputMessage,
  -                    outputMessage,
  -                    faultMessage);
  +            boolean operationSucceeded = false;
  +            if (blocks == SYNC) {
  +                operationSucceeded =
  +                    operation.executeRequestResponseOperation(
  +                        inputMessage,
  +                        outputMessage,
  +                        faultMessage);
  +
  +            } else if (blocks == ASYNC) {
  +                WSIFMessage context = null;
  +                context.setObjectPart(
  +                    WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo",
  +                    TestUtilities.getWsifProperty("wsif.async.replytoq2"));
  +                operation.setContext(context);
  +
  +                WSIFCorrelationId id =
  +                    operation.executeRequestResponseAsync(inputMessage);
  +                System.out.println(
  +                    "async operation done, correlation id="
  +                        + id.getCorrelationId());
  +
  +                Object jmsResponse =
  +                    TestUtilities.getJMSAsyncResponse(
  +                        id.getCorrelationId(),
  +                        TestUtilities.getWsifProperty("wsif.async.replytoq2"));
  +
  +                operationSucceeded =
  +                    operation.processAsyncResponse(
  +                        jmsResponse,
  +                        outputMessage,
  +                        faultMessage);
  +
  +            } else
  +                assertTrue(false);
   
               System.out.println(
                   "JmsFaultTest "
  @@ -170,6 +322,7 @@
                       + (names == null));
   
               assertTrue(
  +                "Bad boolean success value from executeRequestReponseOperation",
                   (operationSucceeded && (names == null))
                       || (!operationSucceeded && (names != null)));
                       
  @@ -180,11 +333,19 @@
                       it.next();
                       i++;
                   }
  -                assertTrue(i == names.length);
  +                assertTrue(
  +                    "Bad number of parts in the fault message expected="
  +                        + names.length
  +                        + " got="
  +                        + i,
  +                    i == names.length);
   
                   for (i = 0; i < names.length; i++) {
                       Object o = faultMessage.getObjectPart(names[i]);
  -                    assertTrue(parts[i].equals(o));
  +
  +                    assertTrue(
  +                        "Bad value for partName=" + names[i] + " " + o,
  +                        parts[i].equals(o));
                   }
               }
               
  
  
  
  1.3       +58 -6     xml-axis-wsif/java/test/jms/JmsFault.wsdl
  
  Index: JmsFault.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/jms/JmsFault.wsdl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JmsFault.wsdl     9 Oct 2002 11:52:11 -0000       1.2
  +++ JmsFault.wsdl     10 Oct 2002 14:51:43 -0000      1.3
  @@ -24,6 +24,12 @@
       <part name="faultInt3" type="xsd:int"/>
     </message>
   
  +  <message name="IndicPropFault">
  +    <part name="faultIndic" type="xsd:byte"/>
  +    <part name="faultProp" type="xsd:string"/>
  +    <part name="faultText" type="xsd:string"/>
  +  </message>
  +  
     <!-- port type declns -->
     <portType name="JmsFault">
       <operation name="throwSimple">
  @@ -32,17 +38,23 @@
         <fault name="SimpleFault" message="tns:SimpleFault"/>
         <fault name="IntFault" message="tns:IntFault"/>
         <fault name="TwoIntFault" message="tns:IntFault"/>
  +      <fault name="EmptyJmsFault" message="tns:IntFault"/>
  +    </operation>
  +    <operation name="throwIndicInt">
  +      <input message="tns:SimpleReq"/>
  +      <output message="tns:SimpleResp"/>
  +      <fault name="SimpleFault" message="tns:SimpleFault"/>
  +    </operation>
  +    <operation name="throwProperties">
  +      <input message="tns:SimpleReq"/>
  +      <output message="tns:SimpleResp"/>
  +      <fault name="IndicPropFault" message="tns:IndicPropFault"/>
  +      <fault name="JmsPropFault" message="tns:IndicPropFault"/>
       </operation>
     </portType>
   
     <!--
     A todo list of other tests that should be included here ...
  -  - <jms:property in the <fault - need to implement output properties
  -  - <jms:fault included/excluded in the <fault
  -  - multiple <fault's as in a switch
  -  - parts="xxx" included/excluded in the <jms:fault
  -  - different types for the <jms:faultProperty
  -  - the jms property's value does not match a <jms:faultProperty is not an exception
     - async and sync
     - <fault with and without name="xxx"
     - <fault with and without message="xxx" (don't really know what that means)
  @@ -93,6 +105,46 @@
             <jms:faultProperty name="faultIndicator" type="xsd:string" 
value="twoints"/>
           </jms:faultIndicator>
           <jms:fault parts="faultInt1 faultInt2"/>
  +      </fault>
  +      <fault name="EmptyJmsFault">
  +        <jms:faultIndicator type="property">
  +          <jms:faultProperty name="faultIndicator" type="xsd:string" value="ints"/>
  +        </jms:faultIndicator>
  +        <jms:fault/>
  +      </fault>
  +    </operation>
  +    <operation name="throwIndicInt">
  +      <input/>
  +      <output/>
  +      <fault name="SimpleFault">
  +        <jms:faultIndicator type="property">
  +          <jms:faultProperty name="faultIndicator" type="xsd:int" value="43"/>
  +        </jms:faultIndicator>
  +      </fault>
  +    </operation>
  +    <operation name="throwProperties">
  +      <input/>
  +      <output/>
  +      <fault name="IndicPropFault">
  +        <jms:faultIndicator type="property">
  +          <jms:faultProperty name="faultIndicator" 
  +                             type="xsd:byte" 
  +                             value="-1" 
  +                             part="faultIndic"/>
  +        </jms:faultIndicator>
  +        <jms:fault parts="faultText"/>
  +      </fault>
  +      <fault name="JmsPropFault">
  +        <jms:faultIndicator type="property">
  +          <jms:faultProperty name="faultIndicator" 
  +                             type="xsd:byte" 
  +                             value="-2" 
  +                             part="faultIndic"/>
  +        </jms:faultIndicator>
  +        <jms:property name="anotherProperty" 
  +                      type="xsd:string" 
  +                      part="faultProp"/>
  +        <jms:fault parts="faultText"/>
         </fault>
       </operation>
     </binding>
  
  
  
  1.10      +13 -8     
xml-axis-wsif/java/src/org/apache/wsif/providers/jms/JMSFormatter.java
  
  Index: JMSFormatter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/JMSFormatter.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JMSFormatter.java 9 Oct 2002 11:52:11 -0000       1.9
  +++ JMSFormatter.java 10 Oct 2002 14:51:43 -0000      1.10
  @@ -101,6 +101,7 @@
       private String reqOpName;
       private String reqInputName;
       private String reqOutputName;
  +    private BindingFault lastBindingFault = null;
   
       /**
        * Constructor for JMSFormatter
  @@ -460,6 +461,7 @@
   
                               resp.setOutgoingMessage(msg);
                               resp.setIsFault(true);
  +                            lastBindingFault = bndF;
                               Trc.exit(true);
                               return true;
                           }
  @@ -510,27 +512,24 @@
                   || fProp.getValue() == null)
                   continue;
   
  -            String propValue = null;
  +            Object propValue = null;
               try {
                   if (!out.propertyExists(propName))
                       continue;
   
  -                // Need to sort out the type here ???
  -                // NativeJms propertyValues also ignore the type ???
  -                // We assume the type is a string. This is a HACK.
  -
  -                propValue = out.getStringProperty(propName);
  +                propValue = out.getObjectProperty(propName);
               } catch (JMSException je) {
                   Trc.ignoredException(je);
                   continue;
               }
   
  -            if (propValue != null && propValue.equals(fProp.getValue())) {
  +            if (propValue != null
  +                && fProp.getValue().equals(propValue.toString())) {
                   Trc.exit(true);
                   return true;
               }
  -
           }
  +
           Trc.exit(false);
           return false;
       }
  @@ -652,6 +651,12 @@
   
       private void setOutputName(String s) {
          reqOutputName = s;
  +    }
  +    
  +    public BindingFault getLastBindingFault() {
  +        Trc.entry(this);
  +        Trc.exit(lastBindingFault);
  +        return lastBindingFault;
       }
   
   }
  
  
  
  1.31      +77 -26    
xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java
  
  Index: WSIFOperation_Jms.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- WSIFOperation_Jms.java    9 Oct 2002 11:52:11 -0000       1.30
  +++ WSIFOperation_Jms.java    10 Oct 2002 14:51:43 -0000      1.31
  @@ -63,6 +63,7 @@
   import java.util.List;
   import java.util.Map;
   
  +import javax.wsdl.BindingFault;
   import javax.wsdl.BindingInput;
   import javax.wsdl.BindingOperation;
   import javax.wsdl.BindingOutput;
  @@ -96,6 +97,8 @@
   import org.apache.wsif.wsdl.extensions.jms.JMSAddress;
   import org.apache.wsif.wsdl.extensions.jms.JMSBinding;
   import org.apache.wsif.wsdl.extensions.jms.JMSConstants;
  +import org.apache.wsif.wsdl.extensions.jms.JMSFaultIndicator;
  +import org.apache.wsif.wsdl.extensions.jms.JMSFaultProperty;
   import org.apache.wsif.wsdl.extensions.jms.JMSInput;
   import org.apache.wsif.wsdl.extensions.jms.JMSOutput;
   import org.apache.wsif.wsdl.extensions.jms.JMSProperty;
  @@ -479,15 +482,19 @@
           WSIFMessage output,
           WSIFMessage fault)
           throws WSIFException {
  +        Trc.entry(this, responseObject, output, fault);
   
           if (!(responseObject instanceof javax.jms.Message))
  -                throw new WSIFException("Object is not of type javax.jms.Message");
  +            throw new WSIFException("Object is not of type javax.jms.Message");
   
           WSIFResponse resp =
               formatter.unformatResponse((javax.jms.Message) responseObject);
   
           if (resp.getIsFault()) {
               formatter.copyTo(resp.getOutgoingMessage(), fault);
  +            setFaultProperties(fault,formatter.getLastBindingFault());
  +
  +            Trc.exit(false);
               return false;
           } else {
   
  @@ -505,17 +512,15 @@
                       wsdlOutputParts.remove(partName);
                   }
               }
  +
               for (Iterator i = wsdlOutputParts.iterator(); i.hasNext();) {
                   output.setObjectPart((String) i.next(), null);
               }
  +
  +            setOutProperties(output);
  +            Trc.exit(true);
               return true;
           }
  -
  -        /**
  -         * Need to retrieve the header, property values from the JMS Message and 
assign them to WSIFMessage
  -         */
  -             //setOutProperties( jmsDest, output ); TODO output properties
  -
       }
   
       /**
  @@ -524,19 +529,21 @@
        * the property that part is for. 
        */
       private HashMap getPropertyParts() {
  -     HashMap propertyParts = new HashMap();
  -     
  -     // the input message properties
  -     if ( fieldInputJmsProperties != null ) {
  -        for (Iterator i=fieldInputJmsProperties.keySet().iterator();i.hasNext(); ) {
  -               String propertyName = (String)i.next();
  -               propertyParts.put(
  -                  propertyName,
  -                  fieldInputJmsProperties.get( propertyName ) );
  -        }
  -     }
  -     
  -     return propertyParts;
  +        HashMap propertyParts = new HashMap();
  +
  +        // the input message properties
  +        if (fieldInputJmsProperties != null) {
  +            for (Iterator i = fieldInputJmsProperties.keySet().iterator();
  +                i.hasNext();
  +                ) {
  +                String propertyName = (String) i.next();
  +                propertyParts.put(
  +                    propertyName,
  +                    fieldInputJmsProperties.get(propertyName));
  +            }
  +        }
  +
  +        return propertyParts;
       }
   
       private void setPropertyValues() {
  @@ -602,17 +609,14 @@
        */
       private void setOutProperties(WSIFMessage output) {
   
  -        String partName;
  -        String propertyName;
  -        String propertyValue;
           if (output != null && fieldOutputProperties != null) {
               for (Iterator i = fieldOutputProperties.keySet().iterator();
                   i.hasNext();
                   ) {
  -                partName = (String) i.next();
  -                propertyName = (String) fieldOutputProperties.get(partName);
  +                String partName = (String) i.next();
  +                String propertyName = (String) fieldOutputProperties.get(partName);
                   try {
  -                    propertyValue = (String) jmsDest.getProperty(propertyName);
  +                    Object propertyValue = jmsDest.getProperty(propertyName);
                       output.setObjectPart(partName, propertyValue);
                   } catch (WSIFException ex) {
                       Trc.ignoredException(ex);
  @@ -621,6 +625,53 @@
           }
       }
   
  +    private void setFaultProperties(
  +        WSIFMessage fault,
  +        BindingFault bindingFault) {
  +
  +        Trc.entry(this, fault, bindingFault);
  +
  +        Iterator it = bindingFault.getExtensibilityElements().iterator();
  +        while (it.hasNext()) {
  +            Object ele = it.next();
  +            if (ele instanceof JMSFaultIndicator) {
  +                JMSFaultIndicator indic = (JMSFaultIndicator) ele;
  +                List fProps = indic.getJMSFaultProperties();
  +                Iterator itFProp = fProps.iterator();
  +                while (itFProp.hasNext()) {
  +                    Object next = itFProp.next();
  +                    if (next instanceof JMSFaultProperty) {
  +                        JMSFaultProperty fProp = (JMSFaultProperty) next;
  +                        String partName = fProp.getPart();
  +                        String propName = fProp.getName();
  +
  +                        if (partName != null && partName.length() > 0)
  +                            try {
  +                                Object propValue =
  +                                    jmsDest.getProperty(propName);
  +                                fault.setObjectPart(partName, propValue);
  +                            } catch (WSIFException ex) {
  +                                Trc.ignoredException(ex);
  +                            }
  +                    }
  +                }
  +            } else if (ele instanceof JMSProperty) {
  +                JMSProperty prop = (JMSProperty) ele;
  +                String partName = prop.getPart();
  +                String propName = prop.getName();
  +
  +                try {
  +                    Object propValue = jmsDest.getProperty(propName);
  +                    fault.setObjectPart(partName, propValue);
  +                } catch (WSIFException ex) {
  +                    Trc.ignoredException(ex);
  +                }
  +            }
  +        }
  +
  +        Trc.exit();
  +    }
  +    
       /**
        * set the specified jms property values
        */
  
  
  
  1.11      +40 -0     xml-axis-wsif/java/test/util/TestUtilities.java
  
  Index: TestUtilities.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/util/TestUtilities.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestUtilities.java        7 Oct 2002 15:25:52 -0000       1.10
  +++ TestUtilities.java        10 Oct 2002 14:51:44 -0000      1.11
  @@ -66,6 +66,15 @@
   import java.util.Properties;
   import java.util.StringTokenizer;
   
  +import javax.jms.JMSException;
  +import javax.jms.Message;
  +import javax.jms.Queue;
  +import javax.jms.QueueConnection;
  +import javax.jms.QueueConnectionFactory;
  +import javax.jms.QueueReceiver;
  +import javax.jms.QueueSession;
  +import javax.jms.Session;
  +
   import org.apache.wsif.WSIFException;
   import org.apache.wsif.base.WSIFDefaultCorrelationService;
   import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis;
  @@ -73,10 +82,13 @@
   import org.apache.wsif.spi.WSIFProvider;
   import org.apache.wsif.util.WSIFCorrelationServiceLocator;
   import org.apache.wsif.util.WSIFPluggableProviders;
  +import org.apache.wsif.util.WSIFProperties;
   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.jms.NativeJMSRequestListener;
  +import org.apache.wsif.util.jms.WSIFJMSFinder;
  +import org.apache.wsif.util.jms.WSIFJMSFinderForJndi;
   
   public class TestUtilities {
       private static final String WSIF_TEST_PROPERTIES = "wsif.test.properties";
  @@ -274,6 +286,34 @@
             getCorrelationService()).shutdown();
       }
   
  +    public static Message getJMSAsyncResponse(String id, String queueName)
  +        throws WSIFException, JMSException {
  +
  +        String initialContextFactory =
  +            "com.sun.jndi.fscontext.RefFSContextFactory";
  +        String jndiUrl = "file:///JNDI-Directory";
  +        String queueConnectionFactory = "WSIFSampleQCF";
  +
  +        WSIFJMSFinder finder =
  +            new WSIFJMSFinderForJndi(
  +                null,
  +                initialContextFactory,
  +                jndiUrl,
  +                WSIFJMSFinder.STYLE_QUEUE,
  +                queueConnectionFactory,
  +                null,
  +                null);
  +
  +        QueueConnectionFactory factory = finder.getFactory();
  +        QueueConnection connection = factory.createQueueConnection();
  +        connection.start();
  +        QueueSession session =
  +            connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
  +        Queue readQ = session.createQueue(queueName);
  +        QueueReceiver receiver =
  +            session.createReceiver(readQ, "JMSCorrelationID='" + id + "'");
  +        return receiver.receive(WSIFProperties.getAsyncTimeout());
  +    }
   }
   
   class BridgeThread extends Thread {
  
  
  
  1.11      +1 -0      
xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSDestination.java
  
  Index: WSIFJMSDestination.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSDestination.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- WSIFJMSDestination.java   8 Oct 2002 08:58:06 -0000       1.10
  +++ WSIFJMSDestination.java   10 Oct 2002 14:51:44 -0000      1.11
  @@ -379,6 +379,7 @@
                   rec = session.createReceiver(readQ);
   
               msg = rec.receive(timeout);
  +            lastMessage = msg;
   
               if (msg == null)
                   throw new WSIFException(
  
  
  
  1.5       +2 -1      
xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSProperties.java
  
  Index: WSIFJMSProperties.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSProperties.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WSIFJMSProperties.java    7 Aug 2002 15:10:26 -0000       1.4
  +++ WSIFJMSProperties.java    10 Oct 2002 14:51:44 -0000      1.5
  @@ -254,7 +254,8 @@
               throw WSIFJMSConstants.ToWsifException(je);
           }
       
  -        Trc.exit(deep());
  +        if (Trc.ON)
  +            Trc.exit(deep());
       }
   
       public void clear() {
  
  
  
  1.13      +5 -42     xml-axis-wsif/java/test/async/AsyncTests.java
  
  Index: AsyncTests.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/async/AsyncTests.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AsyncTests.java   16 Sep 2002 08:18:55 -0000      1.12
  +++ AsyncTests.java   10 Oct 2002 14:51:44 -0000      1.13
  @@ -57,30 +57,17 @@
   
   package async;
   
  -import javax.jms.JMSException;
  -import javax.jms.Message;
  -import javax.jms.Queue;
  -import javax.jms.QueueConnection;
  -import javax.jms.QueueConnectionFactory;
  -import javax.jms.QueueReceiver;
  -import javax.jms.QueueSession;
  -import javax.jms.Session;
   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.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis;
  -import org.apache.wsif.util.WSIFPluggableProviders;
  -import org.apache.wsif.util.WSIFProperties;
  -import org.apache.wsif.util.jms.WSIFJMSFinder;
  -import org.apache.wsif.util.jms.WSIFJMSFinderForJndi;
   import util.TestUtilities;
   
   import addressbook.wsiftypes.Address;
  @@ -430,7 +417,10 @@
            WSIFCorrelationId id = op.executeRequestResponseAsync( input );
            System.out.println( "async operation done, correlation id=" + 
id.getCorrelationId() );
            
  -         Object jmsResponse = getJMSResponse( id.getCorrelationId() );
  +        Object jmsResponse =
  +            TestUtilities.getJMSAsyncResponse(
  +                id.getCorrelationId(),
  +                TestUtilities.getWsifProperty("wsif.async.replytoq2"));
   
            output = op.createOutputMessage();
            WSIFMessage fault = op.createFaultMessage();
  @@ -442,32 +432,5 @@
         return output;
     }
   
  -    private Message getJMSResponse(String id) throws WSIFException, JMSException {
  -        String initialContextFactory = "com.sun.jndi.fscontext.RefFSContextFactory";
  -        String jndiUrl = "file:///JNDI-Directory";
  -        String queueConnectionFactory = "WSIFSampleQCF";
  -    
  -        WSIFJMSFinder finder =
  -            new WSIFJMSFinderForJndi(
  -                null,
  -                initialContextFactory,
  -                jndiUrl,
  -                WSIFJMSFinder.STYLE_QUEUE,
  -                queueConnectionFactory,
  -                null,
  -                null);
  -    
  -        QueueConnectionFactory factory = finder.getFactory();
  -        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());
  -    }
       
   }
  
  
  
  1.15      +27 -8     
xml-axis-wsif/java/test/org/apache/wsif/util/jms/NativeJMSRequestListener.java
  
  Index: NativeJMSRequestListener.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/test/org/apache/wsif/util/jms/NativeJMSRequestListener.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- NativeJMSRequestListener.java     9 Oct 2002 11:52:10 -0000       1.14
  +++ NativeJMSRequestListener.java     10 Oct 2002 14:51:44 -0000      1.15
  @@ -263,10 +263,10 @@
               } else if ( "whoami".equals( operationName ) ) {
                reply = inoutWhoami( (ObjectMessage) msg );
                   sendReply( msg, reply );
  -            } else if ( "throwSimple".equals( operationName ) ) {
  -             throwSimple( (ObjectMessage) msg );
  +            } else if (operationName.startsWith("throw")) {
  +                throwFault(operationName, (ObjectMessage) msg);
               } else {
  -             System.err.println( "unknown operation: " + operationName ) ;
  +                System.err.println("unknown operation: " + operationName);
               }
        } catch (Exception ex) {
                ex.printStackTrace();
  @@ -346,7 +346,9 @@
          return hmr;
       }
       
  -    private void throwSimple(ObjectMessage msg) throws Exception { 
  +    private void throwFault(String operationName, ObjectMessage msg)
  +        throws Exception {
  +
           Queue replyTo = (Queue) (msg.getJMSReplyTo());
           if (replyTo == null)
               return;
  @@ -358,19 +360,36 @@
                case 0 :
                    break;
               case 1 :
  -                faultMsg.setObject((Serializable) "A Simple Fault");
                   faultMsg.setStringProperty("faultIndicator", "simple");
  +                faultMsg.setObject((Serializable) "A Simple Fault");
                   break;
               case 2 :
               case 3 :
  +                faultMsg.setStringProperty(
  +                    "faultIndicator",
  +                    choice == 2 ? "ints" : "twoints");
                   HashMap hm = new HashMap();
                   hm.put("faultInt1", new Integer(1));
                   hm.put("faultInt2", new Integer(2));
                   hm.put("faultInt3", new Integer(3));
                   faultMsg.setObject((Serializable) hm);
  -                faultMsg.setStringProperty(
  -                    "faultIndicator",
  -                    choice == 2 ? "ints" : "twoints");
  +                break;
  +            case 4 :
  +                faultMsg.setIntProperty("faultIndicator", 43);
  +                faultMsg.setObject((Serializable) "A Simple Fault");
  +                break;
  +            case 5 :
  +                faultMsg.setStringProperty("faultIndicator", "not a fault");
  +                faultMsg.setObject((Serializable) "Not a Fault");
  +                break;
  +            case 6 :
  +                faultMsg.setByteProperty("faultIndicator", (byte)-1);
  +                faultMsg.setObject((Serializable) "A Fault Indicator");
  +                break;
  +            case 7 :
  +                faultMsg.setByteProperty("faultIndicator", (byte)-2);
  +                faultMsg.setObject((Serializable) "Another Property Fault");
  +                faultMsg.setStringProperty("anotherProperty", "Another JMS 
Property");
                   break;
               default :
                   throw new RuntimeException("throwSimple: Bad choice");
  
  
  


Reply via email to