diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-13 09:12:10 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-13 09:12:10 +0000 |
commit | 54e286702977afebc52449cb83cf388251cc96f4 (patch) | |
tree | 16ece28e81e2e7f92d6fdd2f24a9a1a0fb57c9a1 /java/sca | |
parent | 86f556b8a9314edd5a9095727bfe4e67a3aff163 (diff) |
Add itest for jms callbacks using a temporary callback queue
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@676288 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
5 files changed, 132 insertions, 9 deletions
diff --git a/java/sca/itest/jms-callbacks/pom.xml b/java/sca/itest/jms-callbacks/pom.xml index f1434c0b7d..ea68585961 100644 --- a/java/sca/itest/jms-callbacks/pom.xml +++ b/java/sca/itest/jms-callbacks/pom.xml @@ -71,10 +71,19 @@ </dependency>
<dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node2-impl</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- uses ActiveMQ 5.1 as 4.1 Session.createQueue does not work using
+ a temporary queue name -->
+ <dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
- <version>4.1.1</version>
- <scope>runtime</scope>
+ <version>5.1.0</version>
+ <scope>test</scope>
</dependency>
</dependencies>
diff --git a/java/sca/itest/jms-callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java b/java/sca/itest/jms-callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java index 3a8cb90096..9d75685a8a 100644 --- a/java/sca/itest/jms-callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java +++ b/java/sca/itest/jms-callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java @@ -27,10 +27,10 @@ import org.osoa.sca.annotations.Service; @Service(JMSClient.class)
public class JMSClientImpl implements JMSClient, JMSServiceCallback {
- @Reference protected JMSService myService;
+ @Reference protected JMSService myService;
- public static String result;
- public static Object lock = new Object();
+ public static String result;
+ public static Object lock = new Object();
public void aClientMethod() {
System.out.println("aClientMethod " + this + " on thread " + Thread.currentThread());
@@ -44,8 +44,7 @@ public class JMSClientImpl implements JMSClient, JMSServiceCallback { // wakeup the waiting testcase
synchronized (lock) {
- lock.notifyAll();
- }
+ lock.notifyAll();
+ }
}
-
}
diff --git a/java/sca/itest/jms-callbacks/src/main/resources/jndi.properties b/java/sca/itest/jms-callbacks/src/main/resources/jndi.properties index 46a6a74a4f..608fe747f5 100644 --- a/java/sca/itest/jms-callbacks/src/main/resources/jndi.properties +++ b/java/sca/itest/jms-callbacks/src/main/resources/jndi.properties @@ -20,7 +20,7 @@ java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
# use the following property to configure the default connector
-java.naming.provider.url = vm://localhost?broker.persistent=false
+java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false
# use the following property to specify the JNDI name the connection factory
# should appear as.
diff --git a/java/sca/itest/jms-callbacks/src/main/resources/simple/tempq.composite b/java/sca/itest/jms-callbacks/src/main/resources/simple/tempq.composite new file mode 100644 index 0000000000..636e951d03 --- /dev/null +++ b/java/sca/itest/jms-callbacks/src/main/resources/simple/tempq.composite @@ -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"
+ targetNamespace="http://jms"
+ name="CallbackClientComposite">
+
+<!--
+
+The client component does not define the callback destination so a temporary queue should be used
+
+-->
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.JMSClientImpl" />
+ <reference name="myService">
+ <binding.jms uri="jms:ServiceQueue"/>
+ <callback>
+ <binding.jms />
+ </callback>
+ </reference>
+ </component>
+
+ <component name="ServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.JMSServiceImpl" />
+ <service name="JMSService">
+ <binding.jms uri="jms:ServiceQueue"/>
+ <callback>
+ <binding.jms />
+ </callback>
+ </service>
+ </component>
+
+</composite>
diff --git a/java/sca/itest/jms-callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java b/java/sca/itest/jms-callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java new file mode 100644 index 0000000000..18c3bfbce2 --- /dev/null +++ b/java/sca/itest/jms-callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java @@ -0,0 +1,65 @@ +/*
+ * 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.net.MalformedURLException;
+
+import org.apache.tuscany.sca.node.SCAClient;
+import org.apache.tuscany.sca.node.SCANode2;
+import org.apache.tuscany.sca.node.SCANode2Factory;
+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 TempCallbackQTestCase {
+
+ private SCAClient scaClient;
+
+ @Before
+ public void init() throws MalformedURLException {
+ this.scaClient = (SCAClient)SCANode2Factory.newInstance().createSCANode("src/main/resources/simple/tempq.composite");
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ JMSClient client = scaClient.getService(JMSClient.class, "ClientComponent");
+
+ client.aClientMethod();
+
+ // wait for up to 5 seconds but should wake up as soon as done
+ synchronized (JMSClientImpl.lock) {
+ JMSClientImpl.lock.wait(5000);
+ }
+
+ assertEquals(" -> someMethod -> receiveResult ", JMSClientImpl.result);
+ }
+
+ @After
+ public void end() {
+ if (scaClient != null) {
+ ((SCANode2)scaClient).stop();
+ }
+ }
+
+}
|