@Test
void equality()
{

    PrincipalIndentifier john = new DistinguishedName("CN=John Doe");
    PrincipalIndentifier jane = new DistinguishedName("CN=Jane Doe");
    PrincipalIndentifier johnAlias = new DistinguishedName(new X500Name("CN=John Doe"));
    PrincipalIndentifier johnOtherImpl = new PrincipalIndentifier()
    {
        @Override
        public byte[] getEncoded() throws IOException
        {
            return new X500Name("CN=John Doe").getEncoded();
        }
        @Override
        public String getName()
        {
            return "CN=John Doe";
        }
    };
    PrincipalIndentifier janeOtherImpl = new PrincipalIndentifier()
    {
        @Override
        public byte[] getEncoded() throws IOException
        {
            return new X500Name("CN=Jane Doe").getEncoded();
        }
        @Override
        public String getName()
        {
            return "CN=Jane Doe";
        }
    };
    assertThat(john, equalTo(john));
    assertThat(john, equalTo(johnAlias));
    assertThat(john, equalTo(johnOtherImpl));
    assertThat(john, not(equalTo(jane)));
    assertThat(jane, not(equalTo(john)));
    assertThat(john, not(equalTo(janeOtherImpl)));
    assertThat(john, not(equalTo(new Object())));
}