summaryrefslogtreecommitdiffstats
path: root/sandbox/sebastien/java/sca-node/itest/exceptions
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/sebastien/java/sca-node/itest/exceptions')
-rw-r--r--sandbox/sebastien/java/sca-node/itest/exceptions/pom.xml45
-rw-r--r--sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java58
-rw-r--r--sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java32
-rw-r--r--sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java30
-rw-r--r--sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java38
-rw-r--r--sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java57
-rw-r--r--sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java115
-rw-r--r--sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java44
-rw-r--r--sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java45
-rw-r--r--sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java116
-rw-r--r--sandbox/sebastien/java/sca-node/itest/exceptions/src/main/resources/ExceptionTest.composite41
-rw-r--r--sandbox/sebastien/java/sca-node/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java73
12 files changed, 694 insertions, 0 deletions
diff --git a/sandbox/sebastien/java/sca-node/itest/exceptions/pom.xml b/sandbox/sebastien/java/sca-node/itest/exceptions/pom.xml
new file mode 100644
index 0000000000..d138e13fc0
--- /dev/null
+++ b/sandbox/sebastien/java/sca-node/itest/exceptions/pom.xml
@@ -0,0 +1,45 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-exceptions</artifactId>
+ <name>Apache Tuscany SCA Exceptions Integration Tests</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>2.0-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-incubating-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java
new file mode 100644
index 0000000000..b95b0ccb31
--- /dev/null
+++ b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java
@@ -0,0 +1,58 @@
+/*
+ * 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.test.exceptions;
+
+
+public class Checked extends Exception {
+ private static final long serialVersionUID = -129752837478357452L;
+
+ /**
+ *
+ */
+ public Checked() {
+
+ }
+
+ /**
+ * @param message
+ */
+ public Checked(String message) {
+ super(message);
+
+ }
+
+ /**
+ * @param cause
+ */
+ public Checked(Throwable cause) {
+ super(cause);
+
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public Checked(String message, Throwable cause) {
+ super(message, cause);
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java
new file mode 100644
index 0000000000..5740e053a9
--- /dev/null
+++ b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java
@@ -0,0 +1,32 @@
+/*
+ * 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.test.exceptions;
+
+public interface ExceptionHandler {
+
+ public void testing();
+
+ public Checked getTheBad();
+
+ public String getTheGood();
+
+ public UnChecked getTheUgly();
+
+}
diff --git a/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java
new file mode 100644
index 0000000000..f923133ee9
--- /dev/null
+++ b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java
@@ -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.test.exceptions;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Remote exception thrower
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface ExceptionRemoteThrower extends ExceptionThrower {
+}
diff --git a/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java
new file mode 100644
index 0000000000..55d81102d2
--- /dev/null
+++ b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java
@@ -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.test.exceptions;
+
+
+/**
+ * Local exception thrower
+ * @version $Rev$ $Date$
+ */
+public interface ExceptionThrower {
+ public static final Checked BAD = new Checked("theBad");
+ public static final UnChecked UGLY = new UnChecked("theUgly");
+ public static final String SO_THEY_SAY = "All is good that ends good.";
+
+ public String theGood() throws Checked;
+
+ public String theBad() throws Checked;
+
+ public String theUgly() throws Checked;
+
+}
diff --git a/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java
new file mode 100644
index 0000000000..453528444d
--- /dev/null
+++ b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java
@@ -0,0 +1,57 @@
+/*
+ * 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.test.exceptions;
+
+public class UnChecked extends RuntimeException {
+ private static final long serialVersionUID = -1318118082838092244L;
+
+ /**
+ *
+ */
+ public UnChecked() {
+
+ }
+
+ /**
+ * @param message
+ */
+ public UnChecked(String message) {
+ super(message);
+
+ }
+
+ /**
+ * @param cause
+ */
+ public UnChecked(Throwable cause) {
+ super(cause);
+
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public UnChecked(String message, Throwable cause) {
+ super(message, cause);
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java
new file mode 100644
index 0000000000..1987490a0a
--- /dev/null
+++ b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java
@@ -0,0 +1,115 @@
+/*
+ * 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.test.exceptions.impl;
+
+import org.apache.tuscany.sca.test.exceptions.Checked;
+import org.apache.tuscany.sca.test.exceptions.ExceptionHandler;
+import org.apache.tuscany.sca.test.exceptions.ExceptionThrower;
+import org.apache.tuscany.sca.test.exceptions.UnChecked;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("COMPOSITE")
+public class ExceptionHandlerImpl implements ExceptionHandler {
+ static final String INIT = "INIT";
+
+ private ExceptionThrower exceptionThrower;
+
+ private String theGood;
+
+ private Checked theBad;
+
+ private UnChecked theUgly;
+
+ public void testing() {
+
+ assert exceptionThrower != null : "'exceptionThrower' never wired";
+ String result = INIT;
+ try {
+ theGood = result = exceptionThrower.theGood();
+ assert result == ExceptionThrower.SO_THEY_SAY;
+ } catch (Throwable e) {
+ assert result == INIT;
+ assert false;
+ e.printStackTrace();
+ }
+
+ result = INIT;
+ try {
+ result = exceptionThrower.theBad();
+ // incredible
+ assert false : "Expected 'Check' Exception";
+
+ } catch (Checked e) {
+ // This is good...
+ assert result == INIT;
+ theBad = e;
+ } catch (Throwable t) {
+ // This is not so good.
+ t.printStackTrace();
+ assert result == INIT;
+ assert false : "Got wrong exception '" + t.getClass().getName();
+ }
+
+ result = INIT;
+ try {
+ result = exceptionThrower.theUgly();
+ // incredible
+ assert false : "Expected 'UnCheck' Exception";
+
+ } catch (Checked e) {
+ // This is not so good...
+ assert false : "Got wrong exception '" + e.getClass().getName();
+ assert result == INIT;
+ } catch (UnChecked e) {
+ theUgly = e;
+
+ } catch (Throwable t) {
+ // This is not good.
+ assert false;
+ assert result == INIT;
+
+ System.out.println(ExceptionThrower.SO_THEY_SAY + " " + INIT);
+ }
+
+ }
+
+ @Reference
+ public void setExceptionThrower(ExceptionThrower exceptionThrower) {
+ this.exceptionThrower = exceptionThrower;
+ }
+
+ public String getTheGood() {
+ return theGood;
+ }
+
+ public Checked getTheBad() {
+ return theBad;
+ }
+
+ public UnChecked getTheUgly() {
+ return theUgly;
+ }
+
+ public ExceptionThrower getExceptionThrower() {
+ return exceptionThrower;
+ }
+
+}
diff --git a/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java
new file mode 100644
index 0000000000..c4cb52f94c
--- /dev/null
+++ b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.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.test.exceptions.impl;
+
+import org.apache.tuscany.sca.test.exceptions.Checked;
+import org.apache.tuscany.sca.test.exceptions.ExceptionRemoteThrower;
+import org.osoa.sca.annotations.Service;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(ExceptionRemoteThrower.class)
+public class ExceptionRemoteThrowerImpl implements ExceptionRemoteThrower {
+ public String theBad() throws Checked {
+ throw BAD;
+ }
+
+ public String theGood() throws Checked {
+ return SO_THEY_SAY;
+ }
+
+ public String theUgly() throws Checked {
+ throw UGLY;
+ }
+
+}
diff --git a/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java
new file mode 100644
index 0000000000..cf8740ba56
--- /dev/null
+++ b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java
@@ -0,0 +1,45 @@
+/*
+ * 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.test.exceptions.impl;
+
+import org.apache.tuscany.sca.test.exceptions.Checked;
+import org.apache.tuscany.sca.test.exceptions.ExceptionThrower;
+import org.osoa.sca.annotations.Service;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(ExceptionThrower.class)
+public class ExceptionThrowerImpl implements ExceptionThrower {
+
+ public String theBad() throws Checked {
+ throw BAD;
+ }
+
+ public String theGood() throws Checked {
+ return SO_THEY_SAY;
+ }
+
+ public String theUgly() throws Checked {
+ throw UGLY;
+ }
+
+}
diff --git a/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java
new file mode 100644
index 0000000000..f82a30d529
--- /dev/null
+++ b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java
@@ -0,0 +1,116 @@
+/*
+ * 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.test.exceptions.impl;
+
+import org.apache.tuscany.sca.test.exceptions.Checked;
+import org.apache.tuscany.sca.test.exceptions.ExceptionHandler;
+import org.apache.tuscany.sca.test.exceptions.ExceptionRemoteThrower;
+import org.apache.tuscany.sca.test.exceptions.ExceptionThrower;
+import org.apache.tuscany.sca.test.exceptions.UnChecked;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("COMPOSITE")
+public class RemoteExceptionHandlerImpl implements ExceptionHandler {
+ static final String INIT = "INIT";
+
+ private ExceptionRemoteThrower exceptionThrower;
+
+ private String theGood;
+
+ private Checked theBad;
+
+ private UnChecked theUgly;
+
+ public void testing() {
+
+ assert exceptionThrower != null : "'exceptionThrower' never wired";
+ String result = INIT;
+ try {
+ theGood = result = exceptionThrower.theGood();
+ assert result == ExceptionThrower.SO_THEY_SAY;
+ } catch (Throwable e) {
+ assert result == INIT;
+ assert false;
+ e.printStackTrace();
+ }
+
+ result = INIT;
+ try {
+ result = exceptionThrower.theBad();
+ // incredible
+ assert false : "Expected 'Check' Exception";
+
+ } catch (Checked e) {
+ // This is good...
+ assert result == INIT;
+ theBad = e;
+ } catch (Throwable t) {
+ // This is not so good.
+ t.printStackTrace();
+ assert result == INIT;
+ assert false : "Got wrong exception '" + t.getClass().getName();
+ }
+
+ result = INIT;
+ try {
+ result = exceptionThrower.theUgly();
+ // incredible
+ assert false : "Expected 'UnCheck' Exception";
+
+ } catch (Checked e) {
+ // This is not so good...
+ assert false : "Got wrong exception '" + e.getClass().getName();
+ assert result == INIT;
+ } catch (UnChecked e) {
+ theUgly = e;
+
+ } catch (Throwable t) {
+ // This is not good.
+ assert false;
+ assert result == INIT;
+
+ System.out.println(ExceptionThrower.SO_THEY_SAY + " " + INIT);
+ }
+
+ }
+
+ @Reference
+ public void setExceptionThrower(ExceptionRemoteThrower exceptionThrower) {
+ this.exceptionThrower = exceptionThrower;
+ }
+
+ public String getTheGood() {
+ return theGood;
+ }
+
+ public Checked getTheBad() {
+ return theBad;
+ }
+
+ public UnChecked getTheUgly() {
+ return theUgly;
+ }
+
+ public ExceptionRemoteThrower getExceptionThrower() {
+ return exceptionThrower;
+ }
+
+}
diff --git a/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/resources/ExceptionTest.composite b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/resources/ExceptionTest.composite
new file mode 100644
index 0000000000..d27797c2fe
--- /dev/null
+++ b/sandbox/sebastien/java/sca-node/itest/exceptions/src/main/resources/ExceptionTest.composite
@@ -0,0 +1,41 @@
+<?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" xmlns:foo="http://foo" targetNamespace="http://foo"
+ name="ExceptionTest">
+ <component name="main">
+ <implementation.java class="org.apache.tuscany.sca.test.exceptions.impl.ExceptionHandlerImpl" />
+ <reference name="exceptionThrower" target="exceptionThrower" />
+ </component>
+
+ <component name="exceptionThrower">
+ <implementation.java class="org.apache.tuscany.sca.test.exceptions.impl.ExceptionThrowerImpl" />
+ </component>
+
+ <component name="mainRemote">
+ <implementation.java class="org.apache.tuscany.sca.test.exceptions.impl.RemoteExceptionHandlerImpl" />
+ <reference name="exceptionThrower" target="exceptionThrowerRemote" />
+ </component>
+
+ <component name="exceptionThrowerRemote">
+ <implementation.java class="org.apache.tuscany.sca.test.exceptions.impl.ExceptionRemoteThrowerImpl" />
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/sca-node/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java b/sandbox/sebastien/java/sca-node/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java
new file mode 100644
index 0000000000..f84205c096
--- /dev/null
+++ b/sandbox/sebastien/java/sca-node/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java
@@ -0,0 +1,73 @@
+/*
+ * 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.test.exceptions;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class ExceptionsTestCase extends TestCase {
+
+ private SCADomain domain;
+
+ /**
+ * Test exception handling over a local interface
+ */
+ public void testLocal() {
+ ExceptionHandler exceptionHandler = domain.getService(ExceptionHandler.class, "main");
+ exceptionHandler.testing();
+ assertEquals(ExceptionThrower.SO_THEY_SAY, exceptionHandler.getTheGood() );
+ assertNotNull(exceptionHandler.getTheBad());
+ assertEquals( Checked.class, exceptionHandler.getTheBad().getClass());
+ assertSame(ExceptionThrower.BAD, exceptionHandler.getTheBad());
+ assertNotNull(exceptionHandler.getTheUgly());
+ assertEquals( UnChecked.class, exceptionHandler.getTheUgly().getClass());
+ assertSame(ExceptionThrower.UGLY, exceptionHandler.getTheUgly());
+ }
+
+ /**
+ * Test exception handling over a remotable interface
+ */
+ public void testRemote() {
+ ExceptionHandler exceptionHandler = domain.getService(ExceptionHandler.class, "mainRemote");
+ exceptionHandler.testing();
+ assertEquals(ExceptionThrower.SO_THEY_SAY, exceptionHandler.getTheGood() );
+ assertNotNull(exceptionHandler.getTheBad());
+ assertEquals( Checked.class, exceptionHandler.getTheBad().getClass());
+ assertNotSame(ExceptionThrower.BAD, exceptionHandler.getTheBad());
+ assertNotNull(exceptionHandler.getTheUgly());
+ assertEquals( UnChecked.class, exceptionHandler.getTheUgly().getClass());
+
+ // [rfeng] We're not in a position to copy non business exceptions
+ // assertNotSame(ExceptionThrower.UGLY, exceptionHandler.getTheUgly());
+
+ }
+
+
+ @Override
+ protected void setUp() throws Exception {
+ domain = SCADomain.newInstance("ExceptionTest.composite");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+}