You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2008/04/17 10:27:46 UTC

svn commit: r648998 - in /incubator/tuscany/java/sca/itest/jms/src: main/java/org/apache/tuscany/sca/binding/jms/ main/resources/nonSCAclient/ test/java/org/apache/tuscany/sca/binding/jms/

Author: antelder
Date: Thu Apr 17 01:27:30 2008
New Revision: 648998

URL: http://svn.apache.org/viewvc?rev=648998&view=rev
Log:
Add itests from varrious jms message types

Added:
    incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java   (with props)
    incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java   (with props)
    incubator/tuscany/java/sca/itest/jms/src/main/resources/nonSCAclient/
    incubator/tuscany/java/sca/itest/jms/src/main/resources/nonSCAclient/service.composite
    incubator/tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java   (with props)
Modified:
    incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java

Added: incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java?rev=648998&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java (added)
+++ incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java Thu Apr 17 01:27:30 2008
@@ -0,0 +1,29 @@
+/*
+ * 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.tuscany.sca.binding.jms;
+
+import org.osoa.sca.annotations.OneWay;
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface OneWayObjectService {
+
+    @OneWay
+    void sayHello(Object name);
+}

Propchange: incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java?rev=648998&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java (added)
+++ incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java Thu Apr 17 01:27:30 2008
@@ -0,0 +1,34 @@
+/*
+ * 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.tuscany.sca.binding.jms;
+
+public class OneWayObjectServiceImpl implements OneWayObjectService {
+
+    public static Object mutex = new Object();
+    public static Object name;
+
+    public void sayHello(Object name) {
+        OneWayObjectServiceImpl.name = name;
+        synchronized (OneWayObjectServiceImpl.mutex) {
+            OneWayObjectServiceImpl.mutex.notify();
+        }
+    }
+
+}

Propchange: incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java?rev=648998&r1=648997&r2=648998&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java (original)
+++ incubator/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java Thu Apr 17 01:27:30 2008
@@ -23,9 +23,9 @@
 import javax.jms.Session;
 
 import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
-import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorImpl;
+import org.apache.tuscany.sca.binding.jms.provider.XMLTextMessageProcessor;
 
-public class TestMessageProcessor extends JMSMessageProcessorImpl {
+public class TestMessageProcessor extends XMLTextMessageProcessor {
 
     public static boolean insertPayloadIntoJMSMessageCalled;
     public static boolean extractPayloadFromJMSMessageCalled;

Added: incubator/tuscany/java/sca/itest/jms/src/main/resources/nonSCAclient/service.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/jms/src/main/resources/nonSCAclient/service.composite?rev=648998&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/jms/src/main/resources/nonSCAclient/service.composite (added)
+++ incubator/tuscany/java/sca/itest/jms/src/main/resources/nonSCAclient/service.composite Thu Apr 17 01:27:30 2008
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+ -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+           name="RPCComposite">
+
+    <component name="DefaultService">
+        <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayServiceImpl"/>
+        <service name="OneWayService">
+            <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61618"
+                         messageProcessor="XMLTextMessage">
+            </binding.jms>
+        </service>
+    </component>
+
+    <component name="TextService">
+        <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayServiceImpl"/>
+        <service name="OneWayService">
+            <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61618"
+                         messageProcessor="TextMessage"
+                         uri="jms:TextDest" />
+        </service>
+    </component>
+
+    <component name="ObjectService">
+        <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayObjectServiceImpl"/>
+        <service name="OneWayObjectService">
+            <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61618"
+                         messageProcessor="ObjectMessage"
+                         uri="jms:ObjectDest" />
+        </service>
+    </component>
+
+</composite>

Added: incubator/tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java?rev=648998&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java (added)
+++ incubator/tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java Thu Apr 17 01:27:30 2008
@@ -0,0 +1,139 @@
+/*
+ * 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.tuscany.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.naming.NamingException;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class NonSCAClientTestCase {
+
+    private static SCADomain scaDomain;
+
+    @Before
+    public void init() throws Exception {
+        startBroker();
+        scaDomain = SCADomain.newInstance("http://localhost", "/", "nonSCAclient/service.composite");
+        OneWayServiceImpl.name = null;
+    }
+
+    @Test
+    public void testXMLText() throws Exception {
+
+        synchronized (OneWayServiceImpl.mutex) {
+
+            sendTextMessage("dynamicQueues/OneWayService", "<arg0>Petra</arg0>");
+
+            // wait up to 10 seconds but it will likely be a lot less
+            // as the service invocation will wake this up earlier
+            OneWayServiceImpl.mutex.wait(10000);
+        }
+        assertEquals("Petra", OneWayServiceImpl.name);
+    }
+
+    @Test
+    public void testText() throws Exception {
+
+        synchronized (OneWayServiceImpl.mutex) {
+
+            sendTextMessage("dynamicQueues/TextDest", "Petra");
+
+            // wait up to 10 seconds but it will likely be a lot less
+            // as the service invocation will wake this up earlier
+            OneWayServiceImpl.mutex.wait(10000);
+        }
+        assertEquals("Petra", OneWayServiceImpl.name);
+    }
+
+    @Test
+    public void testObject() throws Exception {
+
+        Set<Integer> arg = new HashSet<Integer>();
+        arg.add(new Integer(3));
+
+        synchronized (OneWayObjectServiceImpl.mutex) {
+
+            sendObjectMessage("dynamicQueues/ObjectDest", arg);
+
+            // wait up to 10 seconds but it will likely be a lot less
+            // as the service invocation will wake this up earlier
+            OneWayObjectServiceImpl.mutex.wait(10000);
+        }
+        assertEquals(arg, OneWayObjectServiceImpl.name);
+    }
+
+    @After
+    public void end() throws Exception {
+        if (scaDomain != null) {
+            scaDomain.close();
+        }
+        stopBroker();
+    }
+
+    private BrokerService broker;
+    protected void startBroker() throws Exception {
+        broker = new BrokerService();
+        broker.setPersistent(false);
+        broker.setUseJmx(false);
+        broker.addConnector("tcp://localhost:61618");
+        broker.start();
+    }
+    protected void stopBroker() throws Exception {
+        if (broker != null) {
+            broker.stop();
+        }
+    }
+
+    protected static void sendTextMessage(String destName, String payload) throws JMSException, NamingException {
+        JMSResourceFactory rf = new JMSResourceFactory(null, null, "tcp://localhost:61618");
+        Session session = rf.getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageProducer p = session.createProducer(rf.lookupDestination(destName));
+        rf.getConnection().start();
+        session.run();
+        p.send(session.createTextMessage(payload));
+        rf.closeConnection();
+    }
+
+    protected static void sendObjectMessage(String destName, Object payload) throws JMSException, NamingException {
+        JMSResourceFactory rf = new JMSResourceFactory(null, null, "tcp://localhost:61618");
+        Session session = rf.getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageProducer p = session.createProducer(rf.lookupDestination(destName));
+        rf.getConnection().start();
+        session.run();
+        p.send(session.createObjectMessage((Serializable)payload));
+        rf.closeConnection();
+    }
+}

Propchange: incubator/tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org