jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepak Shetty <shet...@gmail.com>
Subject Re: Error invoking bsh method
Date Fri, 15 Oct 2010 17:30:55 GMT
hi
you have redeclared
*               FileInputStream  is = new FileInputStream(f1);

               byte[] buffer1 = new byte[8192];

               int  read = 0;
*
change to (only the SECOND time you use it)
*               is = new FileInputStream(f1);

               byte[] buffer1 = new byte[8192];

               read = 0;

*Your condition is
Failure=!(vars.get("output1").equals(vars.get("output2")));
but you never set values into vars for these variables (you will get a Null
pointer) . you should have
                        print("MD5 for 191 the first time is " +output);
                               *vars.put("output1", output);* //added this


                  print("MD5 for 191 the second time is:" + output1);
*                               vars.put("output2", output1);*

If you have problems copy your beanshell script to a Java Editor like
eclipse and get it to work there (you can spoof vars and Failure objects)

regards
deepak

On Fri, Oct 15, 2010 at 8:23 AM, Anupindi, Satish <
Satish_Anupindirao@cable.comcast.com> wrote:

>
>
> Hi,
>
> I get a Error invoking bsh method error when I invoke a BeanShell
> script. The whole error is :
>
> Assertion failure message: org.apache.jorphan.util.JMeterException:
> Error invoking bsh method: eval   Sourced file: inline evaluation of:
> ``import java.io.File; import java.io.FileInputStream; import
> java.io.FileNotFound . . . ''. the script runs fine on the BeanShell
> interpreter.
>
>
>
> import java.io.File;
>
> import java.io.FileInputStream;
>
> import java.io.FileNotFoundException;
>
> import java.io.IOException;
>
> import java.io.InputStream;
>
> import java.math.BigInteger;
>
> import java.security.MessageDigest;
>
> import java.security.NoSuchAlgorithmException;
>
>
>
>                print("where am i?");
>
>                MessageDigest digest = MessageDigest.getInstance("MD5");
>
>                File f = new File("c:\\Program
> Files\\jakarta-jmeter-2.3.4\\bin\\ubd191_a28_1.xml");
>
>                InputStream is = new FileInputStream(f);
>
>
>                byte[] buffer = new byte[8192];
>
>                int read = 0;
>
>                try {
>
>                                while( (read = is.read(buffer)) > 0) {
>
>                                                digest.update(buffer, 0,
> read);
>
>                                }
>
>                                byte[] md5sum = digest.digest();
>
>                                BigInteger bigInt = new BigInteger(1,
> md5sum);
>
>                                String output = bigInt.toString(16);
>
>                                print("MD5 for 191 the first time is " +
> output);
>
>                }
>
>                catch(IOException e) {
>
>                                throw new RuntimeException("Unable to
> process file for MD5", e);
>
>                }
>
>                finally {
>
>                                try {
>
>                                                is.close();
>
>                                }
>
>                                catch(IOException e) {
>
>                                                throw new
> RuntimeException("Unable to close input stream for MD5 calculation", e);
>
>                                }
>
>                }
>
>                File f1 = new File("c:\\Program
> Files\\jakarta-jmeter-2.3.4\\bin\\ubd191_a28_1.xml");
>
>                InputStream is = new FileInputStream(f1);
>
>                byte[] buffer1 = new byte[8192];
>
>                int read = 0;
>
>                try {
>
>                                while( (read = is.read(buffer1)) > 0) {
>
>                                                digest.update(buffer1,
> 0, read);
>
>                                }
>
>                                byte[] md5sum1 = digest.digest();
>
>                                BigInteger bigInt1 = new BigInteger(1,
> md5sum1);
>
>                                String output1 = bigInt1.toString(16);
>
>                                print("MD5 for 191 the second time is:"
> + output1);
>
>                                }
>
>                catch(IOException e) {
>
>                                throw new RuntimeException("Unable to
> process file for MD5", e);
>
>                }
>
>                finally {
>
>                                try {
>
>                                                is.close();
>
>                                }
>
>                                catch(IOException e) {
>
>                                                throw new
> RuntimeException("Unable to close input stream for MD5 calculation", e);
>
>                                }
>
>                }
>
>
> Failure=!(vars.get("output1").equals(vars.get("output2")));
>
>
>
>
>
>
>
>
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message