@Test
    public void testSameWeights() throws Exception {
        // setup
        final SrvRecord hostA = new SrvRecord("hostA", 5222, false, 1, 10);
        final SrvRecord hostB = new SrvRecord("hostB", 5222, false, 1, 10);
        final SrvRecord[] hosts = new SrvRecord[] { hostA, hostB };

        // do magic
        boolean hostAWasFirst = false;
        boolean hostBWasFirst = false;
        final int maxTries = Integer.MAX_VALUE;
        for (int i=0; i<maxTries; i++) {
            final List<Set<SrvRecord>> result = SrvRecord.prioritize(hosts);
            if (hostA.equals(result.get(0).iterator().next())) {
                hostAWasFirst = true;
            }

            if (hostB.equals(result.get(0).iterator().next())) {
                hostBWasFirst = true;
            }

            if (hostAWasFirst && hostBWasFirst) {
                break;
            }

            if (i%1000000==0 && i>0) {
                System.err.println("The last " + i + " iterations of this test all had the same result, which is very unlikely to occur (there should be an even distribution between two possible outcomes). We'll iterate up to "+ maxTries +" times, but you might want to abort the unit test at this point...");
            }
        }

        // verify
        assertTrue( hostAWasFirst );
        assertTrue( hostBWasFirst );
    }
A test that verifies that hosts with equal weight are alternately first in the resulting list.

The test that is done here re-executes until each of the input records was included in the output as the first
record. This indicates that the returning list is at the very least not always ordered in the exact same way.
xmppserver/src/test/java/org/jivesoftware/openfire/net/SrvRecordTest.java