FileDocCategorySizeDatePackage
WhiteMesaSoap12AddTestSvcTestCase.javaAPI DocApache Axis 1.425092Sat Apr 22 18:57:26 BST 2006test.wsdl.soap12.additional

WhiteMesaSoap12AddTestSvcTestCase

public class WhiteMesaSoap12AddTestSvcTestCase extends TestCase
Additional SOAP 1.2 tests. For details, see: http://www.w3.org/2000/xp/Group/2/03/soap1.2implementation.html#addtests Auto-generated from WhiteMesa's WSDL, with additional coding by:
author
Davanum Srinivas (dims@apache.org)
author
Glen Daniels (gdaniels@apache.org)

Fields Summary
public static final String
STRING_VAL
public static final float
FLOAT_VAL
public static final Float
FLOAT_OBJVAL
public static final int
INT_VAL
public static final Integer
INT_OBJVAL
public final String
TEST_NS
public final QName
ECHO_STRING_QNAME
public static String
HOST
public static String
RPC_ENDPOINT
public static String
DOC_ENDPOINT
public static String
GET_DOC_ENDPOINT
public static String
GET_RPC_ENDPOINT
public static String
DOC_INT_ENDPOINT
public static String
DOC_INT_UC_ENDPOINT
private QName
SOAPSTRUCT_QNAME
static String
configFile
Constructors Summary
public WhiteMesaSoap12AddTestSvcTestCase(String name)

        super(name);
    
Methods Summary
public static voidmain(java.lang.String[] args)


           
        // If we have an argument, it's a configuration file.
        if (args.length > 0) {
            configFile = args[0];
        }
        WhiteMesaSoap12AddTestSvcTestCase tester = new WhiteMesaSoap12AddTestSvcTestCase("testXMLP5");
        tester.setUp();
        tester.testXMLP19();
        System.out.println("Done.");
//        junit.textui.TestRunner.run(WhiteMesaSoap12AddTestSvcTestCase.class);
    
protected voidsetUp()

        if (configFile == null) {
            configFile = System.getProperty("configFile");
        }

        if (configFile == null) {
            return;
        }

        Document doc = XMLUtils.newDocument(configFile);
        NodeList nl = doc.getDocumentElement().getChildNodes();
        for (int i = 0; i < nl.getLength(); i++) {
            Node node = nl.item(i);
            if (!(node instanceof Element))
                continue;
            Element el = (Element) node;
            String tag = el.getLocalName();
            String data = XMLUtils.getChildCharacterData(el);
            if ("host".equals(tag)) {
                HOST = data;
                RPC_ENDPOINT = HOST + "/soap12/add-test-rpc";
                DOC_ENDPOINT = HOST + "/soap12/add-test-doc";
                GET_DOC_ENDPOINT = HOST + "/soap12/add-test-doc/getTime";
                GET_RPC_ENDPOINT = HOST + "/soap12/add-test-rpc/getTime";
                DOC_INT_ENDPOINT = HOST + "/soap12/add-test-doc-int";
                DOC_INT_UC_ENDPOINT = HOST + "/soap12/add-test-doc-int-uc";
            } else if ("rpcEndpoint".equals(tag)) {
                RPC_ENDPOINT = data;
            } else if ("docEndpoint".equals(tag)) {
                DOC_ENDPOINT = data;
            } else if ("getRpcEndpoint".equals(tag)) {
                GET_RPC_ENDPOINT = data;
            } else if ("getDocEndpoint".equals(tag)) {
                GET_DOC_ENDPOINT = data;
            } else if ("docIntEndpoint".equals(tag)) {
                DOC_INT_ENDPOINT = data;
            } else if ("docIntUcEndpoint".equals(tag)) {
                DOC_INT_UC_ENDPOINT = data;
            }
        }
    
public voidtestSoap12AddTestDocIntermediaryPortWSDL()

        javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
        java.net.URL url = new java.net.URL(new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestDocIntermediaryPortAddress() + "?WSDL");
        javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getServiceName());
        assertTrue(service != null);
    
