/** * Create a random Unicode string. */ public static String randomString() { return randomString(new Random()); }
/** * Create a random Unicode string. */ public static String randomString() { return randomString(new Random()); }
/** * Create a random Unicode string. */ public static String randomString() { return randomString(new Random()); }
/** * Create a random length Unicode string based on the {@link Random} object passed in. */ public static String randomString(final Random r) { return randomString(r, Math.abs(r.nextInt(257))); }
/** * Create a random length Unicode string based on the {@link Random} object passed in. */ public static String randomString(final Random r) { return randomString(r, Math.abs(r.nextInt(257))); }
/** * Create a random length Unicode string based on the {@link Random} object * passed in. */ public static String randomString(Random r) { return randomString(r, Math.abs(r.nextInt(257))); }
public TestBean(Random r) { if (r != null) { arg1 = StringUtil.randomString(r, 25); arg2 = r.nextInt(); arg3 = r.nextLong(); arg4 = r.nextDouble(); arg5 = (byte) r.nextInt(); } }
static List<Object> randomList(final Random r, final int size, final char[] invalid, final char valid) { List<Object> ret = new ArrayList<>(); for (int i = 0; i < size; i++) { final Object add; if (r.nextBoolean()) { add = r.nextInt(); } else if (r.nextBoolean()) { add = r.nextDouble(); } else { String str = StringUtil.randomString(r, r.nextInt(30)); for (char c : invalid) { // replace all w/ 'a'.. str = str.replace(c, valid); } add = str; } ret.add(add); } return ret; }
@Test public void testRandomString() { // just execute it because it doesn't really matter.. String s = StringUtil.randomString(); assertTrue(s.length() < 257); }