From 697b869bb1de72358f5534b0128c6ce6aa9b6418 Mon Sep 17 00:00:00 2001
From: al_xipe <al_xipe@localhost>
Date: Tue, 17 Jul 2007 22:42:13 +0000
Subject: [PATCH] Refactored the index test suite to leverage the best-practices of the sample suite
---
opendj-sdk/opends/tests/functional-tests/shared/functions/utils.xml | 121 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 121 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opends/tests/functional-tests/shared/functions/utils.xml b/opendj-sdk/opends/tests/functional-tests/shared/functions/utils.xml
index 8349234..3b26f61 100755
--- a/opendj-sdk/opends/tests/functional-tests/shared/functions/utils.xml
+++ b/opendj-sdk/opends/tests/functional-tests/shared/functions/utils.xml
@@ -789,5 +789,126 @@
</sequence>
</function>
+ <function name="runFunction">
+ <function-map-args>
+ <function-arg-def name="functionName" type="required">
+ <function-arg-description>
+ Name of the function to run
+ </function-arg-description>
+ </function-arg-def>
+
+ <function-arg-def name="functionArguments" type="optional">
+ <function-arg-description>
+ Arguments to be passed on to the called function.
+ This can be a map or a list of arguments, whatever the called function
+ expects will be carried on here.
+ . for a map, pass the arguments like this:
+ { 'argumentA' : 'argumentAvalue' ,
+ 'argumentB' : 1 ,
+ ...
+ }
+ . for a list, pass the arguments like this:
+ [ 'argumentAvalue, 1, ... ]
+ </function-arg-description>
+ </function-arg-def>
+
+ <function-arg-def name="expectedRC" type="optional" default="0">
+ <function-arg-description>
+ The expected return code of the function to run.
+ This is then passed onto the checkRC function.
+ It is also used to throw an exception if the argument
+ functionException is provided and set the test case status if the
+ argument functionSetsTCStatus is provided
+ </function-arg-description>
+ <function-arg-property name="type" value="integer"/>
+ </function-arg-def>
+
+ <function-arg-def name="functionException" type="optional">
+ <function-arg-description>
+ The exception to throw if the return code differs from the expected
+ RC. The exception is appended to STAXException.
+ </function-arg-description>
+ </function-arg-def>
+
+ <function-arg-def name="functionMessage" type="optional">
+ <function-arg-description>
+ An optional message to display before running the function
+ </function-arg-description>
+ </function-arg-def>
+
+ <function-arg-def name="functionSetsTCStatus" type="optional">
+ <function-arg-description>
+ Whether the function to run sets the testcase status or not.
+ If this is set, the test case status is set according to whether
+ or not the function meets the expected return code.
+ True or False should be used for this argument.
+ </function-arg-description>
+ </function-arg-def>
+ </function-map-args>
+ <sequence>
+ <script>
+ <!-- defining the booleans here should temporary while I find a nicer
+ solution. We have a chicken and egg problem between the
+ loadGlobalEnvironment and loadSharedLibraries functions in
+ environment.xml at the moment.
+ -->
+ if not False:
+ False=0
+
+ if not True:
+ True=1
+
+ _throwException=False
+ if functionException:
+ _throwException=True
+
+ _displayMessage=False
+ if functionMessage:
+ _displayMessage=True
+
+ _tcStatus='fail'
+ _doSetTCStatus=False
+ if functionSetsTCStatus:
+ _doSetTCStatus=True
+ </script>
+ <message log="1" level="'info'" if="_displayMessage == True">'%s' % functionMessage</message>
+ <message log="1" level="'debug'">'runFunction: %s: called with parameters [%s]' % (functionName,functionArguments)</message>
+ <call function="'%s' % functionName">functionArguments</call>
+ <message log="1" level="'debug'">'runFunction: %s: returned [%s]' % (functionName,RC)</message>
+ <script>
+ _functionRC = RC
+ </script>
+ <call function="'checkRC'" >
+ { 'returncode' : RC ,
+ 'result' : STAXResult,
+ 'expected' : expectedRC
+ }
+ </call>
+
+ <!-- this section handles the optional case when we need to set the
+ test case status
+ -->
+ <if expr="_doSetTCStatus == True">
+ <sequence>
+ <if expr="_functionRC == expectedRC">
+ <script>_tcStatus='pass'</script>
+ </if>
+ <tcstatus result="_tcStatus" />
+ </sequence>
+ </if>
+
+ <!-- this section handles the optional case when we need to throw an
+ exception upon unexpected function return code
+ -->
+ <if expr="_throwException == True" >
+ <if expr="_functionRC != expectedRC" >
+ <throw exception="'STAXException.%s' % functionException" />
+ </if>
+ </if>
+
+ <!-- bubble the function return code up one level -->
+ <return>_functionRC</return>
+ </sequence>
+ </function>
</stax>
--
Gitblit v1.10.0