public voidtestSoap12AddTestDocPortWSDL()

        javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
        java.net.URL url = new java.net.URL(new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestDocPortAddress() + "?WSDL");
        javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getServiceName());
        assertTrue(service != null);
    
public voidtestSoap12AddTestDocUpperPortWSDL()

        javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
        java.net.URL url = new java.net.URL(new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestDocUpperPortAddress() + "?WSDL");
        javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getServiceName());
        assertTrue(service != null);
    
public voidtestSoap12AddTestRpcPortWSDL()

        javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
        java.net.URL url = new java.net.URL(new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestRpcPortAddress() + "?WSDL");
        javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getServiceName());
        assertTrue(service != null);
    
public voidtestXMLP1()
Test xmlp-1 - call echoString with no arguments (even though it expects one). Confirm bad arguments fault from endpoint.

throws
Exception

        Call call = new Call(RPC_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
        try {
            call.invoke(ECHO_STRING_QNAME, null);
        } catch (AxisFault fault) {
            assertEquals(Constants.FAULT_SOAP12_SENDER, fault.getFaultCode());
            QName [] subCodes = fault.getFaultSubCodes();
            assertNotNull(subCodes);
            assertEquals(1, subCodes.length);
            assertEquals(Constants.FAULT_SUBCODE_BADARGS, subCodes[0]);
            return;
        }
        fail("Didn't catch expected fault");
    
public voidtestXMLP11()
Test xmlp-11 : send a string where an integer is expected, confirm BadArguments fault.

throws
Exception

        Call call = new Call(RPC_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
        call.setProperty(Call.SEND_TYPE_ATTR, Boolean.FALSE);
        try {
            call.invoke(new QName(TEST_NS, "echoInteger"),
                        new Object [] { new RPCParam("inputInteger",
                                                     "ceci n'est pas un int")
                                      }
                       );
        } catch (AxisFault fault) {
            assertEquals(Constants.FAULT_SOAP12_SENDER, fault.getFaultCode());
            QName [] subCodes = fault.getFaultSubCodes();
            assertNotNull(subCodes);
            assertEquals(1, subCodes.length);
            assertEquals(Constants.FAULT_SUBCODE_BADARGS, subCodes[0]);
            return;
        }
        fail("Didn't catch expected fault");        
    
public voidtestXMLP12()
Test xmlp-12 : unknown method call to RPC endpoint. Confirm "ProcedureNotPresent" subcode of "Sender" fault.

throws
Exception

        Call call = new Call(RPC_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
        call.addParameter(new QName("inputInteger"), Constants.XSD_INT, ParameterMode.IN);
        try {
            call.invoke(new QName(TEST_NS, "unknownFreakyMethod"), new Object [] { new Integer(5) });
        } catch (AxisFault fault) {
            assertEquals(Constants.FAULT_SOAP12_SENDER, fault.getFaultCode());
            QName [] subCodes = fault.getFaultSubCodes();
            assertNotNull(subCodes);
            assertEquals(1, subCodes.length);
            assertEquals(Constants.FAULT_SUBCODE_PROC_NOT_PRESENT, subCodes[0]);
            return;
        }
        fail("Didn't catch expected fault");
    
public voidtestXMLP13()
Test xmlp-13 : doc/lit echoString which sends back the original message via a transparent "forwarding intermediary"

        String ARG = "i FeEL sTrAnGEly CAsEd (but I like it)";
        Call call = new Call(DOC_INT_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
        call.setOperationStyle(Style.WRAPPED);
        call.addParameter(new QName(TEST_NS, "inputString"),
                          Constants.XSD_STRING, ParameterMode.IN);
        call.setReturnType(Constants.XSD_STRING);
        
        String ret = (String)call.invoke(ECHO_STRING_QNAME, new Object [] { ARG });
        assertEquals("Return didn't match argument", ARG, ret);        
    
public voidtestXMLP14()
Test xmlp-14 : doc/lit echoString which sends back the original message via an "active intermediary" (translating the string to uppercase)

        String ARG = "i FeEL sTrAnGEly CAsEd (and dream of UPPER)";
        Call call = new Call(DOC_INT_UC_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
        call.setOperationStyle(Style.WRAPPED);
        call.addParameter(new QName(TEST_NS, "inputString"),
                          Constants.XSD_STRING, ParameterMode.IN);
        call.setReturnType(Constants.XSD_STRING);
        
        String ret = (String)call.invoke(ECHO_STRING_QNAME, new Object [] { ARG });
        assertEquals("Return wasn't uppercased argument", ARG.toUpperCase(), ret);
    
public voidtestXMLP15()

        String HEADER_VAL = "I'm going to be discarded!";
        String HEADER_NS = "http://test-xmlp-15";
        String HEADER_NAME = "unknown";
        
        Call call = new Call(DOC_INT_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
        call.setOperationStyle(Style.WRAPPED);
        call.setOperationUse(Use.LITERAL);

        SOAPHeaderElement header = new SOAPHeaderElement(HEADER_NS, HEADER_NAME);
        header.setRole(Constants.URI_SOAP12_NEXT_ROLE);
        header.setObjectValue(HEADER_VAL);
        call.addHeader(header);
        
        call.invoke(ECHO_STRING_QNAME, new Object [] { "body string" });
        
        SOAPEnvelope respEnv = call.getMessageContext().getResponseMessage().getSOAPEnvelope();
        
        // Confirm we got no headers back
        Vector headers = respEnv.getHeaders();
        assertTrue("Headers Vector wasn't empty", headers.isEmpty());
    
public voidtestXMLP16()

        String HEADER_VAL = "I'm going all the way through!";
        String HEADER_NS = "http://test-xmlp-16";
        String HEADER_NAME = "unknown";
        QName HEADER_QNAME = new QName(HEADER_NS, HEADER_NAME);
        
        Call call = new Call(DOC_INT_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);

        SOAPHeaderElement header = new SOAPHeaderElement(HEADER_NS, HEADER_NAME);
        header.setRole(Constants.URI_SOAP12_NONE_ROLE);
        header.setObjectValue(HEADER_VAL);
        call.addHeader(header);
        
        call.invoke(ECHO_STRING_QNAME, new Object [] { "body string" });
        
        SOAPEnvelope respEnv = call.getMessageContext().getResponseMessage().getSOAPEnvelope();
        
        // Confirm we got our header back
        Vector headers = respEnv.getHeaders();
        assertEquals(1, headers.size());
        SOAPHeaderElement respHeader = (SOAPHeaderElement)headers.get(0);
        assertEquals(Constants.URI_SOAP12_NONE_ROLE, respHeader.getRole());
        assertEquals(HEADER_QNAME, respHeader.getQName());
        assertEquals(HEADER_VAL, respHeader.getValue());
    
public voidtestXMLP17()

        String HEADER_VAL = "I'm going all the way through!";
        String HEADER_NS = "http://test-xmlp-17";
        String HEADER_NAME = "seekrit";
        QName HEADER_QNAME = new QName(HEADER_NS, HEADER_NAME);
        
        Call call = new Call(DOC_INT_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);

        SOAPHeaderElement header = new SOAPHeaderElement(HEADER_NS, HEADER_NAME);
        header.setRole(Constants.URI_SOAP12_ULTIMATE_ROLE);
        header.setObjectValue(HEADER_VAL);
        call.addHeader(header);
        
        call.invoke(ECHO_STRING_QNAME, new Object [] { "body string" });
        
        SOAPEnvelope respEnv = call.getMessageContext().getResponseMessage().getSOAPEnvelope();
        
        // Confirm we got a single header back, targeted at the ultimate
        // receiver
        Vector headers = respEnv.getHeaders();
        assertEquals(1, headers.size());
        SOAPHeaderElement respHeader = (SOAPHeaderElement)headers.get(0);
        assertEquals(Constants.URI_SOAP12_ULTIMATE_ROLE, respHeader.getRole());
        assertEquals(HEADER_QNAME, respHeader.getQName());
        assertEquals(HEADER_VAL, respHeader.getValue());
    
public voidtestXMLP18()

        String HEADER_VAL = "I'm going all the way through!";
        String HEADER_NS = "http://test-xmlp-17";
        String HEADER_NAME = "seekrit";
        QName HEADER_QNAME = new QName(HEADER_NS, HEADER_NAME);
        
        Call call = new Call(DOC_INT_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);

        SOAPHeaderElement header = new SOAPHeaderElement(HEADER_NS, HEADER_NAME);
        header.setRole(Constants.URI_SOAP12_NEXT_ROLE);
        header.setRelay(true);
        header.setObjectValue(HEADER_VAL);
        call.addHeader(header);
        
        call.invoke(ECHO_STRING_QNAME, new Object [] { "body string" });
        
        SOAPEnvelope respEnv = call.getMessageContext().getResponseMessage().getSOAPEnvelope();
        
        // Confirm we got a single header back, targeted at the ultimate
        // receiver
        Vector headers = respEnv.getHeaders();
        assertEquals(1, headers.size());
        SOAPHeaderElement respHeader = (SOAPHeaderElement)headers.get(0);
        assertEquals(Constants.URI_SOAP12_NEXT_ROLE, respHeader.getRole());
        assertTrue(respHeader.getRelay());
        assertEquals(HEADER_QNAME, respHeader.getQName());
        assertEquals(HEADER_VAL, respHeader.getValue());
    
public voidtestXMLP19()

        String HEADER_VAL = "I'm going to generate a fault!";
        String HEADER_NS = "http://test-xmlp-17";
        String HEADER_NAME = "seekrit";
        
        Call call = new Call(DOC_INT_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);

        SOAPHeaderElement header = new SOAPHeaderElement(HEADER_NS, HEADER_NAME);
        header.setRole(Constants.URI_SOAP12_NEXT_ROLE);
        header.setMustUnderstand(true);
        header.setObjectValue(HEADER_VAL);
        call.addHeader(header);
        
        try {
            call.invoke(ECHO_STRING_QNAME, new Object [] { "body string" });
        } catch (AxisFault fault) {
            // Got the expected Fault - make sure it looks right
            assertEquals(Constants.FAULT_SOAP12_MUSTUNDERSTAND,
                         fault.getFaultCode());
            return;
        }

        fail("Didn't catch expected fault");        
    
public voidtestXMLP2()
Test xmlp-2, using the GET webmethod.

throws
Exception

        Call call = new Call(GET_DOC_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
        call.setProperty(SOAP12Constants.PROP_WEBMETHOD, "GET");
        call.setOperationStyle(Style.DOCUMENT);
        call.setOperationUse(Use.LITERAL);
        call.invoke();
        SOAPEnvelope env = call.getMessageContext().getResponseMessage().getSOAPEnvelope();
        Object result = env.getFirstBody().getValueAsType(Constants.XSD_TIME);
        assertEquals(org.apache.axis.types.Time.class, result.getClass());
        // Suppose we could check the actual time here too, but we aren't
        // gonna for now.
    
public voidtestXMLP3()
Test xmlp-3, using the GET webmethod and RPC mode (i.e. deal with the rpc:result element).

throws
Exception

        Call call = new Call(GET_RPC_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
        call.setProperty(SOAP12Constants.PROP_WEBMETHOD, "GET");
        call.setOperationStyle(Style.RPC);
        call.setReturnType(Constants.XSD_TIME);
        Object ret = call.invoke("", new Object [] {});
        assertEquals(org.apache.axis.types.Time.class, ret.getClass());
        // Suppose we could check the actual time here too, but we aren't
        // gonna for now.
    
public voidtestXMLP4()

        Call call = new Call(RPC_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
        call.registerTypeMapping(SOAPStruct.class, SOAPSTRUCT_QNAME,
                                 new BeanSerializerFactory(SOAPStruct.class, SOAPSTRUCT_QNAME),
                                 new BeanDeserializerFactory(SOAPStruct.class, SOAPSTRUCT_QNAME));
        call.addParameter(new QName("", "inputFloat"),
                          Constants.XSD_FLOAT, ParameterMode.IN);
        call.addParameter(new QName("", "inputInteger"),
                          Constants.XSD_INT, ParameterMode.IN);
        call.addParameter(new QName("", "inputString"),
                          Constants.XSD_STRING, ParameterMode.IN);
        call.setReturnType(SOAPSTRUCT_QNAME);
        SOAPStruct ret = (SOAPStruct)call.invoke(
                new QName(TEST_NS, "echoSimpleTypesAsStruct"),
                new Object [] {
                    new Float(FLOAT_VAL),
                    new Integer(INT_VAL),
                    STRING_VAL 
                });
        assertEquals(STRING_VAL, ret.getVarString());
        assertEquals(FLOAT_VAL, ret.getVarFloat(), 0.0004F);
        assertEquals(INT_VAL, ret.getVarInt());
    
public voidtestXMLP5()

        Call call = new Call(RPC_ENDPOINT);
        try {
            call.invoke(new QName(TEST_NS, "echoVoid"), null);        
        } catch (AxisFault fault) {
            // Got the expected Fault - make sure it looks right
            assertEquals(Constants.FAULT_VERSIONMISMATCH, fault.getFaultCode());
            return;
        }
        fail("Didn't catch expected fault");
    
public voidtestXMLP6()

        Call call = new Call(RPC_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
        SOAPHeaderElement unknownHeader =
                new SOAPHeaderElement("http://example.org",
                                      "unknown",
                                      "Nobody understands me!");
        unknownHeader.setMustUnderstand(true);
        call.addHeader(unknownHeader);
        try {
            call.invoke(new QName(TEST_NS, "echoVoid"), null);        
        } catch (AxisFault fault) {
            // Got the expected Fault - make sure it looks right
            assertEquals(Constants.FAULT_SOAP12_MUSTUNDERSTAND,
                         fault.getFaultCode());
            return;
        }
        fail("Didn't catch expected fault");        
    
public voidtestXMLP7()

        URL url = new URL(DOC_ENDPOINT);
        test.wsdl.soap12.additional.Soap12AddTestDocBindingStub binding;
        try {
            binding = (test.wsdl.soap12.additional.Soap12AddTestDocBindingStub)
                          new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestDocPort(url);
        }
        catch (javax.xml.rpc.ServiceException jre) {
            if(jre.getLinkedCause()!=null)
                jre.getLinkedCause().printStackTrace();
            throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
        }
        assertNotNull("binding is null", binding);

        // Time out after a minute
        binding.setTimeout(60000);

        // Test operation
        try {
            binding.echoSenderFault(STRING_VAL);
        } catch (java.rmi.RemoteException e) {
            if (e instanceof AxisFault) {
                AxisFault af = (AxisFault)e;
                assertEquals(Constants.FAULT_SOAP12_SENDER,
                             af.getFaultCode());
                return; // success
            }
        }
        
        fail("Should have received sender fault!");
    
public voidtestXMLP8()

        Call call = new Call(DOC_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
        QName qname = new QName(TEST_NS, "echoReceiverFault");
        try {
            call.invoke(qname, null);
        } catch (AxisFault af) {
            assertEquals(Constants.FAULT_SOAP12_RECEIVER,
                    af.getFaultCode());
            return; // success
        }
        
        fail("Should have received receiver fault!");
    
public voidtestXMLP9()
Test xmlp-9 : do an "echoString" call with a bad (unknown) encoding style on the argument. Confirm Sender fault from endpoint.

throws
Exception

        Call call = new Call(RPC_ENDPOINT);
        call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
        SOAPEnvelope reqEnv = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
        SOAPBodyElement body = new SOAPBodyElement(new PrefixedQName(TEST_NS, "echoString", "ns"));
        reqEnv.addBodyElement(body);
        MessageElement arg = new MessageElement("", "inputString");
        arg.setEncodingStyle("http://this-is-a-bad-encoding-style");
        body.addChild(arg);
        try {
            call.invoke(reqEnv);
        } catch (AxisFault fault) {
            assertEquals(Constants.FAULT_SOAP12_DATAENCODINGUNKNOWN, fault.getFaultCode());            
            return;
        }
        fail("Didn't catch expected fault");