* Parse the test file, and shuffle the elements to ensure that there aren't any test dependencies
* on the particulars of how the contents of the file are ordered.
*/
@Test
public void testShuffle() {
PolicyFile policyFile = loadTestPolicy();
final Random r = new Random(0);
for (int i = 0; i < 10; i++) {
policyFile.accept(new PolicyVisitor() {
/**
* Shuffle nested lists.
*/
@Override
public void traverse(List<? extends PolicyNode> list) {
if (list != null) {
Collections.shuffle(list, r);
}
super.traverse(list);
}
/**
* Don't re-order the internal state of an Ident.
*/
@Override
public boolean visit(Ident<?> x) {
return false;
}
});
try {
doTest(policyFile.toSource());
} catch (IllegalArgumentException e) {
System.err.println(i + " Failing source:\n" + policyFile.toSource());
throw e;
}
}
}