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/07/13 11:12:10 UTC
svn commit: r676288 - in /tuscany/java/sca/itest/jms-callbacks: ./
src/main/java/org/apache/tuscany/sca/binding/jms/ src/main/resources/
src/main/resources/simple/ src/test/java/org/apache/tuscany/sca/binding/jms/
Author: antelder
Date: Sun Jul 13 02:12:10 2008
New Revision: 676288
URL: http://svn.apache.org/viewvc?rev=676288&view=rev
Log:
Add itest for jms callbacks using a temporary callback queue
Added:
tuscany/java/sca/itest/jms-callbacks/src/main/resources/simple/tempq.composite
tuscany/java/sca/itest/jms-callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java
Modified:
tuscany/java/sca/itest/jms-callbacks/pom.xml
tuscany/java/sca/itest/jms-callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java
tuscany/java/sca/itest/jms-callbacks/src/main/resources/jndi.properties
Modified: tuscany/java/sca/itest/jms-callbacks/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms-callbacks/pom.xml?rev=676288&r1=676287&r2=676288&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms-callbacks/pom.xml (original)
+++ tuscany/java/sca/itest/jms-callbacks/pom.xml Sun Jul 13 02:12:10 2008
@@ -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>
Modified: tuscany/java/sca/itest/jms-callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms-callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java?rev=676288&r1=676287&r2=676288&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms-callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java (original)
+++ tuscany/java/sca/itest/jms-callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java Sun Jul 13 02:12:10 2008
@@ -27,10 +27,10 @@
@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 @@
// wakeup the waiting testcase
synchronized (lock) {
- lock.notifyAll();
- }
+ lock.notifyAll();
+ }
}
-
}
Modified: tuscany/java/sca/itest/jms-callbacks/src/main/resources/jndi.properties
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms-callbacks/src/main/resources/jndi.properties?rev=676288&r1=676287&r2=676288&view=diff
==============================================================================
--- tuscany/java/sca/itest/jms-callbacks/src/main/resources/jndi.properties (original)
+++ tuscany/java/sca/itest/jms-callbacks/src/main/resources/jndi.properties Sun Jul 13 02:12:10 2008
@@ -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.
Added: tuscany/java/sca/itest/jms-callbacks/src/main/resources/simple/tempq.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms-callbacks/src/main/resources/simple/tempq.composite?rev=676288&view=auto
==============================================================================
--- tuscany/java/sca/itest/jms-callbacks/src/main/resources/simple/tempq.composite (added)
+++ tuscany/java/sca/itest/jms-callbacks/src/main/resources/simple/tempq.composite Sun Jul 13 02:12:10 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"
+ 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>
Added: tuscany/java/sca/itest/jms-callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms-callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java?rev=676288&view=auto
==============================================================================
--- tuscany/java/sca/itest/jms-callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java (added)
+++ tuscany/java/sca/itest/jms-callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java Sun Jul 13 02:12:10 2008
@@ -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();
+ }
+ }
+
+}