reg : cobertura with java reflection.

View: New views
7 Messages — Rating Filter:   Alert me  

reg : cobertura with java reflection.

by Madurai Muthu Eswaran :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi John,

 

Could you please let me know the procedure to get the code coverage of the jar file which is not added in the classpath, but loaded dynamically using class loader and invoked using java reflection.

 

 

Regards

Eswar,

Disclaimer:
If you have received this e-mail in error please notify the sender. 
Please note that any views or opinions presented in this e-mail are solely 
those of the author and do not necessarily represent those of TEMENOS. 
We recommend that you check this e-mail and any attachments against viruses. 
TEMENOS accepts no liability for any damage caused by any malicious code 
or virus transmitted by this e-mail.


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Cobertura-devel mailing list
Cobertura-devel@...
https://lists.sourceforge.net/lists/listinfo/cobertura-devel

Re: reg : cobertura with java reflection.

by Jim Showalter-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is there a reason you can't just add the name of the JAR file to the
classpath you define in the ant script (or maven pom) that runs the
coverage tool? It doesn't have to be on the compilation classpath,
just the execution classpath of Cobertura itself.

----- Original Message -----
From: "Eswaran Muthu" <eswaranmuthu@...>
To: "John W. Lewis" <JohnW.Lewis@...>
Cc: <cobertura-devel@...>
Sent: Monday, September 21, 2009 9:56 PM
Subject: [Cobertura-devel] reg : cobertura with java reflection.


Hi John,



Could you please let me know the procedure to get the code coverage of
the jar file which is not added in the classpath, but loaded
dynamically
using class loader and invoked using java reflection.





Regards

Eswar,


Disclaimer:
If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are
solely
those of the author and do not necessarily represent those of TEMENOS.
We recommend that you check this e-mail and any attachments against
viruses.
TEMENOS accepts no liability for any damage caused by any malicious
code
or virus transmitted by this e-mail.



--------------------------------------------------------------------------------


> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF,
> CA
> is the only developer event you need to attend this year. Jumpstart
> your
> developing skills, take BlackBerry mobile applications to market and
> stay
> ahead of the curve. Join us from November 9-12, 2009. Register
> now!
> http://p.sf.net/sfu/devconf


--------------------------------------------------------------------------------


> _______________________________________________
> Cobertura-devel mailing list
> Cobertura-devel@...
> https://lists.sourceforge.net/lists/listinfo/cobertura-devel
>


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Cobertura-devel mailing list
Cobertura-devel@...
https://lists.sourceforge.net/lists/listinfo/cobertura-devel

Re: reg : cobertura with java reflection.

by Madurai Muthu Eswaran :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jim,

Yes jim the application is designed such way, I cannot amend it.

* normal execution (without coverage), will not have the jar file in
class path, instead loaded dynamically.

Will this work ??

* instrument  this jar, into instrument folder.
* set this instrument folder in class path before execution.
 
-----Original Message-----
From: Jim Showalter [mailto:jim@...]
Sent: Tuesday, September 22, 2009 10:39 AM
To: Eswaran Muthu; John W. Lewis
Cc: cobertura-devel@...
Subject: Re: [Cobertura-devel] reg : cobertura with java reflection.

Is there a reason you can't just add the name of the JAR file to the
classpath you define in the ant script (or maven pom) that runs the
coverage tool? It doesn't have to be on the compilation classpath,
just the execution classpath of Cobertura itself.

----- Original Message -----
From: "Eswaran Muthu" <eswaranmuthu@...>
To: "John W. Lewis" <JohnW.Lewis@...>
Cc: <cobertura-devel@...>
Sent: Monday, September 21, 2009 9:56 PM
Subject: [Cobertura-devel] reg : cobertura with java reflection.


Hi John,



Could you please let me know the procedure to get the code coverage of
the jar file which is not added in the classpath, but loaded
dynamically
using class loader and invoked using java reflection.





Regards

Eswar,


