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();
    }

Areas (Search) (RSS Feeds)

Home
Blog
Resources
JarAnalyzer (download now)
AssAnalyzer (download now)
About
My Resume

My Planet

Speaking Gigs

Please see My Schedule sidebar on my blog for up-to-date speaking engagements and events.