Author: sebb
Date: Tue Feb  2 23:09:53 2010
New Revision: 905832

URL: http://svn.apache.org/viewvc?rev=905832&view=rev
Log:
Response Assertion and Size Assertion can now be applied to a JMeter variable

Added:
    
jakarta/jmeter/trunk/docs/images/screenshots/assertion/assertionscopevar.png   
(with props)
    
jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/AbstractScopedJMeterGuiComponent.java
   (with props)
    
jakarta/jmeter/trunk/xdocs/images/screenshots/assertion/assertionscopevar.png   
(with props)
Modified:
    jakarta/jmeter/trunk/docs/images/screenshots/assertion/assertion.png
    jakarta/jmeter/trunk/docs/images/screenshots/regex_extractor.png
    jakarta/jmeter/trunk/docs/images/screenshots/size_assertion.png
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/SizeAssertion.java
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/SizeAssertionGui.java
    
jakarta/jmeter/trunk/src/core/org/apache/jmeter/assertions/gui/AbstractAssertionGui.java
    
jakarta/jmeter/trunk/src/core/org/apache/jmeter/processor/gui/AbstractPostProcessorGui.java
    
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedAssertion.java
    
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedTestElement.java
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/ScopePanel.java
    jakarta/jmeter/trunk/xdocs/changes.xml
    jakarta/jmeter/trunk/xdocs/images/screenshots/assertion/assertion.png
    jakarta/jmeter/trunk/xdocs/images/screenshots/regex_extractor.png
    jakarta/jmeter/trunk/xdocs/images/screenshots/size_assertion.png
    jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jakarta/jmeter/trunk/docs/images/screenshots/assertion/assertion.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/assertion/assertion.png?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
Binary files - no diff available.

Added: 
jakarta/jmeter/trunk/docs/images/screenshots/assertion/assertionscopevar.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/assertion/assertionscopevar.png?rev=905832&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
jakarta/jmeter/trunk/docs/images/screenshots/assertion/assertionscopevar.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Modified: jakarta/jmeter/trunk/docs/images/screenshots/regex_extractor.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/regex_extractor.png?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
Binary files - no diff available.

Modified: jakarta/jmeter/trunk/docs/images/screenshots/size_assertion.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/size_assertion.png?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
Binary files - no diff available.

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
 Tue Feb  2 23:09:53 2010
@@ -291,7 +291,9 @@
         }
 
         // What are we testing against?
