joel-shemtov commented on issue #345: When failing to close conduit, distinct 
read faults from write faults
URL: https://github.com/apache/cxf/pull/345#issuecomment-347911005
 
 
   Hi Sergei, I checked and found that there actually is a method called 
testTimeout() in _org.apache.cxf.systest.dispatch.DispatchClientServerTest_. 
However I'm not sure if it really tests timeout.  
   
   This is the current code on master
   
   
   `
   
       @Test
       public void testTimeout() throws Exception {
           //CXF-2384
           URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
           assertNotNull(wsdl);
   
           //pick one of the other service/ports that would have an address
           //without a service running
           QName otherServiceName = new 
QName("http://apache.org/hello_world_soap_http";,
                   "SOAPProviderService");
           QName otherPortName = new 
QName("http://apache.org/hello_world_soap_http";, "SoapProviderPort");
   
   
           SOAPService service = new SOAPService(wsdl, otherServiceName);
           assertNotNull(service);
   
           Dispatch<SOAPMessage> disp = service
               .createDispatch(otherPortName, SOAPMessage.class, 
Service.Mode.MESSAGE);
           
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                                        "http://localhost:";
                                        + TestUtil.getPortNumber("fake-port")
                                        + 
"/SOAPDispatchService/SoapDispatchPort");
   
           DispatchImpl<?> dispImpl = (DispatchImpl<?>)disp;
           HTTPConduit cond = (HTTPConduit)dispImpl.getClient().getConduit();
           cond.getClient().setConnectionTimeout(500);
   
           InputStream is = 
getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
           SOAPMessage soapReqMsg = 
MessageFactory.newInstance().createMessage(null, is);
           assertNotNull(soapReqMsg);
   
           try {
               disp.invoke(soapReqMsg);
               fail("Should have faulted");
           } catch (SOAPFaultException ex) {
               fail("should not be a SOAPFaultException");
           } catch (WebServiceException ex) {
               //expected
               assertTrue(ex.getCause().getClass().getName(),
                          ex.getCause() instanceof java.net.ConnectException
                          || ex.getCause() instanceof 
java.net.SocketTimeoutException);
           }
           dispImpl.close();
   
       }
   `
   
   To me it seems that the usage of "fake-port", guarantees that only 
ConnectionException gets caught. SocketTimeoutException is never actually 
thrown.
   
   As far as I understand, these are two different scenarios. Shouldn't they be 
in two separate tests? As you suggested I'll try to run it locally. When I have 
it modified and tried, I'll open a new pull request.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to