jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1310745 - in /jmeter/trunk: src/core/org/apache/jmeter/engine/util/ src/core/org/apache/jmeter/samplers/ src/core/org/apache/jmeter/threads/ src/protocol/java/org/apache/jmeter/protocol/java/sampler/ src/protocol/jdbc/org/apache/jmeter/pro...
Date Sat, 07 Apr 2012 12:19:19 GMT
Author: pmouawad
Date: Sat Apr  7 12:19:19 2012
New Revision: 1310745

URL: http://svn.apache.org/viewvc?rev=1310745&view=rev
Log:
Bug 53042 - Introduce a new Interface to be implemented by AbstractSampler to allow Sampler
to decide wether a config element applies to Sampler

Also made ConfigTestElement that have SimpleConfigGui as GUI_CLASS be applied where they returned
false before

Added:
    jmeter/trunk/src/core/org/apache/jmeter/engine/util/ConfigMergabilityIndicator.java  
(with props)
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/samplers/AbstractSampler.java
    jmeter/trunk/src/core/org/apache/jmeter/samplers/Sampler.java
    jmeter/trunk/src/core/org/apache/jmeter/threads/TestCompiler.java
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSampler.java
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BeanShellSampler.java
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JSR223Sampler.java
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java
    jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
    jmeter/trunk/xdocs/changes.xml

Added: jmeter/trunk/src/core/org/apache/jmeter/engine/util/ConfigMergabilityIndicator.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/engine/util/ConfigMergabilityIndicator.java?rev=1310745&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/engine/util/ConfigMergabilityIndicator.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/engine/util/ConfigMergabilityIndicator.java Sat
Apr  7 12:19:19 2012
@@ -0,0 +1,37 @@
+/*
+ * 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.engine.util;
+
+import org.apache.jmeter.config.ConfigTestElement;
+import org.apache.jmeter.threads.TestCompiler;
+
+/**
+ * Interface that gives a hint about the merge policy to apply between Samplers and Config
elements
+ * @see TestCompiler#configureWithConfigElements
+ * @since 2.7 
+ */
+public interface ConfigMergabilityIndicator {
+
+    /**
+     * Does configElement apply to Sampler 
+     * @param configElement {@link ConfigTestElement}
+     * @return boolean
+     */
+    public boolean applies(ConfigTestElement configElement);
+}

Propchange: jmeter/trunk/src/core/org/apache/jmeter/engine/util/ConfigMergabilityIndicator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/AbstractSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/AbstractSampler.java?rev=1310745&r1=1310744&r2=1310745&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/AbstractSampler.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/AbstractSampler.java Sat Apr  7 12:19:19
2012
@@ -19,9 +19,10 @@
 package org.apache.jmeter.samplers;
 
 import org.apache.jmeter.config.ConfigTestElement;
+import org.apache.jmeter.engine.util.ConfigMergabilityIndicator;
 import org.apache.jmeter.testelement.AbstractTestElement;
 
