@Test
public void testEncode() {

    // compute token
    long ts = new Date().getTime();
    long random = new Random(ts).nextInt();
    String clearToken = String.format("%d:%d:%s:%s", ts, random, PASSWORD, USERNAME);
    byte[] hashedToken;
    try {
        hashedToken = MessageDigest.getInstance("MD5").digest(clearToken.getBytes());
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException("Cannot compute token", e);
    }
    String formerToken = org.nuxeo.client.util.Base64.encode(hashedToken);
    String token = ENCODER.encodeToString(hashedToken);
    assertEquals(token, formerToken);
}