Authentication { public String generateToken(String username) { String plainToken = "token-" + (++counter) + "-" + username; byte[] digestedToken = md5Digest.digest(plainToken.getBytes()); return convertHexToString(digestedToken); }  abstract String connect(String username, String password); abstract boolean canSend(String token, String topic); abstract boolean canSubscribe(String token, String topic); String generateToken(String username); static final Authentication ALLOW_ALL_INSTANCE; static final Authentication DENY_ALL_INSTANCE; }
@Test public void testGenerateToken() throws Exception { assertNotNull(authentication.generateToken("test")); }
@Test public void testGenerateToken_null() throws Exception { assertNotNull(authentication.generateToken(null)); }
@Test public void testGenerateToken_same_user() throws Exception { String token1 = authentication.generateToken("test"); String token2 = authentication.generateToken("test"); assertFalse(token1.equals(token2)); }