@Test
    public void testGenerateCertificateSubjectAlternativeNames() throws Exception
    {
        // Setup fixture.
        final KeyPair keyPair = subjectKeyPair;
        final int days = 2;
        final String issuerCommonName = "issuer common name";
        final String subjectCommonName = "subject common name";
        final String domain = "domain.example.org";
        final Set<String> sanDnsNames = Stream.of( "alternative-a.example.org", "alternative-b.example.org" ).collect( Collectors.toSet() );

        // Execute system under test.
        final X509Certificate result = CertificateManager.createX509V3Certificate( keyPair, days, issuerCommonName, subjectCommonName, domain, SIGNATURE_ALGORITHM, sanDnsNames );

        // Verify results.
        assertNotNull( result );

        final ArrayList<List<?>> expectedNames = new ArrayList<>();
        for ( final String sanDnsName : sanDnsNames ) {
            expectedNames.add( Arrays.asList( 2 , sanDnsName ) );
        }

        assertThat( "Expected to find all 'alternative names' as DNS entries in the subject alternative names (but does not).",
                    result.getSubjectAlternativeNames(),
                    both( hasSize( sanDnsNames.size() ) )
                        .and( containsInAnyOrder( expectedNames.toArray() ) )
        );
    }
Asserts that the provided subject alternative DNS names are returned as part of the subject alternative names in a certificate that is generated by {@link org.jivesoftware.util.CertificateManager#createX509V3Certificate(KeyPair, int, X500NameBuilder, X500NameBuilder, String, String, Set)}
xmppserver/src/test/java/org/jivesoftware/util/CertificateManagerTest.java