-public abstract class AbstractSampler extends AbstractTestElement implements Sampler {
+public abstract class AbstractSampler extends AbstractTestElement implements Sampler, ConfigMergabilityIndicator
{
     private static final long serialVersionUID = 240L;
 
     /**

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/Sampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/Sampler.java?rev=1310745&r1=1310744&r2=1310745&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/Sampler.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/Sampler.java Sat Apr  7 12:19:19 2012
@@ -18,7 +18,6 @@
 
 package org.apache.jmeter.samplers;
 
-import org.apache.jmeter.config.ConfigTestElement;
 import org.apache.jmeter.testelement.TestElement;
 
 /**
@@ -33,11 +32,4 @@ public interface Sampler extends java.io
      * into a SampleResult.
      */
     public SampleResult sample(Entry e);
-    
-    /**
-     * Does configElement apply to Sampler 
-     * @param configElement {@link ConfigTestElement}
-     * @return boolean
-     */
-    public boolean applies(ConfigTestElement configElement);
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/TestCompiler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/TestCompiler.java?rev=1310745&r1=1310744&r2=1310745&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/threads/TestCompiler.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/threads/TestCompiler.java Sat Apr  7 12:19:19
2012
@@ -32,6 +32,7 @@ import org.apache.jmeter.control.Control
 import org.apache.jmeter.control.TransactionController;
 import org.apache.jmeter.control.TransactionSampler;
 import org.apache.jmeter.engine.event.LoopIterationListener;
+import org.apache.jmeter.engine.util.ConfigMergabilityIndicator;
 import org.apache.jmeter.engine.util.NoConfigMerge;
 import org.apache.jmeter.processor.PostProcessor;
 import org.apache.jmeter.processor.PreProcessor;
@@ -288,7 +289,12 @@ public class TestCompiler implements Has
         for (ConfigTestElement config  : configs) {
             if (!(config instanceof NoConfigMerge)) 
             {
-                if(sam.applies(config)) {
+                if(sam instanceof ConfigMergabilityIndicator) {
+                    if(((ConfigMergabilityIndicator)sam).applies(config)) {
+                        sam.addTestElement(config);
+                    }
+                } else {
+                    // Backward compatibility
                     sam.addTestElement(config);
                 }
             }

Modified: jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSampler.java?rev=1310745&r1=1310744&r2=1310745&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSampler.java
(original)
+++ jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSampler.java
Sat Apr  7 12:19:19 2012
@@ -19,16 +19,21 @@
 package org.apache.jmeter.protocol.java.sampler;
 
 import java.io.FileInputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.bsf.BSFEngine;
 import org.apache.bsf.BSFException;
 import org.apache.bsf.BSFManager;
 import org.apache.commons.io.IOUtils;
 import org.apache.jmeter.config.ConfigTestElement;
+import org.apache.jmeter.engine.util.ConfigMergabilityIndicator;
 import org.apache.jmeter.samplers.Entry;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.samplers.Sampler;
 import org.apache.jmeter.testbeans.TestBean;
+import org.apache.jmeter.testelement.TestElement;
 import org.apache.jmeter.util.BSFTestElement;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
@@ -37,7 +42,11 @@ import org.apache.log.Logger;
  * A sampler which understands BSF
  *
  */
-public class BSFSampler extends BSFTestElement implements Sampler, TestBean {
+public class BSFSampler extends BSFTestElement implements Sampler, TestBean, ConfigMergabilityIndicator
{
+
+    private static final Set<String> APPLIABLE_CONFIG_CLASSES = new HashSet<String>(
+            Arrays.asList(new String[]{
+                    "org.apache.jmeter.config.gui.SimpleConfigGui"}));
 
     private static final long serialVersionUID = 240L;
 
@@ -126,12 +135,13 @@ public class BSFSampler extends BSFTestE
         }
 
         return res;
-    }
-    
+    }    
+
     /**
-     * {@inheritDoc}
+     * @see org.apache.jmeter.samplers.AbstractSampler#applies(org.apache.jmeter.config.ConfigTestElement)
      */
     public boolean applies(ConfigTestElement configElement) {
-        return false;
+        String guiClass = configElement.getProperty(TestElement.GUI_CLASS).getStringValue();
+        return APPLIABLE_CONFIG_CLASSES.contains(guiClass);
     }
 }

Modified: jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BeanShellSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BeanShellSampler.java?rev=1310745&r1=1310744&r2=1310745&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BeanShellSampler.java
(original)
+++ jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BeanShellSampler.java
Sat Apr  7 12:19:19 2012
@@ -18,11 +18,17 @@
 
 package org.apache.jmeter.protocol.java.sampler;
 
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.jmeter.config.ConfigTestElement;
+import org.apache.jmeter.engine.util.ConfigMergabilityIndicator;
 import org.apache.jmeter.samplers.Entry;
 import org.apache.jmeter.samplers.Interruptible;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.samplers.Sampler;
+import org.apache.jmeter.testelement.TestElement;
 import org.apache.jmeter.util.BeanShellInterpreter;
 import org.apache.jmeter.util.BeanShellTestElement;
 import org.apache.jorphan.logging.LoggingManager;
@@ -33,8 +39,12 @@ import org.apache.log.Logger;
  * A sampler which understands BeanShell
  *
  */
-public class BeanShellSampler extends BeanShellTestElement implements Sampler, Interruptible
+public class BeanShellSampler extends BeanShellTestElement implements Sampler, Interruptible,
ConfigMergabilityIndicator
 {
+    private static final Set<String> APPLIABLE_CONFIG_CLASSES = new HashSet<String>(
+            Arrays.asList(new String[]{
+                    "org.apache.jmeter.config.gui.SimpleConfigGui"}));
+    
     private static final Logger log = LoggingManager.getLoggerForClass();
 
     private static final long serialVersionUID = 3;
@@ -166,10 +176,10 @@ public class BeanShellSampler extends Be
     }
 
     /**
-     * No config element applies to BeanShellSampler
      * @see org.apache.jmeter.samplers.AbstractSampler#applies(org.apache.jmeter.config.ConfigTestElement)
      */
     public boolean applies(ConfigTestElement configElement) {
-        return false;
+        String guiClass = configElement.getProperty(TestElement.GUI_CLASS).getStringValue();
+        return APPLIABLE_CONFIG_CLASSES.contains(guiClass);
     }
 }
\ No newline at end of file

Modified: jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JSR223Sampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JSR223Sampler.java?rev=1310745&r1=1310744&r2=1310745&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JSR223Sampler.java
(original)
+++ jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JSR223Sampler.java
Sat Apr  7 12:19:19 2012
@@ -19,21 +19,29 @@
 package org.apache.jmeter.protocol.java.sampler;
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
 
 import javax.script.ScriptEngineManager;
 import javax.script.ScriptException;
 
 import org.apache.jmeter.config.ConfigTestElement;
+import org.apache.jmeter.engine.util.ConfigMergabilityIndicator;
 import org.apache.jmeter.samplers.Entry;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.samplers.Sampler;
 import org.apache.jmeter.testbeans.TestBean;
+import org.apache.jmeter.testelement.TestElement;
 import org.apache.jmeter.util.JSR223TestElement;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
 
-public class JSR223Sampler extends JSR223TestElement implements Cloneable, Sampler, TestBean
{
-
+public class JSR223Sampler extends JSR223TestElement implements Cloneable, Sampler, TestBean,
ConfigMergabilityIndicator {
+    private static final Set<String> APPLIABLE_CONFIG_CLASSES = new HashSet<String>(
+            Arrays.asList(new String[]{
+                    "org.apache.jmeter.config.gui.SimpleConfigGui"}));
+    
     private static final long serialVersionUID = 234L;
 
     private static final Logger log = LoggingManager.getLoggerForClass();
@@ -81,9 +89,10 @@ public class JSR223Sampler extends JSR22
     }
 
     /**
-     * {@inheritDoc}
+     * @see org.apache.jmeter.samplers.AbstractSampler#applies(org.apache.jmeter.config.ConfigTestElement)
      */
     public boolean applies(ConfigTestElement configElement) {
-        return true;
+        String guiClass = configElement.getProperty(TestElement.GUI_CLASS).getStringValue();
+        return APPLIABLE_CONFIG_CLASSES.contains(guiClass);
     }
 }

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java?rev=1310745&r1=1310744&r2=1310745&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java
(original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java
Sat Apr  7 12:19:19 2012
@@ -20,14 +20,19 @@ package org.apache.jmeter.protocol.jdbc.
 
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.jmeter.config.ConfigTestElement;
+import org.apache.jmeter.engine.util.ConfigMergabilityIndicator;
 import org.apache.jmeter.protocol.jdbc.AbstractJDBCTestElement;
 import org.apache.jmeter.protocol.jdbc.config.DataSourceElement;
 import org.apache.jmeter.samplers.Entry;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.samplers.Sampler;
 import org.apache.jmeter.testbeans.TestBean;
+import org.apache.jmeter.testelement.TestElement;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
 
@@ -35,7 +40,10 @@ import org.apache.log.Logger;
  * A sampler which understands JDBC database requests.
  *
  */
-public class JDBCSampler extends AbstractJDBCTestElement implements Sampler, TestBean {
+public class JDBCSampler extends AbstractJDBCTestElement implements Sampler, TestBean, ConfigMergabilityIndicator
{
+    private static final Set<String> APPLIABLE_CONFIG_CLASSES = new HashSet<String>(
+            Arrays.asList(new String[]{
+                    "org.apache.jmeter.config.gui.SimpleConfigGui"}));
     
     private static final long serialVersionUID = 234L;
     
@@ -96,9 +104,10 @@ public class JDBCSampler extends Abstrac
     }
 
     /**
-     * {@inheritDoc}
+     * @see org.apache.jmeter.samplers.AbstractSampler#applies(org.apache.jmeter.config.ConfigTestElement)
      */
     public boolean applies(ConfigTestElement configElement) {
-        return true;
+        String guiClass = configElement.getProperty(TestElement.GUI_CLASS).getStringValue();
+        return APPLIABLE_CONFIG_CLASSES.contains(guiClass);
     }
 }

Modified: jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java?rev=1310745&r1=1310744&r2=1310745&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
(original)
+++ jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
Sat Apr  7 12:19:19 2012
@@ -22,9 +22,12 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.Enumeration;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import javax.mail.AuthenticationFailedException;
 import javax.mail.BodyPart;
@@ -44,6 +47,7 @@ import org.apache.jmeter.samplers.Abstra
 import org.apache.jmeter.samplers.Entry;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.services.FileServer;
+import org.apache.jmeter.testelement.TestElement;
 import org.apache.jmeter.testelement.property.CollectionProperty;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
@@ -59,6 +63,10 @@ public class SmtpSampler extends Abstrac
 
     private static final long serialVersionUID = 1L;
 
+    private static final Set<String> APPLIABLE_CONFIG_CLASSES = new HashSet<String>(
+            Arrays.asList(new String[]{
+                    "org.apache.jmeter.config.gui.SimpleConfigGui"}));
+
     private static final Logger log = LoggingManager.getLoggerForClass();
 
     //+JMX file attribute names - do not change any values!
@@ -373,12 +381,12 @@ public class SmtpSampler extends Abstrac
         }
     }
     
