1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 AbstractMimeMessageTestCase {
28
29 protected SoapMessage soapMessage;
30
31 protected MimeMessage createMimeMessage() throws Exception {
32 soapMessage = createSoapMessage();
33 return soapMessage;
34 }
35
36 protected abstract SoapMessage createSoapMessage() throws Exception;
37
38 public void testValidate() throws Exception {
39 XmlValidator validator =
40 XmlValidatorFactory.createValidator(getSoapSchemas(), XmlValidatorFactory.SCHEMA_W3C_XML);
41 SAXParseException[] errors = validator.validate(soapMessage.getEnvelope().getSource());
42 if (errors.length > 0) {
43 fail(StringUtils.arrayToCommaDelimitedString(errors));
44 }
45 }
46
47 public void testSoapAction() throws Exception {
48 assertEquals("Invalid default SOAP Action", "\"\"", soapMessage.getSoapAction());
49 soapMessage.setSoapAction("SoapAction");
50 assertEquals("Invalid SOAP Action", "\"SoapAction\"", soapMessage.getSoapAction());
51 }
52
53 protected abstract Resource[] getSoapSchemas();
54
55 public abstract void testGetVersion() throws Exception;
56
57 public abstract void testWriteToTransportOutputStream() throws Exception;
58
59 public abstract void testWriteToTransportResponseAttachment() throws Exception;
60 }