summaryrefslogtreecommitdiffstats
path: root/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding')
-rw-r--r--sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/GreetingService.java26
-rw-r--r--sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/GreetingServiceImpl.java27
-rw-r--r--sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/HelloworldService.java26
-rw-r--r--sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/HelloworldServiceImpl.java27
-rw-r--r--sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/IntroService.java23
-rw-r--r--sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/IntroServiceImpl.java36
-rw-r--r--sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/JMSBindingLoaderTestCase.java110
-rw-r--r--sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/JMSBindingTestCaseX.java112
-rw-r--r--sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/JMSProxyTestCase.java89
-rw-r--r--sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/databinding/JmsTransformerTestCase.java64
10 files changed, 540 insertions, 0 deletions
diff --git a/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/GreetingService.java b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/GreetingService.java
new file mode 100644
index 0000000000..24472afa53
--- /dev/null
+++ b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/GreetingService.java
@@ -0,0 +1,26 @@
+/*
+ * 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.binding.jms;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface GreetingService {
+ String greet(String name);
+}
diff --git a/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/GreetingServiceImpl.java b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/GreetingServiceImpl.java
new file mode 100644
index 0000000000..abf7ecef88
--- /dev/null
+++ b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/GreetingServiceImpl.java
@@ -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.binding.jms;
+
+public class GreetingServiceImpl implements GreetingService {
+
+ public String greet(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/HelloworldService.java b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/HelloworldService.java
new file mode 100644
index 0000000000..21c40bd6b6
--- /dev/null
+++ b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/HelloworldService.java
@@ -0,0 +1,26 @@
+/*
+ * 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.binding.jms;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface HelloworldService {
+ String getGreetings(String name);
+}
diff --git a/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/HelloworldServiceImpl.java b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..8119bde323
--- /dev/null
+++ b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/HelloworldServiceImpl.java
@@ -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.binding.jms;
+
+public class HelloworldServiceImpl implements HelloworldService {
+
+ public String getGreetings(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/IntroService.java b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/IntroService.java
new file mode 100644
index 0000000000..0b5acb44cc
--- /dev/null
+++ b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/IntroService.java
@@ -0,0 +1,23 @@
+/*
+ * 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.binding.jms;
+
+public interface IntroService {
+ public String greet(String name);
+}
diff --git a/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/IntroServiceImpl.java b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/IntroServiceImpl.java
new file mode 100644
index 0000000000..6222f368ad
--- /dev/null
+++ b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/IntroServiceImpl.java
@@ -0,0 +1,36 @@
+/*
+ * 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.binding.jms;
+
+import org.osoa.sca.annotations.Reference;
+
+public class IntroServiceImpl implements IntroService {
+
+ private GreetingService extService;
+
+ @Reference
+ public void setExtService(GreetingService extService) {
+ this.extService = extService;
+ }
+
+ public String greet(String name) {
+ return extService.greet(name);
+ }
+
+}
diff --git a/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/JMSBindingLoaderTestCase.java b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/JMSBindingLoaderTestCase.java
new file mode 100644
index 0000000000..d2bf4bfcda
--- /dev/null
+++ b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/JMSBindingLoaderTestCase.java
@@ -0,0 +1,110 @@
+/*
+ * 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.binding.jms;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.loader.LoaderException;
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+public class JMSBindingLoaderTestCase extends TestCase {
+
+ private JMSBindingLoader loader;
+
+ public void testMinimal() throws LoaderException, XMLStreamException {
+ String xml = "<binding.jms></binding.jms>";
+ XMLStreamReader reader = createReader(xml);
+ JMSBindingDefinition jmsBinding = loader.load(null, null, reader, null);
+ assertNotNull(jmsBinding);
+ }
+
+ public void testCorrelationScheme() throws LoaderException, XMLStreamException {
+ XMLStreamReader reader =
+ createReader("<binding.jms correlationScheme=\"RequestMsgIDToCorrelID\"></binding.jms>");
+ JMSBindingDefinition jmsBinding = loader.load(null, null, reader, null);
+ assertEquals("RequestMsgIDToCorrelID", jmsBinding.getCorrelationScheme());
+
+ reader = createReader("<binding.jms correlationScheme=\"RequestCorrelIDToCorrelID\"></binding.jms>");
+ jmsBinding = loader.load(null, null, reader, null);
+ assertEquals("RequestCorrelIDToCorrelID", jmsBinding.getCorrelationScheme());
+
+ reader = createReader("<binding.jms correlationScheme=\"none\"></binding.jms>");
+ jmsBinding = loader.load(null, null, reader, null);
+ assertEquals("none", jmsBinding.getCorrelationScheme());
+
+ reader = createReader("<binding.jms correlationScheme=\"xxx\"></binding.jms>");
+ try {
+ jmsBinding = loader.load(null, null, reader, null);
+ fail("expecting invalid correlationScheme");
+ } catch (LoaderException e) {
+ // expected
+ }
+ }
+
+ public void testDestination() throws LoaderException, XMLStreamException {
+ XMLStreamReader reader = createReader("<binding.jms><destination name=\"foo\"/></binding.jms>");
+ JMSBindingDefinition jmsBinding = loader.load(null, null, reader, null);
+ assertEquals("foo", jmsBinding.getDestinationName());
+ }
+
+ public void testInitialContextFactory() throws LoaderException, XMLStreamException {
+ XMLStreamReader reader = createReader("<binding.jms initialContextFactory=\"myicf\"></binding.jms>");
+ JMSBindingDefinition jmsBinding = loader.load(null, null, reader, null);
+ assertEquals("myicf", jmsBinding.getInitialContextFactoryName());
+ }
+
+ public void testJNDIProviderURL() throws LoaderException, XMLStreamException {
+ XMLStreamReader reader = createReader("<binding.jms JNDIProviderURL=\"myURL\"></binding.jms>");
+ JMSBindingDefinition jmsBinding = loader.load(null, null, reader, null);
+ assertEquals("myURL", jmsBinding.getJNDIProviderURL());
+ }
+
+ public void testConnectionFactory() throws LoaderException, XMLStreamException {
+ XMLStreamReader reader = createReader("<binding.jms> <connectionFactory name=\"myfactory\"/> </binding.jms>");
+ JMSBindingDefinition jmsBinding = loader.load(null, null, reader, null);
+ assertEquals("myfactory", jmsBinding.getConnectionFactoryName());
+ }
+
+ public void testActivationSpec() throws LoaderException, XMLStreamException {
+ XMLStreamReader reader = createReader("<binding.jms> <activationSpec name=\"myas\"/></binding.jms>");
+ JMSBindingDefinition jmsBinding = loader.load(null, null, reader, null);
+ assertEquals("myas", jmsBinding.getActivationSpecName());
+ }
+
+ private XMLStreamReader createReader(String xml) throws XMLStreamException {
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+
+ String xxx = "<xxx xmlns=\"" + XML_NAMESPACE_1_0 + "\">" + xml + "</xxx>";
+ XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(xxx));
+ reader.nextTag();
+ reader.nextTag();
+ return reader;
+ }
+
+ protected void setUp() throws Exception {
+ this.loader = new JMSBindingLoader(null);
+ }
+}
diff --git a/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/JMSBindingTestCaseX.java b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/JMSBindingTestCaseX.java
new file mode 100644
index 0000000000..115c88f8b7
--- /dev/null
+++ b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/JMSBindingTestCaseX.java
@@ -0,0 +1,112 @@
+/*
+ * 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.binding.jms;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.naming.NamingException;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.activemq.broker.BrokerContainer;
+import org.activemq.broker.impl.BrokerContainerImpl;
+import org.activemq.store.vm.VMPersistenceAdapter;
+import org.apache.tuscany.test.SCATestCase;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+import org.xml.sax.SAXException;
+
+public class JMSBindingTestCaseX extends SCATestCase {
+
+ private IntroService introService;
+ private BrokerContainer broker;
+
+ protected static final String REQUEST_XML =
+ "<ns:getGreetings xmlns:ns=\"http://helloworld\"><ns:name>petra</ns:name></ns:getGreetings>";
+ protected static final String REPLY_XML =
+ "<ns1:getGreetingsResponse xmlns:ns1=\"http://helloworld\"><ns1:getGreetingsReturn>Hello petra</ns1:getGreetingsReturn></ns1:getGreetingsResponse>";
+
+ public void testJMSBinding() throws InvocationTargetException, SAXException, IOException,
+ ParserConfigurationException, NamingException, JMSException {
+ String reply = introService.greet("Rajith");
+ assertEquals("Hello Rajith", reply);
+
+ // TODO: the rest should be in a seperate test method but that doesn't
+ // work as you get broker conflicts
+ JMSTargetInvoker invoker = createJMSInvoker();
+ Object[] response = (Object[])invoker.invokeTarget(new Object[] {REQUEST_XML}, (short)0);
+
+ Diff diff = XMLUnit.compareXML(REPLY_XML, response[0].toString());
+ assertTrue(diff.toString(), diff.similar());
+
+ }
+
+ private JMSTargetInvoker createJMSInvoker() throws NamingException, JMSException {
+ JMSBindingDefinition binding = new JMSBindingDefinition();
+ binding.setInitialContextFactoryName("org.activemq.jndi.ActiveMQInitialContextFactory");
+ binding.setConnectionFactoryName("ConnectionFactory");
+ binding.setJNDIProviderURL("tcp://localhost:61616");
+ binding.setDestinationName("dynamicQueues/HelloworldServiceQueue");
+ binding.setTimeToLive(3000);
+ binding.setXMLFormat(true);
+ JMSResourceFactory rf = new SimpleJMSResourceFactory(binding);
+ Destination requestDest = rf.lookupDestination(binding.getDestinationName());
+ DefaultOperationAndDataBinding odb = new DefaultOperationAndDataBinding(binding);
+ JMSTargetInvoker invoker = new JMSTargetInvoker(rf, binding, "getGreetings", odb, odb, requestDest, null);
+ return invoker;
+ }
+
+ protected void setUp() throws Exception {
+ startBroker();
+ setApplicationSCDL(IntroService.class, "META-INF/sca/default.scdl");
+ addExtension("jms.binding", getClass().getClassLoader().getResource("META-INF/sca/jms.system.scdl"));
+ addExtension("idl.wsdl", getClass().getClassLoader().getResource("META-INF/sca/idl.wsdl.scdl"));
+ addExtension("databinding.axiom", getClass().getResource("/META-INF/sca/databinding.axiom.scdl"));
+ super.setUp();
+ CompositeContext context = CurrentCompositeContext.getContext();
+ introService = context.locateService(IntroService.class, "IntroServiceComponent");
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ broker.stop();
+ }
+
+ public static void main(String[] args) {
+ JMSBindingTestCaseX test = new JMSBindingTestCaseX();
+ try {
+ test.setUp();
+ test.testJMSBinding();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void startBroker() throws Exception {
+ broker = new BrokerContainerImpl("JMS BindingDefinition Test");
+ // configure the broker
+ broker.addConnector("tcp://localhost:61616");
+ broker.setPersistenceAdapter(new VMPersistenceAdapter());
+ broker.start();
+ }
+}
diff --git a/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/JMSProxyTestCase.java b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/JMSProxyTestCase.java
new file mode 100644
index 0000000000..63a82ab6da
--- /dev/null
+++ b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/JMSProxyTestCase.java
@@ -0,0 +1,89 @@
+/*
+ * 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.binding.jms;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.naming.NamingException;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+
+public class JMSProxyTestCase extends TestCase {
+
+ /**
+ * Tests the jms response msg has correlation id set to the request msg id
+ */
+ public void testOnMessageRequestMsgIDToCorrelID() throws NamingException, JMSException {
+
+ String id = "123";
+
+ MessageProducer producer = EasyMock.createNiceMock(MessageProducer.class);
+
+ Session session = EasyMock.createNiceMock(Session.class);
+ EasyMock.expect(session.createProducer(EasyMock.isA(Destination.class))).andReturn(producer);
+ EasyMock.replay(session);
+
+ ObjectMessage responseJMSMsg = EasyMock.createMock(ObjectMessage.class);
+ responseJMSMsg.setJMSDeliveryMode(1);
+ responseJMSMsg.setJMSPriority(1);
+ responseJMSMsg.setJMSCorrelationID(id);
+ EasyMock.replay(responseJMSMsg);
+
+ JMSResourceFactory jmsResourceFactory = EasyMock.createMock(JMSResourceFactory.class);
+ EasyMock.expect(jmsResourceFactory.createSession()).andReturn(session);
+
+ OperationAndDataBinding odb = EasyMock.createMock(OperationAndDataBinding.class);
+ EasyMock.expect(odb.createJMSMessage(EasyMock.eq(session), EasyMock.isA(Exception.class)))
+ .andReturn(responseJMSMsg);
+ EasyMock.replay(odb);
+
+ JMSProxy jmsProxy = new JMSProxy(null, jmsResourceFactory, null, odb, null);
+
+ Message requestJMSMsg = EasyMock.createMock(Message.class);
+ EasyMock.expect(requestJMSMsg.getJMSReplyTo()).andReturn(new Destination() {
+ });
+
+ EasyMock.expect(requestJMSMsg.getJMSDeliveryMode()).andReturn(1);
+ EasyMock.expect(requestJMSMsg.getJMSPriority()).andReturn(1);
+
+ EasyMock.expect(requestJMSMsg.getJMSReplyTo()).andReturn(new Destination() {
+ });
+ EasyMock.expect(requestJMSMsg.getJMSMessageID()).andReturn(id);
+
+ producer.send(EasyMock.isA(Message.class));
+ EasyMock.replay(producer);
+
+ EasyMock.replay(requestJMSMsg);
+ EasyMock.replay(jmsResourceFactory);
+
+ jmsProxy.onMessage(requestJMSMsg);
+
+ EasyMock.verify(requestJMSMsg);
+ EasyMock.verify(jmsResourceFactory);
+ EasyMock.verify(producer);
+ EasyMock.verify(session);
+ }
+
+}
diff --git a/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/databinding/JmsTransformerTestCase.java b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/databinding/JmsTransformerTestCase.java
new file mode 100644
index 0000000000..7c9420b7f9
--- /dev/null
+++ b/sandbox/old/contrib/binding-jms/src/test/java/org/apache/tuscany/binding/jms/databinding/JmsTransformerTestCase.java
@@ -0,0 +1,64 @@
+/*
+ * 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.binding.jms.databinding;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for transformers
+ */
+public class JmsTransformerTestCase extends TestCase {
+ private Input2JmsInputTransformer t1;
+ private JmsInput2InputTransformer t2;
+ private Output2JmsOutputTransformer t3;
+ private JmsOutput2OutputTransformer t4;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ t1 = new Input2JmsInputTransformer();
+ t2 = new JmsInput2InputTransformer();
+ t3 = new Output2JmsOutputTransformer();
+ t4 = new JmsOutput2OutputTransformer();
+ }
+
+ public void testInput() {
+ Object[] args1 = new Object[] {1, "ABC", 1.0d};
+ Object[] args2 = t1.transform(args1, null);
+ assertEquals(1, args2.length);
+ assertTrue(args2[0] instanceof byte[]);
+ Object[] args3 = t2.transform(args2, null);
+ for (int i = 0; i < args3.length; i++) {
+ assertEquals(args1[i], args3[i]);
+ }
+
+ }
+
+ public void testOutput() {
+ Object args1 = "ABC";
+ Object args2 = t3.transform(args1, null);
+ assertTrue(args2 instanceof byte[]);
+ Object args3 = t4.transform(args2, null);
+ assertEquals(args1, args3);
+ }
+
+}