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

TestRoundTrip

public class TestRoundTrip extends TestCase
Test round-trip serialization/deserialization of SOAP messages

Fields Summary
private org.apache.axis.server.AxisServer
server
private String
header
private String
footer
private String
response
Constructors Summary
public TestRoundTrip(String name)


       
        this(name, Constants.URI_DEFAULT_SCHEMA_XSI,
                   Constants.URI_DEFAULT_SCHEMA_XSD);
    
public TestRoundTrip(String name, String NS_XSI, String NS_XSD)

        super(name);
        TypeMappingRegistry tmr = server.getTypeMappingRegistry();
        TypeMapping tm = (TypeMapping) tmr.createTypeMapping();
        tm.setSupportedEncodings(new String[]{Constants.URI_DEFAULT_SOAP_ENC});
        tmr.register(Constants.URI_DEFAULT_SOAP_ENC, tm);
        tm.register(test.encoding.RETURN.class,
                new QName("urn:test.encoding", "RETURN"),
                new org.apache.axis.encoding.ser.BeanSerializerFactory(
                        test.encoding.RETURN.class,
                        new QName("urn:test.encoding", "RETURN")),
                new org.apache.axis.encoding.ser.BeanDeserializerFactory(
                        test.encoding.RETURN.class,
                        new QName("urn:test.encoding", "RETURN")));
    
Methods Summary
protected voidcheckRoundTrip(java.lang.String xml1)

        Message message = new Message(xml1);
        message.setMessageContext(new MessageContext(server));

        SOAPEnvelope envelope = (SOAPEnvelope) message.getSOAPEnvelope();
        RPCElement body = (RPCElement) envelope.getFirstBody();
        Vector arglist = body.getParams();
        Object ret1 = ((RPCParam) arglist.get(0)).getObjectValue();

        String xml2 = message.getSOAPPartAsString();
        Message message2 = new Message(xml2);
        message2.setMessageContext(new MessageContext(server));

        SOAPEnvelope envelope2 = (SOAPEnvelope) message2.getSOAPEnvelope();
        RPCElement body2 = (RPCElement) envelope2.getFirstBody();
        Vector arglist2 = body2.getParams();
        Object ret2 = ((RPCParam) arglist2.get(0)).getObjectValue();

        if (!equals(ret1, ret2)) {
            assertEquals("The result is not what is expected.", ret1, ret2);
        }
    
private static booleanequals(java.lang.Object obj1, java.lang.Object obj2)

        if ((obj1 == null) || (obj2 == null)) return (obj1 == obj2);
        if (obj1.equals(obj2)) return true;
        return false;
    
public static voidmain(java.lang.String[] args)

        TestRoundTrip trip = new TestRoundTrip("Test RoundTrip");
        trip.testRoundTrip();
    
public voidtestRoundTrip()

        checkRoundTrip(header + response + footer);