Disclaimer:
If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are
solely
those of the author and do not necessarily represent those of TEMENOS.
We recommend that you check this e-mail and any attachments against
viruses.
TEMENOS accepts no liability for any damage caused by any malicious
code
or virus transmitted by this e-mail.



------------------------------------------------------------------------
--------


>
------------------------------------------------------------------------
------
> Come build with us! The BlackBerry® Developer Conference in SF,
> CA
> is the only developer event you need to attend this year. Jumpstart
> your
> developing skills, take BlackBerry mobile applications to market and
> stay
> ahead of the curve. Join us from November 9-12, 2009. Register
> now!
> http://p.sf.net/sfu/devconf


------------------------------------------------------------------------
--------


> _______________________________________________
> Cobertura-devel mailing list
> Cobertura-devel@...
> https://lists.sourceforge.net/lists/listinfo/cobertura-devel
>

Disclaimer:
If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely
those of the author and do not necessarily represent those of TEMENOS.
We recommend that you check this e-mail and any attachments against viruses.
TEMENOS accepts no liability for any damage caused by any malicious code
or virus transmitted by this e-mail.


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Cobertura-devel mailing list
Cobertura-devel@...
https://lists.sourceforge.net/lists/listinfo/cobertura-devel

Re: reg : cobertura with java reflection.

by Madurai Muthu Eswaran :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jim,


Please find the attached test program, I have tested reflection and
cobertura.
In the public class there are two methods withoutreflection and
reflection both invokes same method from another class, the code
coverage works fine with withoutreflection but not with reflection.
Please suggest me some solution.


Regards,
Eswar

-----Original Message-----
From: Jim Showalter [mailto:jim@...]
Sent: Tuesday, September 22, 2009 10:39 AM
To: Eswaran Muthu; John W. Lewis
Cc: cobertura-devel@...
Subject: Re: [Cobertura-devel] reg : cobertura with java reflection.

Is there a reason you can't just add the name of the JAR file to the
classpath you define in the ant script (or maven pom) that runs the
coverage tool? It doesn't have to be on the compilation classpath,
just the execution classpath of Cobertura itself.

----- Original Message -----
From: "Eswaran Muthu" <eswaranmuthu@...>
To: "John W. Lewis" <JohnW.Lewis@...>
Cc: <cobertura-devel@...>
Sent: Monday, September 21, 2009 9:56 PM
Subject: [Cobertura-devel] reg : cobertura with java reflection.


Hi John,



Could you please let me know the procedure to get the code coverage of
the jar file which is not added in the classpath, but loaded
dynamically
using class loader and invoked using java reflection.





Regards

Eswar,


Disclaimer:
If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are
solely
those of the author and do not necessarily represent those of TEMENOS.
We recommend that you check this e-mail and any attachments against
viruses.
TEMENOS accepts no liability for any damage caused by any malicious
code
or virus transmitted by this e-mail.



------------------------------------------------------------------------
--------


>
------------------------------------------------------------------------
------
> Come build with us! The BlackBerry® Developer Conference in SF,
> CA
> is the only developer event you need to attend this year. Jumpstart
> your
> developing skills, take BlackBerry mobile applications to market and
> stay
> ahead of the curve. Join us from November 9-12, 2009. Register
> now!
> http://p.sf.net/sfu/devconf


------------------------------------------------------------------------
--------


> _______________________________________________
> Cobertura-devel mailing list
> Cobertura-devel@...
> https://lists.sourceforge.net/lists/listinfo/cobertura-devel
>


Disclaimer:
If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely
those of the author and do not necessarily represent those of TEMENOS.
We recommend that you check this e-mail and any attachments against viruses.
TEMENOS accepts no liability for any damage caused by any malicious code
or virus transmitted by this e-mail.

package connection;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

import java.net.URL;
import java.net.URLClassLoader;

public class RestrictedURLClassLoader1 extends URLClassLoader {
    public RestrictedURLClassLoader1(URL[] urls) {
        super(urls, null);
    }

