ShortID { public static String randomID() { return INSTANCE.generate(); } private  ShortID(Random random, String alphabet, long reduceTime, int version, int clusterWorkerId); static String randomID(); String generate(); static final String DEFAULT_ALPHABET; static final String DOLLARAT_ALPHABET; }
@Test public void testUnique() { int num = 20000; Set<String> set = new HashSet<>(num); int maxlen = 0; for(int i=0;i<num;i++) { String id = ShortID.randomID(); maxlen = Math.max(maxlen, id.length()); set.add(id); } assertTrue(maxlen < 17); assertEquals(num, set.size()); }