-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CXF-9076: Exception message is not unmarshalled with JDK17+ (#2137)
- Loading branch information
Showing
4 changed files
with
157 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerExceptionServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* 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.jaxws; | ||
|
||
import jakarta.jws.WebService; | ||
import jakarta.xml.ws.Endpoint; | ||
import org.apache.cxf.testutil.common.AbstractBusTestServerBase; | ||
|
||
public class ClientServerExceptionServer extends AbstractBusTestServerBase { | ||
static final String PORT = allocatePort(ClientServerExceptionServer.class); | ||
|
||
@WebService(endpointInterface = "org.apache.cxf.systest.jaxws.ExceptionService", | ||
serviceName = "ExceptionService", targetNamespace = "http://cxf.apache.org/") | ||
static class ExceptionServiceImpl implements ExceptionService { | ||
@Override | ||
public String saySomething(String text) throws IllegalArgumentException { | ||
throw new IllegalArgumentException("Simulated!"); | ||
} | ||
} | ||
|
||
protected void run() { | ||
Object implementor = new ExceptionServiceImpl(); | ||
String address = "http://localhost:" + PORT + "/ExceptionService"; | ||
Endpoint.publish(address, implementor); | ||
} | ||
|
||
public static void main(String[] args) { | ||
try { | ||
ClientServerExceptionServer s = new ClientServerExceptionServer(); | ||
s.start(); | ||
} catch (Exception ex) { | ||
ex.printStackTrace(); | ||
System.exit(-1); | ||
} finally { | ||
System.out.println("done!"); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerExceptionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* 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.jaxws; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
import javax.xml.namespace.QName; | ||
|
||
import jakarta.xml.ws.Service; | ||
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertThrows; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class ClientServerExceptionTest extends AbstractBusClientServerTestBase { | ||
@BeforeClass | ||
public static void startServers() throws Exception { | ||
assertTrue("server did not launch correctly", launchServer(ClientServerExceptionServer.class, true)); | ||
} | ||
|
||
@Test | ||
public void exceptionMessageIsPreserved() throws MalformedURLException { | ||
URL wsdlURL = new URL("http://localhost:" + ClientServerExceptionServer.PORT + "/ExceptionService?wsdl"); | ||
QName qname = new QName("http://cxf.apache.org/", "ExceptionService"); | ||
Service service = Service.create(wsdlURL, qname); | ||
ExceptionService port = service.getPort(ExceptionService.class); | ||
|
||
final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, | ||
() -> port.saySomething("Hello World!")); | ||
assertEquals("Simulated!", ex.getMessage()); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ExceptionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* 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.jaxws; | ||
|
||
import jakarta.jws.WebService; | ||
|
||
@WebService | ||
interface ExceptionService { | ||
String saySomething(String text) throws IllegalArgumentException; | ||
} |