Author: rfeng
Date: Wed Jun 25 08:52:32 2008
New Revision: 671590

URL: http://svn.apache.org/viewvc?rev=671590&view=rev
Log:
Merge the fix for TUSCANY-2406 from trunk

Added:
    
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloException.java
      - copied unchanged from r671234, 
tuscany/java/sca/modules/binding-rmi/src/test/java/helloworld/HelloException.java
Modified:
    
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java
    
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java
    
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java
    
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiService.java
    
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldService.java
    
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java

Modified: 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java
URL: 
http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java?rev=671590&r1=671589&r2=671590&view=diff
==============================================================================
--- 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java
 (original)
+++ 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java
 Wed Jun 25 08:52:32 2008
@@ -97,7 +97,17 @@
         enhancer.setSuperclass(UnicastRemoteObject.class);
         enhancer.setCallback(new MethodInterceptor() {
             public Object intercept(Object arg0, Method method, Object[] args, 
MethodProxy arg3) throws Throwable {
-                return invokeTarget(JavaInterfaceUtil.findOperation(method, 
serviceInterface.getOperations()), args);
+                try {
+                    return 
invokeTarget(JavaInterfaceUtil.findOperation(method, 
serviceInterface.getOperations()), args);
+                } catch (InvocationTargetException e) {
+                    Throwable cause = e.getCause();
+                    for (Class<?> declaredType : method.getExceptionTypes()) {
+                        if (declaredType.isInstance(cause)) {
+                            throw e;
+                        }
+                    }
+                    throw cause;
+                }
             }
         });
         Class targetJavaInterface = getTargetJavaClass(serviceInterface);

Modified: 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java?rev=671590&r1=671589&r2=671590&view=diff
==============================================================================
--- 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java
 (original)
+++ 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java
 Wed Jun 25 08:52:32 2008
@@ -33,7 +33,10 @@
         return "Hello from the RMI Service to - " + name;
     }
     
-    public String sayHi(String name, String greeter) {
+    public String sayHi(String name, String greeter) throws HelloException {
+        if (name == null || greeter == null) {
+            throw new HelloException("Invalid name or greeter: name=" + name + 
" greeter=" + greeter);
+        }
         return "Hi from " + greeter + " in RMI Service to - " + name;
     }
 }

Modified: 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java?rev=671590&r1=671589&r2=671590&view=diff
==============================================================================
--- 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java
 (original)
+++ 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java
 Wed Jun 25 08:52:32 2008
@@ -43,7 +43,7 @@
         return extService.sayHello(name) + " thro the RMI Reference";
     }
     
-    public String sayRmiHi(String name, String greeter) {
+    public String sayRmiHi(String name, String greeter) throws HelloException {
         return extService.sayHi(name, greeter) + " thro the RMI Reference";
     }
 

Modified: 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiService.java
URL: 
http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiService.java?rev=671590&r1=671589&r2=671590&view=diff
==============================================================================
--- 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiService.java
 (original)
+++ 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiService.java
 Wed Jun 25 08:52:32 2008
@@ -26,6 +26,6 @@
 public interface HelloWorldRmiService {
 
     String sayRmiHello(String name);
-    String sayRmiHi(String name, String greeter);
+    String sayRmiHi(String name, String greeter) throws HelloException;
 
 }

Modified: 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldService.java
URL: 
http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldService.java?rev=671590&r1=671589&r2=671590&view=diff
==============================================================================
--- 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldService.java
 (original)
+++ 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/helloworld/HelloWorldService.java
 Wed Jun 25 08:52:32 2008
@@ -26,6 +26,6 @@
 public interface HelloWorldService {
 
     String sayHello(String name);
-    String sayHi(String name, String greeter);
+    String sayHi(String name, String greeter) throws HelloException;
 
 }

Modified: 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java?rev=671590&r1=671589&r2=671590&view=diff
==============================================================================
--- 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java
 (original)
+++ 
tuscany/branches/sca-java-1.3/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java
 Wed Jun 25 08:52:32 2008
@@ -18,6 +18,7 @@
  */
 package org.apache.tuscany.sca.binding.rmi;
 
+import helloworld.HelloException;
 import helloworld.HelloWorldRmiService;
 import junit.framework.Assert;
 
@@ -34,32 +35,38 @@
 public class BindingTestCase {
     private static HelloWorldRmiService helloWorldRmiService;
     private static SCADomain domain;
- 
+
     @Test
     public void testRmiService() {
-        System.out.println(helloWorldRmiService.sayRmiHello("Tuscany World!"));
-        Assert.assertEquals("Hello from the RMI Service to - Tuscany World! 
thro the RMI Reference",
-                helloWorldRmiService.sayRmiHello("Tuscany World!"));
-        
-        System.out.println(helloWorldRmiService.sayRmiHi("Tuscany World!", 
"Apache World"));
-        
-        Assert.assertEquals("Hi from Apache World in RMI Service to - Tuscany 
World! thro the RMI Reference",
-                            helloWorldRmiService.sayRmiHi("Tuscany World!", 
"Apache World"));
-    }
+        String msg = helloWorldRmiService.sayRmiHello("Tuscany World!");
+        System.out.println(msg);
+        Assert.assertEquals("Hello from the RMI Service to - Tuscany World! 
thro the RMI Reference", msg);
+
+        try {
+            msg = helloWorldRmiService.sayRmiHi("Tuscany World!", "Apache 
World");
+            System.out.println(msg);
+            Assert.assertEquals("Hi from Apache World in RMI Service to - 
Tuscany World! thro the RMI Reference", msg);
+        } catch (HelloException e) {
+            Assert.fail(e.getMessage());
+        }
+        try {
+            msg = helloWorldRmiService.sayRmiHi(null, "Apache World");
+            Assert.fail("HelloException should have been thrown");
+        } catch (HelloException e) {
 
+        }
+    }
 
-    
     @BeforeClass
     public static void init() throws Exception {
-try {
-        domain = SCADomain.newInstance("RMIBindingTest.composite");
-        helloWorldRmiService = 
-            domain.getService(HelloWorldRmiService.class, 
"HelloWorldRmiServiceComponent");
-} catch (Exception e) {
-    e.printStackTrace();
-}
-  }
-    
+        try {
+            domain = SCADomain.newInstance("RMIBindingTest.composite");
+            helloWorldRmiService = 
domain.getService(HelloWorldRmiService.class, "HelloWorldRmiServiceComponent");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     @AfterClass
     public static void destroy() throws Exception {
         domain.close();


Reply via email to