@Test
    public void testPartialChainUnordered() throws Exception
    {
        // Setup fixture.
        final X509CertSelector selector = new X509CertSelector();
        selector.setSubject( validChain[0].getSubjectX500Principal() );
        final List<X509Certificate> input = new ArrayList<>( Arrays.asList( validChain ));
        input.remove( input.size() - 1 );
        final List<X509Certificate> shuffled = new ArrayList<>( input );
        while ( input.equals( shuffled ) ) {
            Collections.shuffle( shuffled );
        }
        final X509Certificate[] chain = shuffled.toArray(new X509Certificate[0]);


        // Execute system under test.
        final CertPath result = trustManager.checkChainTrusted( selector, chain );

        // Verify results
        Assert.assertNotNull( result );
    }
Verifies that providing a valid chain that does not contain the root certificate and is not ordered does not
throw an exception (selection criteria during this test: match on subject).
xmppserver/src/test/java/org/jivesoftware/openfire/keystore/CheckChainTrustedTest.java