jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1542394 - in /jmeter/trunk: src/components/org/apache/jmeter/assertions/ src/components/org/apache/jmeter/extractor/ xdocs/
Date Sat, 16 Nov 2013 01:05:59 GMT
On 15 November 2013 20:52,  <pmouawad@apache.org> wrote:
> Author: pmouawad
> Date: Fri Nov 15 20:52:46 2013
> New Revision: 1542394
>
> URL: http://svn.apache.org/r1542394
> Log:
> Bug 55694 - Assertions and Extractors : Avoid NullPointerException when scope is variable
and variable is missing
> Bugzilla Id: 55694
>
> Modified:
>     jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
>     jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java
>     jmeter/trunk/src/components/org/apache/jmeter/extractor/HtmlExtractor.java
>     jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java
>     jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java
>     jmeter/trunk/xdocs/changes.xml
>
> Modified: jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java?rev=1542394&r1=1542393&r2=1542394&view=diff
> ==============================================================================
> --- jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java (original)
> +++ jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java Fri
Nov 15 20:52:46 2013
> @@ -22,6 +22,7 @@ import java.io.Serializable;
>  import java.net.URL;
>  import java.util.ArrayList;
>
> +import org.apache.commons.lang3.StringUtils;
>  import org.apache.jmeter.samplers.SampleResult;
>  import org.apache.jmeter.testelement.AbstractScopedAssertion;
>  import org.apache.jmeter.testelement.property.CollectionProperty;
> @@ -334,7 +335,7 @@ public class ResponseAssertion extends A
>              log.debug("Type:" + (contains?"Contains":"Match") + (notTest? "(not)": ""));
>          }
>
> -        if (toCheck.length() == 0) {
> +        if (StringUtils.isEmpty(toCheck)) {
>              if (notTest) { // Not should always succeed against an empty result
>                  return result;
>              }
>
> Modified: jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java?rev=1542394&r1=1542393&r2=1542394&view=diff
> ==============================================================================
> --- jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java (original)
> +++ jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java Fri
Nov 15 20:52:46 2013
> @@ -24,6 +24,7 @@ import java.io.Serializable;
>
>  import javax.xml.parsers.ParserConfigurationException;
>
> +import org.apache.commons.lang3.StringUtils;
>  import org.apache.jmeter.samplers.SampleResult;
>  import org.apache.jmeter.testelement.AbstractScopedAssertion;
>  import org.apache.jmeter.testelement.property.BooleanProperty;
> @@ -78,12 +79,15 @@ public class XPathAssertion extends Abst
>
>          try {
>              if (isScopeVariable()){
> -                responseData = getThreadContext().getVariables().get(getVariableName()).getBytes("UTF-8");
> +                String inputString=getThreadContext().getVariables().get(getVariableName());
> +                if(!StringUtils.isEmpty(inputString)) {
> +                    responseData = inputString.getBytes("UTF-8");
> +                }
>              } else {
>                  responseData = response.getResponseData();
>              }
>
> -            if (responseData.length == 0) {
> +            if (responseData == null || responseData.length == 0) {
>                  return result.setResultForNull();
>              }
>
>
> Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/HtmlExtractor.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/HtmlExtractor.java?rev=1542394&r1=1542393&r2=1542394&view=diff
> ==============================================================================
> --- jmeter/trunk/src/components/org/apache/jmeter/extractor/HtmlExtractor.java (original)
> +++ jmeter/trunk/src/components/org/apache/jmeter/extractor/HtmlExtractor.java Fri Nov
15 20:52:46 2013
> @@ -20,8 +20,10 @@ package org.apache.jmeter.extractor;
>
>  import java.io.Serializable;
>  import java.util.ArrayList;
> +import java.util.Collections;
>  import java.util.List;
>
> +import org.apache.commons.lang3.StringUtils;
>  import org.apache.jmeter.processor.PostProcessor;
>  import org.apache.jmeter.samplers.SampleResult;
>  import org.apache.jmeter.testelement.AbstractScopedTestElement;
> @@ -179,7 +181,14 @@ public class HtmlExtractor extends Abstr
>          List<String> result = new ArrayList<String>();
>          if (isScopeVariable()){
>              String inputString=vars.get(getVariableName());
> -            getExtractorImpl().extract(expression, attribute, matchNumber, inputString,
result, found, "-1");
> +            if(!StringUtils.isEmpty(inputString)) {
> +                getExtractorImpl().extract(expression, attribute, matchNumber, inputString,
result, found, "-1");
> +            } else {
> +                if(inputString==null) {
> +                    log.warn("No variable '"+getVariableName()+"' found to process by
Css/JQuery Extractor '"+getName()+"', skipping processing");
> +                }
> +                return Collections.emptyList();
> +            }
>          } else {
>              List<SampleResult> sampleList = getSampleList(previousResult);
>              int i=0;
>
> Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java?rev=1542394&r1=1542393&r2=1542394&view=diff
> ==============================================================================
> --- jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java (original)
> +++ jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java Fri Nov
15 20:52:46 2013
> @@ -196,7 +196,7 @@ public class RegexExtractor extends Abst
>          if (isScopeVariable()){
>              String inputString=vars.get(getVariableName());
>              if(inputString == null) {
> -                log.warn("No variable '"+getVariableName()+"' found to process by RegexExtractor
"+getName()+", skipping processing");
> +                log.warn("No variable '"+getVariableName()+"' found to process by RegexExtractor
'"+getName()+"', skipping processing");
>                  return Collections.emptyList();
>              }
>              matchStrings(matchNumber, matcher, pattern, matches, found,
>
> Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java?rev=1542394&r1=1542393&r2=1542394&view=diff
> ==============================================================================
> --- jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java (original)
> +++ jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java Fri Nov
15 20:52:46 2013
> @@ -128,8 +128,14 @@ public class XPathExtractor extends Abst
>          try{
>              if (isScopeVariable()){
>                  String inputString=vars.get(getVariableName());
> -                Document d =  parseResponse(inputString);
> -                getValuesForXPath(d,getXPathQuery(),matches);
> +                if(inputString != null) {
> +                    if(inputString.length()>0) {

Can we use StringUtils.isEmpty(inputString) here ?

> +                        Document d =  parseResponse(inputString);
> +                        getValuesForXPath(d,getXPathQuery(),matches);
> +                    }
> +                } else {
> +                    log.warn("No variable '"+getVariableName()+"' found to process by
XPathExtractor '"+getName()+"', skipping processing");
> +                }
>              } else {
>                  List<SampleResult> samples = getSampleList(previousResult);
>                  for (SampleResult res : samples) {
>
> Modified: jmeter/trunk/xdocs/changes.xml
> URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1542394&r1=1542393&r2=1542394&view=diff
> ==============================================================================
> --- jmeter/trunk/xdocs/changes.xml (original)
> +++ jmeter/trunk/xdocs/changes.xml Fri Nov 15 20:52:46 2013
> @@ -146,7 +146,7 @@ A workaround is to use a Java 7 update 4
>
>  <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
>  <ul>
> -<li><bugzilla>55694</bugzilla> - java.lang.NullPointerException if
Apply to is set to a missing JMeter variable</li>
> +<li><bugzilla>55694</bugzilla> - Assertions and Extractors : Avoid
NullPointerException when scope is variable and variable is missing</li>
>  <li><bugzilla>55721</bugzilla> - HTTP Cache Manager - no-store directive
is wrongly interpreted</li>
>  </ul>
>
>
>

Mime
View raw message