use of org.apache.axiom.soap.SOAPHeaderBlock in project webservices-axiom by apache.
the class TestWrongParent2 method runTest.
@Override
protected void runTest() throws Throwable {
SOAPFault parent = soapFactory.createSOAPFault();
OMElement child1 = soapFactory.createSOAPFaultCode(parent);
SOAPHeaderBlock hb = soapFactory.createSOAPHeaderBlock("MyHeader", soapFactory.createOMNamespace("urn:test", "p"));
try {
child1.insertSiblingAfter(hb);
fail("Expected SOAPProcessingException");
} catch (SOAPProcessingException ex) {
// Expected
}
}
use of org.apache.axiom.soap.SOAPHeaderBlock in project webservices-axiom by apache.
the class TestWrongParent1 method runTest.
@Override
protected void runTest() throws Throwable {
SOAPBody parent = soapFactory.createSOAPBody();
SOAPHeaderBlock hb = soapFactory.createSOAPHeaderBlock("MyHeader", soapFactory.createOMNamespace("urn:test", "p"));
try {
parent.addChild(hb);
fail("Expected SOAPProcessingException");
} catch (SOAPProcessingException ex) {
// Expected
}
}
use of org.apache.axiom.soap.SOAPHeaderBlock in project webservices-axiom by apache.
the class TestExamineAllHeaderBlocks method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope soapEnvelope = soapFactory.createSOAPEnvelope();
SOAPHeader soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
OMNamespace namespace = soapFactory.createOMNamespace("http://www.example.org", "test");
soapHeader.addHeaderBlock("echoOk1", namespace);
soapHeader.addHeaderBlock("echoOk2", namespace);
Iterator<SOAPHeaderBlock> iterator = soapHeader.examineAllHeaderBlocks();
iterator.hasNext();
SOAPHeaderBlock headerBlock1 = iterator.next();
assertNotNull("SOAP Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns empty iterator", headerBlock1);
assertEquals("SOAP Header Test : - HeaderBlock1 local name mismatch", "echoOk1", headerBlock1.getLocalName());
assertEquals("SOAP Header Test : - HeaderBlock1 namespace uri mismatch", "http://www.example.org", headerBlock1.getNamespace().getNamespaceURI());
assertTrue(iterator.hasNext());
SOAPHeaderBlock headerBlock2 = iterator.next();
assertNotNull("SOAP Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns an iterator with only one object", headerBlock2);
assertEquals("SOAP Header Test : - HeaderBlock2 local name mismatch", "echoOk2", headerBlock2.getLocalName());
assertEquals("SOAP Header Test : - HeaderBlock2 namespace uri mismatch", "http://www.example.org", headerBlock2.getNamespace().getNamespaceURI());
assertFalse("SOAP Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns an iterator with more than two object", iterator.hasNext());
}
use of org.apache.axiom.soap.SOAPHeaderBlock in project webservices-axiom by apache.
the class TestExamineHeaderBlocks method runTest.
@Override
protected void runTest() throws Throwable {
String roleNextURI = spec.getNextRoleURI();
SOAPEnvelope soapEnvelope = soapFactory.createSOAPEnvelope();
SOAPHeader soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
OMNamespace namespace = soapFactory.createOMNamespace("http://www.example.org", "test");
soapHeader.addHeaderBlock("echoOk1", namespace).setRole("urn:test-role");
soapHeader.addHeaderBlock("echoOk2", namespace).setRole(roleNextURI);
Iterator<SOAPHeaderBlock> iterator = soapHeader.examineHeaderBlocks(roleNextURI);
iterator.hasNext();
SOAPHeaderBlock headerBlockWithRole = iterator.next();
assertEquals("SOAP Header Test : - headerBlockWithRole local name mismatch", "echoOk2", headerBlockWithRole.getLocalName());
assertEquals("SOAP Header Test : - headerBlockWithRole role value mismatch", roleNextURI, headerBlockWithRole.getRole());
assertFalse("SOAP Header Test : - header has one headerBlock with role, but examineHeaderBlocks(String role) method returns an iterator with more than one object", iterator.hasNext());
}
use of org.apache.axiom.soap.SOAPHeaderBlock in project webservices-axiom by apache.
the class TestGetHeadersToProcessWithParser method runTest.
@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
SOAPHeader soapHeader = envelope.getHeader();
String[] roles = { "http://example.org/myCustomRole" };
RolePlayer rp = new MyRolePlayer(true, roles);
Iterator<SOAPHeaderBlock> headers = soapHeader.getHeadersToProcess(rp);
assertTrue("No headers!", headers.hasNext());
int numHeaders = 0;
while (headers.hasNext()) {
headers.next();
numHeaders++;
}
assertEquals("Didn't get right number of headers (with custom role)", 6, numHeaders);
rp = new MyRolePlayer(true);
headers = soapHeader.getHeadersToProcess(rp);
assertTrue(headers.hasNext());
numHeaders = 0;
while (headers.hasNext()) {
headers.next();
numHeaders++;
}
assertEquals("Didn't get right number of headers (no custom role)", 5, numHeaders);
// Intermediary test
rp = new MyRolePlayer(false);
headers = soapHeader.getHeadersToProcess(rp);
assertTrue(headers.hasNext());
numHeaders = 0;
while (headers.hasNext()) {
headers.next();
numHeaders++;
}
assertEquals("Didn't get right number of headers (no custom role)", 2, numHeaders);
}
Aggregations