tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r682647 - in /tuscany/java/sca/itest/jms/src: main/java/org/apache/tuscany/sca/binding/jms/ main/resources/properties/ test/java/org/apache/tuscany/sca/binding/jms/
Date Tue, 05 Aug 2008 09:33:16 GMT
Author: antelder
Date: Tue Aug  5 02:33:14 2008
New Revision: 682647

URL: http://svn.apache.org/viewvc?rev=682647&view=rev
Log:
Add tests for properties

Added:
    tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java
    tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java
    tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java
    tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java
    tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java
    tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java
    tuscany/java/sca/itest/jms/src/main/resources/properties/
    tuscany/java/sca/itest/jms/src/main/resources/properties/properties.composite
    tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java

Added: tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java?rev=682647&view=auto
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java
(added)
+++ tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java
Tue Aug  5 02:33:14 2008
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+
+/**
+ * The client interface
+ */
+public interface JMSClient {
+
+    void aClientMethod();
+}

Added: tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java?rev=682647&view=auto
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java
(added)
+++ tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java
Tue Aug  5 02:33:14 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;
+
+
+/**
+ * The client interface
+ */
+public interface MsgClient {
+
+    void aClientMethod();
+    void op2();
+}

Added: tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java?rev=682647&view=auto
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java
(added)
+++ tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java
Tue Aug  5 02:33:14 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.Reference;
+import org.osoa.sca.annotations.Service;
+
+@Service(MsgClient.class)
+public class MsgClientImpl implements MsgClient {
+
+    @Reference protected MsgClientService myService;
+
+    public void aClientMethod() {
+        myService.aClientMethod();
+    }
+
+    public void op2() {
+        myService.op2();
+    }
+
+}

Added: tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java?rev=682647&view=auto
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java
(added)
+++ tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java
Tue Aug  5 02:33:14 2008
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+
+/**
+ * The client interface
+ */
+public interface MsgClientService {
+
+    void aClientMethod();
+
+    void op2();
+}

Added: tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java?rev=682647&view=auto
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java
(added)
+++ tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java
Tue Aug  5 02:33:14 2008
@@ -0,0 +1,27 @@
+/*
+ * 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 interface MsgService {
+    
+    void onMessage(javax.jms.Message msg);
+
+}

Added: tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java?rev=682647&view=auto
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java
(added)
+++ tuscany/java/sca/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java
Tue Aug  5 02:33:14 2008
@@ -0,0 +1,39 @@
+/*
+ * 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 javax.jms.Message;
+
+import org.osoa.sca.annotations.Service;
+
+@Service(MsgService.class)
+public class MsgServiceImpl implements MsgService {
+
+    public static Object lock = new Object();
+    public static Message msg;
+    
+    public void onMessage(Message msg) {
+        MsgServiceImpl.msg = msg;
+        synchronized(lock) {
+            lock.notifyAll();
+        }
+    }
+
+}

Added: tuscany/java/sca/itest/jms/src/main/resources/properties/properties.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/main/resources/properties/properties.composite?rev=682647&view=auto
==============================================================================
--- tuscany/java/sca/itest/jms/src/main/resources/properties/properties.composite (added)
+++ tuscany/java/sca/itest/jms/src/main/resources/properties/properties.composite Tue Aug
 5 02:33:14 2008
@@ -0,0 +1,55 @@
+<?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="PropertiesClientComposite">
+
+    <component name="ClientComponent">
+        <implementation.java class="org.apache.tuscany.sca.binding.jms.MsgClientImpl"
/>
+        <reference name="myService">
+            <binding.jms uri="jms:ServiceQueue">
+               <headers JMSType="myType"
+                        JMSCorrelationID="xyz"
+                        JMSDeliveryMode="PERSISTENT"
+                        JMSTimeToLive="4321"	
+                        JMSPriority="7">
+                  <property name="headP1">myHeadP1</property>    
+               </headers>
+               <operationProperties name="op2" nativeOperation="nativeOp2">
+                  <headers JMSType="op2Type"
+                     JMSCorrelationID="op2CID"
+                     JMSDeliveryMode="NON_PERSISTENT"
+                     JMSTimeToLive="6"
+                     JMSPriority="8">
+                     <property name="op2P2">foo</property>
+                  </headers>
+               </operationProperties>
+            </binding.jms>
+        </reference>
+    </component>
+
+    <component name="ServiceComponent">
+        <implementation.java class="org.apache.tuscany.sca.binding.jms.MsgServiceImpl"
/>
+        <service name="MsgService">
+            <binding.jms uri="jms:ServiceQueue"/>
+        </service>
+    </component>
+
+</composite>

Added: tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java?rev=682647&view=auto
==============================================================================
--- tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java
(added)
+++ tuscany/java/sca/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java
Tue Aug  5 02:33:14 2008
@@ -0,0 +1,92 @@
+/*
+ * 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 static org.junit.Assert.assertNotNull;
+
+import javax.jms.DeliveryMode;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ */
+public class PropertiesTestCase {
+
+    private static SCADomain scaDomain;
+
+    @Before
+    public void init() {
+        scaDomain = SCADomain.newInstance("http://localhost", "/", "properties/properties.composite");
+    }
+
+    @Test
+    public void testProps1() throws Exception {
+        JMSClient client = scaDomain.getService(JMSClient.class, "ClientComponent");
+
+        client.aClientMethod();
+
+        // wait for up to 5 seconds but should wake up as soon as done
+        synchronized(MsgServiceImpl.lock) {
+            if (MsgServiceImpl.msg == null) {
+                MsgServiceImpl.lock.wait(5000);
+            }
+        }
+        assertNotNull(MsgServiceImpl.msg);
+
+        assertEquals("myType", MsgServiceImpl.msg.getJMSType());
+        assertEquals("xyz", MsgServiceImpl.msg.getJMSCorrelationID());
+        assertEquals(DeliveryMode.PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode());
+        // assertEquals(3, MsgServiceImpl.msg.getJMSPriority()); // Doesn't seem to work
with ActiveMQ
+        assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1"));
+    }
+
+    @Test
+    public void testOp2() throws Exception {
+        MsgClient client = scaDomain.getService(MsgClient.class, "ClientComponent");
+
+        client.op2();
+
+        // wait for up to 5 seconds but should wake up as soon as done
+        synchronized(MsgServiceImpl.lock) {
+            if (MsgServiceImpl.msg == null) {
+                MsgServiceImpl.lock.wait(5000);
+            }
+        }
+        assertNotNull(MsgServiceImpl.msg);
+
+        assertEquals("op2Type", MsgServiceImpl.msg.getJMSType());
+        assertEquals("op2CID", MsgServiceImpl.msg.getJMSCorrelationID());
+        // assertEquals(DeliveryMode.NON_PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode());
// Doesn't seem to work with ActiveMQ
+        // assertEquals(3, MsgServiceImpl.msg.getJMSPriority()); // Doesn't seem to work
with ActiveMQ
+        assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1"));
+        assertEquals("foo", MsgServiceImpl.msg.getStringProperty("op2P2"));
+        assertEquals("nativeOp2", MsgServiceImpl.msg.getStringProperty("scaOperationName"));
+    }
+
+    @After
+    public void end() {
+        if (scaDomain != null) {
+            scaDomain.close();
+        }
+    }
+}



Mime
View raw message