net.javacrumbs.springws.test
Class MockWebServiceConnection

java.lang.Object
  extended by net.javacrumbs.springws.test.MockWebServiceConnection
All Implemented Interfaces:
org.springframework.ws.transport.WebServiceConnection

public class MockWebServiceConnection
extends java.lang.Object
implements org.springframework.ws.transport.WebServiceConnection

Mock WS connection that instead of actually calling the WS uses RequestProcessors to validate all the requests and generate responses.

Author:
Lukas Krecan

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
MockWebServiceConnection(java.net.URI uri)
           
 
Method Summary
 void close()
           
protected  org.springframework.ws.WebServiceMessage generateResponse(org.springframework.ws.WebServiceMessageFactory messageFactory)
          Calls all request processors.
 java.lang.String getErrorMessage()
           
 java.util.List<org.springframework.ws.server.EndpointInterceptor> getInterceptors()
           
 org.springframework.ws.WebServiceMessage getRequest()
           
 java.util.Collection<RequestProcessor> getRequestProcessors()
           
 java.net.URI getUri()
           
 XmlUtil getXmlUtil()
           
protected  boolean handleRequest(org.springframework.ws.context.MessageContext messageContext)
          Iterates over all interceptors.
protected  void handleResponse(org.springframework.ws.context.MessageContext messageContext)
          Processes response using interceptors.
protected  org.springframework.ws.WebServiceMessage handleResponseNotFound(org.springframework.ws.WebServiceMessageFactory messageFactory)
          Throws NoResponseGeneratorSpecifiedException.
 boolean hasError()
           
protected  boolean hasFault(org.springframework.ws.context.MessageContext messageContext)
          Returns true if the message has fault.
 org.springframework.ws.WebServiceMessage receive(org.springframework.ws.WebServiceMessageFactory messageFactory)
          Calls all interceptors and RequestProcessors.
 void send(org.springframework.ws.WebServiceMessage message)
          Stores the message.
 void setInterceptors(java.util.List<org.springframework.ws.server.EndpointInterceptor> interceptors)
           
 void setRequestProcessors(java.util.List<RequestProcessor> responseGenerators)
           
 void setXmlUtil(XmlUtil xmlUtil)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

MockWebServiceConnection

public MockWebServiceConnection(java.net.URI uri)
Method Detail

send

public void send(org.springframework.ws.WebServiceMessage message)
          throws java.io.IOException
Stores the message.

Specified by:
send in interface org.springframework.ws.transport.WebServiceConnection
Throws:
java.io.IOException

receive

public org.springframework.ws.WebServiceMessage receive(org.springframework.ws.WebServiceMessageFactory messageFactory)
                                                 throws java.io.IOException
Calls all interceptors and RequestProcessors. Returns first generated response or first thrown exception.

Specified by:
receive in interface org.springframework.ws.transport.WebServiceConnection
Throws:
java.io.IOException

handleRequest

protected boolean handleRequest(org.springframework.ws.context.MessageContext messageContext)
                         throws java.io.IOException
Iterates over all interceptors. If one of them returns false, false is returned. True is returned otherwise.

Parameters:
messageContext -
Returns:
Throws:
java.io.IOException

handleResponse

protected void handleResponse(org.springframework.ws.context.MessageContext messageContext)
                       throws java.io.IOException
Processes response using interceptors.

Parameters:
messageContext -
Throws:
java.io.IOException

hasFault

protected boolean hasFault(org.springframework.ws.context.MessageContext messageContext)
Returns true if the message has fault.

Parameters:
messageContext -
Returns:

generateResponse

protected org.springframework.ws.WebServiceMessage generateResponse(org.springframework.ws.WebServiceMessageFactory messageFactory)
                                                             throws java.io.IOException
Calls all request processors. If a processor returns null, the next processor is called. If all processor return null handleResponseNotFound(org.springframework.ws.WebServiceMessageFactory) method is called. In default implementation it throws NoResponseGeneratorSpecifiedException.

Parameters:
messageFactory -
Returns:
Throws:
java.io.IOException

handleResponseNotFound

protected org.springframework.ws.WebServiceMessage handleResponseNotFound(org.springframework.ws.WebServiceMessageFactory messageFactory)
Throws NoResponseGeneratorSpecifiedException. Can be overrriden.

Parameters:
messageFactory -
Returns:

close

public void close()
           throws java.io.IOException
Specified by:
close in interface org.springframework.ws.transport.WebServiceConnection
Throws:
java.io.IOException

getErrorMessage

public java.lang.String getErrorMessage()
                                 throws java.io.IOException
Specified by:
getErrorMessage in interface org.springframework.ws.transport.WebServiceConnection
Throws:
java.io.IOException

getUri

public java.net.URI getUri()
                    throws java.net.URISyntaxException
Specified by:
getUri in interface org.springframework.ws.transport.WebServiceConnection
Throws:
java.net.URISyntaxException

hasError

public boolean hasError()
                 throws java.io.IOException
Specified by:
hasError in interface org.springframework.ws.transport.WebServiceConnection
Throws:
java.io.IOException

getRequest

public org.springframework.ws.WebServiceMessage getRequest()

getXmlUtil

public XmlUtil getXmlUtil()

setXmlUtil

public void setXmlUtil(XmlUtil xmlUtil)

getRequestProcessors

public java.util.Collection<RequestProcessor> getRequestProcessors()

setRequestProcessors

public void setRequestProcessors(java.util.List<RequestProcessor> responseGenerators)

getInterceptors

public java.util.List<org.springframework.ws.server.EndpointInterceptor> getInterceptors()

setInterceptors

public void setInterceptors(java.util.List<org.springframework.ws.server.EndpointInterceptor> interceptors)


Copyright © 2011. All Rights Reserved.