Search in sources :

Example 1 with RolePlayer

use of org.apache.axiom.soap.RolePlayer 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);
}
Also used : SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) RolePlayer(org.apache.axiom.soap.RolePlayer) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Aggregations

RolePlayer (org.apache.axiom.soap.RolePlayer)1 SOAPHeader (org.apache.axiom.soap.SOAPHeader)1 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)1