Bean Shell sampler With Example
String line = "quick, brown, fox, jumped, over";
String[] words = line.split(",");
for (int i = 0; i < words.length; i++) {
log.info(words[i]);
if (i == 2) {
log.info("Third word is: " + words[2]);
}
}
String str= "ram";
String str2="raj";
String str3;
log.info(words[2]+"concat"+words[3]);
str3= words[2].concat(words[3]);
//log.info();
log.info(str+str2);
vars.put("REF_NAME",str3);
Logs :
-----
13:42:21,452 INFO o.a.j.e.StandardJMeterEngine: Running the test!
, 13:42:21,453 INFO o.a.j.s.SampleEvent: List of sample_variables: []
, 13:42:21,454 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*)
, 13:42:21,613 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group
, 13:42:21,613 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group Thread Group.
, 13:42:21,613 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error
, 13:42:21,613 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 perThread=1000.0 delayedStart=false
, 13:42:21,622 INFO o.a.j.t.ThreadGroup: Started thread group number 1
, 13:42:21,622 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started
, 13:42:21,623 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
, 13:42:21,626 INFO o.a.j.u.BeanShellTestElement: quick
, 13:42:21,626 INFO o.a.j.u.BeanShellTestElement: brown
, 13:42:21,626 INFO o.a.j.u.BeanShellTestElement: fox
, 13:42:21,627 INFO o.a.j.u.BeanShellTestElement: Third word is: fox
, 13:42:21,627 INFO o.a.j.u.BeanShellTestElement: jumped
, 13:42:21,627 INFO o.a.j.u.BeanShellTestElement: over
, 13:42:21,628 INFO o.a.j.u.BeanShellTestElement: foxconcat jumped
, 13:42:21,628 INFO o.a.j.u.BeanShellTestElement: ramraj
, 13:42:21,629 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``String line = "quick, brown, fox, jumped, over"; String[] words = line.split("," . . . '' Token Parsing Error: Lexical error at line 18, column 19. Encountered: "\u201d" (8221), after : ""
, 13:42:21,629 WARN o.a.j.m.BeanShellPreProcessor: Problem in BeanShell script. org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``String line = "quick, brown, fox, jumped, over"; String[] words = line.split("," . . . '' Token Parsing Error: Lexical error at line 18, column 19. Encountered: "\u201d" (8221), after : ""
, 13:42:21,631 INFO o.a.j.u.BeanShellTestElement: quick
, 13:42:21,631 INFO o.a.j.u.BeanShellTestElement: brown
, 13:42:21,631 INFO o.a.j.u.BeanShellTestElement: fox
, 13:42:21,631 INFO o.a.j.u.BeanShellTestElement: Third word is: fox
, 13:42:21,631 INFO o.a.j.u.BeanShellTestElement: jumped
, 13:42:21,632 INFO o.a.j.u.BeanShellTestElement: over
, 13:42:21,632 INFO o.a.j.u.BeanShellTestElement: foxconcat jumped
, 13:42:21,633 INFO o.a.j.u.BeanShellTestElement: ramraj
, 13:42:21,633 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``String line = "quick, brown, fox, jumped, over"; String[] words = line.split("," . . . '' Token Parsing Error: Lexical error at line 18, column 19. Encountered: "\u201d" (8221), after : ""
, 13:42:21,633 WARN o.a.j.m.BeanShellPreProcessor: Problem in BeanShell script. org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``String line = "quick, brown, fox, jumped, over"; String[] words = line.split("," . . . '' Token Parsing Error: Lexical error at line 18, column 19. Encountered: "\u201d" (8221), after : ""
, 13:42:21,634 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-1
, 13:42:21,634 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1
, 13:42:21,635 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
, 13:42:21,635 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
, 13:43:49,597 INFO o.a.j.e.StandardJMeterEngine: Running the test!
, 13:43:49,597 INFO o.a.j.s.SampleEvent: List of sample_variables: []
, 13:43:49,600 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*)
, 13:43:49,770 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group
, 13:43:49,770 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group Thread Group.
, 13:43:49,770 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error
, 13:43:49,770 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 perThread=1000.0 delayedStart=false
, 13:43:49,780 INFO o.a.j.t.ThreadGroup: Started thread group number 1
, 13:43:49,781 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started
, 13:43:49,782 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
, 13:43:49,785 INFO o.a.j.u.BeanShellTestElement: quick
, 13:43:49,785 INFO o.a.j.u.BeanShellTestElement: brown
, 13:43:49,786 INFO o.a.j.u.BeanShellTestElement: fox
, 13:43:49,786 INFO o.a.j.u.BeanShellTestElement: Third word is: fox
, 13:43:49,786 INFO o.a.j.u.BeanShellTestElement: jumped
, 13:43:49,786 INFO o.a.j.u.BeanShellTestElement: over
, 13:43:49,787 INFO o.a.j.u.BeanShellTestElement: foxconcat jumped
, 13:43:49,787 INFO o.a.j.u.BeanShellTestElement: ramraj
, 13:43:49,790 INFO o.a.j.u.BeanShellTestElement: quick
, 13:43:49,791 INFO o.a.j.u.BeanShellTestElement: brown
, 13:43:49,791 INFO o.a.j.u.BeanShellTestElement: fox
, 13:43:49,791 INFO o.a.j.u.BeanShellTestElement: Third word is: fox
, 13:43:49,791 INFO o.a.j.u.BeanShellTestElement: jumped
, 13:43:49,791 INFO o.a.j.u.BeanShellTestElement: over
, 13:43:49,792 INFO o.a.j.u.BeanShellTestElement: foxconcat jumped
, 13:43:49,792 INFO o.a.j.u.BeanShellTestElement: ramraj
, 13:43:49,793 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-1
, 13:43:49,794 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1
, 13:43:49,795 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
, 13:43:49,795 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
Comments
Post a Comment