cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [01/33] cxf git commit: [CXF-6923] Handle org.omg.CORBA.SystemException for Jacorb correctly [Forced Update!]
Date Sun, 05 Jun 2016 17:02:29 GMT
Repository: cxf
Updated Branches:
  refs/heads/master-jaxrs-2.1 97d71d2c9 -> 375c541b8 (forced update)


[CXF-6923] Handle org.omg.CORBA.SystemException for Jacorb correctly

(cherry picked from commit 0759f57a0786ef71a25e03c4d65c58632be3a18a)

Conflicts:
	systests/uncategorized/pom.xml


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

Branch: refs/heads/master-jaxrs-2.1
Commit: 0865c3a85b9687f857b51d1ae56c8f8e97bdbf5b
Parents: 3615f20
Author: Grzegorz Grzybek <gr.grzybek@gmail.com>
Authored: Mon May 30 16:49:06 2016 +0200
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Tue May 31 14:22:32 2016 +0800

----------------------------------------------------------------------
 .../apache/cxf/binding/corba/CorbaConduit.java  |  5 +
 systests/uncategorized/pom.xml                  |  5 +
 .../systest/corba/BaseGreeterTimeoutImpl.java   | 96 ++++++++++++++++++++
 .../cxf/systest/corba/CorbaTimeoutTest.java     | 85 +++++++++++++++++
 .../apache/cxf/systest/corba/ServerTimeout.java | 51 +++++++++++
 5 files changed, 242 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0865c3a8/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaConduit.java