    public Class loadClass(String name) throws ClassNotFoundException {
        Class cls = super.loadClass(name);

        if (cls == null) {
            throw new ClassNotFoundException("Restricted ClassLoader" + " is unable to find class: " + name);
        }

        return cls;
    }

    public static void withoutreflection() {

        connection1.test.main("Testing CODE COVERAGE");

    }

    public static void reflection() {

        File f = new File("C:\\jazz\\db2tafj\\bin");
        URL u;
        try {

            u = f.toURL();

            URL[] urls = { u };
            RestrictedURLClassLoader1 rr = new RestrictedURLClassLoader1(urls);
            try {
                Class cc = rr.loadClass("connection1.test");
                System.out.println(cc.getName());
                try {
                    Method med = cc.getMethod("main", new Class[] { String.class });
                    try {
                        med.invoke(null, new Object[] { "Testing CODE COVERAGE" });
                    } catch (IllegalArgumentException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IllegalAccessException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                } catch (SecurityException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (NoSuchMethodException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            } catch (ClassNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    public static void main(String args[]) {

        RestrictedURLClassLoader1.reflection();           // code is covered with cobertura

        RestrictedURLClassLoader1.withoutreflection();   //  code is not covered with cobertura

    }
}

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Cobertura-devel mailing list
Cobertura-devel@...
https://lists.sourceforge.net/lists/listinfo/cobertura-devel

Re: reg : cobertura with java reflection.

by Jim Showalter-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Please also include the ant script or maven pom you are using to drive
Cobertura.

Also, I'm not the best person to investigate this--I'm not a Cobertura
developer, just a user of the tool.

----- Original Message -----
From: "Eswaran Muthu" <eswaranmuthu@...>
To: "Jim Showalter" <jim@...>; "John W. Lewis"
<JohnW.Lewis@...>
Cc: <cobertura-devel@...>
Sent: Tuesday, September 22, 2009 1:42 AM
Subject: RE: [Cobertura-devel] reg : cobertura with java reflection.


Hi Jim,


Please find the attached test program, I have tested reflection and
cobertura.
In the public class there are two methods withoutreflection and
reflection both invokes same method from another class, the code
coverage works fine with withoutreflection but not with reflection.
Please suggest me some solution.


Regards,
Eswar

-----Original Message-----
From: Jim Showalter [mailto:jim@...]
Sent: Tuesday, September 22, 2009 10:39 AM
To: Eswaran Muthu; John W. Lewis
Cc: cobertura-devel@...
Subject: Re: [Cobertura-devel] reg : cobertura with java reflection.

Is there a reason you can't just add the name of the JAR file to the
classpath you define in the ant script (or maven pom) that runs the
coverage tool? It doesn't have to be on the compilation classpath,
just the execution classpath of Cobertura itself.

----- Original Message -----
From: "Eswaran Muthu" <eswaranmuthu@...>
To: "John W. Lewis" <JohnW.Lewis@...>
Cc: <cobertura-devel@...>
Sent: Monday, September 21, 2009 9:56 PM
Subject: [Cobertura-devel] reg : cobertura with java reflection.


Hi John,



Could you please let me know the procedure to get the code coverage of
the jar file which is not added in the classpath, but loaded
dynamically
using class loader and invoked using java reflection.





Regards

Eswar,


Disclaimer:
If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are
solely
those of the author and do not necessarily represent those of TEMENOS.
We recommend that you check this e-mail and any attachments against
viruses.
TEMENOS accepts no liability for any damage caused by any malicious
code
or virus transmitted by this e-mail.



------------------------------------------------------------------------
--------


>
------------------------------------------------------------------------
------
> Come build with us! The BlackBerry® Developer Conference in SF,
> CA
> is the only developer event you need to attend this year. Jumpstart
> your
> developing skills, take BlackBerry mobile applications to market and
> stay
> ahead of the curve. Join us from November 9-12, 2009. Register
> now!
> http://p.sf.net/sfu/devconf


------------------------------------------------------------------------
--------


> _______________________________________________
> Cobertura-devel mailing list
> Cobertura-devel@...
> https://lists.sourceforge.net/lists/listinfo/cobertura-devel
>


Disclaimer:
If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are
solely
those of the author and do not necessarily represent those of TEMENOS.
We recommend that you check this e-mail and any attachments against
viruses.
TEMENOS accepts no liability for any damage caused by any malicious
code
or virus transmitted by this e-mail.


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Cobertura-devel mailing list
Cobertura-devel@...
https://lists.sourceforge.net/lists/listinfo/cobertura-devel

Re: reg : cobertura with java reflection.

by Jim Showalter-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

By the way, the comments in the code are backwards from your email.

The comments say:

        RestrictedURLClassLoader1.reflection();           // code is
covered with cobertura

        RestrictedURLClassLoader1.withoutreflection();   //  code is
not covered with cobertura

but the email says:

the code coverage works fine with withoutreflection but not with
reflection.


----- Original Message -----
From: "Eswaran Muthu" <eswaranmuthu@...>
To: "Jim Showalter" <jim@...>; "John W. Lewis"
<JohnW.Lewis@...>
Cc: <cobertura-devel@...>
Sent: Tuesday, September 22, 2009 1:42 AM
Subject: RE: [Cobertura-devel] reg : cobertura with java reflection.


Hi Jim,


Please find the attached test program, I have tested reflection and
cobertura.
In the public class there are two methods withoutreflection and
reflection both invokes same method from another class, the code
coverage works fine with withoutreflection but not with reflection.
Please suggest me some solution.


Regards,
Eswar

-----Original Message-----
From: Jim Showalter [mailto:jim@...]
Sent: Tuesday, September 22, 2009 10:39 AM
To: Eswaran Muthu; John W. Lewis
Cc: cobertura-devel@...
Subject: Re: [Cobertura-devel] reg : cobertura with java reflection.

Is there a reason you can't just add the name of the JAR file to the
classpath you define in the ant script (or maven pom) that runs the
coverage tool? It doesn't have to be on the compilation classpath,
just the execution classpath of Cobertura itself.

----- Original Message -----
From: "Eswaran Muthu" <eswaranmuthu@...>
To: "John W. Lewis" <JohnW.Lewis@...>
Cc: <cobertura-devel@...>
Sent: Monday, September 21, 2009 9:56 PM
Subject: [Cobertura-devel] reg : cobertura with java reflection.


Hi John,



Could you please let me know the procedure to get the code coverage of
the jar file which is not added in the classpath, but loaded
dynamically
using class loader and invoked using java reflection.





Regards

Eswar,


Disclaimer:
If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are
solely
those of the author and do not necessarily represent those of TEMENOS.
We recommend that you check this e-mail and any attachments against
viruses.
TEMENOS accepts no liability for any damage caused by any malicious
code
or virus transmitted by this e-mail.



------------------------------------------------------------------------
--------


>
------------------------------------------------------------------------
------
> Come build with us! The BlackBerry® Developer Conference in SF,
> CA
> is the only developer event you need to attend this year. Jumpstart
> your
> developing skills, take BlackBerry mobile applications to market and
> stay
> ahead of the curve. Join us from November 9-12, 2009. Register
> now!
> http://p.sf.net/sfu/devconf


------------------------------------------------------------------------
--------


> _______________________________________________
> Cobertura-devel mailing list
> Cobertura-devel@...
> https://lists.sourceforge.net/lists/listinfo/cobertura-devel
>


Disclaimer:
If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are
solely
those of the author and do not necessarily represent those of TEMENOS.
We recommend that you check this e-mail and any attachments against
viruses.
TEMENOS accepts no liability for any damage caused by any malicious
code
or virus transmitted by this e-mail.


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Cobertura-devel mailing list
Cobertura-devel@...
https://lists.sourceforge.net/lists/listinfo/cobertura-devel

Re: reg : cobertura with java reflection.

by Madurai Muthu Eswaran :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Sorry Jim its my mistake, I have miss placed the comments.

        RestrictedURLClassLoader1.reflection();   //  code is
not covered with cobertura          

        RestrictedURLClassLoader1.withoutreflection();  // code is
covered with cobertura

John,  could you please help me with this (cobertura with reflection).


Regards,
Eswar
 

-----Original Message-----
From: Jim Showalter [mailto:jim@...]
Sent: Tuesday, September 22, 2009 10:34 PM
To: Eswaran Muthu; John W. Lewis
Cc: cobertura-devel@...
Subject: Re: [Cobertura-devel] reg : cobertura with java reflection.

By the way, the comments in the code are backwards from your email.

The comments say:

        RestrictedURLClassLoader1.reflection();           // code is
covered with cobertura

        RestrictedURLClassLoader1.withoutreflection();   //  code is
not covered with cobertura

but the email says:

the code coverage works fine with withoutreflection but not with
reflection.


----- Original Message -----
From: "Eswaran Muthu" <eswaranmuthu@...>
To: "Jim Showalter" <jim@...>; "John W. Lewis"
<JohnW.Lewis@...>
Cc: <cobertura-devel@...>
Sent: Tuesday, September 22, 2009 1:42 AM
Subject: RE: [Cobertura-devel] reg : cobertura with java reflection.


Hi Jim,


Please find the attached test program, I have tested reflection and
cobertura.
In the public class there are two methods withoutreflection and
reflection both invokes same method from another class, the code
coverage works fine with withoutreflection but not with reflection.
Please suggest me some solution.


Regards,
Eswar

-----Original Message-----
From: Jim Showalter [mailto:jim@...]
Sent: Tuesday, September 22, 2009 10:39 AM
To: Eswaran Muthu; John W. Lewis
Cc: cobertura-devel@...
Subject: Re: [Cobertura-devel] reg : cobertura with java reflection.

Is there a reason you can't just add the name of the JAR file to the
classpath you define in the ant script (or maven pom) that runs the
coverage tool? It doesn't have to be on the compilation classpath,
just the execution classpath of Cobertura itself.

----- Original Message -----
From: "Eswaran Muthu" <eswaranmuthu@...>
To: "John W. Lewis" <JohnW.Lewis@...>
Cc: <cobertura-devel@...>
Sent: Monday, September 21, 2009 9:56 PM
Subject: [Cobertura-devel] reg : cobertura with java reflection.


Hi John,



Could you please let me know the procedure to get the code coverage of
the jar file which is not added in the classpath, but loaded
dynamically
using class loader and invoked using java reflection.





Regards

Eswar,


Disclaimer:
If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are
solely
those of the author and do not necessarily represent those of TEMENOS.
We recommend that you check this e-mail and any attachments against
viruses.
TEMENOS accepts no liability for any damage caused by any malicious
code
or virus transmitted by this e-mail.



------------------------------------------------------------------------
--------


>
------------------------------------------------------------------------
------
> Come build with us! The BlackBerry® Developer Conference in SF,
> CA
> is the only developer event you need to attend this year. Jumpstart
> your
> developing skills, take BlackBerry mobile applications to market and
> stay
> ahead of the curve. Join us from November 9-12, 2009. Register
> now!
> http://p.sf.net/sfu/devconf


------------------------------------------------------------------------
--------


> _______________________________________________
> Cobertura-devel mailing list
> Cobertura-devel@...
> https://lists.sourceforge.net/lists/listinfo/cobertura-devel
>


Disclaimer:
If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are
solely
those of the author and do not necessarily represent those of TEMENOS.
We recommend that you check this e-mail and any attachments against
viruses.
TEMENOS accepts no liability for any damage caused by any malicious
code
or virus transmitted by this e-mail.

Disclaimer:
If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely
those of the author and do not necessarily represent those of TEMENOS.
We recommend that you check this e-mail and any attachments against viruses.
TEMENOS accepts no liability for any damage caused by any malicious code
or virus transmitted by this e-mail.


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Cobertura-devel mailing list
Cobertura-devel@...
https://lists.sourceforge.net/lists/listinfo/cobertura-devel