Java Code Examples for org.apache.axiom.om.OMElement#getFirstElement()
The following examples show how to use
org.apache.axiom.om.OMElement#getFirstElement() .
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: SpecifyBothMinMaxByExpressionTestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = {"wso2.esb"}, description = "higher number of messages than minimum count") public void testMoreNumberThanMinimum() throws IOException, XMLStreamException { int responseCount=0; no_of_requests=8; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response= aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2= AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator =soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertTrue(minMessageCount<=responseCount&&responseCount<=no_of_requests); }
Example 2
Source File: DBReportMediatorTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE }) @Test(groups = "wso2.esb", description = "Insert or update DB table using message contents.") public void DBReportUseMessageContentTestCase() throws Exception { double price = 200.0; OMElement response; String priceMessageContent; h2DataBaseManager.executeUpdate("INSERT INTO company VALUES(100.0,'ABC')"); h2DataBaseManager.executeUpdate("INSERT INTO company VALUES(2000.0,'XYZ')"); h2DataBaseManager.executeUpdate("INSERT INTO company VALUES(" + price + ",'WSO2')"); h2DataBaseManager.executeUpdate("INSERT INTO company VALUES(300.0,'MNO')"); priceMessageContent = getPrice(); assertEquals(priceMessageContent, Double.toString(price), "Fault, invalid response"); response = axis2Client .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("dbReportMediatorUsingMessageContentTestProxy"), null, "WSO2"); priceMessageContent = getPrice(); OMElement returnElement = response.getFirstElement(); OMElement lastElement = returnElement.getFirstChildWithName(new QName("http://services.samples/xsd", "last")); assertEquals(priceMessageContent, lastElement.getText(), "Fault, invalid response"); }
Example 3
Source File: SpecifyMaxMessageCountAsExpressionTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "higher number of messages than minimum count") public void testMoreNumberThanMinimum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = 8; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertTrue(minMessageCount <= responseCount && responseCount <= no_of_requests); }
Example 4
Source File: SpecifyMaxMessageCountAsExpressionTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "number of messages is equal to the minimum") public void testEqualtoMinimum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = minMessageCount; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched"); }
Example 5
Source File: SpecifyMaxMessageCountAsExpressionTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "less number of messages than minimum count") public void testLessThanMinimum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = 3; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched"); }
Example 6
Source File: SpecifyMinMessageCountAsExpressionTestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = {"wso2.esb"}, description = "less number of messages than minimum count") public void testLessThanMinimum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = 3; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched"); }
Example 7
Source File: IterateEndpointsTest.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = "wso2.esb", description = "Tests for https endpoint") public void testHTTPS() throws Exception { verifyProxyServiceExistence("iterateWithHttpsEndPointTestProxy"); String response = client.getMultipleResponse( getProxyServiceURLHttps("iterateWithHttpsEndPointTestProxy"), "WSO2", 2); Assert.assertNotNull(response); OMElement envelope = client.toOMElement(response); OMElement soapBody = envelope.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); int i = 0; while (iterator.hasNext()) { i++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("WSO2")); } Assert.assertEquals(i ,2, "Message count mismatched"); }
Example 8
Source File: IterateRegistryAsTargetTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = "wso2.esb", description = "Tests for sequence from governors registry ") public void testGovernersSequence() throws Exception { String response = client .getMultipleResponse(getProxyServiceURLHttp("iterateWithTargetGovernanceTestProxy"), "WSO2", 2); Assert.assertNotNull(response); OMElement envelope = client.toOMElement(response); OMElement soapBody = envelope.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); int i = 0; while (iterator.hasNext()) { i++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("WSO2")); } Assert.assertEquals(i, 2, "Child Element count mismatched"); }
Example 9
Source File: SpecifyMaxMessageCountAsExpressionTestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = {"wso2.esb"}, description = "number of messages is equal to the minimum") public void testEqualtoMinimum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = minMessageCount; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched"); }
Example 10
Source File: AggregateWithMaxMInLimitsTestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = {"wso2.esb"}, description = "number of messages is equal to the maximum") public void testEqualtoMaximum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = 100; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertTrue(2 <= responseCount && responseCount <= no_of_requests); }
Example 11
Source File: XMLDataSourceFields.java From carbon-commons with Apache License 2.0 | 6 votes |
public String[] getAllFields(String file) throws ReportingException { List<String> names = new ArrayList<String>(); OMElementHandler omElementHandler = new OMElementHandler(); try { OMElement omElement = omElementHandler.createOMElement(file); OMElement element = omElement.getFirstElement(); names.add(element.getLocalName()); Iterator<OMElement> iterator = element.getChildElements(); while (iterator.hasNext()) { names.add(element.getLocalName()); } } catch (ReportingException e) { throw new ReportingException("OMElement creation fail from " + file); } return names.toArray(new String[names.size()]); }
Example 12
Source File: SpecifyMinMessageCountAsExpressionTestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = {"wso2.esb"}, description = "more number of messages than maximum count") public void testMoreNumberThanMaximum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = 15; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertTrue(minMessageCount <= responseCount && responseCount <= maxMessageCount); }
Example 13
Source File: ExposeSOAPasSOAPTest.java From product-ei with Apache License 2.0 | 6 votes |
@Test(description = "4.1.1.1.14") public void testPublishingWSDLModifyUserWSDLPortAddres() throws IOException, XMLStreamException { String url = getProxyServiceURLHttp("4_1_1_1_14_Proxy_PublishWSDLModifyUserWSDLPortAddress"); String backendURL = "http://ei-backend.scenarios.wso2.org:8080/axis2/services/SimpleStockQuoteService"; RESTClient restClient = new RESTClient(); HttpResponse response = restClient.doGet(url + "?wsdl", null); Assert.assertEquals(HTTPUtils.getHTTPResponseCode(response), 200, "Response failed"); OMElement responseOM = HTTPUtils.getOMFromResponse(response); OMElement serviceElement = responseOM.getFirstChildWithName(new QName(WSDL_NS, "service")); Assert.assertNotNull(serviceElement, "Unable to extract service element from WSDL"); OMElement portElement = serviceElement.getFirstChildWithName(new QName(WSDL_NS, "port")); Assert.assertNotNull(portElement, "Unable to extract port element from WSDL"); if (portElement.getFirstElement() != null) { Assert.assertEquals(portElement.getFirstElement().getLocalName(), "address", "address not available under " + "port in the WSDL"); OMAttribute locationAttr = portElement.getFirstElement().getAttribute(new QName("location")); Assert.assertTrue(locationAttr.getAttributeValue().trim().startsWith(backendURL), "Service location " + "modified by the EI"); return; } Assert.fail("Expected \"address\" element not found under port tag"); }
Example 14
Source File: EnrichIntegrationAddChildXpathTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = "wso2.esb", description = "Add custom content as a child to the part of message" + " specified by xpath expression ") public void testEnrichMediator() throws Exception { OMElement response; response = axis2Client .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("enrichAddChildByXPathTestProxy"), null, createQuoteRequestBody()); assertNotNull(response, "Response message null"); OMElement returnTag = response.getFirstElement(); String symbolResponse = returnTag.getFirstChildWithName(new QName("http://services.samples/xsd", "symbol")) .getText(); assertEquals(symbolResponse, "Test", "child symbol not added."); }
Example 15
Source File: AggregateWithHighMaxAndLowMinTestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = {"wso2.esb"}, description = "less number of messages than minimum count") public void testLessThanMinimum() throws IOException, XMLStreamException { int responseCount=0; no_of_requests=1; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response= aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2= AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator =soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched"); }
Example 16
Source File: HomeAttribute.java From openxds with Apache License 2.0 | 5 votes |
public void set(OMElement root) { String localname = root.getLocalName(); if (isIdentifiable(localname)) root.addAttribute("home", home, null); for (OMNode child=root.getFirstElement(); child != null; child=child.getNextOMSibling()) { if (child instanceof OMText) { continue; } OMElement child_e = (OMElement) child; set(child_e); } }
Example 17
Source File: LogMediatorAfterSendMediatorTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = {"wso2.esb"}, description = "use Log mediator after send mediator", enabled = false) public void logMediatorAfterSendMediatorTest() throws Exception { OMElement response = axis2Client.sendSimpleStockQuoteRequest( getProxyServiceURLHttp("sendMediatorWithLogAfterwardsTestProxy"), null, "WSO2"); assertNotNull(response, "Response is null"); assertEquals(response.getLocalName(), "getQuoteResponse", "getQuoteResponse mismatch"); OMElement omElement = response.getFirstElement(); String symbolResponse = omElement.getFirstChildWithName (new QName("http://services.samples/xsd", "symbol")).getText(); assertEquals(symbolResponse, "WSO2", "Symbol is not match"); }
Example 18
Source File: SendIntegrationSequenceAtGovRegistryTestCase.java From micro-integrator with Apache License 2.0 | 5 votes |
@Test(groups = { "wso2.esb" }, description = "Receiving sequence at governance registry not build message before receive message") public void sequenceAtGovRegistryBuildMessageNoTest() throws Exception { OMElement response = axis2Client.sendSimpleStockQuoteRequest( getProxyServiceURLHttp("sendMediatorReceiveSeqAtGovBuildMessageFalseTestProxy"), null, "WSO2"); assertNotNull(response, "Response is null"); assertEquals(response.getLocalName(), "getQuoteResponse", "getQuoteResponse mismatch"); OMElement omElement = response.getFirstElement(); String symbolResponse = omElement.getFirstChildWithName(new QName("http://services.samples/xsd", "symbol")) .getText(); assertEquals(symbolResponse, "WSO2", "Symbol is not match"); }
Example 19
Source File: SendIntegrationSequenceAtConfigRegistryTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = {"wso2.esb"},description = "Receiving sequence at config registry build message") public void testSequenceAtConfigRegistryBuildMessage() throws Exception { OMElement response = axis2Client.sendSimpleStockQuoteRequest( getProxyServiceURLHttp("sendMediatorReceiveSeqAtConfigBuildMessageTrueTestProxy"), null, "WSO2"); assertNotNull(response,"Response is null"); assertEquals(response.getLocalName(),"getQuoteResponse","getQuoteResponse mismatch"); OMElement omElement=response.getFirstElement(); String symbolResponse=omElement.getFirstChildWithName (new QName("http://services.samples/xsd","symbol")).getText(); assertEquals(symbolResponse,"WSO2","Symbol is not match"); }
Example 20
Source File: ReScheduleTaskTestCase.java From product-ei with Apache License 2.0 | 4 votes |
private double getEmployeeSalary(OMElement employeeRecord) { OMElement employee = employeeRecord.getFirstElement(); OMElement salary = (OMElement) employee.getChildrenWithLocalName("salary").next(); return Double.parseDouble(salary.getText()); }