+
     /**
-     * No config element associated
      * @see org.apache.jmeter.samplers.AbstractSampler#applies(org.apache.jmeter.config.ConfigTestElement)
      */
-    @Override
     public boolean applies(ConfigTestElement configElement) {
-        return false;
+        String guiClass = configElement.getProperty(TestElement.GUI_CLASS).getStringValue();
+        return APPLIABLE_CONFIG_CLASSES.contains(guiClass);
     }
 }
\ No newline at end of file

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1310745&r1=1310744&r2=1310745&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Apr  7 12:19:19 2012
@@ -36,6 +36,10 @@ Earlier changes are detailed in the <a h
 
 <h2>New and Noteworthy</h2>
 
+<p>
+Plugin writers : New interface org.apache.jmeter.engine.util.ConfigMergabilityIndicator has
been introduced to tell wether a ConfigTestElement can be merged in Sampler(see Bug 53042):<br/>
+public boolean applies(ConfigTestElement configElement);
+</p>
 
 <!--  =================== Known bugs =================== -->
 
@@ -77,10 +81,6 @@ JMeter now expands the Test Plan tree to
 Graph Full Results Listener has been removed.
 </p>
 
-<p>
-Plugin writers : Sampler interface contains a new method (see Bug 53042):<br/>
-public boolean applies(ConfigTestElement configElement);
-</p>
 <!-- =================== Bug fixes =================== -->
 
 <h2>Bug fixes</h2>



Mime
View raw message