[CXF-6923] Fix test execution for different ORB implementations (cherry picked from commit 08c2c22439dcd85c19b21e555d45692135faae43)
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/76f7fad3 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/76f7fad3 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/76f7fad3 Branch: refs/heads/master Commit: 76f7fad3558a129e1e34352b0188eced086d8c36 Parents: 0865c3a Author: Grzegorz Grzybek <gr.grzy...@gmail.com> Authored: Mon May 30 20:57:15 2016 +0200 Committer: Freeman Fang <freeman.f...@gmail.com> Committed: Tue May 31 14:22:46 2016 +0800 ---------------------------------------------------------------------- .../systest/corba/BaseGreeterTimeoutImpl.java | 25 +-- .../cxf/systest/corba/CorbaTimeoutTest.java | 24 ++- .../apache/cxf/systest/corba/ServerTimeout.java | 2 +- .../wsdl_systest/hello_world_corba_timeout.wsdl | 191 +++++++++++++++++++ 4 files changed, 214 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/76f7fad3/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 index efa0503..b89b993 100644 --- 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 @@ -18,13 +18,8 @@ */ 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; /** @@ -46,14 +41,13 @@ import org.junit.Assert; * under the License. */ -@javax.jws.WebService(portName = "GreeterCORBAPort", - serviceName = "GreeterCORBAService", +@javax.jws.WebService(portName = "GreeterTimeoutCORBAPort", + serviceName = "GreeterTimeoutCORBAService", targetNamespace = "http://cxf.apache.org/hello_world_corba", - wsdlLocation = "classpath:/wsdl_systest/hello_world_corba.wsdl", + wsdlLocation = "classpath:/wsdl_systest/hello_world_corba_timeout.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"; @@ -72,7 +66,6 @@ public class BaseGreeterTimeoutImpl extends Assert implements Greeter { } public void greetMeOneWay(String me) { - assertEquals("William", me); } public String sayHi() { @@ -80,17 +73,5 @@ public class BaseGreeterTimeoutImpl extends Assert implements Greeter { } 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/76f7fad3/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 index db7fb34..a52c0d8 100644 --- 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 @@ -20,10 +20,12 @@ package org.apache.cxf.systest.corba; import java.io.File; +import java.lang.reflect.Field; import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.WebServiceException; +import org.apache.cxf.binding.corba.utils.CorbaBindingHelper; import org.apache.cxf.bus.spring.SpringBusFactory; import org.apache.cxf.hello_world_corba.Greeter; import org.apache.cxf.hello_world_corba.GreeterCORBAService; @@ -34,7 +36,7 @@ import org.junit.Test; import org.omg.CORBA.TIMEOUT; /** - * + * This test uses Jacorb implementation, but cleans after itself. */ public class CorbaTimeoutTest extends AbstractBusClientServerTestBase { @@ -42,10 +44,12 @@ public class CorbaTimeoutTest extends AbstractBusClientServerTestBase { private static final QName SERVICE_NAME = new QName("http://cxf.apache.org/hello_world_corba", - "GreeterCORBAService"); + "GreeterTimeoutCORBAService"); @BeforeClass public static void startServers() throws Exception { + cleanDefaultORB(); + assertTrue( "Server failed to launch", launchServer(ServerTimeout.class) @@ -54,7 +58,8 @@ public class CorbaTimeoutTest extends AbstractBusClientServerTestBase { @AfterClass public static void cleanupFile() throws Exception { - File file = new File("./HelloWorld.ref"); + cleanDefaultORB(); + File file = new File("./HelloWorldTimeout.ref"); if (file.exists()) { file.delete(); } @@ -68,18 +73,27 @@ public class CorbaTimeoutTest extends AbstractBusClientServerTestBase { 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"); + URL wsdlUrl = this.getClass().getResource("/wsdl_systest/hello_world_corba_timeout.wsdl"); new SpringBusFactory().createBus("org/apache/cxf/systest/corba/hello_world_client.xml"); GreeterCORBAService gcs = new GreeterCORBAService(wsdlUrl, SERVICE_NAME); - Greeter port = gcs.getGreeterCORBAPort(); + Greeter port = gcs.getPort(new QName("http://cxf.apache.org/hello_world_corba", "GreeterTimeoutCORBAPort"), GreeterCORBAService.GreeterProxy.class); try { port.greetMe("Betty"); fail("Should throw org.omg.CORBA.TIMEOUT exception"); } catch (WebServiceException e) { assertTrue(e.getCause() instanceof TIMEOUT); + } finally { + System.getProperties().remove("org.omg.CORBA.ORBClass"); + System.getProperties().remove("org.omg.CORBA.ORBSingletonClass"); } } + private static void cleanDefaultORB() throws NoSuchFieldException, IllegalAccessException { + Field f = CorbaBindingHelper.class.getDeclaredField("defaultORB"); + f.setAccessible(true); + f.set(null, null); + } + } http://git-wip-us.apache.org/repos/asf/cxf/blob/76f7fad3/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 index a1bb2c5..4e62771 100644 --- 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 @@ -33,7 +33,7 @@ public class ServerTimeout extends AbstractBusTestServerBase { 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"; + String address = "file:./HelloWorldTimeout.ref"; Endpoint.publish(address, implementor); } http://git-wip-us.apache.org/repos/asf/cxf/blob/76f7fad3/systests/uncategorized/src/test/resources/wsdl_systest/hello_world_corba_timeout.wsdl ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/hello_world_corba_timeout.wsdl b/systests/uncategorized/src/test/resources/wsdl_systest/hello_world_corba_timeout.wsdl new file mode 100644 index 0000000..3a1ef56 --- /dev/null +++ b/systests/uncategorized/src/test/resources/wsdl_systest/hello_world_corba_timeout.wsdl @@ -0,0 +1,191 @@ +<?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. +--> +<wsdl:definitions xmlns:tns="http://cxf.apache.org/hello_world_corba" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:corba="http://schemas.apache.org/yoko/bindings/corba" xmlns:ns1="http://cxf.apache.org/hello_world_corba/corba/typemap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:x1="http://cxf.apache.org/hello_world_corba/types" xmlns:x2="http://cxf.apache.org/hello_world_corba" name="HelloWorld" targetNamespace="http://cxf.apache.org/hello_world_corba"> + <wsdl:types> + <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://cxf.apache.org/hello_world_corba/types" targetNamespace="http://cxf.apache.org/hello_world_corba/types" elementFormDefault="qualified"> + <simpleType name="MyStringType"> + <restriction base="string"> + <maxLength value="30"/> + </restriction> + </simpleType> + <element name="sayHi"> + <complexType/> + </element> + <element name="sayHiResponse"> + <complexType> + <sequence> + <element name="responseType" type="string"/> + </sequence> + </complexType> + </element> + <element name="greetMe"> + <complexType> + <sequence> + <element name="requestType" type="tns:MyStringType"/> + </sequence> + </complexType> + </element> + <element name="greetMeResponse"> + <complexType> + <sequence> + <element name="responseType" type="string"/> + </sequence> + </complexType> + </element> + <element name="greetMeOneWay"> + <complexType> + <sequence> + <element name="requestType" type="string"/> + </sequence> + </complexType> + </element> + <element name="pingMe"> + <complexType> + <sequence> + <element name="faultType" type="string"/> + </sequence> + </complexType> + </element> + <element name="pingMeResponse"> + <complexType/> + </element> + <element name="faultDetail"> + <complexType> + <sequence> + <element name="minor" type="short"/> + <element name="major" type="short"/> + </sequence> + </complexType> + </element> + </schema> + </wsdl:types> + <wsdl:message name="sayHiRequest"> + <wsdl:part element="x1:sayHi" name="in"/> + </wsdl:message> + <wsdl:message name="sayHiResponse"> + <wsdl:part element="x1:sayHiResponse" name="out"/> + </wsdl:message> + <wsdl:message name="greetMeRequest"> + <wsdl:part element="x1:greetMe" name="in"/> + </wsdl:message> + <wsdl:message name="greetMeResponse"> + <wsdl:part element="x1:greetMeResponse" name="out"/> + </wsdl:message> + <wsdl:message name="greetMeOneWayRequest"> + <wsdl:part element="x1:greetMeOneWay" name="in"/> + </wsdl:message> + <wsdl:message name="pingMeRequest"> + <wsdl:part name="in" element="x1:pingMe"/> + </wsdl:message> + <wsdl:message name="pingMeResponse"> + <wsdl:part name="out" element="x1:pingMeResponse"/> + </wsdl:message> + <wsdl:message name="pingMeFault"> + <wsdl:part name="faultDetail" element="x1:faultDetail"/> + </wsdl:message> + <wsdl:portType name="Greeter"> + <wsdl:operation name="sayHi"> + <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/> + <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/> + </wsdl:operation> + <wsdl:operation name="greetMe"> + <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/> + <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/> + </wsdl:operation> + <wsdl:operation name="greetMeOneWay"> + <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/> + </wsdl:operation> + <wsdl:operation name="pingMe"> + <wsdl:input name="pingMeRequest" message="tns:pingMeRequest"/> + <wsdl:output name="pingMeResponse" message="tns:pingMeResponse"/> + <wsdl:fault name="pingMeFault" message="tns:pingMeFault"/> + </wsdl:operation> + </wsdl:portType> + <corba:typeMapping xmlns:ns3="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://cxf.apache.org/hello_world_corba/corba/typemap/"> + <corba:anonstring bound="30" type="corba:string" name="MyStringType"/> + <corba:struct xmlns:x1="http://cxf.apache.org/hello_world_corba/types" repositoryID="IDL:pingMeResponse:1.0" type="x1:pingMeResponse" name="pingMeResponse"/> + <corba:struct xmlns:x1="http://cxf.apache.org/hello_world_corba/types" repositoryID="IDL:sayHiResponse:1.0" type="x1:sayHiResponse" name="sayHiResponse"> + <corba:member qualified="true" name="responseType" idltype="corba:string"/> + </corba:struct> + <corba:struct xmlns:x1="http://cxf.apache.org/hello_world_corba/types" repositoryID="IDL:pingMe:1.0" type="x1:pingMe" name="pingMe"> + <corba:member qualified="true" name="faultType" idltype="corba:string"/> + </corba:struct> + <corba:struct xmlns:x1="http://cxf.apache.org/hello_world_corba/types" repositoryID="IDL:sayHi:1.0" type="x1:sayHi" name="sayHi"/> + <corba:struct xmlns:x1="http://cxf.apache.org/hello_world_corba/types" repositoryID="IDL:greetMeOneWay:1.0" type="x1:greetMeOneWay" name="greetMeOneWay"> + <corba:member qualified="true" name="requestType" idltype="corba:string"/> + </corba:struct> + <corba:struct xmlns:x1="http://cxf.apache.org/hello_world_corba/types" repositoryID="IDL:greetMe:1.0" type="x1:greetMe" name="greetMe"> + <corba:member xmlns:ns1="http://cxf.apache.org/hello_world_corba/corba/typemap/" qualified="true" name="requestType" idltype="ns1:MyStringType"/> + </corba:struct> + <corba:struct xmlns:x1="http://cxf.apache.org/hello_world_corba/types" repositoryID="IDL:greetMeResponse:1.0" type="x1:greetMeResponse" name="greetMeResponse"> + <corba:member qualified="true" name="responseType" idltype="corba:string"/> + </corba:struct> + <corba:exception xmlns:x1="http://cxf.apache.org/hello_world_corba/types" repositoryID="IDL:faultDetail:1.0" type="x1:faultDetail" name="faultDetail"> + <corba:member qualified="true" name="minor" idltype="corba:short"/> + <corba:member qualified="true" name="major" idltype="corba:short"/> + </corba:exception> + </corba:typeMapping> + <wsdl:binding name="Greeter_CORBABinding" type="x2:Greeter"> + <corba:binding xmlns:ns3="http://schemas.xmlsoap.org/wsdl/" repositoryID="IDL:Greeter:1.0"/> + <wsdl:operation name="sayHi"> + <corba:operation xmlns:ns3="http://schemas.xmlsoap.org/wsdl/" name="sayHi"> + <corba:return name="responseType" idltype="corba:string"/> + </corba:operation> + <wsdl:input name="sayHiRequest"> + </wsdl:input> + <wsdl:output name="sayHiResponse"> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="greetMe"> + <corba:operation xmlns:ns3="http://schemas.xmlsoap.org/wsdl/" name="greetMe"> + <corba:param xmlns:ns1="http://cxf.apache.org/hello_world_corba/corba/typemap/" mode="in" name="requestType" idltype="ns1:MyStringType"/> + <corba:return name="responseType" idltype="corba:string"/> + </corba:operation> + <wsdl:input name="greetMeRequest"> + </wsdl:input> + <wsdl:output name="greetMeResponse"> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="greetMeOneWay"> + <corba:operation xmlns:ns3="http://schemas.xmlsoap.org/wsdl/" name="greetMeOneWay"> + <corba:param mode="in" name="requestType" idltype="corba:string"/> + </corba:operation> + <wsdl:input name="greetMeOneWayRequest"> + </wsdl:input> + </wsdl:operation> + <wsdl:operation name="pingMe"> + <corba:operation xmlns:ns3="http://schemas.xmlsoap.org/wsdl/" name="pingMe"> + <corba:param mode="in" name="faultType" idltype="corba:string"/> + <corba:raises xmlns:ns1="http://cxf.apache.org/hello_world_corba/corba/typemap/" exception="ns1:faultDetail"/> + </corba:operation> + <wsdl:input name="pingMeRequest"> + </wsdl:input> + <wsdl:output name="pingMeResponse"> + </wsdl:output> + <wsdl:fault name="pingMeFault"> + </wsdl:fault> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="GreeterTimeoutCORBAService"> + <wsdl:port name="GreeterTimeoutCORBAPort" binding="tns:Greeter_CORBABinding"> + <corba:address xmlns:ns3="http://schemas.xmlsoap.org/wsdl/" location="file:./HelloWorldTimeout.ref"/> + </wsdl:port> + </wsdl:service> +</wsdl:definitions>