----------------------------------------------------------------------
diff --git a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaConduit.java
b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaConduit.java
index 91758e9..7518ece 100644
--- a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaConduit.java
+++ b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaConduit.java
@@ -198,6 +198,11 @@ public class CorbaConduit implements Conduit {
         }
         Exception ex = request.env().exception();
         if (ex != null) {
+            if (ex instanceof SystemException) {
+                message.setContent(Exception.class, new Fault(ex));
+                message.setSystemException((SystemException) ex);
+                return;
+            }
             if (ex instanceof UnknownUserException) {
                 UnknownUserException userEx = (UnknownUserException) ex;
                 Any except = userEx.except;

http://git-wip-us.apache.org/repos/asf/cxf/blob/0865c3a8/systests/uncategorized/pom.xml
----------------------------------------------------------------------
diff --git a/systests/uncategorized/pom.xml b/systests/uncategorized/pom.xml
index c9fd693..5110143 100644
--- a/systests/uncategorized/pom.xml
+++ b/systests/uncategorized/pom.xml
@@ -377,6 +377,11 @@
         <dependency>
             <groupId>org.qi4j.library</groupId>
             <artifactId>org.qi4j.library.circuitbreaker</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jacorb</groupId>
+            <artifactId>jacorb</artifactId>
+            <version>3.7</version>
             <scope>test</scope>
         </dependency>
     </dependencies>

http://git-wip-us.apache.org/repos/asf/cxf/blob/0865c3a8/systests/uncategorized/src/test/java/org/apache/cxf/systest/corba/BaseGreeterTimeoutImpl.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/corba/BaseGreeterTimeoutImpl.java
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/corba/BaseGreeterTimeoutImpl.java
new file mode 100644
index 0000000..efa0503
--- /dev/null
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/corba/BaseGreeterTimeoutImpl.java
@@ -0,0 +1,96 @@
+/**
+ * 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.systest.corba;
+
+import java.util.ResourceBundle;
+
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.hello_world_corba.Greeter;
+import org.apache.cxf.hello_world_corba.PingMeFault;
+import org.apache.cxf.hello_world_corba.types.FaultDetail;
+import org.apache.cxf.interceptor.Fault;
+import org.junit.Assert;
+
+/**
+ * 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.
+ */
+
+@javax.jws.WebService(portName = "GreeterCORBAPort",
+        serviceName = "GreeterCORBAService",
+        targetNamespace = "http://cxf.apache.org/hello_world_corba",
+        wsdlLocation = "classpath:/wsdl_systest/hello_world_corba.wsdl",
+        endpointInterface = "org.apache.cxf.hello_world_corba.Greeter")
+
+public class BaseGreeterTimeoutImpl extends Assert implements Greeter {
+    public static final String GREETME_IN = "test in";
+    public static final String GREETME_OUT = "test out";
+    static final String EX_STRING = "CXF RUNTIME EXCEPTION";
+
+    public String greetMe(String me) {
+        String timeout = System.getProperty("jacorb.connection.client.pending_reply_timeout",
"0");
+        if (timeout != null) {
+            try {
+                Integer ms = Integer.parseInt(timeout);
+                if (ms > 0) {
+                    Thread.sleep(ms + 1000);
+                }
+            } catch (InterruptedException ignore) {
+            }
+        }
+        return "Hello " + me;
+    }
+
+    public void greetMeOneWay(String me) {
+        assertEquals("William", me);
+    }
+
+    public String sayHi() {
+        return GREETME_OUT;
+    }
+
+    public void pingMe(String faultType) throws PingMeFault {
+        if ("USER".equals(faultType)) {
+
+            FaultDetail detail = new FaultDetail();
+            detail.setMajor((short)1);
+            detail.setMinor((short)2);
+            throw new PingMeFault("USER FAULT TEST", detail);
+        } else if ("SYSTEM".equals(faultType)) {
+            throw new Fault(new Message(EX_STRING, (ResourceBundle)null,
+                    new Object[]{"FAULT TEST"}));
+        } else {
+            throw new IllegalArgumentException(EX_STRING);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/0865c3a8/systests/uncategorized/src/test/java/org/apache/cxf/systest/corba/CorbaTimeoutTest.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/corba/CorbaTimeoutTest.java
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/corba/CorbaTimeoutTest.java
new file mode 100644
index 0000000..db7fb34
--- /dev/null
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/corba/CorbaTimeoutTest.java
@@ -0,0 +1,85 @@
+/**
+ * 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.systest.corba;
+
+import java.io.File;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceException;
+
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.hello_world_corba.Greeter;
+import org.apache.cxf.hello_world_corba.GreeterCORBAService;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.omg.CORBA.TIMEOUT;
+
+/**
+ *
+ */
+public class CorbaTimeoutTest extends AbstractBusClientServerTestBase {
+
+    public static final String PORT = Server.PERSIST_PORT;
+
+    private static final QName SERVICE_NAME =
+        new QName("http://cxf.apache.org/hello_world_corba",
+                  "GreeterCORBAService");
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue(
+            "Server failed to launch",
+            launchServer(ServerTimeout.class)
+        );
+    }
+
+    @AfterClass
+    public static void cleanupFile() throws Exception {
+        File file = new File("./HelloWorld.ref");
+        if (file.exists()) {
+            file.delete();
+        }
+    }
+
+    @Test
+    public void testTimeout() throws Exception {
+        System.getProperties().remove("com.sun.CORBA.POA.ORBServerId");
+        System.getProperties().remove("com.sun.CORBA.POA.ORBPersistentServerPort");
+        System.setProperty("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
+        System.setProperty("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton");
+        System.setProperty("jacorb.connection.client.pending_reply_timeout", "1000");
+
+        URL wsdlUrl = this.getClass().getResource("/wsdl_systest/hello_world_corba.wsdl");
+        new SpringBusFactory().createBus("org/apache/cxf/systest/corba/hello_world_client.xml");
+
+        GreeterCORBAService gcs = new GreeterCORBAService(wsdlUrl, SERVICE_NAME);
+        Greeter port = gcs.getGreeterCORBAPort();
+
+        try {
+            port.greetMe("Betty");
+            fail("Should throw org.omg.CORBA.TIMEOUT exception");
+        } catch (WebServiceException e) {
+            assertTrue(e.getCause() instanceof TIMEOUT);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/0865c3a8/systests/uncategorized/src/test/java/org/apache/cxf/systest/corba/ServerTimeout.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/corba/ServerTimeout.java
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/corba/ServerTimeout.java
new file mode 100644
index 0000000..a1bb2c5
--- /dev/null
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/corba/ServerTimeout.java
@@ -0,0 +1,51 @@
+/**
+ * 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.systest.corba;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class ServerTimeout extends AbstractBusTestServerBase {
+    public static final String PERSIST_PORT = allocatePort(ServerTimeout.class);
+
+    protected void run()  {
+        System.out.println("Starting Server");
+        System.setProperty("com.sun.CORBA.POA.ORBServerId", "1");
+        System.setProperty("com.sun.CORBA.POA.ORBPersistentServerPort", PERSIST_PORT);
+        new SpringBusFactory().createBus("org/apache/cxf/systest/corba/hello_world_server.xml");
+        Object implementor = new BaseGreeterTimeoutImpl();
+        String address = "file:./HelloWorld.ref";
+        Endpoint.publish(address, implementor);
+    }
+
+    public static void main(String[] args) {
+        try {
+            ServerTimeout s = new ServerTimeout();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+}


Mime
View raw message