cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r792262 - in /cxf/trunk: rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ rt/transports/jms/src/main/resources/schemas/wsdl/ systests/src/test/java/org/apache/cxf/systest/jms/ testutils/src/main/resources/wsdl/
Date Wed, 08 Jul 2009 19:01:59 GMT
Author: dkulp
Date: Wed Jul  8 19:01:58 2009
New Revision: 792262

URL: http://svn.apache.org/viewvc?rev=792262&view=rev
Log:
[CXF-2316] Support for replyTo header even on one-ways (a bit against
spec, but some older servers expect it).   Patch from Marat Bedretdinov
applied.

Added:
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWays.java
  (with props)
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWaysDeferredReply.java
  (with props)
Modified:
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java
    cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
    cxf/trunk/testutils/src/main/resources/wsdl/jms_test.wsdl

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java?rev=792262&r1=792261&r2=792262&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
Wed Jul  8 19:01:58 2009
@@ -32,6 +32,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.MessageListener;
 import javax.jms.Session;
@@ -112,7 +113,7 @@
         if (outMessage == null) {
             throw new RuntimeException("Exchange to be sent has no outMessage");
         }
-
+        
         boolean isTextPayload = JMSConstants.TEXT_MESSAGE_TYPE.equals(jmsConfig.getMessageType());
         if (isTextPayload && MessageUtils.isTrue(outMessage.getContextualProperty(
             org.apache.cxf.message.Message.MTOM_ENABLED)) 
@@ -122,10 +123,10 @@
             throw new ConfigurationException(msg);
         }
         
-        JMSMessageHeadersType headers = (JMSMessageHeadersType)outMessage
+        final JMSMessageHeadersType headers = (JMSMessageHeadersType)outMessage
             .get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
 
