Java Code Examples for org.apache.axiom.om.OMElement#getChildrenWithName()
The following examples show how to use
org.apache.axiom.om.OMElement#getChildrenWithName() .
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: NestedAggregatesTestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = {"wso2.esb"}, description = "Sending request for aggregation") public void test() throws IOException, XMLStreamException { int responseCount = 0; OMElement response = AXIOMUtil.stringToOM(aggregatedRequestClient.getResponse()); OMElement soapBody = response.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 Company")); } Assert.assertEquals(no_of_requests, responseCount, "Response Aggregation not as expected"); }
Example 2
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 3
Source File: SpecifyMinMessageCountAsExpressionTestCase.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 = maxMessageCount; 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: 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 5
Source File: AggregateWithMaxMInLimitsTestCase.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 6
Source File: AggregationWithoutMaxValueTestCase.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 = 80; 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(50 <= responseCount && responseCount <= no_of_requests); }
Example 7
Source File: NestedAggregatesTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "sending nested aggregate request") public void testNestedAggregate() throws IOException, XMLStreamException { String response = aggregatedRequestClient.getResponse(createNestedQuoteRequestBody("WSO2", no_of_requests)); OMElement response2 = AXIOMUtil.stringToOM(response); OMElement soapBody = response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); int responseCount = 0; while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("WSO2 Company")); } Assert.assertEquals(responseCount, no_of_requests * no_of_requests, "Response count Mismatched"); }
Example 8
Source File: TenantWorkflowConfigHolder.java From carbon-apimgt with Apache License 2.0 | 6 votes |
private void loadProperties(OMElement executorElem, Object workflowClass) throws WorkflowException { for (Iterator it = executorElem.getChildrenWithName(PROP_Q); it.hasNext(); ) { OMElement propertyElem = (OMElement) it.next(); OMAttribute attribute = propertyElem.getAttribute(ATT_NAME); if (attribute == null) { handleException("An Executor class property must specify the name attribute"); } else { String propName = attribute.getAttributeValue(); OMNode omElt = propertyElem.getFirstElement(); if (omElt != null) { setInstanceProperty(propName, omElt, workflowClass); } else if (propertyElem.getText() != null) { String value = MiscellaneousUtil.resolve(propertyElem, secretResolver); setInstanceProperty(propName, value, workflowClass); } else { handleException("An Executor class property must specify " + "name and text value, or a name and a child XML fragment"); } } } }
Example 9
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 10
Source File: SpecifyMaxMessageCountAsExpressionTestCase.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 11
Source File: IterateEndpointsTest.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = "wso2.esb", description = "Tests for http endpoint") public void testHTTP() throws Exception, InterruptedException { String response = client .getMultipleResponse(getProxyServiceURLHttp("iterateWithHttpEndPointTestProxy"), "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 12
Source File: IaasProviderConfigParser.java From attic-stratos with Apache License 2.0 | 6 votes |
private static void loadTemplate(final String fileName, final IaasProvider iaas, final OMElement iaasElt) { Iterator<?> it = iaasElt.getChildrenWithName(new QName(CloudControllerConstants.IMAGE_ID_ELEMENT)); if (it.hasNext()) { OMElement imageElt = (OMElement) it.next(); iaas.setImage(imageElt.getText()); } if (it.hasNext()) { log.warn(fileName + " contains more than one " + CloudControllerConstants.IMAGE_ID_ELEMENT + " elements!" + " Elements other than the first will be neglected."); } }
Example 13
Source File: SpecifyBothMinMaxByExpressionTestCase.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 14
Source File: DiscoveryOMUtils.java From carbon-commons with Apache License 2.0 | 5 votes |
public static QueryMatch getProbeMatchFromOM(OMElement matchElement) throws DiscoveryException { validateTopElement(DiscoveryConstants.PROBE_MATCHES, matchElement); Iterator matches = matchElement.getChildrenWithName( DiscoveryConstants.PROBE_MATCH); List<TargetService> services = new ArrayList<TargetService>(); while (matches.hasNext()) { services.add(createService((OMElement) matches.next(), true)); } return new QueryMatch(DiscoveryConstants.RESULT_TYPE_PROBE_MATCH, services.toArray(new TargetService[services.size()])); }
Example 15
Source File: IdentityConfigParser.java From carbon-identity with Apache License 2.0 | 5 votes |
private void buildEventListenerData() { OMElement eventListeners = this.getConfigElement(IdentityConstants.EVENT_LISTENERS); if (eventListeners != null) { Iterator<OMElement> eventListener = eventListeners.getChildrenWithName( new QName(IdentityCoreConstants.IDENTITY_DEFAULT_NAMESPACE, IdentityConstants.EVENT_LISTENER)); if (eventListener != null) { while (eventListener.hasNext()) { OMElement eventListenerElement = eventListener.next(); String eventListenerType = eventListenerElement.getAttributeValue(new QName( IdentityConstants.EVENT_LISTENER_TYPE)); String eventListenerName = eventListenerElement.getAttributeValue(new QName( IdentityConstants.EVENT_LISTENER_NAME)); int order = Integer.parseInt(eventListenerElement.getAttributeValue(new QName( IdentityConstants.EVENT_LISTENER_ORDER))); String enable = eventListenerElement.getAttributeValue(new QName( IdentityConstants.EVENT_LISTENER_ENABLE)); if (StringUtils.isBlank(eventListenerType) || StringUtils.isBlank(eventListenerName)) { throw IdentityRuntimeException.error("eventListenerType or eventListenerName is not defined " + "correctly"); } IdentityEventListenerConfigKey configKey = new IdentityEventListenerConfigKey(eventListenerType, eventListenerName); IdentityEventListenerConfig identityEventListenerConfig = new IdentityEventListenerConfig(enable, order, configKey); eventListenerConfiguration.put(configKey, identityEventListenerConfig); } } } }
Example 16
Source File: ForEachWithIterateTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = "wso2.esb", description = "Test foreach inline sequence to transform payload, passed to endpoint using iterate and aggregate mediators") public void testForEachInlineSequenceWithIterateEndpoint() throws Exception { loadESBConfigurationFromClasspath( "/artifacts/ESB/mediatorconfig/foreach/foreach_simple.xml"); logViewer.clearLogs(); String response = client.getMultipleCustomResponse(getProxyServiceURLHttp("foreachSequentialExecutionTestProxy"), "IBM", 2); Assert.assertNotNull(response); LogEvent[] logs = logViewer.getAllRemoteSystemLogs(); int forEachCount = 0; for (LogEvent log : logs) { String message = log.getMessage(); if (message.contains("foreach = in")) { if (!message.contains("IBM")) { Assert.fail("Incorrect message entered ForEach scope"); } forEachCount++; } } Assert.assertEquals(forEachCount, 2, "Count of messages entered ForEach scope is incorrect"); 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("IBM")); } Assert.assertEquals(i, 2, "Message count mismatched in response"); }
Example 17
Source File: CloneBurstTestCase.java From product-ei with Apache License 2.0 | 5 votes |
public void run() { while (!trigger.isStopped()) { if (trigger.isTriggered()) { String response = null; Iterator iterator = null; try { response = client.getResponse(getProxyServiceURLHttp("CloneAndAggregateTestProxy"), "WSO2"); Assert.assertNotNull(response); OMElement envelope = client.toOMElement(response); OMElement soapBody = envelope.getFirstElement(); iterator = soapBody.getChildrenWithName(new QName( "http://services.samples", "getQuoteResponse")); } catch (Exception e) { log.error(e); } finally { client.destroy(); } int i = 0; while (iterator.hasNext()) { i++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("WSO2")); } Assert.assertTrue(i == 2); } } }
Example 18
Source File: APIManagerConfiguration.java From carbon-apimgt with Apache License 2.0 | 4 votes |
private void setJWTTokenIssuers(OMElement omElement) { Iterator tokenIssuersElement = omElement.getChildrenWithLocalName(APIConstants.TokenIssuer.TOKEN_ISSUER); while (tokenIssuersElement.hasNext()) { OMElement issuerElement = (OMElement) tokenIssuersElement.next(); String issuer = issuerElement.getAttributeValue(new QName("issuer")); TokenIssuerDto tokenIssuerDto = new TokenIssuerDto(issuer); OMElement jwksConfiguration = issuerElement.getFirstChildWithName(new QName(APIConstants.TokenIssuer.JWKS_CONFIGURATION)); if (jwksConfiguration != null) { JWKSConfigurationDTO jwksConfigurationDTO = tokenIssuerDto.getJwksConfigurationDTO(); jwksConfigurationDTO.setEnabled(true); jwksConfigurationDTO.setUrl(jwksConfiguration .getFirstChildWithName(new QName(APIConstants.TokenIssuer.JWKSConfiguration.URL)).getText()); } OMElement claimMappingsElement = issuerElement.getFirstChildWithName(new QName(APIConstants.TokenIssuer.CLAIM_MAPPINGS)); if (claimMappingsElement != null) { OMAttribute disableDefaultClaimMappingAttribute = claimMappingsElement.getAttribute(new QName("disable-default-claim-mapping")); if (disableDefaultClaimMappingAttribute != null) { String disableDefaultClaimMapping = disableDefaultClaimMappingAttribute.getAttributeValue(); tokenIssuerDto.setDisableDefaultClaimMapping(Boolean.parseBoolean(disableDefaultClaimMapping)); } Iterator claimMapping = claimMappingsElement.getChildrenWithName(new QName(APIConstants.TokenIssuer.CLAIM_MAPPING)); while (claimMapping.hasNext()) { OMElement claim = (OMElement) claimMapping.next(); OMElement remoteClaimElement = claim.getFirstChildWithName( new QName(APIConstants.TokenIssuer.ClaimMapping.REMOTE_CLAIM)); OMElement localClaimElement = claim.getFirstChildWithName( new QName(APIConstants.TokenIssuer.ClaimMapping.LOCAL_CLAIM)); if (remoteClaimElement != null && localClaimElement != null) { String remoteClaim = remoteClaimElement.getText(); String localClaim = localClaimElement.getText(); if (StringUtils.isNotEmpty(remoteClaim) && StringUtils.isNotEmpty(localClaim)) { tokenIssuerDto.getClaimConfigurations().put(remoteClaim, new ClaimMappingDto(remoteClaim, localClaim)); } } } } jwtConfigurationDto.getTokenIssuerDtoMap().put(tokenIssuerDto.getIssuer(), tokenIssuerDto); } }
Example 19
Source File: DataServiceCallMediatorFactory.java From micro-integrator with Apache License 2.0 | 4 votes |
private List<Param> extractParams(OMElement elem, DataServiceCallMediator mediator) { List<Param> paramList = new ArrayList<>(); if (elem != null) { Iterator paramsIterator = elem.getChildrenWithName(new QName(DataServiceCallMediatorConstants.PARAM)); while (paramsIterator.hasNext()) { OMElement paramElement = (OMElement) paramsIterator.next(); OMAttribute nameAtr = paramElement.getAttribute(new QName(DataServiceCallMediatorConstants.NAME)); if (nameAtr != null) { String paramName = nameAtr.getAttributeValue(); String paramValue = paramElement.getAttributeValue(new QName(DataServiceCallMediatorConstants.VALUE)); String paramType = paramElement.getAttributeValue(new QName(DataServiceCallMediatorConstants.TYPE)); String evaluator = paramElement.getAttributeValue(new QName(DataServiceCallMediatorConstants. EVALUATOR)); String paramExpression = paramElement.getAttributeValue(new QName(DataServiceCallMediatorConstants. EXPRESSION)); Param param = mediator.new Param(paramName, paramType); param.setParamValue(paramValue); param.setEvaluator(evaluator); try { if (paramExpression != null) { if (evaluator != null && evaluator.equals(DataServiceCallMediatorConstants.JSON_TYPE)) { if (paramExpression.startsWith("json-eval(")) { paramExpression = paramExpression.substring(10, paramExpression.length() - 1); } param.setParamExpression(SynapseJsonPathFactory.getSynapseJsonPath(paramExpression)); // we have to explicitly define the path type since we are not going to mark // JSON Path's with prefix "json-eval(". param.getParamExpression().setPathType(SynapsePath.JSON_PATH); } else { SynapseXPath sxp = SynapseXPathFactory.getSynapseXPath(paramElement, ATT_EXPRN); //we need to disable stream Xpath forcefully sxp.setForceDisableStreamXpath(Boolean.TRUE); param.setParamExpression(sxp); param.getParamExpression().setPathType(SynapsePath.X_PATH); } } } catch (JaxenException e) { handleException("Invalid XPath expression for attribute expression : " + paramExpression, e); } paramList.add(param); } } } return paramList; }
Example 20
Source File: QueryFactory.java From micro-integrator with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private static Iterator<OMElement> getSQLQueryElements (OMElement queryEl) { return queryEl.getChildrenWithName(new QName(DBSFields.SQL)); }