continue;
}
// XmlObjectTreeModel model = new XmlObjectTreeModel(
// property.getSchemaType().getTypeSystem(),
// XmlObject.Factory.parse( value ) );
XmlObjectTreeModel model = new XmlObjectTreeModel(property.getSchemaType().getTypeSystem(),
XmlUtils.createXmlObject(value));
XmlTreeNode[] nodes = model.selectTreeNodes(context.expand(param.getXpath()));
StringBuffer buffer = new StringBuffer(value);
for (int cnt = 0; cnt < nodes.length; cnt++) {
// find right node
// this finds where node that needs updateing begins
int start = value.indexOf("<" + nodes[cnt].getNodeName()); // keeps
// node
// start
int cnt2 = 0;
// if have more than one node that matches xpath, find
// next one.
while (cnt2 < cnt) {
start = value.indexOf("<" + nodes[cnt].getNodeName(), start + 1);
cnt2++;
}
// get node xml
String nodeXml = getXmlForNode(nodes[cnt]);
// find end of target xml node
int end = value.indexOf("<" + nodes[cnt].getNodeName(), start + 1);
if (end <= 0) {
if (nodeXml.endsWith("</" + nodes[cnt].getDomNode().getNodeName() + ">")) {
end = value.indexOf("</" + nodes[cnt].getDomNode().getNodeName() + ">")
+ ("</" + nodes[cnt].getDomNode().getNodeName() + ">").length();
} else {
end = value.indexOf(">", value.indexOf("/", start));
}
}
if (end <= 0 || end <= start) {
break;
}
// replace node with right value
buffer.replace(start, end + 1, parameterMutations.get(param).get(0));
}
params.put(param.getLabel(), parameterMutations.get(param).get(0));
parameterMutations.get(param).remove(0);
testStep.getProperties().get(param.getName()).setValue(buffer.toString());
}
break;
}
}
}
} else {
for (TestProperty property : testStep.getPropertyList()) {
String value = context.expand(property.getValue());
if (XmlUtils.seemsToBeXml(value)) {
StringBuffer buffer = new StringBuffer(value);
XmlObjectTreeModel model = null;
// model = new XmlObjectTreeModel(
// property.getSchemaType().getTypeSystem(),
// XmlObject.Factory.parse( value ) );
model = new XmlObjectTreeModel(property.getSchemaType().getTypeSystem(),
XmlUtils.createXmlObject(value));
for (SecurityCheckedParameter param : getParameterHolder().getParameterList()) {
if (param.getXpath() == null || param.getXpath().trim().length() == 0) {
if (parameterMutations.containsKey(param)) {
testStep.getProperties().get(param.getName())
.setValue(parameterMutations.get(param).get(0));
params.put(param.getLabel(), parameterMutations.get(param).get(0));
parameterMutations.get(param).remove(0);
}
} else {
// no value, do nothing.
if (value == null || value.trim().equals("")) {
continue;
}
if (param.getName().equals(property.getName())) {
XmlTreeNode[] nodes = model.selectTreeNodes(context.expand(param.getXpath()));
if (parameterMutations.containsKey(param)) {
if (parameterMutations.get(param).size() > 0) {
for (int cnt = 0; cnt < nodes.length; cnt++) {
// find right node
// keeps node start