From c4d07a21150ab4fc4dc7a1e0a439151f8b226e6a Mon Sep 17 00:00:00 2001
From: Gary Williams <gary.williams@forgerock.com>
Date: Fri, 21 Oct 2011 15:01:56 +0000
Subject: [PATCH] Improve xml dom parsing on testgroup, testsuite elements
---
opendj-sdk/opends/tests/staf-tests/shared/python/common.py | 12 ++++++++++--
opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml | 10 ++++------
opendj-sdk/opends/tests/staf-tests/shared/functions/environment.xml | 2 ++
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/functions/environment.xml b/opendj-sdk/opends/tests/staf-tests/shared/functions/environment.xml
index bbbc2ff..61837fc 100755
--- a/opendj-sdk/opends/tests/staf-tests/shared/functions/environment.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/functions/environment.xml
@@ -125,6 +125,8 @@
server.password = DIRECTORY_INSTANCE_PSWD
server.suffix = DIRECTORY_INSTANCE_SFX
server.backend = DIRECTORY_INSTANCE_BE
+
+ TestSuiteStartTime = STAXGlobal([])
</script>
<!-- Set the signal handlers -->
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml b/opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml
index bab8ddd..a42affe 100755
--- a/opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml
@@ -1039,9 +1039,8 @@
testcaseStop=int(time.time())
testcaseDuration=testcaseStop-testcaseStart
shortName=get_test_name(STAXCurrentTestcase)
-
- testgroup = results.getChildNodes().item(3)
- testsuite = testgroup.getChildNodes().item(1)
+
+ testsuite = xml.getElementByAttributeName(qa,'testsuite',ThisSuiteName,'name')
xml.testcase = repdoc.createElement("testcase")
xml.createAttr(repdoc,xml.testcase,"name",STAXCurrentTestcase)
@@ -1135,9 +1134,8 @@
repdoc = xml.parseXMLfile("%s/results_tmp.xml" % logs.reports)
qa = repdoc.getDocumentElement()
- ft = qa.getChildNodes().item(1)
- results = ft.getChildNodes().item(3)
- testgroup = results.getChildNodes().item(3)
+
+ testgroup = xml.getElementByAttributeName(qa,'testgroup',ThisGroupName,'name')
#Create testsuite element
xml.testsuite = repdoc.createElement("testsuite")
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/python/common.py b/opendj-sdk/opends/tests/staf-tests/shared/python/common.py
index 59785a6..7f46f4e 100644
--- a/opendj-sdk/opends/tests/staf-tests/shared/python/common.py
+++ b/opendj-sdk/opends/tests/staf-tests/shared/python/common.py
@@ -715,7 +715,17 @@
tag.setAttributeNode(newAttribute)
except:
print "exception: %s" % traceback.format_exception(*sys.exc_info())
+
+ def getElementByAttributeName(self,root,tag,attr,val):
+ element = root.getElementsByTagName(tag)
+
+ i=0
+ while i < element.getLength():
+ if element.item(i).getAttribute(val) == attr:
+ return element.item(i)
+ i += 1
+
def xml_add_text_node(doc,parent,name,ntext):
node = doc.createElement(name)
@@ -846,5 +856,3 @@
import md5
m = md5.new()
return m
-
-
\ No newline at end of file
--
Gitblit v1.10.0