-        if (isTestFieldResponseData()) {
+        if (isScopeVariable()){
+            toCheck = getThreadContext().getVariables().get(getVariableName());
+        } else if (isTestFieldResponseData()) {
             toCheck = response.getResponseDataAsString(); // (bug25052)
         } else if (isTestFieldResponseCode()) {
             toCheck = response.getResponseCode();
@@ -375,7 +377,9 @@
         StringBuilder sb = new StringBuilder(200);
         sb.append("Test failed: ");
 
-        if (isTestFieldResponseData()) {
+        if (isScopeVariable()){
+            sb.append("variable(").append(getVariableName()).append(')');      
      
+        } else if (isTestFieldResponseData()) {
             sb.append("text");
         } else if (isTestFieldResponseCode()) {
             sb.append("code");

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/SizeAssertion.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/SizeAssertion.java?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/SizeAssertion.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/SizeAssertion.java
 Tue Feb  2 23:09:53 2010
@@ -64,7 +64,20 @@
     public AssertionResult getResult(SampleResult response) {
         AssertionResult result = new AssertionResult(getName());
         result.setFailure(false);
-        long resultSize = response.getBytes();
+        long resultSize=0;
+        if (isScopeVariable()){
+            String variableName = getVariableName();
+            String value = getThreadContext().getVariables().get(variableName);
+            try {
+                resultSize = Integer.parseInt(value);
+            } catch (NumberFormatException e) {
+                result.setFailure(true);
+                result.setFailureMessage("Error parsing variable name: 
"+variableName+" value: "+value);
+                return result;
+            }
+        } else {
+            resultSize = response.getBytes();
+        }
         // is the Sample the correct size?
         if (!(compareSize(resultSize))) {
             result.setFailure(true);

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java
 Tue Feb  2 23:09:53 2010
@@ -264,7 +264,7 @@
         setBorder(makeBorder());
 
         box.add(makeTitlePanel());
-        box.add(createScopePanel());
+        box.add(createScopePanel(true));
         box.add(createFieldPanel());
         box.add(createTypePanel());
         add(box, BorderLayout.NORTH);

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/SizeAssertionGui.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/SizeAssertionGui.java?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/SizeAssertionGui.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/SizeAssertionGui.java
 Tue Feb  2 23:09:53 2010
@@ -149,7 +149,7 @@
 
         add(makeTitlePanel());
 
-        add(createScopePanel());
+        add(createScopePanel(true));
         
         // USER_INPUT
         JPanel sizePanel = new JPanel();

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/assertions/gui/AbstractAssertionGui.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/assertions/gui/AbstractAssertionGui.java?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/assertions/gui/AbstractAssertionGui.java
 (original)
+++ 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/assertions/gui/AbstractAssertionGui.java
 Tue Feb  2 23:09:53 2010
@@ -21,13 +21,9 @@
 import java.util.Arrays;
 import java.util.Collection;
 
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
 
-import org.apache.jmeter.gui.AbstractJMeterGuiComponent;
+import org.apache.jmeter.gui.AbstractScopedJMeterGuiComponent;
 import org.apache.jmeter.gui.util.MenuFactory;
-import org.apache.jmeter.testelement.AbstractScopedAssertion;
-import org.apache.jmeter.util.ScopePanel;
 
 /**
  * This is the base class for JMeter GUI components which manage assertions.
@@ -38,27 +34,10 @@
  * and GUI in synch.
  *
  */
-public abstract class AbstractAssertionGui extends AbstractJMeterGuiComponent {
+public abstract class AbstractAssertionGui extends 
AbstractScopedJMeterGuiComponent {
 
     private static final long serialVersionUID = 240L;
 
-    private ScopePanel assertionScopePanel;
-    
-    /**
-     * When a user right-clicks on the component in the test tree, or selects
-     * the edit menu when the component is selected, the component will be 
asked
-     * to return a JPopupMenu that provides all the options available to the
-     * user from this component.
-     * <p>
-     * This implementation returns menu items appropriate for most assertion
-     * components.
-     *
-     * @return a JPopupMenu appropriate for the component.
-     */
-    public JPopupMenu createPopupMenu() {
-        return MenuFactory.getDefaultAssertionMenu();
-    }
-
     /**
      * This is the list of menu categories this gui component will be available
      * under. This implementation returns
@@ -71,57 +50,4 @@
     public Collection<String> getMenuCategories() {
         return Arrays.asList(new String[] { MenuFactory.ASSERTIONS });
     }
-    
-    /**
-     * Create the scope settings panel.
-     * 
-     * @return the scope settings panel
-     */
-    protected JPanel createScopePanel(){
-        assertionScopePanel = new ScopePanel();
-        return assertionScopePanel;
-    }
-
-    @Override
-    public void clearGui(){
-        super.clearGui();
-        if (assertionScopePanel != null) {
-            assertionScopePanel.clearGui();
-        }
-    }
-
-    /**
-     * Save the scope settings in the test element.
-     * 
-     * @param assertion
-     */
-    protected void saveScopeSettings(AbstractScopedAssertion assertion) {
-        if (assertionScopePanel.isScopeParent()){
-            assertion.setScopeParent();
-        } else if (assertionScopePanel.isScopeChildren()){
-            assertion.setScopeChildren();
-        } else if (assertionScopePanel.isScopeAll()) {
-            assertion.setScopeAll();
-        } else {
-            throw new IllegalArgumentException("Unexpected scope panel state");
-        }
-    }
-
-    /**
-     * Show the scope settings from the test element.
-     * 
-     * @param assertion
-     */
-    protected void showScopeSettings(AbstractScopedAssertion assertion) {
-        String scope = assertion.fetchScope();
-        if (assertion.isScopeParent(scope)) {
-                assertionScopePanel.setScopeParent();                
-        } else if (assertion.isScopeChildren(scope)){
-            assertionScopePanel.setScopeChildren();
-        } else if (assertion.isScopeAll(scope)){
-            assertionScopePanel.setScopeAll();
-        } else {
-            throw new IllegalArgumentException("Invalid scope: "+scope);
-        }
-    }
 }
\ No newline at end of file

Added: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/AbstractScopedJMeterGuiComponent.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/AbstractScopedJMeterGuiComponent.java?rev=905832&view=auto
==============================================================================
--- 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/AbstractScopedJMeterGuiComponent.java
 (added)
+++ 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/AbstractScopedJMeterGuiComponent.java
 Tue Feb  2 23:09:53 2010
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.gui;
+
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+
+import org.apache.jmeter.gui.util.MenuFactory;
+import org.apache.jmeter.testelement.AbstractScopedTestElement;
+import org.apache.jmeter.util.ScopePanel;
+
+
+public abstract class AbstractScopedJMeterGuiComponent extends 
AbstractJMeterGuiComponent {
+
+    private static final long serialVersionUID = 240L;
+
+    private ScopePanel scopePanel;
+
+    @Override
+    public void clearGui(){
+        super.clearGui();
+        if (scopePanel != null) {
+            scopePanel.clearGui();
+        }        
+    }
+    /**
+     * When a user right-clicks on the component in the test tree, or selects
+     * the edit menu when the component is selected, the component will be 
asked
+     * to return a JPopupMenu that provides all the options available to the
+     * user from this component.
+     * <p>
+     * This implementation returns menu items appropriate for most assertion
+     * components.
+     *
+     * @return a JPopupMenu appropriate for the component.
+     */
+    public JPopupMenu createPopupMenu() {
+        return MenuFactory.getDefaultAssertionMenu();
+    }
+
+    /**
+     * Create the scope settings panel.
+     * 
+     * @return the scope settings panel
+     */
+    protected JPanel createScopePanel() {
+        return createScopePanel(false);
+    }
+
+    /**
+     * Create the scope settings panel.
+     * @param enableVariable set true to enable the variable panel
+     * @return the scope settings panel
+     */
+    protected JPanel createScopePanel(boolean enableVariable) {
+        scopePanel = new ScopePanel(enableVariable);
+        return scopePanel;
+    }
+
+    /**
+     * Save the scope settings in the test element.
+     * 
+     * @param testElement
+     */
+    protected void saveScopeSettings(AbstractScopedTestElement testElement) {
+        if (scopePanel.isScopeParent()){
+            testElement.setScopeParent();
+        } else if (scopePanel.isScopeChildren()){
+            testElement.setScopeChildren();
+        } else if (scopePanel.isScopeAll()) {
+            testElement.setScopeAll();
+        } else if (scopePanel.isScopeVariable()) {
+            testElement.setScopeVariable(scopePanel.getVariable());
+        } else {
+            throw new IllegalArgumentException("Unexpected scope panel state");
+        }
+    }
+
+    /**
+     * Show the scope settings from the test element.
+     * 
+     * @param testElement
+     */
+    protected void showScopeSettings(AbstractScopedTestElement testElement) {
+        String scope = testElement.fetchScope();
+        if (testElement.isScopeParent(scope)) {
+                scopePanel.setScopeParent();                
+        } else if (testElement.isScopeChildren(scope)){
+            scopePanel.setScopeChildren();
+        } else if (testElement.isScopeAll(scope)){
+            scopePanel.setScopeAll();
+        } else if (testElement.isScopeVariable(scope)){
+            scopePanel.setScopeVariable(testElement.getVariableName());
+        } else {
+            throw new IllegalArgumentException("Invalid scope: "+scope);
+        }
+    }
+
+
+}

Propchange: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/AbstractScopedJMeterGuiComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/AbstractScopedJMeterGuiComponent.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/processor/gui/AbstractPostProcessorGui.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/processor/gui/AbstractPostProcessorGui.java?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/processor/gui/AbstractPostProcessorGui.java
 (original)
+++ 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/processor/gui/AbstractPostProcessorGui.java
 Tue Feb  2 23:09:53 2010
@@ -21,13 +21,8 @@
 import java.util.Arrays;
 import java.util.Collection;
 
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-
-import org.apache.jmeter.gui.AbstractJMeterGuiComponent;
+import org.apache.jmeter.gui.AbstractScopedJMeterGuiComponent;
 import org.apache.jmeter.gui.util.MenuFactory;
-import org.apache.jmeter.testelement.AbstractScopedTestElement;
-import org.apache.jmeter.util.ScopePanel;
 
 /**
  * This is the base class for JMeter GUI components which manage 
PostProcessors.
@@ -38,71 +33,12 @@
  * and GUI in synch.
  *
  */
-public abstract class AbstractPostProcessorGui extends 
AbstractJMeterGuiComponent {
+public abstract class AbstractPostProcessorGui extends 
AbstractScopedJMeterGuiComponent {
 
     private static final long serialVersionUID = 240L;
 
-    private ScopePanel scopePanel;
-
-    public JPopupMenu createPopupMenu() {
-        return MenuFactory.getDefaultExtractorMenu();
-    }
-
     public Collection<String> getMenuCategories() {
         return Arrays.asList(new String[] { MenuFactory.POST_PROCESSORS });
     }
-    /**
-     * Create the scope settings panel.
-     * GUIs that want to add the panel need to add the following to the init 
method:
-     * <br/>
-     * box.add(createScopePanel());
-     * @return the scope settings panel
-     */
-    protected JPanel createScopePanel(){
-        scopePanel = new ScopePanel();
-        return scopePanel;
-    }
 
-    @Override
-    public void clearGui(){
-        super.clearGui();
-        if (scopePanel != null) {
-            scopePanel.clearGui();
-        }
-    }
-
-    /**
-     * Save the scope settings in the test element.
-     * Needs to be called by the GUIs modifyTestElement method.
-     * @param testElement
-     */
-    protected void saveScopeSettings(AbstractScopedTestElement testElement) {
-        if (scopePanel.isScopeParent()) {
-            testElement.setScopeParent();
-        } else if (scopePanel.isScopeChildren()) {
-            testElement.setScopeChildren();
-        } else if (scopePanel.isScopeAll()) {
-            testElement.setScopeAll();
-        } else {
-            throw new IllegalArgumentException("Unexpected scope panel state");
-        }
-    }
-
-    /**
-     * Show the scope settings from the test element.
-     * Needs to be called by the GUIs configure method.     * 
-     * @param testElement
-     */
-    protected void showScopeSettings(AbstractScopedTestElement testElement) {
-        String scope = testElement.fetchScope();
-        if (testElement.isScopeParent(scope)) {
-                scopePanel.setScopeParent();                
-        } else if (testElement.isScopeChildren(scope)){
-            scopePanel.setScopeChildren();
-        } else if (testElement.isScopeAll(scope)){
-            scopePanel.setScopeAll();
-        } else {
-            throw new IllegalArgumentException("Invalid scope: "+scope);
-        }
-    }
 }

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties 
(original)
+++ 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties 
Tue Feb  2 23:09:53 2010
@@ -684,10 +684,11 @@
 runtime_controller_title=Runtime Controller
 runtime_seconds=Runtime (seconds)
 sample_result_save_configuration=Sample Result Save Configuration
-sample_scope=Which samples to process
+sample_scope=Apply to:
 sample_scope_all=Main sample and sub-samples
 sample_scope_children=Sub-samples only
 sample_scope_parent=Main sample only
+sample_scope_variable=JMeter Variable
 sampler_label=Label
 sampler_on_error_action=Action to be taken after a Sampler error
 sampler_on_error_continue=Continue

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedAssertion.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedAssertion.java?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedAssertion.java
 (original)
+++ 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedAssertion.java
 Tue Feb  2 23:09:53 2010
@@ -34,62 +34,17 @@
  * </ul>
  * </p>
  */
-public abstract class AbstractScopedAssertion extends AbstractTestElement {
+public abstract class AbstractScopedAssertion extends 
AbstractScopedTestElement {
 
     private static final long serialVersionUID = 240L;
 
+    //+ JMX attributes - do not change
     private static final String SCOPE = "Assertion.scope";
-    private static final String SCOPE_PARENT = "parent";
-    private static final String SCOPE_CHILDREN = "children";
-    private static final String SCOPE_ALL = "all";
+    //- JMX
 
-    /**
-     * Get the scope setting
-     * @return the scope, default parent
-     */
-    public String fetchScope() {
-        return getPropertyAsString(SCOPE, SCOPE_PARENT);
+    @Override
+    protected String getScopeName() {
+        return SCOPE;
     }
 
-    /**
-     * Is the assertion to be applied to the main (parent) sample?
-     * 
-     * @param scope
-     * @return if the assertion is to be applied to the parent sample.
-     */
-    public boolean isScopeParent(String scope) {
-        return scope.equals(SCOPE_PARENT);
-    }
-
-    /**
-     * Is the assertion to be applied to the sub-samples (children)?
-     * 
-     * @param scope
-     * @return if the assertion is to be applied to the children.
-     */
-    public boolean isScopeChildren(String scope) {
-        return scope.equals(SCOPE_CHILDREN);
-    }
-
-    /**
-     * Is the assertion to be applied to the all samples?
-     * 
-     * @param scope
-     * @return if the assertion is to be applied to the all samples.
-     */
-    public boolean isScopeAll(String scope) {
-        return scope.equals(SCOPE_ALL);
-    }
-
-    public void setScopeParent() {
-        removeProperty(SCOPE);
-    }
-
-    public void setScopeChildren() {
-        setProperty(SCOPE, SCOPE_CHILDREN);
-    }
-
-    public void setScopeAll() {
-        setProperty(SCOPE, SCOPE_ALL);
-    }
 }

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedTestElement.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedTestElement.java?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedTestElement.java
 (original)
+++ 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedTestElement.java
 Tue Feb  2 23:09:53 2010
@@ -26,7 +26,7 @@
 /**
  * <p>
  * Super-class for TestElements that can be applied to main sample, 
sub-samples or both.
- * [Assertions use a different class because they use a different value for 
the {...@link #SCOPE} constant]
+ * [Assertions use a different class because they use a different value for 
the {...@link #getScopeName()} constant]
  * </p>
  * 
  * <p>
@@ -48,14 +48,21 @@
     private static final String SCOPE_PARENT = "parent"; // $NON-NLS-1$
     private static final String SCOPE_CHILDREN = "children"; // $NON-NLS-1$
     private static final String SCOPE_ALL = "all"; // $NON-NLS-1$
+    private static final String SCOPE_VARIABLE = "variable"; // $NON-NLS-1$
+    private static final String SCOPE_VARIABLE_NAME = "Scope.variable"; // 
$NON-NLS-1$
     //- JMX
 
+
+    protected String getScopeName() {
+        return SCOPE;
+    }
+
     /**
      * Get the scope setting
      * @return the scope, default parent
      */
     public String fetchScope() {
-        return getPropertyAsString(SCOPE, SCOPE_PARENT);
+        return getPropertyAsString(getScopeName(), SCOPE_PARENT);
     }
 
     /**
@@ -88,16 +95,44 @@
         return scope.equals(SCOPE_ALL);
     }
 
+    /**
+     * Is the assertion to be applied to the all samples?
+     * 
+     * @param scope
+     * @return if the assertion is to be applied to the all samples.
+     */
+    public boolean isScopeVariable(String scope) {
+        return scope.equals(SCOPE_VARIABLE);
+    }
+
+    /**
+     * Is the assertion to be applied to the all samples?
+     * 
+     * @return if the assertion is to be applied to the all samples.
+     */
+    protected boolean isScopeVariable() {
+        return isScopeVariable(fetchScope());
+    }
+
+    public String getVariableName(){
+        return getPropertyAsString(SCOPE_VARIABLE_NAME, "");
+    }
+
     public void setScopeParent() {
-        removeProperty(SCOPE);
+        removeProperty(getScopeName());
     }
 
     public void setScopeChildren() {
-        setProperty(SCOPE, SCOPE_CHILDREN);
+        setProperty(getScopeName(), SCOPE_CHILDREN);
     }
 
     public void setScopeAll() {
-        setProperty(SCOPE, SCOPE_ALL);
+        setProperty(getScopeName(), SCOPE_ALL);
+    }
+
+    public void setScopeVariable(String variableName) {
+        setProperty(getScopeName(), SCOPE_VARIABLE);
+        setProperty(SCOPE_VARIABLE_NAME, variableName);
     }
 
     /**

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java 
(original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java 
Tue Feb  2 23:09:53 2010
@@ -575,7 +575,7 @@
             if (assertion instanceof AbstractScopedAssertion){
                 AbstractScopedAssertion scopedAssertion = 
(AbstractScopedAssertion) assertion;
                 String scope = scopedAssertion.fetchScope();
-                if (scopedAssertion.isScopeParent(scope) || 
scopedAssertion.isScopeAll(scope)){
+                if (scopedAssertion.isScopeParent(scope) || 
scopedAssertion.isScopeAll(scope) || scopedAssertion.isScopeVariable(scope)){
                     processAssertion(parent, assertion);
                 }
                 if (scopedAssertion.isScopeChildren(scope) || 
scopedAssertion.isScopeAll(scope)){

Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/ScopePanel.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/ScopePanel.java?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/ScopePanel.java 
(original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/ScopePanel.java Tue 
Feb  2 23:09:53 2010
@@ -19,11 +19,14 @@
 package org.apache.jmeter.util;
 
 import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 
 import javax.swing.BorderFactory;
 import javax.swing.ButtonGroup;
 import javax.swing.JPanel;
 import javax.swing.JRadioButton;
+import javax.swing.JTextField;
 
 import org.apache.jmeter.gui.util.HorizontalPanel;
 import org.apache.jmeter.util.JMeterUtils;
@@ -33,18 +36,31 @@
  * to apply the test element to the parent sample, the child samples or both.
  * 
  */
-public class ScopePanel extends JPanel {
+public class ScopePanel extends JPanel implements ActionListener {
 
     private static final long serialVersionUID = 240L;
 
     private final JRadioButton parentButton;
     private final JRadioButton childButton;
     private final JRadioButton allButton;
-    
-    public ScopePanel() {
+    private final JRadioButton variableButton;
+    private final JTextField variableName;
+
+    public ScopePanel(){
+        this(false);
+    }
+
+    public ScopePanel(boolean enableVariableButton) {
         allButton = new 
JRadioButton(JMeterUtils.getResString("sample_scope_all")); //$NON-NLS-1$
         parentButton = new 
JRadioButton(JMeterUtils.getResString("sample_scope_parent")); //$NON-NLS-1$
         childButton = new 
JRadioButton(JMeterUtils.getResString("sample_scope_children")); //$NON-NLS-1$
+        if (enableVariableButton) {
+            variableButton = new 
JRadioButton(JMeterUtils.getResString("sample_scope_variable")); //$NON-NLS-1$
+            variableName = new JTextField(10);
+        } else {
+            variableButton = null;
+            variableName = null;
+        }
         init();
     }
 
@@ -57,15 +73,20 @@
 
         parentButton.setSelected(true);
         
+        JPanel buttonPanel = new HorizontalPanel();
         ButtonGroup group = new ButtonGroup();
         group.add(allButton);
         group.add(parentButton);
         group.add(childButton);
-        JPanel buttonPanel = new HorizontalPanel();
         buttonPanel.add(parentButton);
         buttonPanel.add(childButton);
         buttonPanel.add(allButton);
-        
+        if (variableButton != null){
+            variableButton.addActionListener(this);
+            group.add(variableButton);
+            buttonPanel.add(variableButton);
+            buttonPanel.add(variableName);
+        }
         add(buttonPanel);
     }
 
@@ -92,6 +113,11 @@
         parentButton.setSelected(true);
     }
 
+    public void setScopeVariable(String value){
+        variableButton.setSelected(true);
+        variableName.setText(value);
+    }
+
     public boolean isScopeParent() {
         return parentButton.isSelected();
     }
@@ -103,4 +129,16 @@
     public boolean isScopeAll() {
         return allButton.isSelected();
     }
+
+    public boolean isScopeVariable() {
+        return variableButton.isSelected();
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        variableName.setEnabled(variableButton.isSelected());
+    }
+
+    public String getVariable() {
+        return variableName.getText();
+    }
 }

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Tue Feb  2 23:09:53 2010
@@ -182,6 +182,7 @@
 <li>Bug 48331 - XpathExtractor does not return XML string representations for 
a Nodeset</li>
 <li>Bug 48511 - add parent,child,all selection to regex extractor</li>
 <li>Add Sampler scope selection to XPathExtractor</li>
+<li>Response Assertion and Size Assertion can now be applied to a JMeter 
variable</li>
 </ul>
 
 <h3>Functions</h3>

Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/assertion/assertion.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/assertion/assertion.png?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
Binary files - no diff available.

Added: 
jakarta/jmeter/trunk/xdocs/images/screenshots/assertion/assertionscopevar.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/assertion/assertionscopevar.png?rev=905832&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
jakarta/jmeter/trunk/xdocs/images/screenshots/assertion/assertionscopevar.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/regex_extractor.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/regex_extractor.png?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
Binary files - no diff available.

Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/size_assertion.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/size_assertion.png?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
Binary files - no diff available.

Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=905832&r1=905831&r2=905832&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Tue Feb  2 
23:09:53 2010
@@ -3165,15 +3165,19 @@
     The default is to apply the assertion to the main sample only.
     If the Assertion supports this option, then there will be an entry on the 
GUI which looks like the following:
     <figure width="533" height="55" 
image="assertion/assertionscope.png">Assertion Scope</figure>
+    or the following
+    <figure width="765" height="55" 
image="assertion/assertionscopevar.png">Assertion Scope</figure>
     If a sub-sampler fails and the main sample is successful,
     then the main sample will be set to failed status and an Assertion Result 
will be added.
+    If the JMeter variable option is used, it is assumed to relate to the main 
sample, and
+    any failure will be applied to the main sample only.
     </p>
        <note>
        The variable <b>JMeterThread.last_sample_ok</b> is set to
        "true" or "false" after all assertions for a sampler have been run.
         </note>
 </description>
-<component name="Response Assertion" index="&sect-num;.5.1" 
anchor="basic_assertion"  width="761" height="422" 
screenshot="assertion/assertion.png">
+<component name="Response Assertion" index="&sect-num;.5.1" 
anchor="basic_assertion"  width="762" height="417" 
screenshot="assertion/assertion.png">
 
 <description><p>The response assertion control panel lets you add pattern 
strings to be compared against various
        fields of the response.
@@ -3212,13 +3216,14 @@
 </description>
 <properties>
         <property name="Name" required="No">Descriptive name for this element 
that is shown in the tree.</property>
-        <property name="Which samples to test" required="Yes">
+        <property name="Apply to:" required="Yes">
         This is for use with samplers that can generate sub-samples, 
         e.g. HTTP Sampler with embedded resources, Mail Reader or samples 
generated by the Transaction Controller.
         <ul>
         <li>Main sample only - assertion only applies to the main sample</li>
         <li>Sub-samples only - assertion only applies to the sub-samples</li>
         <li>Main sample and sub-samples - assertion applies to both.</li>
+        <li>JMeter Variable - assertion is to be applied to the contents of 
the named variable</li>
         </ul>
         </property>
         <property name="Response Field to Test" required="Yes">Instructs 
JMeter which field of the Response to test.
@@ -3284,22 +3289,31 @@
 user) is marked as a failed response.</p></description>
 
 <properties>
-<property name="Name" required="">Descriptive name for this element that is 
shown in the tree.</property>
+        <property name="Name" required="">Descriptive name for this element 
that is shown in the tree.</property>
         <property name="Duration in Milliseconds" required="Yes">The maximum 
number of milliseconds
         each response is allowed before being marked as failed.</property>
-
 </properties>
 </component>
 
-<component name="Size Assertion" index="&sect-num;.5.3"  width="331" 
height="346" screenshot="size_assertion.png">
+<component name="Size Assertion" index="&sect-num;.5.3"  width="732" 
height="358" screenshot="size_assertion.png">
 <description><p>The Size Assertion tests that each response contains the right 
number of bytes in it.  You can specify that
 the size be equal to, greater than, less than, or not equal to a given number 
of bytes.</p>
 <note>Since JMeter 2.3RC3, an empty response is treated as being 0 bytes 
rather than reported as an error.</note>
 </description>
 
 <properties>
-<property name="Name" required="">Descriptive name for this element that is 
shown in the tree.</property>
-        <property name="Size in bytes" required="Yes">The number of bytes to 
use in testing the size of the response.</property>
+        <property name="Name" required="">Descriptive name for this element 
that is shown in the tree.</property>
+        <property name="Apply to:" required="Yes">
+        This is for use with samplers that can generate sub-samples, 
+        e.g. HTTP Sampler with embedded resources, Mail Reader or samples 
generated by the Transaction Controller.
+        <ul>
+        <li>Main sample only - assertion only applies to the main sample</li>
+        <li>Sub-samples only - assertion only applies to the sub-samples</li>
+        <li>Main sample and sub-samples - assertion applies to both.</li>
+        <li>JMeter Variable - assertion is to be applied to the contents of 
the named variable</li>
+        </ul>
+        </property>
+        <property name="Size in bytes" required="Yes">The number of bytes to 
use in testing the size of the response (or value of the JMeter 
variable).</property>
         <property name="Type of Comparison" required="Yes">Whether to test 
that the response is equal to, greater than, less than,
         or not equal to, the number of bytes specified.</property>
 
@@ -4013,13 +4027,13 @@
        after all Assertions have been run.
        </p>
        </description>
-<component name="Regular Expression Extractor" index="&sect-num;.8.1"  
width="626" height="297" screenshot="regex_extractor.png">
+<component name="Regular Expression Extractor" index="&sect-num;.8.1"  
width="618" height="300" screenshot="regex_extractor.png">
 <description><p>Allows the user to extract values from a server response using 
a Perl-type regular expression.  As a post-processor,
 this element will execute after each Sample request in its scope, applying the 
regular expression, extracting the requested values,
 generate the template string, and store the result into the given variable 
name.</p></description>
 <properties>
         <property name="Name" required="">Descriptive name for this element 
that is shown in the tree.</property>
-        <property name="Which samples to process" required="Yes">
+        <property name="Apply to:" required="Yes">
         This is for use with samplers that can generate sub-samples, 
         e.g. HTTP Sampler with embedded resources, Mail Reader or samples 
generated by the Transaction Controller.
         <ul>
@@ -4115,7 +4129,7 @@
    </description>
    <properties>
        <property name="Name" required="No">Descriptive name for this element 
that is shown in the tree.</property>
-       <property name="Which samples to process" required="Yes">
+       <property name="Apply to:" required="Yes">
         This is for use with samplers that can generate sub-samples, 
         e.g. HTTP Sampler with embedded resources, Mail Reader or samples 
generated by the Transaction Controller.
         <ul>



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscr...@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-h...@jakarta.apache.org

Reply via email to