sebb        2004/06/03 16:01:35

  Modified:    src/core/org/apache/jmeter/resources Tag: rel-2_0
                        messages.properties
               src/components/org/apache/jmeter/assertions Tag: rel-2_0
                        ResponseAssertion.java
               src/components/org/apache/jmeter/assertions/gui Tag: rel-2_0
                        AssertionGui.java
               xdocs/usermanual Tag: rel-2_0 component_reference.xml
  Log:
  Bug 28699 - allow Assertion to regard unsuccessful responses - e.g. 404 - as 
successful
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.106.2.4 +1 -0      
jakarta-jmeter/src/core/org/apache/jmeter/resources/messages.properties
  
  Index: messages.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/resources/messages.properties,v
  retrieving revision 1.106.2.3
  retrieving revision 1.106.2.4
  diff -u -r1.106.2.3 -r1.106.2.4
  --- messages.properties       3 Jun 2004 00:08:36 -0000       1.106.2.3
  +++ messages.properties       3 Jun 2004 23:01:34 -0000       1.106.2.4
  @@ -15,6 +15,7 @@
   anchor_modifier_title=HTML Link Parser
   appearance=Look and Feel
   argument_must_not_be_negative=The Argument must not be negative\!
  +assertion_assume_success=Ignore Status
   assertion_code_resp=Response Code
   assertion_contains=Contains
   assertion_matches=Matches
  
  
  
  No                   revision
  No                   revision
  1.16.2.2  +18 -4     
