@Test
  public void testEncryptAndVerify() throws Exception {
    PasswordEncoder encoder = lookup(PasswordEncoder.class, "crypt");

    String crypted = encoder.encodePassword("test", null);

    // System.out.println( "Crypted password: \'" + crypted + "\'" );

    int lastIdx = crypted.lastIndexOf('$');
    int firstIdx = crypted.indexOf('$');

    String salt = crypted.substring(firstIdx + "$1$".length(), lastIdx);

    String check = "{CRYPT}" + MD5Crypt.unixMD5("test", salt);

    // System.out.println( "Check value: \'" + check + "\'" );

    Assert.assertEquals(check, crypted);

    Assert.assertTrue(encoder.isPasswordValid(crypted, "test", null));
  }