TestMUValuespublic 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 |
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 void | checkVal(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 void | setUp()
SimpleProvider provider = new SimpleProvider();
engine = new AxisServer(provider);
| public void | testMustUnderstandValues()
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) {
}
|
|