You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Ramandeep Kaur <ra...@gmail.com> on 2007/02/08 00:32:58 UTC
code coverage: problem in running junit suite lang with emma
Hi All,
I ran code coverage for junit suites - derbynet, lang, jdbcapi, store,
tools.
First of all emma does not work with default derby_tests.policy in
derbyTesting.jar file as emma gives an exception while creating code
coverage file " coverage.ec". So before running code coverage, I edit
derby_tests.policy file to include line "permission
java.security.AllPermission;" in it so that coverage.ec file can get
created.
Now, with the above change in derby_tests.policy, junit suites - derbynet,
jdbcapi, store, and tools run fine, but junit suite - lang does not finish.
After running few tests, it exits out.
The output looks like the following:
>java -Djvmflags=-Demma.verbosity.level=silent -Dverbose=true
junit.textui.TestRunner
org.apache.derbyTesting.functionTests.tests.lang._Suite
EMMA: collecting runtime coverage data
.........................................
.........................................
........................................F.
As adding line "permission java.security.AllPermission;" to
derby_tests.policy makes lang suite to run incompletely, I added line
"permission java.io.FilePermission "${user.home}${/}coverage.ec", "write";"
to derby_tests.policy instead of line "permission
java.security.AllPermission;" and ran tests as following
>java -Demma.coverage.out.file="$HOME/coverage.ec" -Djvmflags=-
Demma.verbosity.level=silent -Dverbose=true junit.textui.TestRunner
org.apache.derbyTesting.functionTests.tests.lang._Suite
The output looked like the following:
EMMA: collecting runtime coverage data ...
.........................................
.........................................
.........................................
.........................................
.........................................
.........................................
.........................................
.........................................
.........................................
.........................................
..............
Time: 909.446
OK (424 tests)
java.security.AccessControlException: access denied
(java.io.FilePermissionC:\Documents and Settings\raman\coverage.ec
read)
at java.security.AccessControlContext.checkPermission(
AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java
:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at java.io.File.exists(File.java:731)
at com.vladium.emma.data.DataFactory.persist(DataFactory.java:525)
at com.vladium.emma.data.DataFactory.persist(DataFactory.java:86)
at com.vladium.emma.rt.RTCoverageDataPersister.dumpCoverageData(
RTCoverageDataPersister.java:54)
at com.vladium.emma.rt.RTExitHook.run(RTExitHook.java:32)
at java.lang.Thread.run(Thread.java:619)
Exception in thread "EMMA shutdown handler thread"
java.lang.RuntimeException: EMMA failed to dump coverage data:
java.security.AccessControlException: access denied
(java.io.FilePermissionC:\Documents and Settings\raman\coverage.ec
read)
at com.vladium.emma.rt.RTCoverageDataPersister.dumpCoverageData(
RTCoverageDataPersister.java:71)
at com.vladium.emma.rt.RTExitHook.run(RTExitHook.java:32)
at java.lang.Thread.run(Thread.java:619)
I am not sure why exception java.security.AccessControlException gets thrown
even though I have "permission java.io.FilePermission
"${user.home}${/}coverage.ec",
"write";" in derby_tests.policy file.
--
Ramandeep Kaur
ramandhindsa@gmail.com
Re: code coverage: problem in running junit suite lang with emma
Posted by Ramandeep Kaur <ra...@gmail.com>.
I tried the following, but non of them worked.
1. I added line "permission java.security.AllPermission;" to the following
in derby_tests.policy:-
grant {
permission java.util.PropertyPermission "derbyRoutineSecurityTest.yes",
"read";
};
became
grant {
permission java.util.PropertyPermission "derbyRoutineSecurityTest.yes",
"read";
permission java.security.AllPermission; //added line
};
The above worked for all junit suites except lang.
With the above, lang suite got hung up as following:
EMMA: collecting runtime coverage data
.........................................
.........................................
........................................F.
2. I also added line "permission java.io.FilePermission
"${user.home}${/}coverage.ec",
"read,write,delete";" to the following in derby_tests.policy:
grant {
permission java.util.PropertyPermission "derbyRoutineSecurityTest.yes",
"read";
};
became
grant {
permission java.util.PropertyPermission "derbyRoutineSecurityTest.yes",
"read";
permission java.io.FilePermission "${user.home}${/}coverage.ec",
"read,write,delete"; //added line
};
With the above change in derby_tests.policy file, I got the following
exception:
java.security.AccessControlException: access denied
(java.io.FilePermissionC:\Documents and Settings\raman\coverage.ec
read
--
Ramandeep Kaur
ramandhindsa@gmail.com
Re: code coverage: problem in running junit suite lang with emma
Posted by Daniel John Debrunner <dj...@apache.org>.
Ramandeep Kaur wrote:
> I ran junit suite - lang with policy file that Dan suggested, and I was
> able to run it fine.
Great, I had asked earlier ...
> Ramandeep Kaur wrote:
>
>> I have tried with
>> permission java.io.FilePermission "${user.home}${/}coverage.ec","read,write,delete";
>> as well, but it did not work.
>
>
> Can you post a diff that shows how you are adding that permission?
Is it possible to show how you were adding the permission to the testing
policy file, so that if needed we could get coverage with that policy
file working?
Dan.
Re: code coverage: problem in running junit suite lang with emma
Posted by Ramandeep Kaur <ra...@gmail.com>.
I ran junit suite - lang with policy file that Dan suggested, and I was able
to run it fine.
So I ran lang suite as following:
>java -Djava.security.manager= -Djava.security.policy="C:/simple.policy"
-Djvmflags=-Demma.verbosity.level=silent -Dverbose=true
junit.textui.TestRunner
org.apache.derbyTesting.functionTests.tests.lang._Suite
The contents of simple.policy file are:
grant codebase "file:/c:/derby/-" {
permission java.security.AllPermission;
};
grant {
permission java.util.PropertyPermission
"derbyRoutineSecurityTest.yes", "read";
};
Thanks,
Ramandeep Kaur
Re: code coverage: problem in running junit suite lang with emma
Posted by Ramandeep Kaur <ra...@gmail.com>.
On 2/8/07, Daniel John Debrunner <dj...@apache.org> wrote:
>
> Ramandeep Kaur wrote:
>
> > I have tried with
> > permission java.io.FilePermission
> > "${user.home}${/}coverage.ec","read,write,delete";
> > as well, but it did not work.
>
>
> Can you post a diff that shows how you are adding that permission?
>
> Another alternative to to try a simple policy file like the one shown
> here:
>
>
> http://wiki.apache.org/db-derby/JunitVmIssues?#head-5e4f58e74b791288845d48a9fc87c30380d81c6e
>
>
> Thanks,
> Dan.
>
>
Thanks Dan. I will try that.
--
Ramandeep Kaur
ramandhindsa@gmail.com
Re: code coverage: problem in running junit suite lang with emma
Posted by Daniel John Debrunner <dj...@apache.org>.
Ramandeep Kaur wrote:
> I have tried with
> permission java.io.FilePermission
> "${user.home}${/}coverage.ec","read,write,delete";
> as well, but it did not work.
Can you post a diff that shows how you are adding that permission?
Another alternative to to try a simple policy file like the one shown here:
http://wiki.apache.org/db-derby/JunitVmIssues?#head-5e4f58e74b791288845d48a9fc87c30380d81c6e
Thanks,
Dan.
Re: code coverage: problem in running junit suite lang with emma
Posted by Ramandeep Kaur <ra...@gmail.com>.
On 2/8/07, Knut Anders Hatlen <Kn...@sun.com> wrote:
> Ramandeep Kaur <ra...@gmail.com> writes:
>
> > As adding line "permission java.security.AllPermission;" to
> > derby_tests.policy makes lang suite to run incompletely, I added line
> > "permission java.io.FilePermission "${user.home}${/}coverage.ec",
> "write";"
> > to derby_tests.policy instead of line "permission
> > java.security.AllPermission;" and ran tests as following
>
> [snip]
>
> > Time: 909.446
> >
> > OK (424 tests)
> >
> > java.security.AccessControlException: access denied
> > (java.io.FilePermissionC:\Documents and Settings\raman\coverage.ec
> > read)
>
> [snip]
>
> > I am not sure why exception java.security.AccessControlException gets
> thrown
> > even though I have "permission java.io.FilePermission
> > "${user.home}${/}coverage.ec",
> > "write";" in derby_tests.policy file.
>
> Note that the exception message says that access was denied to *read*
> the file. Does it work if you specify permission "read, write" instead
> of only "write"?
I have tried with
permission java.io.FilePermission "${user.home
}${/}coverage.ec","read,write,delete";
as well, but it did not work.
Thanks,
Ramandeep Kaur
(ramandhindsa@gmail.com)
Re: code coverage: problem in running junit suite lang with emma
Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
Ramandeep Kaur <ra...@gmail.com> writes:
> As adding line "permission java.security.AllPermission;" to
> derby_tests.policy makes lang suite to run incompletely, I added line
> "permission java.io.FilePermission "${user.home}${/}coverage.ec", "write";"
> to derby_tests.policy instead of line "permission
> java.security.AllPermission;" and ran tests as following
[snip]
> Time: 909.446
>
> OK (424 tests)
>
> java.security.AccessControlException: access denied
> (java.io.FilePermissionC:\Documents and Settings\raman\coverage.ec
> read)
[snip]
> I am not sure why exception java.security.AccessControlException gets thrown
> even though I have "permission java.io.FilePermission
> "${user.home}${/}coverage.ec",
> "write";" in derby_tests.policy file.
Note that the exception message says that access was denied to *read*
the file. Does it work if you specify permission "read, write" instead
of only "write"?
--
Knut Anders