MifosViewerServletContextListener extends ViewerServletContextListener { File copyBIRTResourcesFromClassPathToFilesystemDirectory(ServletContext servletContext) { File directory = new File(System.getProperty("java.io.tmpdir"), "MifosBirtFilesExtractedFromClasspath"); try { directory.mkdirs(); FileUtils.cleanDirectory(directory); copyFromClassPathToDirectory(BIRT_RESOURCES_PATTERN, directory); } catch (IOException e) { error(servletContext, "getResources(\"" + ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + BIRT_RESOURCES_PATTERN + "**\") failed: " + e.getMessage(), e); } return directory; }  @Override void contextInitialized(ServletContextEvent event); static final String SYS_PROP_BIRT_ROOT_TEMP_DIR; }
@Test @SuppressWarnings("unchecked") public void testContextInitializedServletContextEvent() throws Throwable { MifosViewerServletContextListener listener = new MifosViewerServletContextListener(); File dir = listener.copyBIRTResourcesFromClassPathToFilesystemDirectory(null); Collection<File> files = FileUtils.listFiles(dir, null, true); assertTrue(files.size() > 5); }