You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2008/02/25 19:53:00 UTC
svn commit: r630955 - in /incubator/tuscany/java/sca/itest/exceptions/src:
main/java/org/apache/tuscany/sca/test/exceptions/
main/java/org/apache/tuscany/sca/test/exceptions/impl/ main/resources/
test/java/org/apache/tuscany/sca/test/exceptions/
Author: rfeng
Date: Mon Feb 25 10:52:48 2008
New Revision: 630955
URL: http://svn.apache.org/viewvc?rev=630955&view=rev
Log:
Add an itest to cover exception handling over remotable interfaces
Added:
incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java (with props)
incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java (with props)
incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java (with props)
incubator/tuscany/java/sca/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java
- copied, changed from r630244, incubator/tuscany/java/sca/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/IntraCompositeTestCase.java
Removed:
incubator/tuscany/java/sca/itest/exceptions/src/main/resources/intracomposite.composite
incubator/tuscany/java/sca/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/IntraCompositeTestCase.java
Modified:
incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java
incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java
incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java
incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java
incubator/tuscany/java/sca/itest/exceptions/src/main/resources/ExceptionTest.composite
Modified: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java?rev=630955&r1=630954&r2=630955&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java (original)
+++ incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java Mon Feb 25 10:52:48 2008
@@ -21,12 +21,12 @@
public interface ExceptionHandler {
- public abstract void testing();
+ public void testing();
- public abstract Checked getTheBad();
+ public Checked getTheBad();
- public abstract String getTheGood();
+ public String getTheGood();
- public abstract UnChecked getTheUgly();
+ public UnChecked getTheUgly();
-}
\ No newline at end of file
+}
Added: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java?rev=630955&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java (added)
+++ incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java Mon Feb 25 10:52:48 2008
@@ -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 {
+}
Propchange: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java?rev=630955&r1=630954&r2=630955&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java (original)
+++ incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java Mon Feb 25 10:52:48 2008
@@ -19,13 +19,20 @@
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 org.apache.tuscany.sca.test.exceptions.Checked;
+ public String theGood() throws Checked;
- public String theBad() throws org.apache.tuscany.sca.test.exceptions.Checked;
+ public String theBad() throws Checked;
- public String theUgly() throws org.apache.tuscany.sca.test.exceptions.Checked;
+ public String theUgly() throws Checked;
}
Modified: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java?rev=630955&r1=630954&r2=630955&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java (original)
+++ incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java Mon Feb 25 10:52:48 2008
@@ -38,11 +38,6 @@
private UnChecked theUgly;
- /*
- * (non-Javadoc)
- *
- * @see org.apache.tuscany.sca.test.exceptions.impl.ExceptionHandler#testing()
- */
public void testing() {
assert exceptionThrower != null : "'exceptionThrower' never wired";
Added: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java?rev=630955&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java (added)
+++ incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java Mon Feb 25 10:52:48 2008
@@ -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;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java?rev=630955&r1=630954&r2=630955&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java (original)
+++ incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java Mon Feb 25 10:52:48 2008
@@ -21,28 +21,25 @@
import org.apache.tuscany.sca.test.exceptions.Checked;
import org.apache.tuscany.sca.test.exceptions.ExceptionThrower;
-import org.apache.tuscany.sca.test.exceptions.UnChecked;
+import org.osoa.sca.annotations.Service;
/**
- *
- *
+ *
+ * @version $Rev$ $Date$
*/
+@Service(ExceptionThrower.class)
public class ExceptionThrowerImpl implements ExceptionThrower {
public String theBad() throws Checked {
-
- throw new Checked("theBad");
-
+ throw BAD;
}
public String theGood() throws Checked {
-
return SO_THEY_SAY;
}
public String theUgly() throws Checked {
-
- throw new UnChecked("theUgly");
+ throw UGLY;
}
}
Added: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java?rev=630955&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java (added)
+++ incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java Mon Feb 25 10:52:48 2008
@@ -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;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/itest/exceptions/src/main/resources/ExceptionTest.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/exceptions/src/main/resources/ExceptionTest.composite?rev=630955&r1=630954&r2=630955&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/exceptions/src/main/resources/ExceptionTest.composite (original)
+++ incubator/tuscany/java/sca/itest/exceptions/src/main/resources/ExceptionTest.composite Mon Feb 25 10:52:48 2008
@@ -1,27 +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.
+ * 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">
-
- <include name="foo:intracomposite"/>
-
+<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>
Copied: incubator/tuscany/java/sca/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java (from r630244, incubator/tuscany/java/sca/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/IntraCompositeTestCase.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java?p2=incubator/tuscany/java/sca/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java&p1=incubator/tuscany/java/sca/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/IntraCompositeTestCase.java&r1=630244&r2=630955&rev=630955&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/IntraCompositeTestCase.java (original)
+++ incubator/tuscany/java/sca/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java Mon Feb 25 10:52:48 2008
@@ -22,25 +22,45 @@
import org.apache.tuscany.sca.host.embedded.SCADomain;
-public class IntraCompositeTestCase extends TestCase {
+public class ExceptionsTestCase extends TestCase {
private SCADomain domain;
- private ExceptionHandler exceptionHandler;
- public void testALL() {
+ /**
+ * 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());
+ assertNotSame(ExceptionThrower.UGLY, exceptionHandler.getTheUgly());
}
+
@Override
protected void setUp() throws Exception {
domain = SCADomain.newInstance("ExceptionTest.composite");
- exceptionHandler = domain.getService(ExceptionHandler.class, "main");
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org