diff options
Diffstat (limited to 'sandbox/old/contrib/binding-jms/src/test')
12 files changed, 731 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); + } + +} diff --git a/sandbox/old/contrib/binding-jms/src/test/resources/META-INF/sca/default.scdl b/sandbox/old/contrib/binding-jms/src/test/resources/META-INF/sca/default.scdl new file mode 100644 index 0000000000..7291363978 --- /dev/null +++ b/sandbox/old/contrib/binding-jms/src/test/resources/META-INF/sca/default.scdl @@ -0,0 +1,61 @@ + <!--
+ * 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" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ name="jms.sample">
+
+ <service name="GreetingJMSService">
+ <interface.java class="org.apache.tuscany.binding.jms.GreetingService"/>
+ <binding.jms initialContextFactory="org.activemq.jndi.ActiveMQInitialContextFactory" JNDIProviderURL="tcp://localhost:61616" >
+ <destination name="greetingServiceQueue" />
+ <connectionFactory name="ConnectionFactory" />
+ </binding.jms>
+ <reference>GretingServiceComponent</reference>
+ </service>
+
+ <component name="GretingServiceComponent">
+ <implementation.java class="org.apache.tuscany.binding.jms.GreetingServiceImpl"/>
+ </component>
+
+ <component name="IntroServiceComponent">
+ <implementation.java class="org.apache.tuscany.binding.jms.IntroServiceImpl"/>
+ <reference name="extService" target="GreetingJMSReference">GreetingJMSReference</reference>
+ </component>
+
+ <reference name="GreetingJMSReference">
+ <interface.java class="org.apache.tuscany.binding.jms.GreetingService"/>
+ <binding.jms initialContextFactory="org.activemq.jndi.ActiveMQInitialContextFactory" JNDIProviderURL="tcp://localhost:61616" >
+ <destination name="dynamicQueues/greetingServiceQueue" />
+ <connectionFactory name="ConnectionFactory" />
+ </binding.jms>
+ </reference>
+
+ <service name="HelloworldJMSService">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)"
+ wsdli:wsdlLocation="http://helloworld wsdl/helloworld.wsdl" />
+ <binding.jms initialContextFactory="org.activemq.jndi.ActiveMQInitialContextFactory" JNDIProviderURL="tcp://localhost:61616" >
+ <destination name="HelloworldServiceQueue" />
+ <connectionFactory name="ConnectionFactory" />
+ </binding.jms>
+ <reference>HelloworldComponent</reference>
+ </service>
+
+ <component name="HelloworldComponent">
+ <implementation.java class="org.apache.tuscany.binding.jms.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
+
diff --git a/sandbox/old/contrib/binding-jms/src/test/resources/wsdl/helloworld.wsdl b/sandbox/old/contrib/binding-jms/src/test/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..f1a62d8570 --- /dev/null +++ b/sandbox/old/contrib/binding-jms/src/test/resources/wsdl/helloworld.wsdl @@ -0,0 +1,130 @@ +<?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. +--> +<wsdl:definitions targetNamespace="http://helloworld" xmlns:tns="http://helloworld" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="helloworld"> + + <wsdl:types> + <schema elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns="http://www.w3.org/2001/XMLSchema"> + + <element name="getGreetings"> + <complexType> + <sequence> + <element name="name" type="xsd:string"/> + </sequence> + </complexType> + </element> + + <element name="getGreetingsResponse"> + <complexType> + <sequence> + <element name="getGreetingsReturn" type="xsd:string"/> + </sequence> + </complexType> + </element> + + <element name="getGreetingsCallback"> + <complexType> + <sequence> + <element name="getGreetingsReturn" type="xsd:string"/> + </sequence> + </complexType> + </element> + + <element name="getGreetings1"> + <complexType> + <sequence> + <element name="name" type="tns:NameType"> + </element> + </sequence> + </complexType> + </element> + + <complexType name="NameType"> + <sequence> + <element name="firstName" type="string"/> + <element name="lastName" type="string"/> + </sequence> + </complexType> + + <element name="getGreetings1Response"> + <complexType> + <sequence> + <element name="getGreetingsReturn" type="xsd:string"/> + </sequence> + </complexType> + </element> + + </schema> + </wsdl:types> + + <wsdl:message name="getGreetingsRequest"> + <wsdl:part element="tns:getGreetings" name="parameters"/> + </wsdl:message> + + <wsdl:message name="getGreetingsResponse"> + <wsdl:part element="tns:getGreetingsResponse" name="parameters"/> + </wsdl:message> + + <wsdl:message name="getGreetingsCallback"> + <wsdl:part element="tns:getGreetingsCallback" name="parameters"/> + </wsdl:message> + + <wsdl:message name="getGreetings1Request"> + <wsdl:part element="tns:getGreetings1" name="parameters"/> + </wsdl:message> + + <wsdl:message name="getGreetings1Response"> + <wsdl:part element="tns:getGreetings1Response" name="parameters"/> + </wsdl:message> + + <wsdl:portType name="HelloWorld"> + <wsdl:operation name="getGreetings"> + <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/> + <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:portType name="HelloWorldCallback"> + <wsdl:operation name="getGreetingsCallback"> + <wsdl:input message="tns:getGreetingsCallback" name="getGreetingsCallback"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getGreetings"> + <wsdlsoap:operation soapAction=""/> + <wsdl:input name="getGreetingsRequest"> + <wsdlsoap:body use="literal"/> + </wsdl:input> + <wsdl:output name="getGreetingsResponse"> + <wsdlsoap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + + </wsdl:binding> + + <wsdl:service name="HelloWorldService"> + <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort"> + <wsdlsoap:address location="http://localhost:8080/sample-helloworldws-async-1.0-incubator-SNAPSHOT/services/HelloWorldWebService"/> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> |