You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Yevgeniy Grimaylo <Ye...@synopsys.com> on 2017/10/25 15:26:40 UTC
BeanShell Sampler jmx API method: setScript(string) does not set
string into Script area of BeanShell GUI config element
Hello,
I am trying to create jmeter jmx file at run time by using jmx api in java
I have the following code, which should create BeanShell Sampler gui config element with the BeanShell Sampler name, comments and script itself
But, after script execution, I open generated by java jmx file, I noticed that only BeanShell Sampler name and comments are shown, but not Script
So, my question is: how can I create BeanShell Sampler GUI Config element with actual script shown under Script Area ?
I am using jmeter jmx api version 3.3 and java 1.8
Java code fragment:
BeanShellSampler beanshell = new BeanShellSampler();
beanshell.setName("BeanShell Sampler");
beanshell.setComment("This is beanshell sampler");
beanshell.setScript("BeanShell scripting goes here");
beanshell.setEnabled(true);
beanshell.setProperty(TestElement.TEST_CLASS, BeanShellSampler.class.getName());
beanshell.setProperty(TestElement.GUI_CLASS, BeanShellSamplerGui.class.getName());
// Test Plan
TestPlan testPlan = new TestPlan(testPlanName);
testPlan.setEnabled(true);
testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());
testPlan.setProperty(TestElement.GUI_CLASS, TestPlanGui.class.getName());
testPlan.setUserDefinedVariables((Arguments) new ArgumentsPanel().createTestElement());
// Construct Test Plan from previously initialized elements
testPlanTree.add(testPlan);
HashTree threadGroupHashTree = testPlanTree.add(testPlan, threadGroup);
threadGroupHashTree.add(beanshell);
Thanks in advance for your feedback
Yevgeniy Grimaylo
Staff QA Member
Synopsys
(617) 2854671
20 Park Plaza, Suite 1400
Boston, MA 02116
Re: BeanShell Sampler jmx API method: setScript(string) does not set
string into Script area of BeanShell GUI config element
Posted by Philippe Mouawad <ph...@gmail.com>.
Still :-) , follow my advice and move away from Beanshell
We'll probably drop it in upcoming future.
Regards
On Wed, Oct 25, 2017 at 6:49 PM, Yevgeniy Grimaylo <
Yevgeniy.Grimaylo@synopsys.com> wrote:
> Thank you so much, the code below resolved my problem
>
> Yevgeniy Grimaylo
> Staff QA Member
> Synopsys
> (617) 2854671
> 20 Park Plaza, Suite 1400
> Boston, MA 02116
>
> On 10/25/17, 12:45 PM, "Philippe Mouawad" <ph...@gmail.com>
> wrote:
>
> Did you try:
> beanshell.setProperty(BeanShellSampler.SCRIPT, "script code");
>
> By the way, you shouldn't be using Beanshell anymore and look at
> migrating
> to JSR222 + Groovy + Cache.
>
> Regards
>
> On Wed, Oct 25, 2017 at 5:26 PM, Yevgeniy Grimaylo <
> Yevgeniy.Grimaylo@synopsys.com> wrote:
>
> > Hello,
> > I am trying to create jmeter jmx file at run time by using jmx api
> in java
> > I have the following code, which should create BeanShell Sampler gui
> > config element with the BeanShell Sampler name, comments and script
> itself
> > But, after script execution, I open generated by java jmx file, I
> noticed
> > that only BeanShell Sampler name and comments are shown, but not
> Script
> > So, my question is: how can I create BeanShell Sampler GUI Config
> element
> > with actual script shown under Script Area ?
> > I am using jmeter jmx api version 3.3 and java 1.8
> > Java code fragment:
> > BeanShellSampler beanshell = new BeanShellSampler();
> > beanshell.setName("BeanShell Sampler");
> > beanshell.setComment("This is beanshell sampler");
> > beanshell.setScript("BeanShell scripting goes here");
> > beanshell.setEnabled(true);
> > beanshell.setProperty(TestElement.TEST_CLASS,
> BeanShellSampler.class.
> > getName());
> > beanshell.setProperty(TestElement.GUI_CLASS,
> BeanShellSamplerGui.class.
> > getName());
> > // Test Plan
> > TestPlan testPlan = new TestPlan(testPlanName);
> > testPlan.setEnabled(true);
> > testPlan.setProperty(TestElement.TEST_CLASS,
> TestPlan.class.getName());
> > testPlan.setProperty(TestElement.GUI_CLASS,
> TestPlanGui.class.getName());
> > testPlan.setUserDefinedVariables((Arguments) new ArgumentsPanel().
> > createTestElement());
> > // Construct Test Plan from previously initialized elements
> > testPlanTree.add(testPlan);
> > HashTree threadGroupHashTree = testPlanTree.add(testPlan,
> threadGroup);
> > threadGroupHashTree.add(beanshell);
> >
> >
> > Thanks in advance for your feedback
> > Yevgeniy Grimaylo
> > Staff QA Member
> > Synopsys
> > (617) 2854671
> > 20 Park Plaza, Suite 1400
> > Boston, MA 02116
> >
>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>
--
Cordialement.
Philippe Mouawad.
Re: BeanShell Sampler jmx API method: setScript(string) does not
set string into Script area of BeanShell GUI config element
Posted by Yevgeniy Grimaylo <Ye...@synopsys.com>.
Thank you so much, the code below resolved my problem
Yevgeniy Grimaylo
Staff QA Member
Synopsys
(617) 2854671
20 Park Plaza, Suite 1400
Boston, MA 02116
On 10/25/17, 12:45 PM, "Philippe Mouawad" <ph...@gmail.com> wrote:
Did you try:
beanshell.setProperty(BeanShellSampler.SCRIPT, "script code");
By the way, you shouldn't be using Beanshell anymore and look at migrating
to JSR222 + Groovy + Cache.
Regards
On Wed, Oct 25, 2017 at 5:26 PM, Yevgeniy Grimaylo <
Yevgeniy.Grimaylo@synopsys.com> wrote:
> Hello,
> I am trying to create jmeter jmx file at run time by using jmx api in java
> I have the following code, which should create BeanShell Sampler gui
> config element with the BeanShell Sampler name, comments and script itself
> But, after script execution, I open generated by java jmx file, I noticed
> that only BeanShell Sampler name and comments are shown, but not Script
> So, my question is: how can I create BeanShell Sampler GUI Config element
> with actual script shown under Script Area ?
> I am using jmeter jmx api version 3.3 and java 1.8
> Java code fragment:
> BeanShellSampler beanshell = new BeanShellSampler();
> beanshell.setName("BeanShell Sampler");
> beanshell.setComment("This is beanshell sampler");
> beanshell.setScript("BeanShell scripting goes here");
> beanshell.setEnabled(true);
> beanshell.setProperty(TestElement.TEST_CLASS, BeanShellSampler.class.
> getName());
> beanshell.setProperty(TestElement.GUI_CLASS, BeanShellSamplerGui.class.
> getName());
> // Test Plan
> TestPlan testPlan = new TestPlan(testPlanName);
> testPlan.setEnabled(true);
> testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());
> testPlan.setProperty(TestElement.GUI_CLASS, TestPlanGui.class.getName());
> testPlan.setUserDefinedVariables((Arguments) new ArgumentsPanel().
> createTestElement());
> // Construct Test Plan from previously initialized elements
> testPlanTree.add(testPlan);
> HashTree threadGroupHashTree = testPlanTree.add(testPlan, threadGroup);
> threadGroupHashTree.add(beanshell);
>
>
> Thanks in advance for your feedback
> Yevgeniy Grimaylo
> Staff QA Member
> Synopsys
> (617) 2854671
> 20 Park Plaza, Suite 1400
> Boston, MA 02116
>
--
Cordialement.
Philippe Mouawad.
Re: BeanShell Sampler jmx API method: setScript(string) does not set
string into Script area of BeanShell GUI config element
Posted by Philippe Mouawad <ph...@gmail.com>.
Did you try:
beanshell.setProperty(BeanShellSampler.SCRIPT, "script code");
By the way, you shouldn't be using Beanshell anymore and look at migrating
to JSR222 + Groovy + Cache.
Regards
On Wed, Oct 25, 2017 at 5:26 PM, Yevgeniy Grimaylo <
Yevgeniy.Grimaylo@synopsys.com> wrote:
> Hello,
> I am trying to create jmeter jmx file at run time by using jmx api in java
> I have the following code, which should create BeanShell Sampler gui
> config element with the BeanShell Sampler name, comments and script itself
> But, after script execution, I open generated by java jmx file, I noticed
> that only BeanShell Sampler name and comments are shown, but not Script
> So, my question is: how can I create BeanShell Sampler GUI Config element
> with actual script shown under Script Area ?
> I am using jmeter jmx api version 3.3 and java 1.8
> Java code fragment:
> BeanShellSampler beanshell = new BeanShellSampler();
> beanshell.setName("BeanShell Sampler");
> beanshell.setComment("This is beanshell sampler");
> beanshell.setScript("BeanShell scripting goes here");
> beanshell.setEnabled(true);
> beanshell.setProperty(TestElement.TEST_CLASS, BeanShellSampler.class.
> getName());
> beanshell.setProperty(TestElement.GUI_CLASS, BeanShellSamplerGui.class.
> getName());
> // Test Plan
> TestPlan testPlan = new TestPlan(testPlanName);
> testPlan.setEnabled(true);
> testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());
> testPlan.setProperty(TestElement.GUI_CLASS, TestPlanGui.class.getName());
> testPlan.setUserDefinedVariables((Arguments) new ArgumentsPanel().
> createTestElement());
> // Construct Test Plan from previously initialized elements
> testPlanTree.add(testPlan);
> HashTree threadGroupHashTree = testPlanTree.add(testPlan, threadGroup);
> threadGroupHashTree.add(beanshell);
>
>
> Thanks in advance for your feedback
> Yevgeniy Grimaylo
> Staff QA Member
> Synopsys
> (617) 2854671
> 20 Park Plaza, Suite 1400
> Boston, MA 02116
>
--
Cordialement.
Philippe Mouawad.