From e5b7380c874745c989d1816b8f552504f038e1bc Mon Sep 17 00:00:00 2001 From: lresende Date: Thu, 26 Sep 2013 20:33:20 +0000 Subject: 2.0 branch for possible maintenance release git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1526672 13f79535-47bb-0310-9956-ffa450edef68 --- .../jmstextxml/helloworld/CheckedException.java | 28 ++++ .../jmstextxml/helloworld/HelloWorldReference.java | 33 +++++ .../helloworld/HelloWorldReferenceImpl.java | 62 ++++++++ .../jmstextxml/helloworld/HelloWorldService.java | 35 +++++ .../helloworld/HelloWorldServiceImpl.java | 44 ++++++ .../jms/format/jmstextxml/helloworld/Person.java | 42 ++++++ .../main/resources/META-INF/sca-contribution.xml | 23 +++ .../main/resources/jmstextxml/helloworld.composite | 80 ++++++++++ .../src/main/resources/jmstextxml/helloworld.wsdl | 161 +++++++++++++++++++++ .../src/main/resources/jndi.properties | 39 +++++ .../jms/format/FormatJMSTextXMLTestCase.java | 62 ++++++++ 11 files changed, 609 insertions(+) create mode 100644 sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java create mode 100644 sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java create mode 100644 sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java create mode 100644 sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java create mode 100644 sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java create mode 100644 sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java create mode 100644 sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite create mode 100644 sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl create mode 100644 sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/jndi.properties create mode 100644 sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java (limited to 'sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src') diff --git a/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java new file mode 100644 index 0000000000..5e9a7a316e --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java @@ -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.format.jmstextxml.helloworld; + +public class CheckedException extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedException(String s) { + super(s); + } +} diff --git a/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java new file mode 100644 index 0000000000..768b293380 --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java @@ -0,0 +1,33 @@ +/* + * 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.format.jmstextxml.helloworld; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldReference { + + public String getGreetings(String name); + public String getPersonGreetings(Person person); + +} + diff --git a/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java new file mode 100644 index 0000000000..2bac5db5ab --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java @@ -0,0 +1,62 @@ +/* + * 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.format.jmstextxml.helloworld; + +import org.oasisopen.sca.annotation.Reference; + +public class HelloWorldReferenceImpl implements HelloWorldReference { + + @Reference + protected HelloWorldService helloWorldService1; + + @Reference + protected HelloWorldService helloWorldService2; + + @Reference + protected HelloWorldService helloWorldService3; + + public String getGreetings(String name){ + String stringValue = helloWorldService1.getGreetings(name) + " " + + helloWorldService2.getGreetings(name) + " " + + helloWorldService3.getGreetings(name); + + return stringValue; + } + + public String getPersonGreetings(Person person){ + String stringValue = helloWorldService1.getPersonGreetings(person) + " " + + helloWorldService2.getPersonGreetings(person) + " " + + helloWorldService3.getPersonGreetings(person); + + try { + helloWorldService1.throwChecked(person.getLastName()); + } catch (CheckedException e) { + stringValue += " " + e.getMessage(); + } + + try { + helloWorldService1.throwUnChecked(person.getLastName()); + } catch (Exception e) { + stringValue += " " + e.getMessage(); + } + + return stringValue; + } +} + diff --git a/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..fe200e3cbe --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java @@ -0,0 +1,35 @@ +/* + * 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.format.jmstextxml.helloworld; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetings(String name); + public String getPersonGreetings(Person person); + + public String throwChecked(String msg) throws CheckedException; + public String throwUnChecked(String msg); +} + diff --git a/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..80624ee770 --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java @@ -0,0 +1,44 @@ +/* + * 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.format.jmstextxml.helloworld; + + +public class HelloWorldServiceImpl implements HelloWorldService { + + public String getGreetings(String name){ + String response = "Hello " + name; + System.out.println("getGreetings: " + response); + return response; + } + + public String getPersonGreetings(Person person){ + String response = "Hello " + person.getFirstName() + " " + person.getLastName(); + System.out.println("getPersonGreetings: " + response); + return response; + } + + public String throwChecked(String msg) throws CheckedException { + throw new CheckedException("foo"); + } + + public String throwUnChecked(String msg) { + throw new RuntimeException("bla"); + } +} + diff --git a/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java new file mode 100644 index 0000000000..175b482c81 --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java @@ -0,0 +1,42 @@ +/* + * 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.format.jmstextxml.helloworld; + +public class Person { + String firstName; + String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + +} + diff --git a/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..ced023ecdd --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite new file mode 100644 index 0000000000..c15d99550e --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl new file mode 100644 index 0000000000..ac68c85fd5 --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/jndi.properties b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/main/resources/jndi.properties @@ -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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +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 + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] +queue.RequestQueue = RequestQueue +queue.ResponseQueue = ResponseQueue + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic + +# END SNIPPET: jndi diff --git a/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java new file mode 100644 index 0000000000..6054050a5d --- /dev/null +++ b/sca-java-2.x/branches/2.0/testing/itest/jms/format-jmstextxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java @@ -0,0 +1,62 @@ +/* + * 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.format; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.HelloWorldReference; +import org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.Person; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +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 FormatJMSTextXMLTestCase { + + private static Node node; + + @Before + public void init() { + node = NodeFactory.newInstance().createNode().start(); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldReference helloWorldService = node.getService(HelloWorldReference.class, "HelloWorldReferenceComponent"); + + assertEquals("Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs", helloWorldService.getGreetings("Fred Bloggs")); + + Person person = new Person(); + person.setFirstName("Fred"); + person.setLastName("Bloggs"); + assertEquals("Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs foo remote service exception, see nested exception", helloWorldService.getPersonGreetings(person)); + } + + @After + public void end() { + if (node != null) { + node.stop(); + } + } +} -- cgit v1.2.3