TestHrefspublic class TestHrefs extends TestCase Test deserialization of SOAP 1.2 messages with references, by putting the
actual value in various places in the message. |
Fields Summary |
---|
private String | HEAD | private String | HEADERT | private String | BODYT |
Constructors Summary |
---|
public TestHrefs(String name)
this(name, Constants.URI_DEFAULT_SCHEMA_XSI,
Constants.URI_DEFAULT_SCHEMA_XSD);
| public TestHrefs(String name, String NS_XSI, String NS_XSD)
super(name);
HEAD =
"<?xml version=\"1.0\"?>\n" +
"<soap:Envelope " +
"xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" " +
"xmlns:soapenc=\"http://www.w3.org/2003/05/soap-encoding\" " +
"xmlns:xsi=\"" + NS_XSI + "\" " +
"xmlns:xsd=\"" + NS_XSD + "\">\n" +
"<soap:Header>\n";
HEADERT = "</soap:Header>\n" +
"<soap:Body>\n" +
"<methodResult xmlns=\"http://tempuri.org/\">\n";
BODYT = "</methodResult>\n" +
"</soap:Body>\n" +
"</soap:Envelope>\n";
|
Methods Summary |
---|
private void | deserialize(java.lang.String data, java.lang.Object expected, int pos)
Message message = new Message(data);
MessageContext context = new MessageContext(new AxisServer());
message.setMessageContext(context);
context.setProperty(Constants.MC_NO_OPERATION_OK, Boolean.TRUE);
SOAPEnvelope envelope = (SOAPEnvelope)message.getSOAPEnvelope();
assertNotNull("SOAP envelope should not be null", envelope);
RPCElement body = (RPCElement)envelope.getFirstBody();
assertNotNull("SOAP body should not be null", body);
Vector arglist = body.getParams();
assertNotNull("arglist", arglist);
assertTrue("SOAP param.size()<=0 {Should be > 0}", arglist.size()>0);
RPCParam param = (RPCParam) arglist.get(pos);
assertNotNull("SOAP param should not be null", param);
Object result = param.getObjectValue();
assertEquals("Expected result not received", expected, result);
| public void | testIDANDHREF()
String result = HEAD +
HEADERT +
"<result root=\"0\" ref=\"#1\" id=\"1\" xsi:type=\"xsd:string\">abc</result>" +
BODYT;
try {
deserialize(result, "abc", 0);
} catch (AxisFault af) {
assertTrue(af.getFaultString().indexOf(Messages.getMessage("noIDandHREFonSameElement")) != -1 &&
Constants.FAULT_SOAP12_SENDER.equals(af.getFaultCode()));
return;
}
fail("Didn't got the expected fault");
| public void | testIntReference1()
String result = HEAD + HEADERT +
"<result root=\"0\" id=\"1\" xsi:type=\"xsd:int\">567</result>" +
"<reference ref=\"#1\"/>\n" +
BODYT;
deserialize(result, new Integer(567), 1);
| public void | testStringReference1()
String result = HEAD + HEADERT +
"<result root=\"0\" id=\"1\" xsi:type=\"xsd:string\">abc</result>" +
"<reference ref=\"#1\"/>\n" +
BODYT;
deserialize(result, "abc", 1);
| public void | testStringReferenceInHeader()
String result = HEAD +
"<result root=\"0\" id=\"1\" xsi:type=\"xsd:string\">abc</result>" +
HEADERT +
"<reference ref=\"#1\"/>\n" +
BODYT;
deserialize(result, "abc", 0);
|
|