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:
21: import org.springframework.ws.MockWebServiceMessage;
22: import org.springframework.ws.MockWebServiceMessageFactory;
23: import org.springframework.ws.context.DefaultMessageContext;
24: import org.springframework.ws.context.MessageContext;
25: import org.springframework.xml.transform.StringSource;
26:
27: public abstract class AbstractMessageEndpointTestCase extends
28: AbstractEndpointTestCase {
29:
30: private MessageEndpoint endpoint;
31:
32: protected final void setUp() throws Exception {
33: endpoint = createResponseEndpoint();
34: }
35:
36: public void testNoResponse() throws Exception {
37: endpoint = createNoResponseEndpoint();
38: StringSource requestSource = new StringSource(REQUEST);
39:
40: MessageContext context = new DefaultMessageContext(
41: new MockWebServiceMessage(requestSource),
42: new MockWebServiceMessageFactory());
43: endpoint.invoke(context);
44: assertFalse("Response message created", context.hasResponse());
45: }
46:
47: protected final void testSource(Source requestSource)
48: throws Exception {
49: MessageContext context = new DefaultMessageContext(
50: new MockWebServiceMessage(requestSource),
51: new MockWebServiceMessageFactory());
52: endpoint.invoke(context);
53: assertTrue("No response message created", context.hasResponse());
54: assertXMLEqual(RESPONSE, ((MockWebServiceMessage) context
55: .getResponse()).getPayloadAsString());
56: }
57:
58: protected abstract MessageEndpoint createNoResponseEndpoint();
59:
60: protected abstract MessageEndpoint createResponseEndpoint();
61:
62: }
|