|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.javacrumbs.springws.test.simple.WsMockControl
public class WsMockControl
Utility class for easy unit-test mock preparation. Usually used in this way
//create control
WsMockControl mockControl = new WsMockControl();
//create mock
WebServiceMessageSender mockMessageSender = mockControl.expectRequest("PRG-DUB-request.xml").returnResponse("PRG-DUB-response.xml").createMock();
//use the mock
webServiceTemplate.setMessageSender(mockMessageSender);
//do your test here ...
//verify that the mock was used
mockControl.verify();
| Constructor Summary | |
|---|---|
WsMockControl()
|
|
| Method Summary | |
|---|---|
WsMockControl |
addInterceptor(org.springframework.ws.server.EndpointInterceptor interceptor)
|
WsMockControl |
addRequestProcessor(RequestProcessor requestProcessor)
Adds request processor. |
WsMockControl |
addRequestProcessor(RequestProcessor requestProcessor,
java.lang.String requestProcessorDescription)
Adds a request processor. |
WsMockControl |
anyTimes()
|
WsMockControl |
assertThat(java.lang.String expression,
java.util.Map<java.lang.String,java.lang.String> namespaceMap)
Mock will fail if the expression evaluates to false. |
WsMockControl |
atLeastOnce()
|
org.springframework.ws.transport.WebServiceMessageSender |
createMock()
Create mock WebServiceMessageSender. |
protected ResourceLookup |
createResourceLookup(org.springframework.core.io.Resource resource)
Creates resource lookup to be used in request validators and response generators. |
WsMockControl |
expectRequest(org.springframework.core.io.Resource resource)
Expects that request will be the same as content of the resource. |
WsMockControl |
expectRequest(java.lang.String resourceName)
Expects that request will be the same as content of the resource. |
WsMockControl |
expectUri(java.net.URI expectedUri)
Expects given uri. |
WsMockControl |
failIf(java.lang.String expression,
java.util.Map<java.lang.String,java.lang.String> namespaceMap)
Mock will fail if the expression evaluates to true. |
java.util.List<LimitingRequestProcessor> |
getRequestProcessors()
Returns list of request processors. |
org.springframework.core.io.ResourceLoader |
getResourceLoader()
|
WsMockControl |
ignoreWhitespace(boolean ignoreWhitespace)
|
boolean |
isIgnoreWhitespace()
|
WsMockControl |
once()
|
WsMockControl |
returnResponse(org.springframework.core.io.Resource resource)
Mock will return response taken from the resource. |
WsMockControl |
returnResponse(java.lang.String resourceName)
|
void |
setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
|
WsMockControl |
setTestContextAttribute(java.lang.String name,
java.lang.Object value)
Simplifies setting of context attribute. |
WsMockControl |
throwException(java.lang.RuntimeException exception)
Mock will throw an exception. |
WsMockControl |
times(int count)
|
WsMockControl |
times(int min,
int max)
Sets number of calls for the last RequestProcessor. |
WsMockControl |
useFreeMarkerTemplateProcessor()
From now on use FreeMarker for templates. |
WsMockControl |
useTemplateProcessor(TemplateProcessor templateProcessor)
Sets template processor to be used. |
WsMockControl |
useXsltTemplateProcessor()
From now on use XSLT for templates. |
WsMockControl |
validate(org.springframework.xml.validation.XmlValidator xmlValidator)
Validates request using generic XmlValidator. |
WsMockControl |
validateSchema(org.springframework.core.io.Resource... xsds)
Validate requests using given schemas. |
WsMockControl |
validateSchema(java.lang.String... xsdPaths)
Validate requests using given schemas. |
void |
verify()
Verifies that all RequestProcessors were called given number of times. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WsMockControl()
| Method Detail |
|---|
public org.springframework.ws.transport.WebServiceMessageSender createMock()
throws java.lang.IllegalStateException
WebServiceMessageSender. If behavior not defined,
throws IllegalStateException.
java.lang.IllegalStateExceptionpublic WsMockControl addRequestProcessor(RequestProcessor requestProcessor)
addRequestProcessor(RequestProcessor, String).
requestProcessor -
public WsMockControl addRequestProcessor(RequestProcessor requestProcessor,
java.lang.String requestProcessorDescription)
LimitingRequestProcessor it's wrapped in
LimitingRequestProcessorWrapper.
requestProcessor - requestProcessorDescription -
public WsMockControl expectRequest(java.lang.String resourceName)
resourceName -
public WsMockControl expectRequest(org.springframework.core.io.Resource resource)
resource -
public WsMockControl validateSchema(org.springframework.core.io.Resource... xsds)
xsds -
public WsMockControl validateSchema(java.lang.String... xsdPaths)
xsdPaths -
public WsMockControl validate(org.springframework.xml.validation.XmlValidator xmlValidator)
XmlValidator. See XmlValidatorFactory for detailed info.
xmlValidator -
protected ResourceLookup createResourceLookup(org.springframework.core.io.Resource resource)
resourceName -
public WsMockControl failIf(java.lang.String expression,
java.util.Map<java.lang.String,java.lang.String> namespaceMap)
expression - namespaceMap -
public WsMockControl assertThat(java.lang.String expression,
java.util.Map<java.lang.String,java.lang.String> namespaceMap)
expression - namespaceMap -
public WsMockControl returnResponse(java.lang.String resourceName)
public WsMockControl returnResponse(org.springframework.core.io.Resource resource)
resourceName -
public WsMockControl useFreeMarkerTemplateProcessor()
public WsMockControl useXsltTemplateProcessor()
public WsMockControl useTemplateProcessor(TemplateProcessor templateProcessor)
templateProcessor -
public WsMockControl throwException(java.lang.RuntimeException exception)
exception -
public WsMockControl expectUri(java.net.URI expectedUri)
WsTestException is
thrown.
expectedUri -
public java.util.List<LimitingRequestProcessor> getRequestProcessors()
public WsMockControl times(int min,
int max)
RequestProcessor. If given
processor was called less the min times, verify will throw
WsTestException, if it was called for more then max times, the
RequestProcessor will do nothing and return null. See
LimitingRequestProcessor for more details.
min - max -
public WsMockControl times(int count)
public WsMockControl once()
public WsMockControl anyTimes()
public WsMockControl atLeastOnce()
public void verify()
public org.springframework.core.io.ResourceLoader getResourceLoader()
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
public boolean isIgnoreWhitespace()
public WsMockControl ignoreWhitespace(boolean ignoreWhitespace)
public WsMockControl addInterceptor(org.springframework.ws.server.EndpointInterceptor interceptor)
public WsMockControl setTestContextAttribute(java.lang.String name,
java.lang.Object value)
WsTestContext for more details.
name - value -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||