cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject cxf-dosgi git commit: [DOSGI-254] Unit test to show the issue
Date Tue, 11 Jul 2017 08:59:52 GMT
Repository: cxf-dosgi
Updated Branches:
  refs/heads/master 2ce3ed1de -> 7a5315cbd


[DOSGI-254] Unit test to show the issue


Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/7a5315cb
Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/7a5315cb
Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/7a5315cb

Branch: refs/heads/master
Commit: 7a5315cbdc8ac751b43e6d5d1f94db24f6fdb2b0
Parents: 2ce3ed1
Author: Christian Schneider <chris@die-schneider.net>
Authored: Tue Jul 11 10:59:47 2017 +0200
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Tue Jul 11 10:59:47 2017 +0200

----------------------------------------------------------------------
 .../cxf/dosgi/common/proxy/MyBaseService.java   | 25 ++++++++++++++
 .../cxf/dosgi/common/proxy/MyServiceImpl.java   | 35 ++++++++++++++++++++
 .../cxf/dosgi/common/proxy/MySubService.java    | 25 ++++++++++++++
 .../proxy/ServiceInvocationHandlerTest.java     | 26 +++++++++++++--
 4 files changed, 109 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/7a5315cb/common/src/test/java/org/apache/cxf/dosgi/common/proxy/MyBaseService.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/cxf/dosgi/common/proxy/MyBaseService.java b/common/src/test/java/org/apache/cxf/dosgi/common/proxy/MyBaseService.java
new file mode 100644
index 0000000..b6f9495
--- /dev/null
+++ b/common/src/test/java/org/apache/cxf/dosgi/common/proxy/MyBaseService.java
@@ -0,0 +1,25 @@
+/**
+ * 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.cxf.dosgi.common.proxy;
+
+import java.io.IOException;
+
+public interface MyBaseService {
+    void throwException1() throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/7a5315cb/common/src/test/java/org/apache/cxf/dosgi/common/proxy/MyServiceImpl.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/cxf/dosgi/common/proxy/MyServiceImpl.java b/common/src/test/java/org/apache/cxf/dosgi/common/proxy/MyServiceImpl.java
new file mode 100644
index 0000000..60007a9
--- /dev/null
+++ b/common/src/test/java/org/apache/cxf/dosgi/common/proxy/MyServiceImpl.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.cxf.dosgi.common.proxy;
+
+import java.io.IOException;
+
+public class MyServiceImpl implements MySubService {
+
+    @Override
+    public void throwException1() throws IOException {
+        throw new IOException();
+    }
+
+    @Override
+    public void throwException2() throws IOException {
+        throw new IOException();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/7a5315cb/common/src/test/java/org/apache/cxf/dosgi/common/proxy/MySubService.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/cxf/dosgi/common/proxy/MySubService.java b/common/src/test/java/org/apache/cxf/dosgi/common/proxy/MySubService.java
new file mode 100644
index 0000000..5bc74cd
--- /dev/null
+++ b/common/src/test/java/org/apache/cxf/dosgi/common/proxy/MySubService.java
@@ -0,0 +1,25 @@
+/**
+ * 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.cxf.dosgi.common.proxy;
+
+import java.io.IOException;
+
+public interface MySubService extends MyBaseService {
+    void throwException2() throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/7a5315cb/common/src/test/java/org/apache/cxf/dosgi/common/proxy/ServiceInvocationHandlerTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/cxf/dosgi/common/proxy/ServiceInvocationHandlerTest.java
b/common/src/test/java/org/apache/cxf/dosgi/common/proxy/ServiceInvocationHandlerTest.java
index 92cdc75..30cf5a8 100644
--- a/common/src/test/java/org/apache/cxf/dosgi/common/proxy/ServiceInvocationHandlerTest.java
+++ b/common/src/test/java/org/apache/cxf/dosgi/common/proxy/ServiceInvocationHandlerTest.java
@@ -18,6 +18,9 @@
  */
 package org.apache.cxf.dosgi.common.proxy;
 
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.ArrayList;
@@ -26,9 +29,10 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+import org.osgi.framework.ServiceException;
 
-public class ServiceInvocationHandlerTest extends TestCase {
+public class ServiceInvocationHandlerTest {
 
     private static final Map<String, Method> OBJECT_METHODS = new HashMap<String,
Method>(); {
         for (Method m : Object.class.getMethods()) {
@@ -36,6 +40,7 @@ public class ServiceInvocationHandlerTest extends TestCase {
         }
     }
 
+    @Test
     public void testInvoke() throws Throwable {
         ServiceInvocationHandler sih = new ServiceInvocationHandler("hello", String.class);
         Method m = String.class.getMethod("length", new Class[] {});
@@ -72,4 +77,21 @@ public class ServiceInvocationHandlerTest extends TestCase {
                 sih.invoke(null, OBJECT_METHODS.get("toString"), new Object[] {}));
         assertEquals(Arrays.asList("equals", "hashCode", "toString"), called);
     }
+
+    @Test(expected = IOException.class)
+    public void testException() throws IOException {
+        MySubService proxy = (MySubService)ProxyFactory.create(new MyServiceImpl(), MySubService.class);
+        proxy.throwException2();
+    }
+    
+    /**
+     * Shows issue https://issues.apache.org/jira/projects/DOSGI/issues/DOSGI-254
+     * We would expect an IOexcpetion here
+     */
+    @Test(expected = ServiceException.class)
+    public void testInheritedException() throws IOException {
+        MyBaseService proxy = (MyBaseService)ProxyFactory.create(new MyServiceImpl(), MySubService.class);
+        proxy.throwException1();
+    }
+    
 }


Mime
View raw message