Hi All

  I am trying to generate alphanumeric characters IN Jmeter and pass this to
a http request in my test .

I have created a HTTP request and added beanshell preprocessor as a child to
thiis .

Can anyone assist me how to  work with the below code in beanshell
preprocessor  and  send the value from the code to http request.

For this i have wriiten a code in  Java   and the code is as follows


import static java.lang.Math.round;
import static java.lang.Math.random;
import static java.lang.Math.pow;
import static java.lang.Math.abs;
import static java.lang.Math.min;
import static org.apache.commons.lang.StringUtils.leftPad;
import java.util.*;

public class RandomAlphaNum {

static Random rnd = new Random();
  public static String gen(int length) {
    StringBuffer sb = new StringBuffer();
    for (int i = length; i > 0; i -= 12) {
      int n = min(12, abs(i));
      sb.append(leftPad(Long.toString(round(random() * pow(36, n)), 36), n,
'0'));
    }
    return sb.toString();
  }

public static void main(String ar[])
{
 String str = RandomAlphaNum.gen(2);
 System.out.println(str);

}

}
 Thanks in advance

rgds
Sudheer

Reply via email to