Java Code Examples for org.apache.axiom.om.OMNode#getNextOMSibling()

The following examples show how to use org.apache.axiom.om.OMNode#getNextOMSibling() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckAggregateContentTestCase.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
@Test(groups = { "wso2.esb" }, description = "Check the content of the aggregation specified by an xpath")
public void test() throws IOException, XMLStreamException {

    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);

    OMElement responseParts = Response2.getFirstElement().getFirstElement();
    String singleResponse = responseParts.toString();

    Assert.assertTrue(singleResponse.contains("return"),
            "return child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("change"),
            "change child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("earnings"),
            "earnings child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("high"),
            "high child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("last"),
            "last child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("lastTradeTimestamp"),
            "lastTradeTimestamp child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("low"),
            "low child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("marketCap"),
            "marketCap child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("open"),
            "open child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("name"),
            "name child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("open"),
            "open child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("peRatio"),
            "PerRatio child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("percentageChange"),
            "PercentageChange child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("symbol"),
            "symbol child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("volume"),
            "volume child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("getQuoteResponse"),
            "getQuoteResponse child message does not exist in the aggregated response");

    OMNode content = responseParts.getNextOMSibling();

    for (int count = 0; count < no_of_requests - 1; count++) {

        Assert.assertNotNull(content);
        singleResponse = content.toString();
        Assert.assertTrue(singleResponse.contains("return"),
                "return child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("change"),
                "change child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("earnings"),
                "earinings child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("high"),
                "high child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("last"),
                "last child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("lastTradeTimestamp"),
                "lastTradeTimestamp child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("low"),
                "low child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("marketCap"),
                "marketCap child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("open"),
                "open child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("name"),
                "name child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("open"),
                "open child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("peRatio"),
                "PerRatio child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("percentageChange"),
                "PercentageChange child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("symbol"),
                "symbol child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("volume"),
                "volume child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("getQuoteResponse"),
                "getQuoteResponse child message does not exist in the aggregated response");
        content = content.getNextOMSibling();

    }

}
 
Example 2
Source File: CheckAggregateContentTestCase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@Test(groups = {"wso2.esb"}, description = "Check the content of the aggregation specified by an xpath")
public void test() throws IOException, XMLStreamException {


    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);


    OMElement responseParts = Response2.getFirstElement().getFirstElement();
    String singleResponse = responseParts.toString();

    Assert.assertTrue(singleResponse.contains("return"), "return child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("change"), "change child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("earnings"), "earnings child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("high"), "high child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("last"), "last child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("lastTradeTimestamp"), "lastTradeTimestamp child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("low"), "low child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("marketCap"), "marketCap child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("open"), "open child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("name"), "name child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("open"), "open child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("peRatio"), "PerRatio child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("percentageChange"), "PercentageChange child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("symbol"), "symbol child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("volume"), "volume child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("getQuoteResponse"), "getQuoteResponse child message does not exist in the aggregated response");


    OMNode content = responseParts.getNextOMSibling();

    for (int count = 0; count < no_of_requests - 1; count++) {

        Assert.assertNotNull(content);
        singleResponse = content.toString();
        Assert.assertTrue(singleResponse.contains("return"), "return child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("change"), "change child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("earnings"), "earinings child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("high"), "high child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("last"), "last child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("lastTradeTimestamp"), "lastTradeTimestamp child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("low"), "low child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("marketCap"), "marketCap child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("open"), "open child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("name"), "name child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("open"), "open child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("peRatio"), "PerRatio child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("percentageChange"), "PercentageChange child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("symbol"), "symbol child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("volume"), "volume child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("getQuoteResponse"), "getQuoteResponse child message does not exist in the aggregated response");
        content = content.getNextOMSibling();

    }


}
 
Example 3
Source File: HealthCareScenarioTestCase.java    From micro-integrator with Apache License 2.0 3 votes vote down vote up
/**
 * This is a recursive function to count the number of siblings.
 * This is a little confusing, but what it does is traverse through the
 * siblings (getNextOMSibling) by checking to see there is a next sibling.
 * If there is, it sets the count to 1, and calls itself again. When it reaches
 * no next sibling, it returns 1 i.e. the last sibling). Then the method stack
 * should return adding up each of the 1's.
 *
 * @param sibling OMNode
 * @param count   initial count (i.e. first sibling, this should always be 1).
 * @return total sibling count.
 */
private int countSiblings(OMNode sibling, int count) {
    if (sibling.getNextOMSibling() != null) {
        count = 1; // I am a sibling.
        return count + countSiblings(sibling.getNextOMSibling(), 1);
    } else {
        return 1;  // I am the last sibling.
    }
}
 
Example 4
Source File: HealthCareScenarioTestCase.java    From product-ei with Apache License 2.0 3 votes vote down vote up
/**
 * This is a recursive function to count the number of siblings.
 * This is a little confusing, but what it does is traverse through the
 * siblings (getNextOMSibling) by checking to see there is a next sibling.
 * If there is, it sets the count to 1, and calls itself again. When it reaches
 * no next sibling, it returns 1 i.e. the last sibling). Then the method stack
 * should return adding up each of the 1's.
 *
 * @param sibling OMNode
 * @param count   initial count (i.e. first sibling, this should always be 1).
 * @return total sibling count.
 */
private int countSiblings(OMNode sibling, int count) {
    if (sibling.getNextOMSibling() != null) {
        count = 1; // I am a sibling.
        return count + countSiblings(sibling.getNextOMSibling(), 1);
    } else {
        return 1;  // I am the last sibling.
    }
}