If I recall, we initially generated the coverage report manually by using below set of steps. Then the ServerUtils is used to handle that.
1. Create a jarlist.txt eg:* find /home/thilini/Desktop/wso2greg-3.6.0/repository/components/plugins/ >> /home/thilini/Desktop/wso2greg-3.6.0/repository/components/plugins/jarlist.txt * (jarlist.txt should contain absolute paths of jars. Remove unwanted jars from the list. If not there will be issues when starting the server) 2. xargs -n 1 $JAVA_HOME/jre/bin/java -cp emma.jar emma instr -m overwrite -cp < jarlist.txt 3. ruby dynamicImportsPatcher.rb < jarlist.txt (Before running this step need to install rubyzip. Use sudo apt-get install libzip-ruby1.8) 4. Copy emma.jar to */repository/components/plugins, /repository/components/lib *and */lib *directories. 4. Start Carbon Server 5. Do the test 6. Shutdown server 7. cp wso2greg-3.6.0/coverage.ec . 8. java -cp emma.jar emma report -r html -in coverage.em,coverage.ec <http://coverage.ec/>Thanks Thilini On Tue, Mar 20, 2012 at 8:02 AM, Afkham Azeez <az...@wso2.com> wrote: > Emma has been disabled for the past few months, and inevitably, the code > that does the instrumentation does not work. Can the person who wrote the > following method please explain how it works? > > public synchronized static void instrumentJarsForEmma(String carbonHome) > throws IOException { > String workingDir = System.getProperty("user.dir"); > try { > System.setProperty("user.dir", carbonHome); > String emmaHome = System.getProperty("emma.home"); > if (emmaHome == null) { > return; > } else if (!emmaHome.endsWith(File.separator)) { > emmaHome += File.separator; > } > File emmaOutput = new File(System.getProperty("emma.output")); > if (!emmaOutput.exists()) { > FileUtils.forceMkdir(emmaOutput); > } > String emmaJarName = null; > for (File file : new File(emmaHome).listFiles()) { > if > (file.getName().startsWith("org.wso2.carbon.integration.core")) { > ArchiveManipulator archiveManipulator = new > ArchiveManipulator(); > archiveManipulator.extract(file.getAbsolutePath(), > emmaHome); > } else if (file.getName().startsWith("emma")) { > emmaJarName = file.getName(); > } > } > > if (emmaJarName == null) { > return; > } > > String jarList = System.getProperty("jar.list"); > > > FileUtils.copyFile(new File(emmaHome + emmaJarName), > new File(carbonHome + File.separator + "repository" + > File.separator + "components" + File.separator > + "plugins" + > File.separator + "emma.jar")); > FileUtils.copyFile(new File(emmaHome + emmaJarName), > new File(carbonHome + File.separator + "repository" + > File.separator + "components" + File.separator > + "lib" + > File.separator + "emma.jar")); > FileUtils.copyFile(new File(emmaHome + emmaJarName), > new File(carbonHome + File.separator + "lib" + > File.separator + "emma.jar")); > for (File file : new File[]{new File(carbonHome), emmaOutput}) > { > FileUtils.copyFileToDirectory(new File(carbonHome + > File.separator + "lib" + > File.separator + "emma.jar"), file); > FileUtils.copyFileToDirectory(new File(emmaHome + > "gen_emma_coverage.rb"), file); > FileUtils.copyFileToDirectory(new File(jarList), file); > } > > String temp; > Process process = Runtime.getRuntime().exec(new > String[]{"ruby", > "gen_emma_coverage.rb", "instrument", > System.getenv("JAVA_HOME")}, null, > new File(carbonHome)); > BufferedReader reader = new BufferedReader( > new InputStreamReader(process.getInputStream())); > try { > while ((temp = reader.readLine()) != null) { > System.out.println(temp); > } > } catch (IOException ignored) { > } > FileUtils.copyFileToDirectory(new File(carbonHome + > File.separator + "coverage.em"), > emmaOutput); > } finally { > System.setProperty("user.dir", workingDir); > } > } > > -- > *Afkham Azeez* > Director of Architecture; WSO2, Inc.; http://wso2.com > Member; Apache Software Foundation; http://www.apache.org/ > * <http://www.apache.org/>** > email: **az...@wso2.com* <az...@wso2.com>* cell: +94 77 3320919 > blog: **http://blog.afkham.org* <http://blog.afkham.org>* > twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> > * > linked-in: **http://lk.linkedin.com/in/afkhamazeez* > * > * > *Lean . Enterprise . Middleware* > > -- *Regards* *Thilini Ishaka* *WSO2 Inc. http://wso2.com * *Mobile: +94 71 840 8171 * * +94 77 211 8797* *Bolg: thiliniishaka.blogspot.com*
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev