WarAnalyzer extends JarAnalyzer { @Override public void analyze(final File _file) throws FileAnalysisException { try { super.analyze(_file); if (this.workDir != null) this.tmpDir = Paths.get(this.workDir.toString(), "war_analysis"); else { try { this.tmpDir = java.nio.file.Files.createTempDirectory("war_analysis_"); } catch (IOException e) { throw new IllegalStateException("Unable to create temp directory", e); } } this.jarWriter.extract(this.tmpDir); try { JarAnalyzer.insertClasspath( Paths.get(this.tmpDir.toString(), "WEB-INF", "classes").toString()); } catch (Exception e) { WarAnalyzer.log.error( this.toString() + ": Error while updating the classpath: " + e.getMessage()); } } catch (IllegalStateException e) { log.error("IllegalStateException when analyzing file [" + _file + "]: " + e.getMessage()); throw new FileAnalysisException( "Error when analyzing file [" + _file + "]: " + e.getMessage(), e); } catch (IOException e) { log.error("IOException when analyzing file [" + _file + "]: " + e.getMessage()); throw new FileAnalysisException( "Error when analyzing file [" + _file + "]: " + e.getMessage(), e); } catch (Exception e) { log.error("Exception when analyzing file [" + _file + "]: " + e.getMessage()); throw new FileAnalysisException( "Error when analyzing file [" + _file + "]: " + e.getMessage(), e); } }  @Override String[] getSupportedFileExtensions(); @Override void analyze(final File _file); void setIncludeDir(Path _p); void setRename(boolean _b); @Override boolean hasChilds(); @Override Set<FileAnalyzer> getChilds(boolean _recursive); @Override synchronized Set<ConstructId> getConstructIds(); @Override InputStream getInputStream(String _regex, JarEntry _entry);  }
@Test @Category(Slow.class) public void testAnalyze() { try { final WarAnalyzer wa = new WarAnalyzer(); wa.analyze(new File("./src/test/resources/examples.war")); wa.setWorkDir(Paths.get("./target")); wa.setRename(true); WarAnalyzer.setAppContext(new Application("dummy-group", "dummy-artifact", "0.0.1-SNAPSHOT")); wa.call(); final Set<FileAnalyzer> fas = wa.getChilds(true); assertEquals(15, fas.size()); final Set<ConstructId> cids = wa.getConstructIds(); assertEquals(15, cids.size()); } catch (Exception e) { e.printStackTrace(); assertTrue(false); } }