jakarta-jmeter/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
  
  Index: ResponseAssertion.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/assertions/ResponseAssertion.java,v
  retrieving revision 1.16.2.1
  retrieving revision 1.16.2.2
  diff -u -r1.16.2.1 -r1.16.2.2
  --- ResponseAssertion.java    20 May 2004 15:23:11 -0000      1.16.2.1
  +++ ResponseAssertion.java    3 Jun 2004 23:01:35 -0000       1.16.2.2
  @@ -22,12 +22,14 @@
   
   import org.apache.jmeter.samplers.SampleResult;
   import org.apache.jmeter.testelement.AbstractTestElement;
  +import org.apache.jmeter.testelement.property.BooleanProperty;
   import org.apache.jmeter.testelement.property.CollectionProperty;
   import org.apache.jmeter.testelement.property.IntegerProperty;
   import org.apache.jmeter.testelement.property.JMeterProperty;
   import org.apache.jmeter.testelement.property.NullProperty;
   import org.apache.jmeter.testelement.property.PropertyIterator;
   import org.apache.jmeter.testelement.property.StringProperty;
  +import org.apache.jorphan.util.JOrphanUtils;
   import org.apache.oro.text.MalformedCachePatternException;
   import org.apache.oro.text.PatternCacheLRU;
   import org.apache.oro.text.regex.Pattern;
  @@ -36,8 +38,6 @@
   
   /**
    *
  - * @author     Michael Stover
  - * @author     <a href="mailto:[EMAIL PROTECTED]">Jonathan Carlson</a>
    * @version    $Revision$ Last Updated: $Date$
   */
   public class ResponseAssertion
  @@ -50,6 +50,7 @@
      public final static String RESPONSE_DATA = "Assertion.response_data";
      public final static String RESPONSE_CODE = "Assertion.response_code";
      public final static String RESPONSE_MESSAGE = "Assertion.response_message";
  +   public final static String ASSUME_SUCCESS = "Assertion.assume_success";
   
      public final static String TEST_STRINGS = "Asserion.test_strings";
   
  @@ -234,6 +235,14 @@
      {
         setTestType(getTestType() &  ~ NOT);
      }
  +   public boolean getAssumeSuccess()
  +   {
  +     return getPropertyAsBoolean(ASSUME_SUCCESS,false);
  +   }
  +   public void setAssumeSuccess(boolean b)
  +   {
  +       setProperty(ASSUME_SUCCESS,JOrphanUtils.booleanToString(b));
  +   }
      /**
       * Make sure the response satisfies the specified assertion requirements.
       * 
  @@ -247,6 +256,11 @@
         AssertionResult result = new AssertionResult();
         String toCheck=""; // The string to check (Url or data)
         
  +      if (getAssumeSuccess())
  +      {
  +             response.setSuccessful(true);// Allow testing of failure codes
  +      }
  +
         // What are we testing against?
         if (ResponseAssertion.RESPONSE_DATA.equals(getTestField()))
         {
  
  
  
  No                   revision
  No                   revision
  1.17.2.1  +18 -5     
jakarta-jmeter/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java
  
  Index: AssertionGui.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java,v
  retrieving revision 1.17
  retrieving revision 1.17.2.1
  diff -u -r1.17 -r1.17.2.1
  --- AssertionGui.java 5 Mar 2004 01:32:13 -0000       1.17
  +++ AssertionGui.java 3 Jun 2004 23:01:35 -0000       1.17.2.1
  @@ -64,6 +64,12 @@
        /** Radio button indicating that the responseCode should be tested. */
        private JRadioButton responseCodeButton;
   
  +     /**
  +      * Checkbox to indicate whether the response should be forced successful 
before testing.
  +      * This is intended for use when checking the status code or status message.
  +      */
  +     private JCheckBox assumeSuccess;
  +     
       /**
        * Radio button indicating to test if the field contains one of the
        * patterns.
  @@ -147,7 +153,9 @@
                   ra.setTestField(ResponseAssertion.RESPONSE_DATA);
               }
   
  -            if (containsBox.isSelected())
  +             ra.setAssumeSuccess(assumeSuccess.isSelected());
  +
  +             if (containsBox.isSelected())
               {
                   ra.setToContainsType();
               }
  @@ -217,6 +225,8 @@
               labelButton.setSelected(true);
           }
   
  +        assumeSuccess.setSelected(model.getAssumeSuccess());
  +        
           tableModel.clearData();
           PropertyIterator tests = model.getTestStrings().iterator();
           while (tests.hasNext())
  @@ -286,6 +296,9 @@
                panel.add(responseMessageButton);
                
           responseStringButton.setSelected(true);
  +        
  +        assumeSuccess = new 
JCheckBox(JMeterUtils.getResString("assertion_assume_success"));
  +        panel.add(assumeSuccess);
   
           return panel;
       }
  
  
  
  No                   revision
  No                   revision
  1.87.2.5  +16 -5     jakarta-jmeter/xdocs/usermanual/component_reference.xml
  
  Index: component_reference.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/xdocs/usermanual/component_reference.xml,v
  retrieving revision 1.87.2.4
  retrieving revision 1.87.2.5
  diff -u -r1.87.2.4 -r1.87.2.5
  --- component_reference.xml   3 Jun 2004 00:08:36 -0000       1.87.2.4
  +++ component_reference.xml   3 Jun 2004 23:01:35 -0000       1.87.2.5
  @@ -1361,8 +1361,19 @@
   </description>
   <properties>
           <property name="Name" required="">Descriptive name for this element that is 
shown in the tree.</property>
  -        <property name="Response Field to Test" required="Yes">Instructs JMeter to 
test
  -                against either the Response Text from the server, or against the 
URL string that was sampled.</property>
  +        <property name="Response Field to Test" required="Yes">Instructs JMeter 
which field of the Response to test.
  +                This may be the Response Text from the server, the URL string that 
was sampled,
  +                the Response Code (e.g. 404) or the Response Message (e.g. Not 
Found).
  +                <p>
  +                The overall success of the sample is determined by combining the 
result of the
  +                assertion with the existing Response status.
  +                When the Ignore Status checkbox is selected, the Response status is 
forced
  +                to successful before evaluating the Assertion.
  +                </p>
  +                HTTP Responses with statuses in the 4xx and 5xx ranges are normally
  +                regarded as unsuccessful. 
  +                The checkbox can be used to regard a 404 status as successful.
  +                </property>
           <property name="Pattern Matching Rules" required="Yes">Indicates whether 
the text being tested
           must CONTAIN or MATCH the test patterns.  NOT may also be selected to 
indicate the text
           should NOT CONTAIN or NOT MATCH the test patterns.</property>
  
  
  

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

Reply via email to