RandomStringUtils { public static String randomNumeric(int length) { return new RandomStringGenerator.Builder() .filteredBy(NUMBERS) .build().generate(length); } private  RandomStringUtils(); static String random(int length); static String randomLetters(int length); static String randomNumeric(int length);  }
@Test public void testRandomNumbers() throws Exception { for (int length = 1; length < 10; length++) { String value = RandomStringUtils.randomNumeric(length); Assert.assertEquals( "random string has a length of " + length, length, value.length()); Assert.assertEquals( "random string is numeric", true, isAsciiNumeric(value)); } }