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.soap;
18:
19: import org.springframework.core.io.Resource;
20: import org.springframework.util.StringUtils;
21: import org.springframework.ws.mime.AbstractMimeMessageTestCase;
22: import org.springframework.ws.mime.MimeMessage;
23: import org.springframework.xml.validation.XmlValidator;
24: import org.springframework.xml.validation.XmlValidatorFactory;
25: import org.xml.sax.SAXParseException;
26:
27: public abstract class AbstractSoapMessageTestCase extends
28: AbstractMimeMessageTestCase {
29:
30: protected SoapMessage soapMessage;
31:
32: protected MimeMessage createMimeMessage() throws Exception {
33: soapMessage = createSoapMessage();
34: return soapMessage;
35: }
36:
37: protected abstract SoapMessage createSoapMessage() throws Exception;
38:
39: public void testValidate() throws Exception {
40: XmlValidator validator = XmlValidatorFactory.createValidator(
41: getSoapSchemas(), XmlValidatorFactory.SCHEMA_W3C_XML);
42: SAXParseException[] errors = validator.validate(soapMessage
43: .getEnvelope().getSource());
44: if (errors.length > 0) {
45: fail(StringUtils.arrayToCommaDelimitedString(errors));
46: }
47: }
48:
49: public void testSoapAction() throws Exception {
50: String soapAction = "SoapAction";
51: soapMessage.setSoapAction(soapAction);
52: assertEquals("Invalid SOAP Action", soapAction, soapMessage
53: .getSoapAction());
54: }
55:
56: protected abstract Resource[] getSoapSchemas();
57:
58: public abstract void testGetVersion() throws Exception;
59:
60: public abstract void testWriteToTransportOutputStream()
61: throws Exception;
62:
63: public abstract void testWriteToTransportResponseAttachment()
64: throws Exception;
65: }
|