From 08ba6e53202a2b2f20dd8ea6e2a315fb80ff818a Mon Sep 17 00:00:00 2001 From: slaws Date: Tue, 19 May 2009 16:45:52 +0000 Subject: TUSCANY-2967 - to aid investigation of possible exception processing refactoring enhance format tests to test checked and unchecked exceptions. Also add a wf.jmsText test. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@776381 13f79535-47bb-0310-9956-ffa450edef68 --- .../jmstextxml/helloworld/CheckedException.java | 28 ++++++++++++++++++ .../jmstextxml/helloworld/HelloWorldReference.java | 33 ++++++++++++++++++++++ .../helloworld/HelloWorldReferenceImpl.java | 31 ++++++++++++++------ .../jmstextxml/helloworld/HelloWorldService.java | 7 +++-- .../helloworld/HelloWorldServiceImpl.java | 10 +++++++ 5 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java create mode 100644 branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java (limited to 'branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml') diff --git a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java new file mode 100644 index 0000000000..c45e3899e0 --- /dev/null +++ b/branches/sca-java-1.x/itest/jms-format/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/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java new file mode 100644 index 0000000000..e5cd9db281 --- /dev/null +++ b/branches/sca-java-1.x/itest/jms-format/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.osoa.sca.annotations.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/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java index 7a4f4df2e7..c54e195178 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java +++ b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java @@ -20,8 +20,7 @@ package org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld; import org.osoa.sca.annotations.Reference; - -public class HelloWorldReferenceImpl implements HelloWorldService { +public class HelloWorldReferenceImpl implements HelloWorldReference { @Reference protected HelloWorldService helloWorldService1; @@ -33,15 +32,31 @@ public class HelloWorldReferenceImpl implements HelloWorldService { protected HelloWorldService helloWorldService3; public String getGreetings(String name){ - return helloWorldService1.getGreetings(name) + " " + - helloWorldService2.getGreetings(name) + " " + - helloWorldService3.getGreetings(name); + String stringValue = helloWorldService1.getGreetings(name) + " " + + helloWorldService2.getGreetings(name) + " " + + helloWorldService3.getGreetings(name); + + return stringValue; } public String getPersonGreetings(Person person){ - return helloWorldService1.getPersonGreetings(person) + " " + - helloWorldService2.getPersonGreetings(person) + " " + - helloWorldService3.getPersonGreetings(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/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java index bf19e9069b..a98f589b9a 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java +++ b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java @@ -18,6 +18,7 @@ */ package org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld; +import org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.CheckedException; import org.osoa.sca.annotations.Remotable; /** @@ -26,8 +27,10 @@ import org.osoa.sca.annotations.Remotable; @Remotable public interface HelloWorldService { - public String getGreetings(String name); - + public String getGreetings(String name); public String getPersonGreetings(Person person); + + public void throwChecked(String msg) throws CheckedException; + public void throwUnChecked(String msg); } diff --git a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java index e1706dbe6b..7965388013 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java +++ b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java @@ -18,6 +18,8 @@ */ package org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld; +import org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.CheckedException; + public class HelloWorldServiceImpl implements HelloWorldService { public String getGreetings(String name){ @@ -31,5 +33,13 @@ public class HelloWorldServiceImpl implements HelloWorldService { System.out.println("getPersonGreetings: " + response); return response; } + + public void throwChecked(String msg) throws CheckedException { + throw new CheckedException("foo"); + } + + public void throwUnChecked(String msg) { + throw new RuntimeException("bla"); + } } -- cgit v1.2.3