Hello sebb, I see you removed in the process: - clone - readResolve
Are you sure it's OK ? Thank you Regards Philippe On Thu, Nov 8, 2012 at 1:35 AM, <[email protected]> wrote: > Author: sebb > Date: Thu Nov 8 00:35:23 2012 > New Revision: 1406876 > > URL: http://svn.apache.org/viewvc?rev=1406876&view=rev > Log: > BSFTestElement and JSR223TestElement should use shared super-class for > common fields > Bugzilla Id: 54110 > > Added: > jmeter/trunk/src/core/org/apache/jmeter/util/ScriptingTestElement.java > (with props) > Modified: > jmeter/trunk/src/core/org/apache/jmeter/util/BSFTestElement.java > jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java > jmeter/trunk/xdocs/changes.xml > > Modified: jmeter/trunk/src/core/org/apache/jmeter/util/BSFTestElement.java > URL: > http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/BSFTestElement.java?rev=1406876&r1=1406875&r2=1406876&view=diff > > ============================================================================== > --- jmeter/trunk/src/core/org/apache/jmeter/util/BSFTestElement.java > (original) > +++ jmeter/trunk/src/core/org/apache/jmeter/util/BSFTestElement.java Thu > Nov 8 00:35:23 2012 > @@ -30,7 +30,6 @@ import org.apache.bsf.BSFManager; > import org.apache.commons.io.FileUtils; > import org.apache.jmeter.samplers.SampleResult; > import org.apache.jmeter.samplers.Sampler; > -import org.apache.jmeter.testelement.AbstractTestElement; > import org.apache.jmeter.threads.JMeterContext; > import org.apache.jmeter.threads.JMeterContextService; > import org.apache.jmeter.threads.JMeterVariables; > @@ -38,7 +37,7 @@ import org.apache.jorphan.logging.Loggin > import org.apache.jorphan.util.JOrphanUtils; > import org.apache.log.Logger; > > -public abstract class BSFTestElement extends AbstractTestElement > +public abstract class BSFTestElement extends ScriptingTestElement > implements Serializable, Cloneable > { > private static final long serialVersionUID = 233L; > @@ -55,38 +54,8 @@ public abstract class BSFTestElement ext > new String[]{"js"}); //$NON-NLS-1$ > } > > - //++ For TestBean implementations only > - private String parameters; // passed to file or script > - > - private String filename; // file to source (overrides script) > - > - private String script; // script (if file not provided) > - > - private String scriptLanguage; // BSF language to use > - //-- For TestBean implementations only > - > public BSFTestElement() { > super(); > - init(); > - } > - > - private void init() { > - parameters=""; // ensure variables are not null > - filename=""; > - script=""; > - scriptLanguage=""; > - } > - > - protected Object readResolve() { > - init(); > - return this; > - } > - > - @Override > - public Object clone() { > - BSFTestElement o = (BSFTestElement) super.clone(); > - o.init(); > - return o; > } > > protected BSFManager getManager() throws BSFException { > @@ -157,50 +126,4 @@ public abstract class BSFTestElement ext > } > } > > - /** > - * Return the script (TestBean version). > - * Must be overridden for subclasses that don't implement TestBean > - * otherwise the clone() method won't work. > - * > - * @return the script to execute > - */ > - public String getScript(){ > - return script; > - } > - > - /** > - * Set the script (TestBean version). > - * Must be overridden for subclasses that don't implement TestBean > - * otherwise the clone() method won't work. > - * > - * @param s the script to execute (may be blank) > - */ > - public void setScript(String s){ > - script=s; > - } > - > - public String getParameters() { > - return parameters; > - } > - > - public void setParameters(String s) { > - parameters = s; > - } > - > - public String getFilename() { > - return filename; > - } > - > - public void setFilename(String s) { > - filename = s; > - } > - > - public String getScriptLanguage() { > - return scriptLanguage; > - } > - > - public void setScriptLanguage(String s) { > - scriptLanguage = s; > - } > - > } > > Modified: > jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java > URL: > http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java?rev=1406876&r1=1406875&r2=1406876&view=diff > > ============================================================================== > --- jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java > (original) > +++ jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java > Thu Nov 8 00:35:23 2012 > @@ -39,7 +39,6 @@ import org.apache.commons.io.IOUtils; > import org.apache.commons.lang3.StringUtils; > import org.apache.jmeter.samplers.SampleResult; > import org.apache.jmeter.samplers.Sampler; > -import org.apache.jmeter.testelement.AbstractTestElement; > import org.apache.jmeter.testelement.TestStateListener; > import org.apache.jmeter.threads.JMeterContext; > import org.apache.jmeter.threads.JMeterContextService; > @@ -48,7 +47,7 @@ import org.apache.jorphan.logging.Loggin > import org.apache.jorphan.util.JOrphanUtils; > import org.apache.log.Logger; > > -public abstract class JSR223TestElement extends AbstractTestElement > +public abstract class JSR223TestElement extends ScriptingTestElement > implements Serializable, Cloneable, TestStateListener > { > /** > @@ -67,16 +66,8 @@ public abstract class JSR223TestElement > > private static final long serialVersionUID = 233L; > > - //++ For TestBean implementations only > - private String parameters; // passed to file or script > - > - private String filename; // file to source (overrides script) > - > - private String script; // script (if file not provided) > - > - private String scriptLanguage; // JSR223 language to use > - > private String cacheKey = ""; // If not empty then script in > ScriptText will be compiled and cached > + > /** > * Cache of compiled scripts > */ > @@ -84,31 +75,9 @@ public abstract class JSR223TestElement > private static final Map<String, CompiledScript> compiledScriptsCache > = > Collections.synchronizedMap( > new > LRUMap(JMeterUtils.getPropDefault("jsr223.compiled_scripts_cache_size", > 100))); > - //-- For TestBean implementations only > > public JSR223TestElement() { > super(); > - init(); > - } > - > - private void init() { > - parameters=""; // ensure variables are not null > - filename=""; > - script=""; > - scriptLanguage=""; > - cacheKey = ""; > - } > - > - protected Object readResolve() { > - init(); > - return this; > - } > - > - @Override > - public Object clone() { > - JSR223TestElement o = (JSR223TestElement) super.clone(); > - o.init(); > - return o; > } > > protected ScriptEngine getScriptEngine() throws ScriptException { > @@ -239,52 +208,6 @@ public abstract class JSR223TestElement > > > /** > - * Return the script (TestBean version). > - * Must be overridden for subclasses that don't implement TestBean > - * otherwise the clone() method won't work. > - * > - * @return the script to execute > - */ > - public String getScript(){ > - return script; > - } > - > - /** > - * Set the script (TestBean version). > - * Must be overridden for subclasses that don't implement TestBean > - * otherwise the clone() method won't work. > - * > - * @param s the script to execute (may be blank) > - */ > - public void setScript(String s){ > - script=s; > - } > - > - public String getParameters() { > - return parameters; > - } > - > - public void setParameters(String s) { > - parameters = s; > - } > - > - public String getFilename() { > - return filename; > - } > - > - public void setFilename(String s) { > - filename = s; > - } > - > - public String getScriptLanguage() { > - return scriptLanguage; > - } > - > - public void setScriptLanguage(String s) { > - scriptLanguage = s; > - } > - > - /** > * @return the cacheKey > */ > public String getCacheKey() { > > Added: > jmeter/trunk/src/core/org/apache/jmeter/util/ScriptingTestElement.java > URL: > http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/ScriptingTestElement.java?rev=1406876&view=auto > > ============================================================================== > --- jmeter/trunk/src/core/org/apache/jmeter/util/ScriptingTestElement.java > (added) > +++ jmeter/trunk/src/core/org/apache/jmeter/util/ScriptingTestElement.java > Thu Nov 8 00:35:23 2012 > @@ -0,0 +1,91 @@ > +/* > + * 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.util; > + > +import org.apache.jmeter.testelement.AbstractTestElement; > + > +/** > + * Common parent class for the {@link BSFTestElement} and {@link > JSR223TestElement} scripting test elements. > + * These also share the {@link ScriptingBeanInfoSupport} class for > configuration. > + */ > +public abstract class ScriptingTestElement extends AbstractTestElement { > + > + private static final long serialVersionUID = 281L; > + > + //++ For TestBean implementations only > + private String parameters = ""; // passed to file or script > + > + private String filename = ""; // file to source (overrides script) > + > + private String script = ""; // script (if file not provided) > + > + private String scriptLanguage = ""; // BSF/JSR223 language to use > + //-- For TestBean implementations only > + > + public ScriptingTestElement() { > + super(); > + } > + > + /** > + * Return the script (TestBean version). > + * Must be overridden for subclasses that don't implement TestBean > + * otherwise the clone() method won't work. > + * > + * @return the script to execute > + */ > + public String getScript(){ > + return script; > + } > + > + /** > + * Set the script (TestBean version). > + * Must be overridden for subclasses that don't implement TestBean > + * otherwise the clone() method won't work. > + * > + * @param s the script to execute (may be blank) > + */ > + public void setScript(String s){ > + script=s; > + } > + > + public String getParameters() { > + return parameters; > + } > + > + public void setParameters(String s) { > + parameters = s; > + } > + > + public String getFilename() { > + return filename; > + } > + > + public void setFilename(String s) { > + filename = s; > + } > + > + public String getScriptLanguage() { > + return scriptLanguage; > + } > + > + public void setScriptLanguage(String s) { > + scriptLanguage = s; > + } > + > +} > > Propchange: > jmeter/trunk/src/core/org/apache/jmeter/util/ScriptingTestElement.java > > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: > jmeter/trunk/src/core/org/apache/jmeter/util/ScriptingTestElement.java > > ------------------------------------------------------------------------------ > svn:keywords = Author Date Id Revision > > Modified: jmeter/trunk/xdocs/changes.xml > URL: > http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1406876&r1=1406875&r2=1406876&view=diff > > ============================================================================== > --- jmeter/trunk/xdocs/changes.xml (original) > +++ jmeter/trunk/xdocs/changes.xml Thu Nov 8 00:35:23 2012 > @@ -182,6 +182,7 @@ and right angle bracket (>) in search > <ul> > <li><bugzilla>53956</bugzilla> - Add ability to paste (a list of values) > from clipboard for Header Manager</li> > <li>Updated to HttpComponents Client 4.2.2 (from 4.2.1)</li> > +<li><bugzilla>54110</bugzilla> - BSFTestElement and JSR223TestElement > should use shared super-class for common fields</li> > </ul> > > </section> > > > -- Cordialement. Philippe Mouawad.
