@Test public void testCommonsLang3RandomStringUtils() { String r1 = CommonsLang3RandomStringUtils.random(50); assertEquals(50, r1.length(), "random(50) length"); String r2 = CommonsLang3RandomStringUtils.random(50); assertEquals(50, r2.length(), "random(50) length"); assertTrue(!r1.equals(r2), "!r1.equals(r2)"); r1 = CommonsLang3RandomStringUtils.randomAscii(50); assertEquals(50, r1.length(), "randomAscii(50) length"); for(int i = 0; i < r1.length(); i++) { assertTrue(r1.charAt(i) >= 32 && r1.charAt(i) <= 127, "char between 32 and 127"); } r2 = CommonsLang3RandomStringUtils.randomAscii(50); assertTrue(!r1.equals(r2), "!r1.equals(r2)"); r1 = CommonsLang3RandomStringUtils.randomAlphabetic(50); assertEquals(50, r1.length(), "randomAlphabetic(50)"); for(int i = 0; i < r1.length(); i++) { assertTrue(Character.isLetter(r1.charAt(i)) && !Character.isDigit(r1.charAt(i)), "r1 contains alphabetic"); } r2 = CommonsLang3RandomStringUtils.randomAlphabetic(50); assertTrue(!r1.equals(r2), "!r1.equals(r2)"); r1 = CommonsLang3RandomStringUtils.randomAlphanumeric(50); assertEquals(50, r1.length(), "randomAlphanumeric(50)"); for(int i = 0; i < r1.length(); i++) { assertTrue(Character.isLetterOrDigit(r1.charAt(i)), "r1 contains alphanumeric"); } r2 = CommonsLang3RandomStringUtils.randomAlphabetic(50); assertTrue(!r1.equals(r2), "!r1.equals(r2)"); r1 = CommonsLang3RandomStringUtils.randomNumeric(50); assertEquals(50, r1.length(), "randomNumeric(50)"); for(int i = 0; i < r1.length(); i++) { assertTrue(Character.isDigit(r1.charAt(i)) && !Character.isLetter(r1.charAt(i)), "r1 contains numeric"); } r2 = CommonsLang3RandomStringUtils.randomNumeric(50); assertTrue(!r1.equals(r2), "!r1.equals(r2)"); String set = "abcdefg"; r1 = CommonsLang3RandomStringUtils.random(50, set); assertEquals(50, r1.length(), "random(50, \"abcdefg\")"); for(int i = 0; i < r1.length(); i++) { assertTrue(set.indexOf(r1.charAt(i)) > -1, "random char in set"); } r2 = CommonsLang3RandomStringUtils.random(50, set); assertTrue(!r1.equals(r2), "!r1.equals(r2)"); r1 = CommonsLang3RandomStringUtils.random(50, (String) null); assertEquals(50, r1.length(), "random(50) length"); r2 = CommonsLang3RandomStringUtils.random(50, (String) null); assertEquals(50, r2.length(), "random(50) length"); assertTrue(!r1.equals(r2), "!r1.equals(r2)"); set = "stuvwxyz"; r1 = CommonsLang3RandomStringUtils.random(50, set.toCharArray()); assertEquals(50, r1.length(), "random(50, \"stuvwxyz\")"); for(int i = 0; i < r1.length(); i++) { assertTrue(set.indexOf(r1.charAt(i)) > -1, "random char in set"); } r2 = CommonsLang3RandomStringUtils.random(50, set); assertTrue(!r1.equals(r2), "!r1.equals(r2)"); r1 = CommonsLang3RandomStringUtils.random(50, (char[]) null); assertEquals(50, r1.length(), "random(50) length"); r2 = CommonsLang3RandomStringUtils.random(50, (char[]) null); assertEquals(50, r2.length(), "random(50) length"); assertTrue(!r1.equals(r2), "!r1.equals(r2)"); final long seed = System.currentTimeMillis(); r1 = CommonsLang3RandomStringUtils.random(50,0,0,true,true,null,new Random(seed)); r2 = CommonsLang3RandomStringUtils.random(50,0,0,true,true,null,new Random(seed)); assertEquals(r1, r2, "r1.equals(r2)"); r1 = CommonsLang3RandomStringUtils.random(0); assertEquals("", r1, "random(0).equals(\"\")"); }
public CommonsLang3RandomStringUtils() { super(); }
CommonsLang3RandomStringUtils { public CommonsLang3RandomStringUtils() { super(); } }
CommonsLang3RandomStringUtils { public CommonsLang3RandomStringUtils() { super(); } CommonsLang3RandomStringUtils(); }
CommonsLang3RandomStringUtils { public CommonsLang3RandomStringUtils() { super(); } CommonsLang3RandomStringUtils(); static String random(final int count); static String randomAscii(final int count); static String randomAlphabetic(final int count); static String randomAlphanumeric(final int count); static String randomNumeric(final int count); static String random(final int count, final boolean letters, final boolean numbers); static String random(final int count, final int start, final int end, final boolean letters, final boolean numbers); static String random(final int count, final int start, final int end, final boolean letters, final boolean numbers, final char... chars); static String random(int count, int start, int end, final boolean letters, final boolean numbers,
                                final char[] chars, final Random random); static String random(final int count, final String chars); static String random(final int count, final char... chars); }
CommonsLang3RandomStringUtils { public CommonsLang3RandomStringUtils() { super(); } CommonsLang3RandomStringUtils(); static String random(final int count); static String randomAscii(final int count); static String randomAlphabetic(final int count); static String randomAlphanumeric(final int count); static String randomNumeric(final int count); static String random(final int count, final boolean letters, final boolean numbers); static String random(final int count, final int start, final int end, final boolean letters, final boolean numbers); static String random(final int count, final int start, final int end, final boolean letters, final boolean numbers, final char... chars); static String random(int count, int start, int end, final boolean letters, final boolean numbers,
                                final char[] chars, final Random random); static String random(final int count, final String chars); static String random(final int count, final char... chars);  }