01: /*
02: * Copyright 2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.ws.server.endpoint;
18:
19: import javax.xml.transform.Source;
20: import javax.xml.transform.Transformer;
21: import javax.xml.transform.TransformerFactory;
22:
23: import org.springframework.xml.transform.StringResult;
24: import org.springframework.xml.transform.StringSource;
25:
26: public abstract class AbstractPayloadEndpointTestCase extends
27: AbstractEndpointTestCase {
28:
29: private PayloadEndpoint endpoint;
30:
31: private Transformer transformer;
32:
33: protected final void setUp() throws Exception {
34: endpoint = createResponseEndpoint();
35: transformer = TransformerFactory.newInstance().newTransformer();
36: }
37:
38: public void testNoResponse() throws Exception {
39: endpoint = createNoResponseEndpoint();
40: StringSource requestSource = new StringSource(REQUEST);
41: Source resultSource = endpoint.invoke(requestSource);
42: assertNull("Response source returned", resultSource);
43: }
44:
45: public void testNoRequest() throws Exception {
46: endpoint = createNoRequestEndpoint();
47: Source resultSource = endpoint.invoke(null);
48: assertNull("Response source returned", resultSource);
49: }
50:
51: protected final void testSource(Source requestSource)
52: throws Exception {
53: Source responseSource = endpoint.invoke(requestSource);
54: assertNotNull("No response source returned", responseSource);
55: StringResult result = new StringResult();
56: transformer.transform(responseSource, result);
57: assertXMLEqual(RESPONSE, result.toString());
58: }
59:
60: protected abstract PayloadEndpoint createNoResponseEndpoint()
61: throws Exception;
62:
63: protected abstract PayloadEndpoint createResponseEndpoint()
64: throws Exception;
65:
66: protected abstract PayloadEndpoint createNoRequestEndpoint()
67: throws Exception;
68: }
|