-        JmsTemplate jmsTemplate = JMSFactory.createJmsTemplate(jmsConfig, headers);
+        final JmsTemplate jmsTemplate = JMSFactory.createJmsTemplate(jmsConfig, headers);
         String userCID = headers != null ? headers.getJMSCorrelationID() : null;
         DefaultMessageListenerContainer jmsList = jmsListener;
         if (!exchange.isOneWay()) {
@@ -162,8 +163,19 @@
             public javax.jms.Message createMessage(Session session) throws JMSException {
                 String messageType = jmsConfig.getMessageType();
                 final javax.jms.Message jmsMessage;
+                Destination replyToDestination = replyTo;
+                if (exchange.isOneWay() && !jmsConfig.isEnforceSpec()) {
+                    final String contextReplyToName = 
+                        (headers != null) ? headers.getJMSReplyTo() : null;
+                    if (contextReplyToName != null) {
+                        replyToDestination = 
+                            JMSFactory.resolveOrCreateDestination(jmsTemplate, 
+                                                                  contextReplyToName, 
+                                                                  jmsConfig.isPubSubDomain());
+                    }
+                }
                 jmsMessage = JMSUtils.buildJMSMessageFromCXFMessage(jmsConfig, outMessage,
request,
-                                                                    messageType, session,
replyTo,
+                                                                    messageType, session,
replyToDestination,
                                                                     correlationId);
                 LOG.log(Level.FINE, "client sending request: ", jmsMessage);
                 return jmsMessage;

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java?rev=792262&r1=792261&r2=792262&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
Wed Jul  8 19:01:58 2009
@@ -80,6 +80,7 @@
     private long recoveryInterval = DEFAULT_VALUE;
     private int cacheLevel = DEFAULT_VALUE;
     private String cacheLevelName;
+    private boolean enforceSpec = true;
     
     //For jms spec.
     private String targetService;
@@ -457,5 +458,12 @@
     public String getRequestURI() {
         return requestURI;
     }
+    
+    public boolean isEnforceSpec() {
+        return enforceSpec;
+    }
 
+    public void setEnforceSpec(boolean enforceSpec) {
+        this.enforceSpec = enforceSpec;
+    }
 }

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java?rev=792262&r1=792261&r2=792262&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
Wed Jul  8 19:01:58 2009
@@ -196,7 +196,7 @@
      * @param pubSubDomain true=pubSub, false=Queues
      * @return resolved destination
      */
-    private static Destination resolveOrCreateDestination(final JmsTemplate jmsTemplate,
+    protected static Destination resolveOrCreateDestination(final JmsTemplate jmsTemplate,
                                                           final String replyToDestinationName,
                                                           final boolean pubSubDomain) {
         return (Destination)jmsTemplate.execute(new SessionCallback() {

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java?rev=792262&r1=792261&r2=792262&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
Wed Jul  8 19:01:58 2009
@@ -138,6 +138,7 @@
             if (clientConfig.isSetConduitSelectorPrefix()) {
                 jmsConfig.setConduitSelectorPrefix(clientConfig.getConduitSelectorPrefix());
             }
+            jmsConfig.setEnforceSpec(clientConfig.isEnforceSpec());
             jmsConfig.setSubscriptionDurable(serverBehavior.isSetDurableSubscriberName());
      
             jmsConfig.setDurableSubscriptionName(serverBehavior.getDurableSubscriberName());
             jmsConfig.setDurableSubscriptionClientId(serverConfig.getDurableSubscriptionClientId());

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java?rev=792262&r1=792261&r2=792262&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java (original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java Wed
Jul  8 19:01:58 2009
@@ -35,7 +35,9 @@
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.ObjectMessage;
+import javax.jms.Queue;
 import javax.jms.Session;
+import javax.jms.Topic;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.SOAPConstants;
@@ -152,6 +154,15 @@
             messageProperties.setJMSTimeStamp(new Long(message.getJMSTimestamp()));
             messageProperties.setJMSType(message.getJMSType());
 
+            if (message.getJMSReplyTo() != null) {
+                Destination replyTo = message.getJMSReplyTo();
+                if (replyTo instanceof Queue) {
+                    messageProperties.setJMSReplyTo(((Queue)replyTo).getQueueName());
+                } else if (replyTo instanceof Topic) {
+                    messageProperties.setJMSReplyTo(((Topic)replyTo).getTopicName());
+                }
+            }
+
             Map<String, List<String>> protHeaders = new HashMap<String, List<String>>();
             List<JMSPropertyType> props = messageProperties.getProperty();
             Enumeration enm = message.getPropertyNames();

Modified: cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd?rev=792262&r1=792261&r2=792262&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd (original)
+++ cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd Wed Jul  8 19:01:58
2009
@@ -56,6 +56,7 @@
     				default="0" />
                 <xs:attribute name="conduitSelectorPrefix" type="xs:string" use="optional"
default=""/>    				
                 <xs:attribute name="useConduitIdSelector" type="xs:boolean" use="optional"/>
+                <xs:attribute name="enforceSpec" type="xs:boolean" use="optional" default="true"/>
     		</xs:extension>
     	</xs:complexContent>
     </xs:complexType>
@@ -91,6 +92,7 @@
         <xs:attribute name="JMSMessageID" type="xs:string"/>
         <xs:attribute name="JMSPriority" type="xs:int"/>
         <xs:attribute name="JMSRedelivered" type="xs:boolean"/>
+        <xs:attribute name="JMSReplyTo" type="xs:string"/>
         <xs:attribute name="JMSTimeStamp" type="xs:long"/>
         <xs:attribute name="JMSType" type="xs:string"/>
         <xs:attribute name="TimeToLive" type="xs:long"/>

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWays.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWays.java?rev=792262&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWays.java
(added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWays.java
Wed Jul  8 19:01:58 2009
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.jms;
+
+import java.net.URL;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.cxf.hello_world_jms.HelloWorldOneWayPort;
+import org.apache.cxf.hello_world_jms.HelloWorldQueueDecoupledOneWaysService;
+import org.apache.cxf.transport.jms.JMSConstants;
+import org.apache.cxf.transport.jms.JMSMessageHeadersType;
+
+
+
+@WebService(serviceName = "HelloWorldQueueDecoupledOneWaysService", 
+            portName = "HelloWorldQueueDecoupledOneWaysPort", 
+            endpointInterface = "org.apache.cxf.hello_world_jms.HelloWorldOneWayPort",
+            targetNamespace = "http://cxf.apache.org/hello_world_jms",
+            wsdlLocation = "testutils/jms_test.wsdl")
+public class GreeterImplQueueDecoupledOneWays implements HelloWorldOneWayPort {
+    
+    @Resource
+    private WebServiceContext context;
+    private Throwable asyncEx;
+    private String request;
+    private String reply;
+    private CountDownLatch latch = new CountDownLatch(1);
+    private boolean specCompliant;
+
+    public GreeterImplQueueDecoupledOneWays() {
+    }
+
+    public GreeterImplQueueDecoupledOneWays(boolean specCompliant) {
+        this.specCompliant = specCompliant;
+    }
+    
+    public void greetMeOneWay(String value) {
+        synchronized (this) {
+            request = value;
+            notifyAll();
+        }
+        try {
+            if (!latch.await(2000, TimeUnit.MILLISECONDS)) {
+                synchronized (this) {
+                    asyncEx = new Exception("Time out while waiting for command to send reply");
+                    notifyAll();
+                }
+                return;
+            }
+        } catch (InterruptedException e) {
+            synchronized (this) {
+                asyncEx = e;
+                notifyAll();
+            }
+            return;
+        }
+        sendReply();
+    }
+    
+    protected void sendReply() {
+        JMSMessageHeadersType headers = 
+            (JMSMessageHeadersType)context.getMessageContext().get(JMSConstants.JMS_SERVER_REQUEST_HEADERS);
+        if (headers == null || headers.getJMSReplyTo() == null) {
+            synchronized (this) {
+                if (!specCompliant) {
+                    asyncEx = new Exception("ReplyTo header in the server Request context
was null");
+                }
+                notifyAll();
+            }
+            return;
+        } else if (headers != null && headers.getJMSReplyTo() != null &&
specCompliant) {
+            synchronized (this) {
+                asyncEx = new Exception("ReplyTo header in the server Request context was
not null");
+                notifyAll();
+            }
+            return;
+        }
+        
+        QName serviceName = new QName("http://cxf.apache.org/hello_world_jms",
+                                      "HelloWorldQueueDecoupledOneWaysService");
+        QName portName = new QName("http://cxf.apache.org/hello_world_jms",
+                                   "HelloWorldQueueDecoupledOneWaysReplyPort");
+        Throwable e = null;
+        
+        try {
+            URL wsdl = getClass().getResource("/wsdl/jms_test.wsdl");
+            HelloWorldQueueDecoupledOneWaysService service = 
+                new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
+            HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
+            reply = "Re:" + request;
+            greeter.greetMeOneWay(reply);
+        } catch (Throwable t) {
+            e = t;
+        }
+        synchronized (this) {
+            asyncEx = e;
+            notifyAll();
+        }
+
+    }
+
+    public void proceedWithReply() {
+        latch.countDown();
+    }
+        
+    public String ackRequestReceived(long timeout) {
+        synchronized (this) {
+            if (request != null) {
+                return request;
+            }
+            try {
+                wait(timeout);
+            } catch (InterruptedException e) {
+                asyncEx = e;
+                return null;
+            }
+        }
+        return request;
+    }
+
+    public String ackReplySent(long timeout) {
+        synchronized (this) {
+            if (asyncEx != null) {
+                return null;
+            }
+            try {
+                wait(timeout);
+            } catch (InterruptedException e) {
+                asyncEx = e;
+                return null;
+            }
+        }
+        return reply;
+    }
+
+    public boolean ackNoReplySent(long timeout) {
+        synchronized (this) {
+            if (asyncEx != null) {
+                return false;
+            }
+            try {
+                wait(timeout);
+            } catch (InterruptedException e) {
+                asyncEx = e;
+            }
+        }
+        return asyncEx == null;
+    }
+
+    public Throwable getException() {
+        return asyncEx;
+    }
+}

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWays.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWays.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWaysDeferredReply.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWaysDeferredReply.java?rev=792262&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWaysDeferredReply.java
(added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWaysDeferredReply.java
Wed Jul  8 19:01:58 2009
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.jms;
+
+import javax.jws.WebService;
+
+import org.apache.cxf.hello_world_jms.HelloWorldOneWayPort;
+
+
+
+@WebService(serviceName = "HelloWorldQueueDecoupledOneWaysService", 
+            portName = "HelloWorldQueueDecoupledOneWaysReplyPort", 
+            endpointInterface = "org.apache.cxf.hello_world_jms.HelloWorldOneWayPort",
+            targetNamespace = "http://cxf.apache.org/hello_world_jms",
+            wsdlLocation = "testutils/jms_test.wsdl")
+public class GreeterImplQueueDecoupledOneWaysDeferredReply implements HelloWorldOneWayPort
{
+
+    private String request;
+    private Throwable asyncEx;
+    
+    public void greetMeOneWay(String value) {
+        synchronized (this) {
+            request = value;
+            notifyAll();
+        }
+
+    }
+    public String ackRequest(long timeout) {
+        synchronized (this) {
+            try {
+                wait(timeout);
+            } catch (InterruptedException e) {
+                asyncEx = e;
+                return null;
+            }
+        }
+        return request;
+    }
+    
+    public Throwable getException() {
+        return asyncEx;
+    }
+}

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWaysDeferredReply.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/GreeterImplQueueDecoupledOneWaysDeferredReply.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java?rev=792262&r1=792261&r2=792262&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java Wed
Jul  8 19:01:58 2009
@@ -33,10 +33,13 @@
 import javax.xml.namespace.QName;
 import javax.xml.ws.Binding;
 import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Endpoint;
 import javax.xml.ws.Holder;
 import javax.xml.ws.soap.SOAPBinding;
 
 
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.hello_world_jms.BadRecordLitFault;
 import org.apache.cxf.hello_world_jms.HWByteMsgService;
 import org.apache.cxf.hello_world_jms.HelloWorldOneWayPort;
@@ -44,6 +47,7 @@
 import org.apache.cxf.hello_world_jms.HelloWorldPortType;
 import org.apache.cxf.hello_world_jms.HelloWorldPubSubPort;
 import org.apache.cxf.hello_world_jms.HelloWorldPubSubService;
+import org.apache.cxf.hello_world_jms.HelloWorldQueueDecoupledOneWaysService;
 import org.apache.cxf.hello_world_jms.HelloWorldService;
 import org.apache.cxf.hello_world_jms.HelloWorldServiceAppCorrelationIDNoPrefix;
 import org.apache.cxf.hello_world_jms.HelloWorldServiceAppCorrelationIDStaticPrefix;
@@ -56,29 +60,28 @@
 import org.apache.cxf.jms_greeter.JMSGreeterService2;
 import org.apache.cxf.jms_mtom.JMSMTOMPortType;
 import org.apache.cxf.jms_mtom.JMSMTOMService;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.systest.jaxws.Hello;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.transport.jms.AddressType;
+import org.apache.cxf.transport.jms.JMSConduit;
 import org.apache.cxf.transport.jms.JMSConstants;
 import org.apache.cxf.transport.jms.JMSMessageHeadersType;
+import org.apache.cxf.transport.jms.JMSNamingPropertyType;
 import org.apache.cxf.transport.jms.JMSPropertyType;
 import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
 import org.apache.hello_world_doc_lit.Greeter;
 import org.apache.hello_world_doc_lit.PingMeFault;
 import org.apache.hello_world_doc_lit.SOAPService2;
-import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class JMSClientServerTest extends AbstractBusClientServerTestBase {
     
-    protected static boolean serversStarted;
-
-    @Before
-    public void startServers() throws Exception {
-        if (serversStarted) {
-            return;
-        }
+    @BeforeClass
+    public static void startServers() throws Exception {
         Map<String, String> props = new HashMap<String, String>();          
     
         if (System.getProperty("activemq.store.dir") != null) {
             props.put("activemq.store.dir", System.getProperty("activemq.store.dir"));
@@ -91,7 +94,6 @@
 
         assertTrue("server did not launch correctly", 
                    launchServer(Server.class, false));
-        serversStarted = true;
     }
     
     public URL getWSDLURL(String s) throws Exception {
@@ -119,6 +121,17 @@
         String response2 = new String("Bonjour");
         try {
             Greeter greeter = service.getPort(portName, Greeter.class);
+            Client client = ClientProxy.getClient(greeter);
+            EndpointInfo ei = client.getEndpoint().getEndpointInfo();
+            AddressType address = ei.getTraversedExtensor(new AddressType(), AddressType.class);
+            JMSNamingPropertyType name = new JMSNamingPropertyType();
+            JMSNamingPropertyType password = new JMSNamingPropertyType();
+            name.setName("java.naming.security.principal");
+            name.setValue("ivan");
+            password.setName("java.naming.security.credentials");
+            password.setValue("the-terrible");
+            address.getJMSNamingProperty().add(name);
+            address.getJMSNamingProperty().add(password);
             for (int idx = 0; idx < 5; idx++) {
 
                 greeter.greetMeOneWay("test String");
@@ -232,6 +245,8 @@
             }
         } catch (UndeclaredThrowableException ex) {
             throw (Exception)ex.getCause();
+        } catch (Exception t) {
+            throw t;
         }
     }
     
@@ -282,7 +297,7 @@
                 greeter.greetMeOneWay("JMS:PubSub:Milestone-" + idx);
             }
             //Give some time to complete one-way calls.
-            Thread.sleep(100L);
+            Thread.sleep(50L);
         } catch (UndeclaredThrowableException ex) {
             throw (Exception)ex.getCause();
         }
@@ -306,7 +321,7 @@
                 greeter.greetMeOneWay("JMS:PubSub:Milestone-" + idx);
             }
             //Give some time to complete one-way calls.
-            Thread.sleep(100L);
+            Thread.sleep(50L);
         } catch (UndeclaredThrowableException ex) {
             throw (Exception)ex.getCause();
         }
@@ -388,6 +403,131 @@
         }
     }
 
+    @Test
+    public void testQueueDecoupledOneWaysConnection() throws Exception {
+        QName serviceName = getServiceName(new QName("http://cxf.apache.org/hello_world_jms",

+                                                     "HelloWorldQueueDecoupledOneWaysService"));
+        QName portName = getPortName(new QName("http://cxf.apache.org/hello_world_jms", 
+                                               "HelloWorldQueueDecoupledOneWaysPort"));
+        URL wsdl = getClass().getResource("/wsdl/jms_test.wsdl");
+        assertNotNull(wsdl);
+
+        HelloWorldQueueDecoupledOneWaysService service = 
+            new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
+        assertNotNull(service);
+        Endpoint requestEndpoint = null;
+        Endpoint replyEndpoint = null;
+        try {
+            HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
+            GreeterImplQueueDecoupledOneWays requestServant = new GreeterImplQueueDecoupledOneWays();
+            requestEndpoint = Endpoint.publish("", requestServant);
+            GreeterImplQueueDecoupledOneWaysDeferredReply replyServant = 
+                new GreeterImplQueueDecoupledOneWaysDeferredReply();
+            replyEndpoint = Endpoint.publish("", replyServant);
+            
+            InvocationHandler handler  = Proxy.getInvocationHandler(greeter);
+            BindingProvider  bp = (BindingProvider)handler;
+            Map<String, Object> requestContext = bp.getRequestContext();
+            JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+            requestHeader.setJMSReplyTo("dynamicQueues/test.jmstransport.oneway.with.set.replyto.reply");
+            requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
+            String expectedRequest = "JMS:Queue:Request"; 
+            greeter.greetMeOneWay(expectedRequest);
+            String request = requestServant.ackRequestReceived(5000);
+            if (request == null) {
+                if (requestServant.getException() != null) {
+                    fail(requestServant.getException().getMessage());
+                } else {
+                    fail("The oneway call didn't reach its intended endpoint");
+                }
+            }
+            assertEquals(expectedRequest, request);
+            requestServant.proceedWithReply();
+            String expectedReply = requestServant.ackReplySent(5000);
+            if (expectedReply == null) {
+                if (requestServant.getException() != null) {
+                    fail(requestServant.getException().getMessage());
+                } else {
+                    fail("The decoupled one-way reply was not sent");
+                }
+            }
+            String reply = replyServant.ackRequest(5000);
+            if (reply == null) {
+                if (replyServant.getException() != null) {
+                    fail(replyServant.getException().getMessage());
+                } else {
+                    fail("The decoupled one-way reply didn't reach its intended endpoint");
+                }
+            }
+            assertEquals(expectedReply, reply);
+        } catch (Exception ex) {
+            throw ex;
+        } finally {
+            if (requestEndpoint != null) {
+                requestEndpoint.stop();
+            }
+            if (replyEndpoint != null) {
+                replyEndpoint.stop();
+            }
+        }
+    }
+    
+    @Test
+    public void testQueueOneWaySpecCompliantConnection() throws Exception {
+        QName serviceName = getServiceName(new QName("http://cxf.apache.org/hello_world_jms",

+                                                     "HelloWorldQueueDecoupledOneWaysService"));
+        QName portName = getPortName(new QName("http://cxf.apache.org/hello_world_jms", 
+                                               "HelloWorldQueueDecoupledOneWaysPort"));
+        URL wsdl = getClass().getResource("/wsdl/jms_test.wsdl");
+        assertNotNull(wsdl);
+
+        HelloWorldQueueDecoupledOneWaysService service = 
+            new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
+        assertNotNull(service);
+        Endpoint requestEndpoint = null;
+        try {
+            HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
+            GreeterImplQueueDecoupledOneWays requestServant = new GreeterImplQueueDecoupledOneWays(true);
+            requestEndpoint = Endpoint.publish("", requestServant);
+            
+            Client client = ClientProxy.getClient(greeter);
+            ((JMSConduit)client.getConduit()).getJmsConfig().setEnforceSpec(true);
+            InvocationHandler handler  = Proxy.getInvocationHandler(greeter);
+            BindingProvider  bp = (BindingProvider)handler;
+            Map<String, Object> requestContext = bp.getRequestContext();
+            JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
+            requestHeader.setJMSReplyTo("dynamicQueues/test.jmstransport.oneway.with.set.replyto.reply");
+            requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
+            String expectedRequest = "JMS:Queue:Request"; 
+            greeter.greetMeOneWay(expectedRequest);
+            String request = requestServant.ackRequestReceived(5000);
+            if (request == null) {
+                if (requestServant.getException() != null) {
+                    fail(requestServant.getException().getMessage());
+                } else {
+                    fail("The oneway call didn't reach its intended endpoint");
+                }
+            }
+            assertEquals(expectedRequest, request);
+            requestServant.proceedWithReply();
+            boolean ack = requestServant.ackNoReplySent(5000);
+            if (!ack) {
+                if (requestServant.getException() != null) {
+                    fail(requestServant.getException().getMessage());
+                } else {
+                    fail("The decoupled one-way reply was sent");
+                }
+            }
+        } catch (Exception ex) {
+            throw ex;
+        } finally {
+            if (requestEndpoint != null) {
+                requestEndpoint.stop();
+            }
+        }
+
+    }
+
     private static interface CorrelationIDFactory {
         String createCorrealtionID();
     }
@@ -534,7 +674,7 @@
         
         HelloWorldPortType port = service.getPort(portName, HelloWorldPortType.class);
         
-        for (int i = 0; i < 100; ++i) {
+        for (int i = 0; i < 10; ++i) {
             ClientRunnable client =  
                 new ClientRunnable(port,
                     new CorrelationIDFactory() {
@@ -616,7 +756,7 @@
         HelloWorldPortType portEng = service.getPort(portNameEng, HelloWorldPortType.class);
         HelloWorldPortType portSales = service.getPort(portNameSales, HelloWorldPortType.class);
         
-        for (int i = 0; i < 100; ++i) {
+        for (int i = 0; i < 10; ++i) {
             ClientRunnable client =  new ClientRunnable(portEng, "com.mycompany.eng:");
             Thread thread = new Thread(client);
             threads.add(thread);
@@ -661,7 +801,7 @@
         
         HelloWorldPortType port = service.getPort(portName, HelloWorldPortType.class);
         
-        for (int i = 0; i < 100; ++i) {
+        for (int i = 0; i < 10; ++i) {
             ClientRunnable client =  
                 new ClientRunnable(port);
             

Modified: cxf/trunk/testutils/src/main/resources/wsdl/jms_test.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/resources/wsdl/jms_test.wsdl?rev=792262&r1=792261&r2=792262&view=diff
==============================================================================
--- cxf/trunk/testutils/src/main/resources/wsdl/jms_test.wsdl (original)
+++ cxf/trunk/testutils/src/main/resources/wsdl/jms_test.wsdl Wed Jul  8 19:01:58 2009
@@ -504,6 +504,27 @@
         </port>
     </service>
     
+    <service name="HelloWorldQueueDecoupledOneWaysService">
+        <port binding="tns:HelloWorldOneWayBinding" name="HelloWorldQueueDecoupledOneWaysPort">
+            <jms:address
+               jndiConnectionFactoryName="ConnectionFactory" 
+               jndiDestinationName="dynamicQueues/test.jmstransport.oneway.with.set.replyto">
+               <jms:JMSNamingProperty name="java.naming.factory.initial" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
+               <jms:JMSNamingProperty name="java.naming.provider.url" value="tcp://localhost:61500"/>
+            </jms:address>
+            <jms:clientConfig enforceSpec="false"/>
+        </port>
+        <port binding="tns:HelloWorldOneWayBinding" name="HelloWorldQueueDecoupledOneWaysReplyPort">
+            <jms:address
+               jndiConnectionFactoryName="ConnectionFactory" 
+               jndiDestinationName="dynamicQueues/test.jmstransport.oneway.with.set.replyto.reply">
+               <jms:JMSNamingProperty name="java.naming.factory.initial" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
+               <jms:JMSNamingProperty name="java.naming.provider.url" value="tcp://localhost:61500"/>
+            </jms:address>
+        </port>
+        
+    </service>
+     
     <service name="HelloWorldPubSubService">
         <port binding="tns:HelloWorldPubSubBinding" name="HelloWorldPubSubPort">
             <jms:address



Mime
View raw message