Using JarAnalyzer with JUnit
public void testJarCycles() throws Exception {
// Set up the data
File jarDir = new File(_jarDirName);
// Run the test
Analyzer analyzer = new Analyzer();
Jar[] jarbundle = analyzer.analyze(jarDir);
// Check the results
for (int i = 0; i < jarbundle.length; i++) {
Jar jar = jarbundle[i];
assertTrue(jar.getJarFileName() + " in a cycle with " + getJarNames(jar.getCyclicJars()),
!jar.hasCycles());
}
}
private String getJarNames(List jarList) {
StringBuffer names = new StringBuffer();
for (Iterator i = jarList.iterator(); i.hasNext(); ) {
Jar jar = (Jar) i.next();
names.append(jar.getJarFileName());
names.append(" ");
}
return names.toString();
}
Copyright, 2005 Kirk Knoernschild