CodeGenerator { public static String getRandomUrlToken() { SecureRandom sr = new SecureRandom(); byte[] tokenBytes = new byte[ URL_RANDOM_TOKEN_LENGTH ]; sr.nextBytes( tokenBytes ); return Base64Utils.encodeToUrlSafeString( tokenBytes ); }  static String generateUid(); static String generateCode( int codeSize ); static boolean isValidUid( String code ); static String getRandomUrlToken(); static final String letters; static final String ALLOWED_CHARS; static final int NUMBER_OF_CODEPOINTS; static final int CODESIZE; }
@Test public void testGetRandomUrlToken() { assertNotNull( CodeGenerator.getRandomUrlToken() ); assertNotNull( CodeGenerator.getRandomUrlToken() ); assertNotNull( CodeGenerator.getRandomUrlToken() ); assertEquals( 32, CodeGenerator.getRandomUrlToken().length() ); assertEquals( 32, CodeGenerator.getRandomUrlToken().length() ); assertEquals( 32, CodeGenerator.getRandomUrlToken().length() ); }