juergen     2003/07/14 07:25:58

  Modified:    testsuite/testsuite/junit Tprocessor.dtd
               
testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor
                        TProcessors.java
  Log:
  The just checked-in version of t-processor will include following new features:
  
  1)    a waiting period can be set
                        At every position a step may occur the following element may 
occur too:         <wait time="30000" /> Which will wait in this example for 30000 
milli seconds.
  
  2)    the repeater can be terminated either by the iteration count, or a (simple) 
Boolean expression
  the repeater can be terminated with a simple Boolean expression of the format 
"leftSide = rightSide". Left and rightSide are Strings (or variable references) which 
are compared for equality. If both strings are identical, the loop is terminated.
  
  Revision  Changes    Path
  1.5       +14 -5     jakarta-slide/testsuite/testsuite/junit/Tprocessor.dtd
  
  Index: Tprocessor.dtd
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/testsuite/testsuite/junit/Tprocessor.dtd,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Tprocessor.dtd    6 Mar 2002 16:32:38 -0000       1.4
  +++ Tprocessor.dtd    14 Jul 2003 14:25:58 -0000      1.5
  @@ -1,21 +1,30 @@
   <?xml version="1.0" encoding="UTF-8"?>
   <!-- edited with XML Spy v4.1 U (http://www.xmlspy.com) by Juergen Pill (Software 
AG) -->
   <!--Generated by XML Authority-->
  -<!ELEMENT test (specification?, (step | repeater | thread)+, cleanup?)>
  -<!ELEMENT cleanup (step | repeater)+>
  -<!ELEMENT thread (step | repeater)+>
  -<!ELEMENT repeater (step | repeater | thread)+>
  +<!ELEMENT test (specification?, (step | wait | repeater | thread)+, cleanup?)>
  +<!ELEMENT cleanup (step | wait  | repeater)+>
  +<!ELEMENT thread (step | wait  | repeater)+>
  +<!ELEMENT repeater (step | wait  | repeater | thread)+>
   <!ATTLIST repeater
        repeatCount CDATA #REQUIRED
  +     condition CDATA #IMPLIED
        varDefinition CDATA #IMPLIED
        varUsage CDATA #IMPLIED
   >
  +<!ELEMENT wait (#PCDATA)>
  +<!ATTLIST wait 
  +     time CDATA #REQUIRED
  +>
  +<!ELEMENT maxDuration (#PCDATA)>
  +<!ATTLIST maxDuration
  +     time CDATA #REQUIRED
  +>
   <!ELEMENT assign (#PCDATA)>
   <!ATTLIST assign
        varDefinition CDATA #IMPLIED
        varUsage CDATA #IMPLIED
   >
  -<!ELEMENT step (assign*, user?, password?, request, response)>
  +<!ELEMENT step (assign*, user?, password?, maxDuration?, request, response)>
   <!ATTLIST step
        executeIn CDATA #IMPLIED
   >
  
  
  
  1.58      +41 -8     
jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/TProcessors.java
  
  Index: TProcessors.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/TProcessors.java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- TProcessors.java  23 May 2003 11:29:37 -0000      1.57
  +++ TProcessors.java  14 Jul 2003 14:25:58 -0000      1.58
  @@ -530,6 +530,18 @@
       }
   
   
  +    private boolean checkCondition(Element conditionContainer, String condition) 
throws Exception {
  +        if (condition == null) return false;
  +        String evaluatedCondition = replaceKnownVariable(conditionContainer, 
condition, "x=x");
  +        StringTokenizer expression = new StringTokenizer(evaluatedCondition, "=");
  +        if (expression.countTokens() != 2) throw new Exception("Condition 
malformed: " + evaluatedCondition);
  +        String leftSide = expression.nextToken();
  +        String rightSide = expression.nextToken();
  +        return leftSide.equals(rightSide);
  +    }
  +
  +
  +
       private boolean exceuteStepOrRepeater(Iterator items, Vector threadsToExceute, 
Vector cleanUpThreads, HttpClientExtended client) {
           boolean result = true;
   
  @@ -541,6 +553,8 @@
                       if(!executeStep(item, client)){
                           result = false;
                       }
  +                } else if(item.getName().equals("wait")){
  +                    Thread.currentThread().sleep(new 
Long(item.getAttributeValue("time")).longValue());
                   } else if(item.getName().equals("thread")){
                       threadsToExceute.add(new Thread(new 
Runner(item.getChildren().iterator(), Thread.currentThread()), "parallelThread-" + 
(threadsToExceute.size()+1)));
                   } else if(item.getName().equals("cleanup")){
  @@ -551,10 +565,15 @@
                           !item.getAttributeValue("varDefinition").equals("") ) {
                           varName = item.getAttributeValue("varDefinition");
                       }
  +                    String condition = null;
  +                    if (item.getAttribute("condition") != null &&
  +                        !item.getAttributeValue("condition").equals("") ) {
  +                        condition = item.getAttributeValue("condition");
  +                    }
                       knownVariables.put(varName, "undefined");
                       int stackMarker = knownVariables.size();
                       long maximum = new Long(replaceKnownVariable(item, 
item.getAttribute("repeatCount").getValue(), "0")).longValue();
  -                    for (long i = 0; i < maximum; i++){
  +                    for (long i = 0; i < maximum && !checkCondition(item, 
condition); i++){
                           knownVariables.removeAllFramedVariables(stackMarker);
                           knownVariables.put(varName, new Long(i+1).toString());
                           result = 
exceuteStepOrRepeater(item.getChildren().iterator(), threadsToExceute, cleanUpThreads, 
client) && result;
  @@ -643,6 +662,11 @@
               xmlresult.writeElement("method", method.getName());
               xmlresult.writeElement("url", 
URLUtil.URLEncode(method.getPath(),"UTF-8"));
   
  +//            client.setConnectionTimeout(100000);
  +//            if (elt.getChild("maxDuration") != null) {
  +//                client.setConnectionTimeout(new 
Integer(elt.getChild("maxDuration").getAttributeValue("time")).intValue());
  +//            }
  +
               final int MAX = 50;
               int i;
               for (i = 0; true; i++)
  @@ -1250,6 +1274,7 @@
   
       public static List responseStatus (String response){
           List result = new ArrayList();
  +        if (response.equals("*")) return null;
           StringTokenizer st = new StringTokenizer(response);
           st.nextToken(); // ignore the first 'http' element
           String resonseString = st.nextToken();
  @@ -1334,7 +1359,7 @@
        *
        */
       private void fillVariables (HttpMethod m, Element responseElement) {
  -        fillSpecifiedHeaderVariable(m, responseElement);
  +        fillSpecifiedCommandHeaderVariable(m, responseElement);
           if (m instanceof XMLResponseMethodBase){
               fillAutomatedVariables((XMLResponseMethodBase)m);
               fillSpecifiedVariable((XMLResponseMethodBase)m, 
responseElement.getChild("body"));
  @@ -1347,16 +1372,24 @@
       /**
        *
        */
  -    private void fillSpecifiedHeaderVariable (HttpMethod m, Element 
responseElement) {
  +    private void fillSpecifiedCommandHeaderVariable (HttpMethod m, Element 
responseElement) {
   
           if (responseElement == null) return;  // no response, nothing to fill
   
           try {
   
  +            // fill the command variable, if present
  +            String varName = 
responseElement.getChild("command").getAttributeValue("varDefinition");
  +            if (varName != null && !varName.trim().equals("")) {
  +                String responseCode = new Integer(m.getStatusCode()).toString();
  +                knownVariables.put(varName, responseCode);
  +            }
  +
  +            // fill the header variable, if present
               Iterator iter = responseElement.getChildren("header").iterator();
               while (iter.hasNext()) {
                   Element headerElement = (Element)iter.next();
  -                String varName = headerElement.getAttributeValue("varDefinition");
  +                varName = headerElement.getAttributeValue("varDefinition");
                   if (varName != null && !varName.trim().equals("")) {
                       String headerName = 
getResponseHeader(headerElement.getText()).getName();
                       Header h = m.getResponseHeader(headerName);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to