FileDocCategorySizeDatePackage
TestMUValues.javaAPI DocApache Axis 1.43254Sat Apr 22 18:57:28 BST 2006test.message

TestMUValues

public class TestMUValues extends TestCase
This test confirms the behavior of the various possible values for the mustUnderstand attribute in both SOAP 1.1 and SOAP 1.2. In particular: For SOAP 1.1, the only valid values are "0" and "1" For SOAP 1.2, "0"/"false" and "1"/"true" are valid
author
Glen Daniels (gdaniels@apache.org)

Fields Summary
private org.apache.axis.AxisEngine
engine
private String
header
private String
middle
private String
footer
Constructors Summary
public TestMUValues(String name)

        super(name);
    
Methods Summary
public voidcheckVal(java.lang.String val, boolean desiredResult, java.lang.String ns)

        String request = header + ns + middle + val + footer;

        // create a message in context
        MessageContext msgContext = new MessageContext(engine);
        Message message = new Message(request);
        message.setMessageContext(msgContext);

        // Parse the message and check the mustUnderstand value
        SOAPEnvelope envelope = message.getSOAPEnvelope();
        SOAPHeaderElement header = envelope.getHeaderByName("", "test");
        assertEquals("MustUnderstand value wasn't right using value '" +
                     val + "'",
                     desiredResult, header.getMustUnderstand());
    
public voidsetUp()


         
        SimpleProvider provider = new SimpleProvider();
        engine = new AxisServer(provider);
    
public voidtestMustUnderstandValues()

        String soap12 = Constants.URI_SOAP12_ENV;
        String soap11 = Constants.URI_SOAP11_ENV;
        
        checkVal("0", false, soap12);
        checkVal("1", true, soap12);
        checkVal("true", true, soap12);
        checkVal("false", false, soap12);
        try {
            checkVal("dennis", false, soap12);
            fail("Didn't throw exception with bad MU value");
        } catch (Exception e) {
        }

        checkVal("0", false, soap11);
        checkVal("1", true, soap11);
        try {
            checkVal("true", false, soap11);
            fail("Didn't throw exception with bad MU value");
        } catch (Exception e) {
        }
        try {
            checkVal("false", false, soap11);
            fail("Didn't throw exception with bad MU value");
        } catch (Exception e) {
        }
        try {
            checkVal("dennis", false, soap11);
            fail("Didn't throw exception with bad MU value");
        } catch (Exception e) {
        }