Methods Summary |
---|
public static void | main(java.lang.String[] argv)Method main
TestSOAPHeader tester = new TestSOAPHeader("TestSOAPHeader");
tester.setUp();
tester.testExamineHeaderElements1();
tester.testSoapHeadersBUG();
|
protected void | setUp()Method setUp
env = new org.apache.axis.message.SOAPEnvelope();
headerElement1 = new SOAPHeaderElement(HEADER_NAMESPACE, "SomeHeader1",
"SomeValue1");
headerElement1.setActor(ACTOR);
env.addHeader(headerElement1);
headerElement2 = new SOAPHeaderElement(HEADER_NAMESPACE, "SomeHeader2",
"SomeValue2");
headerElement2.setActor(Constants.URI_SOAP11_NEXT_ACTOR);
env.addHeader(headerElement2);
|
public static junit.framework.Test | suite()Method suite
return new TestSuite(test.message.TestSOAPHeader.class);
|
protected void | tearDown()Method tearDown
|
public void | testExamineHeaderElements1()Tests the happy path.
SOAPHeader header =
(org.apache.axis.message.SOAPHeader) env.getHeader();
Iterator iter = header.examineHeaderElements(ACTOR);
// This would be a lot simpler if getHeadersByActor() were visible.
SOAPHeaderElement headerElement = null;
int expectedHeaders = 2;
int foundHeaders = 0;
while (iter.hasNext()) {
headerElement = (SOAPHeaderElement) iter.next();
if (Constants.URI_SOAP11_NEXT_ACTOR.equals(headerElement.getActor())
|| ACTOR.equals(headerElement.getActor())) {
foundHeaders++;
}
}
assertEquals("Didn't find all the right actors.", expectedHeaders,
foundHeaders);
|
public void | testExamineHeaderElements2()Tests when the user submits a null actor.
SOAPHeader header =
(org.apache.axis.message.SOAPHeader) env.getHeader();
Iterator iter = header.examineHeaderElements(null);
// This would be a lot simpler if getHeadersByActor() were visible.
SOAPHeaderElement headerElement = null;
int expectedHeaders = 1;
int foundHeaders = 0;
while (iter.hasNext()) {
headerElement = (SOAPHeaderElement) iter.next();
if (Constants.URI_SOAP11_NEXT_ACTOR.equals(
headerElement.getActor())) {
foundHeaders++;
}
}
assertEquals("Didn't find all the right actors.", expectedHeaders,
foundHeaders);
|
public void | testExtractHeaderElements1()Tests the happy path.
SOAPHeader header =
(org.apache.axis.message.SOAPHeader) env.getHeader();
Iterator iter = header.extractHeaderElements(ACTOR);
// This would be a lot simpler if getHeadersByActor() were visible.
SOAPHeaderElement headerElement = null;
int expectedHeaders = 2;
int foundHeaders = 0;
while (iter.hasNext()) {
headerElement = (SOAPHeaderElement) iter.next();
if (Constants.URI_SOAP11_NEXT_ACTOR.equals(headerElement.getActor())
|| ACTOR.equals(headerElement.getActor())) {
foundHeaders++;
}
}
assertEquals("Didn't find all the right actors.", expectedHeaders,
foundHeaders);
|
public void | testExtractHeaderElements2()Tests when the user submits a null actor.
SOAPHeader header =
(org.apache.axis.message.SOAPHeader) env.getHeader();
Iterator iter = header.extractHeaderElements(null);
// This would be a lot simpler if getHeadersByActor() were visible.
SOAPHeaderElement headerElement = null;
int expectedHeaders = 1;
int foundHeaders = 0;
while (iter.hasNext()) {
headerElement = (SOAPHeaderElement) iter.next();
if (Constants.URI_SOAP11_NEXT_ACTOR.equals(
headerElement.getActor())) {
foundHeaders++;
}
}
assertEquals("Didn't find all the right actors.", expectedHeaders,
foundHeaders);
|
public void | testSoapHeadersBUG()Method testSoapHeadersBUG
MimeHeaders mimeheaders = new MimeHeaders();
mimeheaders.addHeader("Content-Type", "text/xml");
ByteArrayInputStream instream = new ByteArrayInputStream(xmlString.getBytes());
MessageFactory factory =
MessageFactory.newInstance();
SOAPMessage msg =
factory.createMessage(mimeheaders, instream);
org.apache.axis.client.AxisClient axisengine =
new org.apache.axis.client.AxisClient();
// need to set it not null , if not nullpointer in sp.getEnvelope()
((org.apache.axis.Message) msg).setMessageContext(
new org.apache.axis.MessageContext(axisengine));
SOAPPart sp = msg.getSOAPPart();
javax.xml.soap.SOAPEnvelope se = sp.getEnvelope();
javax.xml.soap.SOAPHeader sh = se.getHeader();
SOAPBody sb = se.getBody();
Iterator it = sh.getChildElements();
int count = 0;
while (it.hasNext()) {
SOAPElement el = (SOAPElement) it.next();
count++;
Name name = el.getElementName();
System.out.println("Element:" + el);
System.out.println("HEADER ELEMENT NAME:" + name.getPrefix() + ":"
+ name.getLocalName() + " " + name.getURI());
}
assertTrue(count==1);
|