You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2021/06/12 02:32:51 UTC

[cxf] branch 3.4.x-fixes updated (523d6cc -> c83c815)

This is an automated email from the ASF dual-hosted git repository.

reta pushed a change to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from 523d6cc  Update Spring Boot to 2.3.12.RELEASE
     new 477de79  Adding test cases for HTTPConduit handlin 503/404 w/o IO exceptions (#814)
     new c83c815  Recording .gitmergeinfo Changes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitmergeinfo                                      |   1 +
 .../http/{GreeterImpl.java => BadGreeterImpl.java} |  29 ++--
 .../http/{BareServer.java => BadServer.java}       |  10 +-
 .../systest/http/HTTPConduitIoExceptionsTest.java  | 147 +++++++++++++++++++++
 4 files changed, 166 insertions(+), 21 deletions(-)
 copy systests/transports/src/test/java/org/apache/cxf/systest/http/{GreeterImpl.java => BadGreeterImpl.java} (74%)
 copy systests/transports/src/test/java/org/apache/cxf/systest/http/{BareServer.java => BadServer.java} (83%)
 create mode 100644 systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitIoExceptionsTest.java

[cxf] 02/02: Recording .gitmergeinfo Changes

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit c83c81571fb2fc86b9f8ce0eb2f3fb4de567af04
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Fri Jun 11 22:28:07 2021 -0400

    Recording .gitmergeinfo Changes
---
 .gitmergeinfo | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 7c2331d..aa20651 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -134,6 +134,7 @@ M 941ed53ce451b809809f8270b74aa546be681aa6
 M 954085421900efbf89643b5ab8f187a237e42eb4
 M 975fc9e2fe226ddb8dfa845bd9565839c7391e2a
 M 9980b0472524e1010aaf7a4a3fe5ff072270efe3
+M 9af4071d27e3f14876061ac067d64de7b43f11d1
 M 9bb8e487235d728bb80a90e7e2f4a9433b5ef033
 M 9c1106db2f4b21c5918c5e9ada23d715dc15103e
 M 9c17f2fb90a9929d0dc8e4f090da78547a4e7a02

[cxf] 01/02: Adding test cases for HTTPConduit handlin 503/404 w/o IO exceptions (#814)

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 477de799ea90cb619f7e2c268f838a05c95c8e9b
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Fri Jun 11 18:01:04 2021 -0400

    Adding test cases for HTTPConduit handlin 503/404 w/o IO exceptions (#814)
    
    (cherry picked from commit 136925ad0d2092ae00f2840573abf516decc3802)
---
 .../apache/cxf/systest/http/BadGreeterImpl.java    |  62 +++++++++
 .../org/apache/cxf/systest/http/BadServer.java     |  59 +++++++++
 .../systest/http/HTTPConduitIoExceptionsTest.java  | 147 +++++++++++++++++++++
 3 files changed, 268 insertions(+)

diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/http/BadGreeterImpl.java b/systests/transports/src/test/java/org/apache/cxf/systest/http/BadGreeterImpl.java
new file mode 100644
index 0000000..ef9bd1d
--- /dev/null
+++ b/systests/transports/src/test/java/org/apache/cxf/systest/http/BadGreeterImpl.java
@@ -0,0 +1,62 @@
+/**
+ * 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.http;
+
+import java.util.logging.Logger;
+
+import javax.jws.WebService;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.hello_world.Greeter;
+
+
+@WebService(serviceName = "SOAPService",
+            endpointInterface = "org.apache.hello_world.Greeter",
+            targetNamespace = "http://apache.org/hello_world")
+public class BadGreeterImpl implements Greeter {
+
+    private static final Logger LOG =
+        LogUtils.getLogger(BadGreeterImpl.class,
+                           null,
+                           BadGreeterImpl.class.getPackage().getName());
+
+    public BadGreeterImpl() {
+    }
+
+    public String greetMe(String me) {
+        LOG.info("Executing operation greetMe");
+        return failWith(404, "Not found: " + me);
+    }
+
+    public String sayHi() {
+        LOG.info("Executing operation sayHi");
+        return failWith(503, "Go away");
+    }
+
+    public void pingMe() {
+    }
+    
+    private String failWith(int status, String message) {
+        final Fault f = new Fault(new RuntimeException(message));
+        f.setStatusCode(status);
+        throw f;
+    }
+}
diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/http/BadServer.java b/systests/transports/src/test/java/org/apache/cxf/systest/http/BadServer.java
new file mode 100644
index 0000000..0212c1b
--- /dev/null
+++ b/systests/transports/src/test/java/org/apache/cxf/systest/http/BadServer.java
@@ -0,0 +1,59 @@
+/**
+ * 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.http;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class BadServer extends AbstractBusTestServerBase {
+    public static final String PORT = allocatePort(BadServer.class);
+
+    Endpoint ep;
+
+    @Override
+    protected void run() {
+        Bus bus = new SpringBusFactory().createBus();
+        BusFactory.setDefaultBus(bus);
+        Object implementor = new BadGreeterImpl();
+        String address = "http://localhost:" + PORT + "/Mortimer";
+        ep = Endpoint.publish(address, implementor);
+    }
+    @Override
+    public void tearDown() {
+        ep.stop();
+        ep = null;
+    }
+
+    public static void main(String[] args) {
+        try {
+            // System.out.println("!!!!start");
+            BadServer s = new BadServer();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        }
+    }
+
+}
diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitIoExceptionsTest.java b/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitIoExceptionsTest.java
new file mode 100644
index 0000000..da12052
--- /dev/null
+++ b/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitIoExceptionsTest.java
@@ -0,0 +1,147 @@
+/**
+ * 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.http;
+
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transport.http.HTTPException;
+import org.apache.hello_world.Greeter;
+import org.apache.hello_world.services.SOAPService;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class HTTPConduitIoExceptionsTest extends AbstractBusClientServerTestBase {
+    @Rule public final ExpectedException exception = ExpectedException.none();
+
+    private final QName serviceName =
+        new QName("http://apache.org/hello_world", "SOAPService");
+      
+    private final QName mortimerQ =
+        new QName("http://apache.org/hello_world", "Mortimer");
+
+    public HTTPConduitIoExceptionsTest() {
+    }
+
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", launchServer(BadServer.class, true));
+    }
+
+    @Test
+    public void testNoIoExceptions() throws Exception {
+        final Greeter greeter = getGreeter();
+
+        try (Client client = (Client)greeter) {
+            client.getRequestContext().put(HTTPConduit.NO_IO_EXCEPTIONS, true);
+            
+            exception.expect(SOAPFaultException.class);
+            exception.expectMessage("Go away");
+            
+            greeter.sayHi();
+        }
+    }
+
+    @Test
+    public void testServiceUnavailable() throws Exception {
+        final Greeter greeter = getGreeter();
+
+        exception.expect(WebServiceException.class);
+        exception.expectCause(new TypeSafeMatcher<Throwable>() {
+            private final String message = "HTTP response '503: Service Unavailable' when "
+                + "communicating with http://localhost:" + BadServer.PORT + "/Mortimer";
+
+            @Override
+            public void describeTo(Description description) {
+                description
+                    .appendValue(HTTPException.class)
+                    .appendText(" and message ")
+                    .appendValue(message);
+            }
+
+            @Override
+            protected boolean matchesSafely(Throwable item) {
+                return item instanceof HTTPException && item.getMessage().equals(message);
+            }
+        });
+        
+        
+        greeter.sayHi();
+    }
+
+    @Test
+    public void testNotFound() throws Exception {
+        final Greeter greeter = getGreeter();
+
+        exception.expect(WebServiceException.class);
+        exception.expectCause(new TypeSafeMatcher<Throwable>() {
+            private final String message = "HTTP response '404: Not Found' when "
+                + "communicating with http://localhost:" + BadServer.PORT + "/Mortimer";
+
+            @Override
+            public void describeTo(Description description) {
+                description
+                    .appendValue(HTTPException.class)
+                    .appendText(" and message ")
+                    .appendValue(message);
+            }
+
+            @Override
+            protected boolean matchesSafely(Throwable item) {
+                return item instanceof HTTPException && item.getMessage().equals(message);
+            }
+        });
+        
+        
+        greeter.greetMe("Test");
+    }
+    
+    private Greeter getGreeter() throws MalformedURLException {
+        URL wsdl = getClass().getResource("greeting.wsdl");
+        assertNotNull("WSDL is null", wsdl);
+
+        SOAPService service = new SOAPService(wsdl, serviceName);
+        assertNotNull("Service is null", service);
+
+        Greeter mortimer = service.getPort(mortimerQ, Greeter.class);
+        assertNotNull("Port is null", mortimer);
+        updateAddressPort(mortimer, BadServer.PORT);
+
+        return mortimer;
+    }
+}
+