@Test
    public void testFilterValidWithMixOfValidityAndDuplicates() throws Exception
    {
        // Setup fixture.
        final X509Certificate validA = KeystoreTestUtils.generateValidCertificate().getCertificate();
        final X509Certificate validB = KeystoreTestUtils.generateValidCertificate().getCertificate();
        final X509Certificate invalid = KeystoreTestUtils.generateExpiredCertificate().getCertificate();
        final Collection<X509Certificate> input = new ArrayList<>();
        input.add( validA );
        input.add( validA );
        input.add( validB );
        input.add( invalid );

        // Execute system under test.
        final Collection<X509Certificate> result = CertificateUtils.filterValid( input );

        // Verify results.
        assertEquals( 2, result.size() );
        assertTrue( result.contains( validA ) );
        assertTrue( result.contains( validB ) );
    }
Test for {@link CertificateUtils#filterValid(Collection)}. Verifies that an input argument that
contains:
- one valid
- another valid (duplicated from the first)
- a third valid (no duplicate)
- and one invalid valid certificate
returns a collection that contains the two distinct valid certificates.
xmppserver/src/test/java/org/jivesoftware/openfire/keystore/CertificateUtilsTest.java