db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Myrna van Lunteren" <m.v.lunte...@gmail.com>
Subject Re: [jira] Commented: (DERBY-2006) Add JUnit and JUnitReport task as a target in Ant script
Date Sun, 12 Nov 2006 23:58:18 GMT
On 11/8/06, Daniel John Debrunner <djd@apache.org> wrote:
> Myrna van Lunteren (JIRA) wrote:
> >     [ http://issues.apache.org/jira/browse/DERBY-2006?page=comments#action_12448010
> >
> > Myrna van Lunteren commented on DERBY-2006:
> > -------------------------------------------
> >
> > I played with this for (quite) a while, but with the current version I use to test
j2ME on Windows (wctme5.7 jcl foundation class), which has a problem with security manager
(see: http://wiki.apache.org/db-derby/JunitVmIssues#head-0916dd3630b0667e49460439fbd041c720d93eaf),
I have to jump through quite a few hoops to get things working. In fact, I didn't actually
get things working.
> > I've gotten as far as hard-coding in a number of jvmargs in build.xml:
> >   <target name="junit-oneclass" depends="junit-init">
> >     <junit printsummary="on"
> >            fork="yes" forkmode="once"
> >            jvm="${derby.junit.jvm}"
> >            showoutput="yes"
> >            dir="junit_${derby.junit.DSTAMP}_${derby.junit.TSTAMP}/testout">
> >         <jvmarg value="-Dij.dataSource=org.apache.derby.jdbc.EmbeddedSimpleDataSource"/>
> >         <jvmarg value="-jcl:foun10"/>
> >         <jvmarg value="-Xbootclasspath/a:c:/wctme5.7/ive/lib/jdbc.jar"/>
> >         <jvmarg value="-DderbyTesting.serverhost=localhost"/>
> >         <jvmarg value="-DderbyTesting.clienthost=localhost"/>
> >         <jvmarg value="-DderbyTesting.codeclasses=file:/C:/derby/trunk/classes/"/>
> >         <jvmarg value="-Djava.security.policy=file:/C:/derby/trunk/classes/org/apache/derbyTesting/functionTests/util/derby_tests.policy"/>
> >         <jvmarg value="-Dderby.system.home=c:/derby/trunk/junit_${derby.junit.DSTAMP}_${derby.junit.TSTAMP}"/>
> >       <formatter type="xml"/>
> >       <test name="${derby.junit.testname}" todir="junit_${derby.junit.DSTAMP}_${derby.junit.TSTAMP}"/>
> >       <classpath>
> >         <pathelement path="${out.dir}"/>
> >         <pathelement path="${junit}"/>
> >       </classpath>
> >     </junit>
> >   </target>
> >
> > But this results in:
> > [junit] Exception in thread "main" java.security.AccessControlException: Access
denied (java.lang.RuntimePermission setIO )
> >     [junit]   at java.security.AccessController.checkPermission(AccessController.java:74)
> >     [junit]   at java.lang.SecurityManager.checkPermission(SecurityManager.java:612)
> >     [junit]   at java.lang.System.setOut(System.java:76)
> >     [junit]   at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:309)
> >     [junit]   at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
> >     [junit]   at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
> >     [junit] Test org.apache.derbyTesting.functionTests.tests.tools._Suite FAILED
> >   [antcall] Exiting C:\derbyt\svn2\trunk\build.xml.
> >
> > and the resulting _Suite.xml files are empty.
> >
> > I suspect my specification of either the policy file or derby.system.home is off...
> > Anyways, this issue is closed, I think for now I'll just conclude that the ant target
doesn't work well with wctme5.7 - foundation.
> The JUnit setup sets some additional properties for the ant and junit
> jars that you don't seem to have set above.
> derbyTesting.antjunit
> derbyTesting.junit
> You probably need to set those as well.
> You can also remove this one: ij.dataSource
> Junit does not use ij to get its connections.
> Dan.
Thanks Dan that did help...

So, on top of the previous jvmargs, for making an ant target similar
to junitreport for foundation, I had to add:
Actually, I found that derbyTesting.junit can be file://unused, but
for derbyTesting.antjunit it's really needed to specify the
ant-junit.jar or the test doesn't run ( [junit] Exception in thread
"main" java.security.AccessControlException: Access denied
(java.lang.RuntimePermission setIO ). I also get the same error if the
policy file is not found.)

I also found (and this was collaborated by various websites) that for
j2ME to work, l needed the following in your classpath:
   (otherwise, build.xml errors with:
     Could not create task or type of type: junit.
     Ant could not find the task or a class this task relies upon.)
   (otherwise, you get:
    Exception in thread "main" java.lang.NoClassDefFoundError: org.w3c.dom.Node)
xalan.jar (?)
    (otherwise, you get:
    [junit] Exception in thread "main" java.lang.NullPointerException
    [junit] 	at
Provider  org.apache.xalan.processor.TransformerFactoryImpl not found

    The 1.6.5 ant/lib/xalan.jar was no good for this. I found a copy
of an xslt4j2_0_5/xalan.jar on my machine that had the class it
complained about. I believe this is may now be part of xalan-j 2.7
(probably xsltc.jar) but I did not download that to verify.)

So, after some further work, I made a junitj9report, that basically
copies the junitreport stuff, but 1. excludes jdbc4 and 2. calls the
following target:

  <target name="junitj9-oneclass" depends="junit-init">
    <junit printsummary="on"
           fork="yes" forkmode="once"
        <jvmarg value="-jcl:foun10"/>
        <jvmarg value="-Xbootclasspath/a:${jsr169compile.classpath}"/>
        <jvmarg value="-DderbyTesting.serverhost=host"/>
        <jvmarg value="-DderbyTesting.clienthost=host"/>
        <jvmarg value="-DderbyTesting.codeclasses=file:${out.dir}/"/>
        <jvmarg value="-DderbyTesting.junit=file://unused"/>
      <formatter type="xml"/>
      <test name="${derby.junit.testname}"
        <pathelement path="${out.dir}"/>
        <pathelement path="${junit}"/>

Now, there is one more trouble in running with wctme5.7 foundation
class libraries, and I've not been able to figure this one out...
To run with e.g. jdk14 & jars, all I need to do is change the
environment variable $CLASSPATH.
However, with foundation, because we need to specify the location of
the policy file, I'd need to specify the location of the policy file
within derbyTesting.jar...
And I'm not sure this is possible. I tried a variety of jar:file:/
settings, but nothing seems to work, I continue to get an error
indicating it's not finding the policy file.
For instance, I tried this:
As I can't get the invocation right, I can't run this with jars with foundation.

A further concern is, how to do this. What's best? A separate target
within the common build.xml? A separate xml file? Does anyone care
about this or have an opinion?
(:-)  )


View raw message