@Test
public void testEncodeWritable() throws Exception {

  String[] values = new String[]{"", "a", "bb", "ccc", "dddd", "eeeee",
      "ffffff", "ggggggg", "hhhhhhhh", "iiiiiiiii",
      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM" +
           "NOPQRSTUVWXYZ01234567890!@#$%^&*()-=_+[]{}|;':,./<>?"};
  Token<AbstractDelegationTokenIdentifier> orig;
  Token<AbstractDelegationTokenIdentifier> copy = new Token<>();
  // ensure that for each string the input and output values match
  for(int i=0; i< values.length; ++i) {
    String val = values[i];
    Token.LOG.info("Input = {}", val);
    orig = new Token<>(val.getBytes(),
        val.getBytes(), new Text(val), new Text(val));
    String encode = orig.encodeToUrlString();
    copy.decodeFromUrlString(encode);
    assertEquals(orig, copy);
    checkUrlSafe(encode);
  }
}