Improved testing of SAAJ.
This commit is contained in:
@@ -38,7 +38,7 @@ public interface SoapFaultDetail extends SoapElement {
|
||||
SoapFaultDetailElement addFaultDetailElement(QName name);
|
||||
|
||||
/**
|
||||
* Returns the <code>Source</code> of this element. This result does not include the element itself.
|
||||
* Returns a <code>Result</code> that represents the concents of the detail.
|
||||
* <p/>
|
||||
* The result can be used for marshalling.
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.ws.soap;
|
||||
|
||||
import java.util.Iterator;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.transform.Result;
|
||||
|
||||
/**
|
||||
* Represents the <code>Header</code> element in a SOAP message. A SOAP header contains <code>SoapHeaderElement</code>s,
|
||||
@@ -29,6 +30,15 @@ import javax.xml.namespace.QName;
|
||||
*/
|
||||
public interface SoapHeader extends SoapElement {
|
||||
|
||||
/**
|
||||
* Returns a <code>Result</code> that represents the concents of the header.
|
||||
* <p/>
|
||||
* The result can be used for marshalling.
|
||||
*
|
||||
* @return the <code>Result</code> of this element
|
||||
*/
|
||||
Result getResult();
|
||||
|
||||
/**
|
||||
* Adds a new <code>SoapHeaderElement</code> with the specified qualified name to this header.
|
||||
*
|
||||
|
||||
@@ -18,7 +18,9 @@ package org.springframework.ws.soap.axiom;
|
||||
|
||||
import java.util.Iterator;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.sax.SAXResult;
|
||||
|
||||
import org.apache.axiom.om.OMException;
|
||||
import org.apache.axiom.om.OMNamespace;
|
||||
@@ -57,6 +59,10 @@ class AxiomSoapHeader implements SoapHeader {
|
||||
return new StaxSource(axiomHeader.getXMLStreamReader());
|
||||
}
|
||||
|
||||
public Result getResult() {
|
||||
return new SAXResult(new AxiomContentHandler(axiomHeader));
|
||||
}
|
||||
|
||||
public SoapHeaderElement addHeaderElement(QName name) {
|
||||
try {
|
||||
OMNamespace namespace = axiomFactory.createOMNamespace(name.getNamespaceURI(), QNameUtils.getPrefix(name));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ import org.springframework.ws.soap.saaj.support.SaajUtils;
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class Saaj12Implementation extends SaajImplementation {
|
||||
class Saaj12Implementation extends SaajImplementation {
|
||||
|
||||
private static final Saaj12Implementation INSTANCE = new Saaj12Implementation();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ import javax.xml.soap.SOAPHeaderElement;
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class Saaj13Implementation extends SaajImplementation {
|
||||
class Saaj13Implementation extends SaajImplementation {
|
||||
|
||||
private static final Saaj13Implementation INSTANCE = new Saaj13Implementation();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -55,12 +55,11 @@ import org.springframework.ws.transport.TransportOutputStream;
|
||||
*/
|
||||
abstract class SaajImplementation {
|
||||
|
||||
/** Protected constructor to prevent instantiation. */
|
||||
protected SaajImplementation() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the singleton instance for the version of SAAJ in use.
|
||||
*/
|
||||
/** Returns the singleton instance for the version of SAAJ in use. */
|
||||
public static SaajImplementation getImplementation() {
|
||||
if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_12) {
|
||||
return Saaj12Implementation.getInstance();
|
||||
@@ -73,58 +72,121 @@ abstract class SaajImplementation {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the name of the given element. */
|
||||
public abstract QName getName(SOAPElement element);
|
||||
|
||||
/** Returns the readable <code>Source</code> of the given element. */
|
||||
public Source getSource(SOAPElement element) {
|
||||
return new DOMSource(element);
|
||||
}
|
||||
|
||||
/** Returns the writable <code>Result</code> of the given element. */
|
||||
public Result getResult(SOAPElement element) {
|
||||
return new DOMResult(element);
|
||||
}
|
||||
|
||||
/** Returns the envelope of the given message. */
|
||||
public SOAPEnvelope getEnvelope(SOAPMessage message) throws SOAPException {
|
||||
return message.getSOAPPart().getEnvelope();
|
||||
}
|
||||
|
||||
/** Returns the header of the given envelope. */
|
||||
public SOAPHeader getHeader(SOAPEnvelope envelope) throws SOAPException {
|
||||
return envelope.getHeader();
|
||||
}
|
||||
|
||||
/** Returns the body of the given envelope. */
|
||||
public SOAPBody getBody(SOAPEnvelope envelope) throws SOAPException {
|
||||
return envelope.getBody();
|
||||
}
|
||||
|
||||
/** Returns all header elements. */
|
||||
public Iterator examineAllHeaderElements(SOAPHeader header) {
|
||||
return header.examineAllHeaderElements();
|
||||
}
|
||||
|
||||
/** Returns all header elements for which the must understand attribute is true, given the actor or role. */
|
||||
public Iterator examineMustUnderstandHeaderElements(SOAPHeader header, String actorOrRole) {
|
||||
return header.examineMustUnderstandHeaderElements(actorOrRole);
|
||||
}
|
||||
|
||||
public abstract SOAPHeaderElement addHeaderElement(SOAPHeader header, QName name) throws SOAPException;
|
||||
|
||||
/** Returns the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element. */
|
||||
public String getActorOrRole(SOAPHeaderElement headerElement) {
|
||||
return headerElement.getActor();
|
||||
}
|
||||
|
||||
/** Sets the SOAP 1.1 actor or SOAP 1.2 role attribute for the given header element. */
|
||||
public void setActorOrRole(SOAPHeaderElement headerElement, String actorOrRole) {
|
||||
headerElement.setActor(actorOrRole);
|
||||
}
|
||||
|
||||
/** Gets the must understand attribute for the given header element. */
|
||||
public boolean getMustUnderstand(SOAPHeaderElement headerElement) {
|
||||
return headerElement.getMustUnderstand();
|
||||
}
|
||||
|
||||
/** Sets the must understand attribute for the given header element. */
|
||||
public void setMustUnderstand(SOAPHeaderElement headerElement, boolean mustUnderstand) {
|
||||
headerElement.setMustUnderstand(mustUnderstand);
|
||||
}
|
||||
|
||||
/** Returns <code>true</code> if the body has a fault, <code>false</code> otherwise. */
|
||||
public boolean hasFault(SOAPBody body) {
|
||||
return body.hasFault();
|
||||
}
|
||||
|
||||
/** Returns the fault for the given body, if any. */
|
||||
public SOAPFault getFault(SOAPBody body) {
|
||||
return body.getFault();
|
||||
}
|
||||
|
||||
/** Adds a fault to the given body. */
|
||||
public abstract SOAPFault addFault(SOAPBody body, QName faultCode, String faultString, Locale locale)
|
||||
throws SOAPException;
|
||||
|
||||
/** Returns the fault code for the given fault. */
|
||||
public abstract QName getFaultCode(SOAPFault fault);
|
||||
|
||||
/** Returns the actor for the given fault. */
|
||||
public String getFaultActor(SOAPFault fault) {
|
||||
return fault.getFaultActor();
|
||||
}
|
||||
|
||||
/** Sets the actor for the given fault. */
|
||||
public void setFaultActor(SOAPFault fault, String actorOrRole) throws SOAPException {
|
||||
fault.setFaultActor(actorOrRole);
|
||||
}
|
||||
|
||||
/** Returns the fault string for the given fault. */
|
||||
public String getFaultString(SOAPFault fault) {
|
||||
return fault.getFaultString();
|
||||
}
|
||||
|
||||
/** Returns the fault string language for the given fault. */
|
||||
public Locale getFaultStringLocale(SOAPFault fault) {
|
||||
return fault.getFaultStringLocale();
|
||||
}
|
||||
|
||||
/** Returns the fault detail for the given fault. */
|
||||
public Detail getFaultDetail(SOAPFault fault) {
|
||||
return fault.getDetail();
|
||||
}
|
||||
|
||||
/** Adds a fault detail for the given fault. */
|
||||
public Detail addFaultDetail(SOAPFault fault) throws SOAPException {
|
||||
return fault.addDetail();
|
||||
}
|
||||
|
||||
/** Adds a detail entry to the given detail. */
|
||||
public abstract DetailEntry addDetailEntry(Detail detail, QName name) throws SOAPException;
|
||||
|
||||
public void addTextNode(DetailEntry detailEntry, String text) throws SOAPException {
|
||||
detailEntry.addTextNode(text);
|
||||
}
|
||||
|
||||
/** Returns an iteration over all detail entries. */
|
||||
public Iterator getDetailEntries(Detail detail) {
|
||||
return detail.getDetailEntries();
|
||||
}
|
||||
@@ -139,32 +201,12 @@ abstract class SaajImplementation {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasFault(SOAPBody body) {
|
||||
return body.hasFault();
|
||||
}
|
||||
|
||||
public SOAPFault getFault(SOAPBody body) {
|
||||
return body.getFault();
|
||||
}
|
||||
|
||||
public abstract boolean isSoap11(SOAPElement element);
|
||||
|
||||
public void removeContents(SOAPElement element) {
|
||||
element.removeContents();
|
||||
}
|
||||
|
||||
public abstract DetailEntry addDetailEntry(Detail detail, QName name) throws SOAPException;
|
||||
|
||||
public Iterator examineAllHeaderElements(SOAPHeader header) {
|
||||
return header.examineAllHeaderElements();
|
||||
}
|
||||
|
||||
public Iterator examineMustUnderstandHeaderElements(SOAPHeader header, String actorOrRole) {
|
||||
return header.examineMustUnderstandHeaderElements(actorOrRole);
|
||||
}
|
||||
|
||||
public abstract SOAPHeaderElement addHeaderElement(SOAPHeader header, QName name) throws SOAPException;
|
||||
|
||||
public abstract String getFaultRole(SOAPFault fault);
|
||||
|
||||
public abstract void setFaultRole(SOAPFault fault, String role) throws SOAPException;
|
||||
@@ -174,22 +216,6 @@ abstract class SaajImplementation {
|
||||
public abstract SOAPHeaderElement addUpgradeHeaderElement(SOAPHeader header, String[] supportedSoapUris)
|
||||
throws SOAPException;
|
||||
|
||||
public Detail getFaultDetail(SOAPFault fault) {
|
||||
return fault.getDetail();
|
||||
}
|
||||
|
||||
public Detail addFaultDetail(SOAPFault fault) throws SOAPException {
|
||||
return fault.addDetail();
|
||||
}
|
||||
|
||||
public String getFaultString(SOAPFault fault) {
|
||||
return fault.getFaultString();
|
||||
}
|
||||
|
||||
public Locale getFaultStringLocale(SOAPFault fault) {
|
||||
return fault.getFaultStringLocale();
|
||||
}
|
||||
|
||||
public abstract Iterator getFaultSubcodes(SOAPFault fault);
|
||||
|
||||
public abstract void appendFaultSubcode(SOAPFault fault, QName subcode) throws SOAPException;
|
||||
@@ -202,9 +228,6 @@ abstract class SaajImplementation {
|
||||
|
||||
public abstract void setFaultReasonText(SOAPFault fault, Locale locale, String text) throws SOAPException;
|
||||
|
||||
public abstract SOAPFault addFault(SOAPBody body, QName faultCode, String faultString, Locale locale)
|
||||
throws SOAPException;
|
||||
|
||||
public void writeTo(SOAPMessage message, OutputStream outputStream) throws SOAPException, IOException {
|
||||
if (message.saveRequired()) {
|
||||
message.saveChanges();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@ import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPHeader;
|
||||
import javax.xml.soap.SOAPHeaderElement;
|
||||
import javax.xml.transform.Result;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.soap.SoapHeader;
|
||||
@@ -62,6 +63,10 @@ class SaajSoapHeader extends SaajSoapElement implements SoapHeader {
|
||||
return (SOAPHeader) getSaajElement();
|
||||
}
|
||||
|
||||
public Result getResult() {
|
||||
return getImplementation().getResult(getSaajHeader());
|
||||
}
|
||||
|
||||
private static class SaajSoapHeaderElementIterator implements Iterator {
|
||||
|
||||
private final Iterator iterator;
|
||||
|
||||
@@ -89,12 +89,21 @@ public abstract class AbstractSoapHeaderTestCase extends XMLTestCase {
|
||||
assertFalse("header element iterator has too many elements", iterator.hasNext());
|
||||
}
|
||||
|
||||
public void testGetResult() throws Exception {
|
||||
String content =
|
||||
"<spring:localName xmlns:spring='http://www.springframework.org'><spring:content/></spring:localName>";
|
||||
transformer.transform(new StringSource(content), soapHeader.getResult());
|
||||
Iterator iterator = soapHeader.examineAllHeaderElements();
|
||||
assertTrue("Header has no children", iterator.hasNext());
|
||||
SoapHeaderElement headerElement = (SoapHeaderElement) iterator.next();
|
||||
assertFalse("Header has too many children", iterator.hasNext());
|
||||
assertHeaderElementEqual(headerElement, content);
|
||||
}
|
||||
|
||||
protected void assertHeaderElementEqual(SoapHeaderElement headerElement, String expected) throws Exception {
|
||||
StringResult result = new StringResult();
|
||||
transformer.transform(headerElement.getSource(), result);
|
||||
assertXMLEqual("Invalid contents of header element",
|
||||
"<spring:localName xmlns:spring='http://www.springframework.org'><spring:content/></spring:localName>",
|
||||
result.toString());
|
||||
assertXMLEqual("Invalid contents of header element", expected, result.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,4 +13,6 @@ public class AxiomSoap11HeaderTest extends AbstractSoap11HeaderTestCase {
|
||||
return axiomSoapMessage.getSoapHeader();
|
||||
}
|
||||
|
||||
public void testGetResult() throws Exception {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,4 +29,6 @@ public class AxiomSoap12HeaderTest extends AbstractSoap12HeaderTestCase {
|
||||
return axiomSoapMessage.getSoapHeader();
|
||||
}
|
||||
|
||||
public void testGetResult() throws Exception {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.soap.saaj;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import javax.activation.DataSource;
|
||||
import javax.mail.util.ByteArrayDataSource;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.AttachmentPart;
|
||||
import javax.xml.soap.Detail;
|
||||
import javax.xml.soap.DetailEntry;
|
||||
import javax.xml.soap.MessageFactory;
|
||||
import javax.xml.soap.SOAPBody;
|
||||
import javax.xml.soap.SOAPEnvelope;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPFault;
|
||||
import javax.xml.soap.SOAPHeader;
|
||||
import javax.xml.soap.SOAPHeaderElement;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
|
||||
import org.custommonkey.xmlunit.XMLTestCase;
|
||||
import org.springframework.ws.soap.SoapVersion;
|
||||
import org.springframework.xml.transform.StringResult;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
public abstract class AbstractSaajImplementationTestCase extends XMLTestCase {
|
||||
|
||||
private SaajImplementation implementation;
|
||||
|
||||
private SOAPMessage message;
|
||||
|
||||
protected final void setUp() throws Exception {
|
||||
implementation = createSaajImplementation();
|
||||
MessageFactory messageFactory = MessageFactory.newInstance();
|
||||
message = messageFactory.createMessage();
|
||||
}
|
||||
|
||||
protected abstract SaajImplementation createSaajImplementation();
|
||||
|
||||
public void testGetName() throws Exception {
|
||||
QName name = implementation.getName(message.getSOAPBody());
|
||||
assertEquals("Invalid name", SoapVersion.SOAP_11.getBodyName(), name);
|
||||
}
|
||||
|
||||
public void testGetSource() throws Exception {
|
||||
Source source = implementation.getSource(message.getSOAPBody());
|
||||
assertNotNull("No source returned", source);
|
||||
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
||||
StringResult result = new StringResult();
|
||||
transformer.transform(source, result);
|
||||
assertXMLEqual("<Body xmlns='http://schemas.xmlsoap.org/soap/envelope/'/>", result.toString());
|
||||
}
|
||||
|
||||
public void testGetResult() throws Exception {
|
||||
Source source = new StringSource("<content xmlns='http://springframework.org/spring-ws'/>");
|
||||
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
||||
transformer.transform(source, implementation.getResult(message.getSOAPBody()));
|
||||
}
|
||||
|
||||
public void testGetEnvelope() throws Exception {
|
||||
SOAPEnvelope envelope = implementation.getEnvelope(message);
|
||||
assertEquals("Invalid envelope", message.getSOAPPart().getEnvelope(), envelope);
|
||||
}
|
||||
|
||||
public void testGetHeader() throws Exception {
|
||||
SOAPHeader header = implementation.getHeader(message.getSOAPPart().getEnvelope());
|
||||
assertEquals("Invalid header", message.getSOAPHeader(), header);
|
||||
}
|
||||
|
||||
public void testGetBody() throws Exception {
|
||||
SOAPBody body = implementation.getBody(message.getSOAPPart().getEnvelope());
|
||||
assertEquals("Invalid body", message.getSOAPBody(), body);
|
||||
}
|
||||
|
||||
public void testExampleAllHeaderElements() throws Exception {
|
||||
Iterator iterator = implementation.examineAllHeaderElements(message.getSOAPHeader());
|
||||
assertFalse("Header elements present", iterator.hasNext());
|
||||
createHeaderElement();
|
||||
iterator = implementation.examineAllHeaderElements(message.getSOAPHeader());
|
||||
assertTrue("No header elements present", iterator.hasNext());
|
||||
}
|
||||
|
||||
public void testExampleMustUnderstandHeaderElements() throws Exception {
|
||||
SOAPHeaderElement headerElement = createHeaderElement();
|
||||
headerElement.setMustUnderstand(true);
|
||||
Iterator iterator = implementation.examineAllHeaderElements(message.getSOAPHeader());
|
||||
assertTrue("No header elements present", iterator.hasNext());
|
||||
}
|
||||
|
||||
public void testAddHeaderElement() throws Exception {
|
||||
SOAPHeaderElement headerElement = implementation
|
||||
.addHeaderElement(message.getSOAPHeader(), new QName("http://springframework.org/spring-ws", "Header"));
|
||||
assertNotNull("No header element returned", headerElement);
|
||||
assertEquals("Invalid namespace", "http://springframework.org/spring-ws", headerElement.getNamespaceURI());
|
||||
assertEquals("Invalid local name", "Header", headerElement.getLocalName());
|
||||
}
|
||||
|
||||
public void testGetActorOrRole() throws Exception {
|
||||
SOAPHeaderElement headerElement = createHeaderElement();
|
||||
String actor = "http://springframework.org/spring-ws/Actor";
|
||||
headerElement.setActor(actor);
|
||||
assertEquals("Invalid actor", actor, implementation.getActorOrRole(headerElement));
|
||||
}
|
||||
|
||||
private SOAPHeaderElement createHeaderElement() throws SOAPException {
|
||||
SOAPHeader header = message.getSOAPHeader();
|
||||
return header.addHeaderElement(new QName("http://springframework.org/spring-ws", "Header"));
|
||||
}
|
||||
|
||||
public void testSetActorOrRole() throws Exception {
|
||||
SOAPHeaderElement headerElement = createHeaderElement();
|
||||
String actor = "http://springframework.org/spring-ws/Actor";
|
||||
implementation.setActorOrRole(headerElement, actor);
|
||||
assertEquals("Invalid actor", headerElement.getActor(), actor);
|
||||
}
|
||||
|
||||
public void testGetMustUnderstand() throws Exception {
|
||||
SOAPHeaderElement headerElement = createHeaderElement();
|
||||
headerElement.setMustUnderstand(true);
|
||||
assertTrue("Invalid mustUnderstand", implementation.getMustUnderstand(headerElement));
|
||||
}
|
||||
|
||||
public void testSetMustUnderstand() throws Exception {
|
||||
SOAPHeaderElement headerElement = createHeaderElement();
|
||||
implementation.setMustUnderstand(headerElement, true);
|
||||
assertTrue("Invalid mustUnderstand", headerElement.getMustUnderstand());
|
||||
}
|
||||
|
||||
public void testHasFault() throws Exception {
|
||||
assertFalse("Body has fault", implementation.hasFault(message.getSOAPBody()));
|
||||
message.getSOAPBody().addFault();
|
||||
assertTrue("Body has no fault", implementation.hasFault(message.getSOAPBody()));
|
||||
}
|
||||
|
||||
public void testGetFault() throws Exception {
|
||||
assertNull("Body has fault", implementation.getFault(message.getSOAPBody()));
|
||||
message.getSOAPBody().addFault();
|
||||
assertNotNull("Body has no fault", implementation.getFault(message.getSOAPBody()));
|
||||
}
|
||||
|
||||
public void testAddFault() throws Exception {
|
||||
SOAPBody body = message.getSOAPBody();
|
||||
implementation
|
||||
.addFault(body, new QName("http://springframework.org/spring-ws", "Fault"), "Fault", Locale.ENGLISH);
|
||||
assertTrue("No Fault added", body.hasFault());
|
||||
}
|
||||
|
||||
public void testGetFaultCode() throws Exception {
|
||||
SOAPFault fault = createFault();
|
||||
assertEquals("Invalid fault code", new QName("http://springframework.org/spring-ws", "Fault"),
|
||||
implementation.getFaultCode(fault));
|
||||
}
|
||||
|
||||
private SOAPFault createFault() throws SOAPException {
|
||||
SOAPBody body = message.getSOAPBody();
|
||||
return body.addFault(new QName("http://springframework.org/spring-ws", "Fault"), "Fault", Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public void testGetFaultActor() throws Exception {
|
||||
SOAPFault fault = createFault();
|
||||
String actor = "http://springframework.org/spring-ws/Actor";
|
||||
fault.setFaultActor(actor);
|
||||
assertEquals("Invalid actor", actor, implementation.getFaultActor(fault));
|
||||
}
|
||||
|
||||
public void testSetFaultActor() throws Exception {
|
||||
SOAPFault fault = createFault();
|
||||
String actor = "http://springframework.org/spring-ws/Actor";
|
||||
implementation.setFaultActor(fault, actor);
|
||||
assertEquals("Invalid actor", actor, fault.getFaultActor());
|
||||
}
|
||||
|
||||
public void testGetFaultString() throws Exception {
|
||||
SOAPFault fault = createFault();
|
||||
String faultString = "FaultString";
|
||||
fault.setFaultString(faultString);
|
||||
assertEquals("Invalid fault string", faultString, implementation.getFaultString(fault));
|
||||
}
|
||||
|
||||
public void testGetFaultStringLocale() throws Exception {
|
||||
SOAPFault fault = createFault();
|
||||
assertEquals("Invalid fault string", Locale.ENGLISH, implementation.getFaultStringLocale(fault));
|
||||
}
|
||||
|
||||
public void testGetFaultDetail() throws Exception {
|
||||
SOAPFault fault = createFault();
|
||||
assertNull("Fault Detail returned", implementation.getFaultDetail(fault));
|
||||
fault.addDetail();
|
||||
assertNotNull("No Fault Detail returned", implementation.getFaultDetail(fault));
|
||||
}
|
||||
|
||||
public void testAddFaultDetail() throws Exception {
|
||||
SOAPFault fault = createFault();
|
||||
Detail detail = implementation.addFaultDetail(fault);
|
||||
assertEquals("Invalid fault detail", fault.getDetail(), detail);
|
||||
}
|
||||
|
||||
public void testAddDetailEntry() throws Exception {
|
||||
SOAPFault fault = createFault();
|
||||
Detail detail = fault.addDetail();
|
||||
DetailEntry detailEntry =
|
||||
implementation.addDetailEntry(detail, new QName("http://springframework.org/spring-ws", "DetailEntry"));
|
||||
assertNotNull("No detail entry", detailEntry);
|
||||
Iterator iterator = detail.getDetailEntries();
|
||||
assertTrue("No detail entried", iterator.hasNext());
|
||||
assertEquals("Invalid detail entry", detailEntry, iterator.next());
|
||||
}
|
||||
|
||||
public void testAddTextNode() throws Exception {
|
||||
SOAPFault fault = createFault();
|
||||
Detail detail = fault.addDetail();
|
||||
DetailEntry detailEntry =
|
||||
detail.addDetailEntry(new QName("http://springframework.org/spring-ws", "DetailEntry"));
|
||||
implementation.addTextNode(detailEntry, "text");
|
||||
assertEquals("Invalid text", "text", detailEntry.getTextContent());
|
||||
}
|
||||
|
||||
public void testGetDetailEntries() throws Exception {
|
||||
SOAPFault fault = createFault();
|
||||
Detail detail = fault.addDetail();
|
||||
Iterator iterator = implementation.getDetailEntries(detail);
|
||||
assertFalse("Detail entries found", iterator.hasNext());
|
||||
DetailEntry detailEntry =
|
||||
detail.addDetailEntry(new QName("http://springframework.org/spring-ws", "DetailEntry"));
|
||||
iterator = implementation.getDetailEntries(detail);
|
||||
assertTrue("No detail entries found", iterator.hasNext());
|
||||
assertEquals("Invalid detail entry found", detailEntry, iterator.next());
|
||||
assertFalse("Detail entries found", iterator.hasNext());
|
||||
}
|
||||
|
||||
public void testWriteTo() throws Exception {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
implementation.writeTo(message, os);
|
||||
assertTrue("Nothing written", os.toByteArray().length > 0);
|
||||
}
|
||||
|
||||
public void testGetAttachments() throws Exception {
|
||||
Iterator iterator = implementation.getAttachments(message);
|
||||
assertFalse("Message has attachments", iterator.hasNext());
|
||||
AttachmentPart attachmentPart = message.createAttachmentPart();
|
||||
message.addAttachmentPart(attachmentPart);
|
||||
iterator = implementation.getAttachments(message);
|
||||
assertTrue("Message has no attachments", iterator.hasNext());
|
||||
assertEquals("Invalid attachment part", attachmentPart, iterator.next());
|
||||
}
|
||||
|
||||
public void testAddAttachmentPart() throws Exception {
|
||||
DataSource dataSource = new ByteArrayDataSource("data", "text");
|
||||
AttachmentPart attachmentPart = implementation.addAttachmentPart(message, dataSource);
|
||||
assertNotNull("No attachment part", attachmentPart);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.soap.saaj;
|
||||
|
||||
public class Saaj12ImplementationTest extends AbstractSaajImplementationTestCase {
|
||||
|
||||
protected SaajImplementation createSaajImplementation() {
|
||||
return Saaj12Implementation.getImplementation();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.soap.saaj;
|
||||
|
||||
public class Saaj13ImplementationTest extends AbstractSaajImplementationTestCase {
|
||||
|
||||
protected SaajImplementation createSaajImplementation() {
|
||||
return Saaj13Implementation.getImplementation();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user