floctc
14 years agoNew Contributor
Generate random number in Soap UI using Java
Hello,
I want to genere a random number inside an xml page opened in SoapUI, in order to test a web service.
I have tried this :
It works, but i need only 10 number digit (a phone number )
I thought I could use some java methods to get this :
Or :
I want to genere a random number inside an xml page opened in SoapUI, in order to test a web service.
I have tried this :
<msisdn>079999${=(int)(Math.random()*9999)} </msisdn>
It works, but i need only 10 number digit (a phone number )
I thought I could use some java methods to get this :
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(4);
nf.setGroupingUsed(false);
System.out.println(nf.format((int)(Math.random()*9999)));
Or :
System.out.println(String.format("%04d", new Random().nextInt(9999)));
Unfortunatly it does'nt work, because Groovy doesn't know NumberFormat or Radom...
Have you any solution for my problem?
Thanks for your help