I figured this one out, its extremely simple.
Basically just call the following function in a Beanshell script (make sure
to include the function using the property
beanshell.init.function=[filename-of-functions])
String sha1FromFilename(String filename) {
byte[] bytes = FileUtils.readFileToByteArray(new File(filename));
return DigestUtils.shaHex(bytes);
}
Example:
put a file named user.properties in the location of your .jmx file
put the following line in that file:
beanshell.postprocessor.init=functions.bsh
(replace postprocessor with sampler/preprocessor depending on where you'll
be calling this from).
Now in your functions.bsh file include the sha1FromFilename function
mentioned above.
Now from your beanshell script just call that function, passing in the path
to the filename which you want to compute the sha1 for.
mwolfe38 wrote:
>
> I have a jmeter task that automates the process of uploading some file to
> a server. With this upload I have to send what the sha1 is of the file.
> Right now I do it manually using the command fciv -sha1 [filename]
> which will print the sha1.
> I would like to somehow capture this programatically and store it in a
> variable by using a bsf preprocessor rather than doing it manually and
> putting the value into a user defined variable.
>
> Any ideas how i can get the sha1 of a file (either by calling a command
> from bsf or by using some library that can compute a sha1 in a bsf
> language)?
>
--
View this message in context:
http://old.nabble.com/Calling-a-batch-script-from-a-bsf-preprocessor-to-get-SHA1-tp25997427p26277661.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]