Java源码示例:org.apache.axiom.om.OMNode
示例1
/**
* This is the implementation of the getDigest method and will implement the Extended DOMHASH
* algorithm based HTTP request identifications. This will consider To address of the request,
* HTTP headers and XML Payload in generating the digets. So, in effect
* this will uniquely identify the HTTP request with the same To address, Headers and Payload.
*
* @param msgContext - MessageContext on which the XML node identifier will be generated
* @return Object representing the DOMHASH value of the normalized XML node
* @throws CachingException if there is an error in generating the digest key
*
* @see org.wso2.caching.digest.DigestGenerator
* #getDigest(org.apache.axis2.context.MessageContext)
*/
public String getDigest(MessageContext msgContext) throws CachingException {
OMNode body = msgContext.getEnvelope().getBody();
String toAddress = null;
if (msgContext.getTo() != null) {
toAddress = msgContext.getTo().getAddress();
}
Map<String, String> headers = (Map) msgContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
if (body != null) {
byte[] digest = null;
if (toAddress != null) {
digest = getDigest(body, toAddress, headers, MD5_DIGEST_ALGORITHM);
} else {
digest = getDigest(body, MD5_DIGEST_ALGORITHM);
}
return digest != null ? getStringRepresentation(digest) : null;
} else {
return null;
}
}
示例2
/**
* This is the implementation of the getDigest method and will implement the Extended DOMHASH algorithm based HTTP
* request identifications. This will consider To address of the request, HTTP headers and XML Payload in generating
* the digets. So, in effect this will uniquely identify the HTTP request with the same To address, Headers and
* Payload.
*
* @param msgContext - MessageContext on which the XML node identifier will be generated
* @return Object representing the DOMHASH value of the normalized XML node
* @throws CachingException if there is an error in generating the digest key
* @see org.wso2.caching.digest.DigestGenerator #getDigest(org.apache.axis2.context.MessageContext)
*/
public String getDigest(MessageContext msgContext) throws CachingException {
OMNode body = msgContext.getEnvelope().getBody();
String toAddress = null;
if (msgContext.getTo() != null) {
toAddress = msgContext.getTo().getAddress();
}
Map<String, String> headers = (Map) msgContext.getProperty(
org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
if (body != null) {
byte[] digest = null;
if (toAddress != null) {
digest = getDigest(body, toAddress, headers, MD5_DIGEST_ALGORITHM);
} else {
digest = getDigest(body, MD5_DIGEST_ALGORITHM);
}
return digest != null ? getStringRepresentation(digest) : null;
} else {
return null;
}
}
示例3
/**
* Util method to fetch a swagger resource from the registry.
*
* @param resourcePath registry path to the resource.
* @return null if no resource found or the swagger as string.
*/
public static String fetchSwaggerFromRegistry(String resourcePath) {
String defString = null;
SynapseConfiguration synapseConfig =
SynapseConfigUtils.getSynapseConfiguration(Constants.SUPER_TENANT_DOMAIN_NAME);
Registry registry = synapseConfig.getRegistry();
OMNode regContent = registry.lookup(resourcePath);
if (regContent instanceof OMText) {
defString = ((OMText) regContent).getText();
byte[] decodedBytes = Base64.getDecoder().decode(defString);
defString = new String(decodedBytes);
}
return defString;
}
示例4
public void validate1(OMElement root) {
String localname = root.getLocalName();
if (isIdentifiable(localname)) {
OMAttribute home_att = root.getAttribute(MetadataSupport.home_qname);
if (home_att == null) {
errs += "\nElement of type " + localname + " does not contain a home attribute";
} else {
String home1 = home_att.getAttributeValue();
if (home1 == null) home1 = "";
if ( !home1.equals(home))
errs += "\nElement of type " + localname + " has home of [" + home1 + "] which does not match expected value of [" + home + "]";
}
}
for (OMNode child=root.getFirstElement(); child != null; child=child.getNextOMSibling()) {
OMElement child_e = (OMElement) child;
validate1(child_e);
}
}
示例5
public OMElement add_name_value(OMElement parent, String name, OMElement value1, OMElement value2, OMElement value3) {
OMElement ele = MetadataSupport.om_factory.createOMElement(name, null);
OMNode val1 = value1;
if (val1 == null)
val1 = MetadataSupport.om_factory.createOMText("null");
ele.addChild(val1);
OMNode val2 = value2;
if (val2 == null)
val2 = MetadataSupport.om_factory.createOMText("null");
ele.addChild(val2);
OMNode val3 = value3;
if (val3 == null)
val3 = MetadataSupport.om_factory.createOMText("null");
ele.addChild(val3);
parent.addChild(ele);
return ele;
}
示例6
List<String> getStepIds(File testplan) {
ArrayList<String> ids = new ArrayList<String>();
OMElement tplan;
try {
tplan = Util.parse_xml(testplan);
AXIOMXPath xpathExpression = new AXIOMXPath ("//TestPlan/TestStep");
List<OMNode> nodes = xpathExpression.selectNodes(tplan);
for (int i=0; i<nodes.size(); i++) {
OMElement testStep = (OMElement) nodes.get(i);
ids.add(testStep.getAttributeValue(MetadataSupport.id_qname));
}
} catch (Exception e) {
e.printStackTrace();
System.err.println(ExceptionUtil.exception_details(e));
System.exit(-1);
}
return ids;
}
示例7
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");
}
}
}
}
示例8
private static void extractIaasProviders(OMElement documentElement, List<OMNode> nodeList) {
List<IaasProvider> iaasProviders = CloudControllerConfig.getInstance().getIaasProviders();
if (iaasProviders == null) {
CloudControllerConfig.getInstance().setIaasProviders((iaasProviders = new ArrayList<IaasProvider>()));
}
// this is a valid scenario. User can have 0..1 iaas provider elements
// in cloud-controller xml.
if (nodeList == null || nodeList.isEmpty()) {
log.debug("No IaasProvider element found in " + FILE_NAME);
return;
}
for (OMNode node : nodeList) {
iaasProviders.add(IaasProviderConfigParser.getIaasProvider(FILE_NAME, documentElement, node, null));
}
}
示例9
/**
* This is an overloaded method for the digest generation for OMNode and request
*
* @param node - OMNode to be subjected to the key generation
* @param toAddress - Request To address to be subjected to the key generation
* @param headers - Header parameters to be subjected to the key generation
* @param digestAlgorithm - digest algorithm as a String
* @return byte[] representing the calculated digest over the provided node
* @throws CachingException if there is an error in generating the digest
*/
public byte[] getDigest(OMNode node, String toAddress, Map<String, String> headers,
String digestAlgorithm) throws CachingException {
if (node.getType() == OMNode.ELEMENT_NODE) {
return getDigest((OMElement) node, toAddress, headers, digestAlgorithm);
} else if (node.getType() == OMNode.TEXT_NODE) {
return getDigest((OMText) node, digestAlgorithm);
} else if (node.getType() == OMNode.PI_NODE) {
return getDigest((OMProcessingInstruction) node, digestAlgorithm);
} else {
return new byte[0];
}
}
示例10
/**
* This is an overloaded method for the digest generation for OMNode.
*
* @param node - OMNode to be subjected to the key generation
* @param digestAlgorithm - digest algorithm as a String
* @return byte[] c node
* @throws CachingException if there is an error in generating the digest
*/
public byte[] getDigest(OMNode node, String digestAlgorithm) throws CachingException {
if (node.getType() == OMNode.ELEMENT_NODE) {
return getDigest(node, digestAlgorithm);
} else if (node.getType() == OMNode.TEXT_NODE) {
return getDigest((OMText) node, digestAlgorithm);
} else if (node.getType() == OMNode.PI_NODE) {
return getDigest((OMProcessingInstruction) node, digestAlgorithm);
} else {
return new byte[0];
}
}
示例11
/**
* This is an overloaded method for the digest generation for OMNode and request.
*
* @param node - OMNode to be subjected to the key generation
* @param toAddress - Request To address to be subjected to the key generation
* @param headers - Header parameters to be subjected to the key generation
* @param digestAlgorithm - digest algorithm as a String
* @return byte[] representing the calculated digest over the provided node
* @throws CachingException if there is an error in generating the digest
*/
public byte[] getDigest(OMNode node, String toAddress, Map<String, String> headers,
String digestAlgorithm) throws CachingException {
if (node.getType() == OMNode.ELEMENT_NODE) {
return getDigest((OMElement) node, toAddress, headers, digestAlgorithm);
} else if (node.getType() == OMNode.TEXT_NODE) {
return getDigest((OMText) node, digestAlgorithm);
} else if (node.getType() == OMNode.PI_NODE) {
return getDigest((OMProcessingInstruction) node, digestAlgorithm);
} else {
return new byte[0];
}
}
示例12
/**
* This is an overloaded method for the digest generation for OMNode.
*
* @param node - OMNode to be subjected to the key generation
* @param digestAlgorithm - digest algorithm as a String
* @return byte[] representing the calculated digest over the provided node
* @throws CachingException if there is an error in generating the digest
*/
public byte[] getDigest(OMNode node, String digestAlgorithm) throws CachingException {
if (node.getType() == OMNode.ELEMENT_NODE) {
return getDigest((OMElement) node, digestAlgorithm);
} else if (node.getType() == OMNode.TEXT_NODE) {
return getDigest((OMText) node, digestAlgorithm);
} else if (node.getType() == OMNode.PI_NODE) {
return getDigest((OMProcessingInstruction) node, digestAlgorithm);
} else {
return new byte[0];
}
}
示例13
/**
* Gets the valid element collection of an OMDocument. This returns only the OMElement and OMProcessingInstruction
* nodes
*
* @param document - OMDocument of which the valid elements to be retrieved
* @return the collection of OMProcessingInstructions and OMElements in the provided document
*/
public Collection getValidElements(OMDocument document) {
ArrayList list = new ArrayList();
Iterator itr = document.getChildren();
while (itr.hasNext()) {
OMNode node = (OMNode) itr.next();
if (node.getType() == OMNode.ELEMENT_NODE || node.getType() == OMNode.PI_NODE) {
list.add(node);
}
}
return list;
}
示例14
/**
* This is an overloaded method for the digest generation for OMNode and request.
*
* @param node - OMNode to be subjected to the key generation
* @param toAddress - Request To address to be subjected to the key generation
* @param headers - Header parameters to be subjected to the key generation
* @param digestAlgorithm - digest algorithm as a String
* @return byte[] representing the calculated digest over the provided node
* @throws CachingException if there is an error in generating the digest
*/
public byte[] getDigest(OMNode node, String toAddress, Map<String, String> headers,
String digestAlgorithm) throws CachingException {
if (node.getType() == OMNode.ELEMENT_NODE) {
return getDigest((OMElement) node, toAddress, headers, digestAlgorithm);
} else if (node.getType() == OMNode.TEXT_NODE) {
return getDigest((OMText) node, digestAlgorithm);
} else if (node.getType() == OMNode.PI_NODE) {
return getDigest((OMProcessingInstruction) node, digestAlgorithm);
} else {
return new byte[0];
}
}
示例15
/**
* Create a new SOAP envelope and insert the
* the given omElement into its body.
*
* @param synCtx - original message context
* @return newCtx created by the iteration
* @throws AxisFault if there is a message creation failure
* @throws JaxenException if the expression evauation failure
*/
private MessageContext getOMElementInserted(OMElement omElement, MessageContext synCtx)
throws AxisFault, JaxenException {
Iterator<OMNode> children = synCtx.getEnvelope().getBody().getChildren();
while (children.hasNext()) {
children.next().detach();
}
synCtx.getEnvelope().getBody().addChild(omElement);
return synCtx;
}
示例16
/**
* Function to retrieve resource content as text
*
* @param url
* @return
* @throws IOException
*/
private OMNode readNonXML (URL url) throws IOException {
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
try (InputStream inputStream = urlConnection.getInputStream()) {
if (inputStream == null) {
return null;
}
String mediaType = DEFAULT_MEDIA_TYPE;
Properties metadata = getMetadata(url.getPath());
if (metadata != null) {
mediaType = metadata.getProperty(METADATA_KEY_MEDIA_TYPE, DEFAULT_MEDIA_TYPE);
}
if (DEFAULT_MEDIA_TYPE.equals(mediaType)) {
StringBuilder strBuilder = new StringBuilder();
try (BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream))) {
String line;
while ((line = bReader.readLine()) != null) {
strBuilder.append(line);
}
}
return OMAbstractFactory.getOMFactory().createOMText(strBuilder.toString());
} else {
return OMAbstractFactory.getOMFactory()
.createOMText(new DataHandler(new SynapseBinaryDataSource(inputStream, mediaType)), true);
}
}
}
示例17
@Test
public void testRegistryResourceRead() throws IOException {
OMNode omNode = microIntegratorRegistry.lookup("gov:/custom/checkJsScript.js");
String mediaType = ((DataHandler) ((OMTextImpl) omNode).getDataHandler()).getContentType();
Assert.assertEquals("Media type should be as expected", "application/javascript", mediaType);
}
示例18
static OMText getBinaryNode(OMElement document) {
Iterator<OMNode> childrenIterator = document.getChildren();
while (childrenIterator.hasNext())
{
OMNode container = childrenIterator.next();
if (container instanceof OMText && StringUtils.isNotBlank(((OMText)container).getText()))
{
return (OMText)container;
}
}
return null;
}
示例19
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);
}
}
示例20
public static String getAttributeValue(OMElement doc, String xpath) throws Exception {
XPathEvaluator eval = new XPathEvaluator();
List<OMNode> node_list = eval.evaluateXpath(xpath, doc, null);
for (Iterator<?> it=node_list.iterator(); it.hasNext(); ) {
OMAttribute attr = (OMAttribute) it.next();
return attr.getAttributeValue();
}
throw new Exception("Path " + xpath + " not found");
}
示例21
public static List<String> getAttributeValues(OMElement doc, String xpath) throws Exception {
List<String> values = new ArrayList<String>();
XPathEvaluator eval = new XPathEvaluator();
List<OMNode> node_list = eval.evaluateXpath(xpath, doc, null);
for (Iterator<?> it=node_list.iterator(); it.hasNext(); ) {
OMAttribute attr = (OMAttribute) it.next();
values.add(attr.getAttributeValue());
}
if (values.size() == 0)
throw new Exception("No Values");
return values;
}
示例22
public static List<OMElement> getElements(OMElement doc, String xpath) throws Exception {
XPathEvaluator eval = new XPathEvaluator();
List<OMNode> node_list = eval.evaluateXpath(xpath, doc, null);
List<OMElement> ele_list = new ArrayList<OMElement>();
for (Iterator<?> it=node_list.iterator(); it.hasNext(); ) {
OMNode node = (OMNode) it.next();
if (! (node instanceof OMElement))
continue;
OMElement ele = (OMElement) node;
ele_list.add(ele);
}
return ele_list;
}
示例23
public static String getElementValue(OMElement doc, String xpath) throws Exception {
XPathEvaluator eval = new XPathEvaluator();
List<OMNode> node_list = eval.evaluateXpath(xpath, doc, null);
for (Iterator<?> it=node_list.iterator(); it.hasNext(); ) {
OMNode node = (OMNode) it.next();
if (! (node instanceof OMElement))
continue;
OMElement ele = (OMElement) node;
return ele.getText();
}
throw new Exception("Path " + xpath + " not found");
}
示例24
public OMElement add_name_value(OMElement parent, String name, OMElement value1, OMElement value2) {
OMElement ele = MetadataSupport.om_factory.createOMElement(name, null);
OMNode val1 = value1;
if (val1 == null)
val1 = MetadataSupport.om_factory.createOMText("null");
ele.addChild(val1);
OMNode val2 = value2;
if (val2 == null)
val2 = MetadataSupport.om_factory.createOMText("null");
ele.addChild(val2);
parent.addChild(ele);
return ele;
}
示例25
public OMElement create_name_value(String name, OMElement value) {
OMNode val = value;
OMElement ele = MetadataSupport.om_factory.createOMElement(name, null);
if (val == null)
val = MetadataSupport.om_factory.createOMText("null");
ele.addChild(val);
return ele;
}
示例26
@Test
public void testSetSOAPFault() {
SOAPEnvelope soapEnvelope = Mockito.mock(SOAPEnvelope.class);
SOAPHeader soapHeader = Mockito.mock(SOAPHeader.class);
Iterator iterator = Mockito.mock(Iterator.class);
OMNode soapHeaderBlock = Mockito.mock(OMNode.class);
Mockito.when(messageContext.getMessageID()).thenReturn("123");
Mockito.when(messageContext.getEnvelope()).thenReturn(soapEnvelope);
Mockito.when(soapEnvelope.getHeader()).thenReturn(soapHeader);
Mockito.when(soapHeader.examineAllHeaderBlocks()).thenReturn(iterator);
Mockito.when(iterator.hasNext()).thenReturn(true, false);
// Mockito.when(iterator.next()).thenReturn(omelement);
Mockito.when(iterator.next()).thenReturn(soapHeaderBlock);
Utils.setSOAPFault(messageContext, "", "code", "detail");
Assert.assertTrue(true); // No error has occurred. hence test passes.
//when messageContext.isSOAP11() is true
Mockito.when(messageContext.isSOAP11()).thenReturn(true);
Utils.setSOAPFault(messageContext, "", "code", "detail");
Assert.assertTrue(true); // No error has occurred. hence test passes.
// when messageContext.getFaultTo() != null
EndpointReference endpointReference = Mockito.mock(EndpointReference.class);
Mockito.when(messageContext.getFaultTo()).thenReturn(endpointReference);
Utils.setSOAPFault(messageContext, "", "code", "detail");
Assert.assertTrue(true); // No error has occurred. hence test passes.
// when messageContext.getFaultTo() != null
Mockito.when(messageContext.getFaultTo()).thenReturn(endpointReference);
Utils.setSOAPFault(messageContext, "", "code", "detail");
Assert.assertTrue(true); // No error has occurred. hence test passes.
}
示例27
@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();
}
}
示例28
@Override
public OMNode lookupFormat(String key) {
//TODO verify this
return lookup(key);
}
示例29
@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();
}
}
示例30
public static IaasProvider getIaasProvider(final String fileName, final OMElement elt, final OMNode item, List<IaasProvider> iaases) {
IaasProvider iaas = null;
if (item.getType() == OMNode.ELEMENT_NODE) {
OMElement iaasElt = (OMElement) item;
if (iaases != null) {
// check whether this is a reference to a predefined IaaS.
for (IaasProvider iaasProvider : iaases) {
if (iaasProvider.getType()
.equals(iaasElt.getAttribute(new QName(
CloudControllerConstants.TYPE_ATTR))
.getAttributeValue())) {
iaas = new IaasProvider(iaasProvider);
break;
}
}
}
if (iaas == null) {
iaas = new IaasProvider();
}
if (iaas.getType() == null) {
iaas.setType(iaasElt.getAttribute(new QName(CloudControllerConstants.TYPE_ATTR))
.getAttributeValue());
}
if ("".equals(iaas.getType())) {
String msg =
"'" + CloudControllerConstants.IAAS_PROVIDER_ELEMENT + "' element's '" +
CloudControllerConstants.TYPE_ATTR +
"' attribute should be specified!";
handleException(msg);
}
// this is not mandatory
String name =
(iaasElt.getAttribute(new QName(CloudControllerConstants.NAME_ATTR)) == null)
? iaas.getName()
: iaasElt.getAttributeValue(new QName(
CloudControllerConstants.NAME_ATTR));
iaas.setName(name);
String xpath = CloudControllerConstants.IAAS_PROVIDER_ELEMENT_XPATH;
// load other elements
loadClassName(fileName, iaas, iaasElt);
loadProvider(fileName, iaas, iaasElt);
loadProperties(fileName, iaasElt, iaas.getProperties());
loadTemplate(fileName, iaas, iaasElt);
loadIdentity(fileName, elt, iaas, iaasElt);
loadCredentials(fileName, elt, iaas, iaasElt, xpath);
}
return iaas;
}