FileDocCategorySizeDatePackage
TestHrefs.javaAPI DocApache Axis 1.43295Sat Apr 22 18:57:28 BST 2006test.encoding

TestHrefs

public class TestHrefs extends TestCase
Test deserialization of SOAP messages with references, by putting the actual value in various places in the message.
author
Glen Daniels (gdaniels@apache.org)

Fields Summary
private String
header
private String[]
messageParts
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);

        header =
            "<?xml version=\"1.0\"?>\n" +
            "<soap:Envelope " +
              "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
              "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
              "xmlns:xsi=\"" + NS_XSI + "\" " +
              "xmlns:xsd=\"" + NS_XSD + "\">\n" +
              "<soap:Body>\n" +
                "<methodResult xmlns=\"http://tempuri.org/\">\n" +
                 "<reference href=\"#1\"/>\n" +
                "</methodResult>\n";
        
        messageParts = new String [] {
              "</soap:Body>\n",
        
             "</soap:Envelope>\n" };
    
Methods Summary
private voiddeserialize(java.lang.String data, java.lang.Object expected, int pos)

       String msgString = header;
       
       for (int i = 0; i < messageParts.length; i++) {
           if (pos == i)
               msgString += data;
           msgString += messageParts[i];
       }
       
       Message message = new Message(msgString);
       message.setMessageContext(new MessageContext(new AxisServer()));

       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(0);
       assertNotNull("SOAP param should not be null", param);

       Object result = param.getObjectValue();
       assertEquals("Expected result not received for case " + pos, expected, result);
    
public voidtestIntReference1()

        String result =
            "<result root=\"0\" id=\"1\" xsi:type=\"xsd:int\">567</result>";
        deserialize(result, new Integer(567), 0);
    
public voidtestStringReference1()

        String result =
            "<result root=\"0\" id=\"1\" xsi:type=\"xsd:string\">abc</result>";
        deserialize(result, "abc", 0);
    
public voidtestStringReference2()

        String result =
            "<result root=\"0\" id=\"1\" xsi:type=\"xsd:string\">abc</result>";
        deserialize(result, "abc", 1);