package test.encoding;
import junit.framework.TestCase;
import org.apache.axis.Constants;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.server.AxisServer;
import org.custommonkey.xmlunit.XMLTestCase;
/**
* Test deserialization of SOAP responses
*/
public class TestOutputter extends XMLTestCase {
private String header;
private String footer;
private AxisServer server = new AxisServer();
public TestOutputter(String name) {
this(name, Constants.URI_DEFAULT_SCHEMA_XSI,
Constants.URI_DEFAULT_SCHEMA_XSD);
}
public TestOutputter(String name, String NS_XSI, String NS_XSD) {
super(name);
header =
"\n" +
"\n" +
"\n" +
"\n";
footer =
"\n" +
"\n" +
"";
}
/**
* Verify that a given XML deserialized produces the expected result
*/
protected void roundtrip(String data)
throws Exception
{
Message message = new Message(header + data + footer);
message.setMessageContext(new MessageContext(server));
message.getSOAPEnvelope();
assertXMLEqual(header+data+footer, message.getSOAPPartAsString());
}
public void testString() throws Exception {
roundtrip("abc");
}
public void testEscapedText() throws Exception {
roundtrip("<&>");
}
public void testEscapedAttributes() throws Exception {
roundtrip("");
// roundtrip("");
}
public static void main(String [] args) throws Exception
{
TestOutputter tester = new TestOutputter("test");
tester.testString();
}
}