OK. I got the hang of it. But now it is failing with the following error.

Caused by: java.io.FileNotFoundException: Source
'/Users/azeez/projects/wso2/org/carbon/kernel/trunk/distribution/integration/tests/target/carbontmp1332214836127/wso2carbon-core-4.0.0-SNAPSHOT/coverage.em'
does not exist
 at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:767)
at org.apache.commons.io.FileUtils.copyFileToDirectory(FileUtils.java:706)
 at org.apache.commons.io.FileUtils.copyFileToDirectory(FileUtils.java:670)
at
org.wso2.carbon.integration.framework.utils.ServerUtils.instrumentJarsForEmma(ServerUtils.java:232)
 at
org.wso2.carbon.integration.framework.utils.ServerUtils.startServerUsingCarbonHome(ServerUtils.java:55)


On Tue, Mar 20, 2012 at 8:44 AM, Afkham Azeez <[email protected]> wrote:

> Can you please explain how that method works?
>
> 1. What does the following block do?
>
> 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();
>                 }
>             }
>
>
> 2. What does the following block do?
>
> 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);
>             }
>
> gen_emma_coverage.rb is inside the resources directory in the Maven
> module. How does it get picked?
>
>
> On Tue, Mar 20, 2012 at 8:28 AM, Thilini Ishaka <[email protected]> wrote:
>
>> 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 <[email protected]> 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: **[email protected]* <[email protected]>* 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*
>>
>>
>
>
> --
> *Afkham Azeez*
> Director of Architecture; WSO2, Inc.; http://wso2.com
> Member; Apache Software Foundation; http://www.apache.org/
> * <http://www.apache.org/>**
> email: **[email protected]* <[email protected]>* 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*
>
>


-- 
*Afkham Azeez*
Director of Architecture; WSO2, Inc.; http://wso2.com
Member; Apache Software Foundation; http://www.apache.org/
* <http://www.apache.org/>**
email: **[email protected]* <[email protected]>* 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*
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to