StringUtils { public static String makeRandomId(int length) { char[] chars = new char[length]; for (int ix = 0; ix < length; ix++) chars[ix] = (char) (65 + rand.nextInt(26)); return new String(chars); }  static String escapeHTMLEntities(String value); static void escapeHTMLEntities(String value, Writer out); static String makeRandomId(int length); static String normalizeId(String name); static final String VERY_UNLIKELY_STRING; }
@Test public void testMakeRandomId() { String id = StringUtils.makeRandomId(10); Assert.assertTrue("random id had wrong length", id.length() == 10); }
@Test public void testMakeTwoRandomIds() { String id1 = StringUtils.makeRandomId(10); String id2 = StringUtils.makeRandomId(10); Assert.assertTrue("random id1 had wrong length", id1.length() == 10); Assert.assertTrue("random id2 had wrong length", id2.length() == 10); Assert.assertTrue("random ids are equal!", !id1.equals(id2)); }