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 ho...@pacbell.net on 2006/08/31 00:25:06 UTC

Integrating a JUnit test into the test harness was: Re: [Db-derby Wiki] Update of "IntroToJUnit" by SusanCline

As Dan mentioned below my example about integrating a JUnit test into the Derby test harness
was not accurate.  I've changed the wiki page IntroToJUnit to point to the other JUnit wiki
pages which are more relevant to Derby for information about this.
 
However, I've spent some time trying to get my JUnit test that runs fine in stand-alone mode
to be integrated into the test harness.  
 
To be clear what I mean about stand-alone mode, I am successful with these two invocations
of the MathTrigFunctionsTest JUnit class:
 
C:\derby_src\development_branch\trunk>java junit.textui.TestRunner org.apache.de
rbyTesting.functionTests.tests.lang.MathTrigFunctionsTest
................
Time: 21.231
OK (16 tests)
 
C:\derby_src\development_branch\trunk>java org.apache.derbyTesting.functionTests
.harness.RunTest lang/MathTrigFunctionsTest.junit
*** Start: MathTrigFunctionsTest jdk1.4.2_09 2006-08-30 14:24:08 ***
*** End:   MathTrigFunctionsTest jdk1.4.2_09 2006-08-30 14:24:48 ***
 
I'm not sure if I have enough time to get this working, or if someone else can help.  Here's what I've 
done so far, maybe someone has an idea of what needs to be done to get this to work.
 
1) Created a class that extends the BaseJDBCTestCase class, which is in the 
    org.apache.derbyTesting.functionTests.tests.lang package.
    (I've removed the private Connection variable per Dan's suggestion below.)
 
2) I created a suite() method shown below:
 
 public static Test suite() {
  TestSuite suite = new TestSuite();
  suite.addTestSuite(MathTrigFunctionsTest.class);
  TestSetup wrapper = new BaseJDBCTestSetup(suite) {
   public void setUp() throws Exception {
        // initialize variables
   }
   protected void tearDown() throws Exception {
    super.tearDown();
   }
  };
  return wrapper;
 }

3) I looked at the _Suite.java file in the lang package.  From what I can tell this adds the
suites from LangScripts class' suite.
 
4) Looking at the LangScripts class it runs only SQL tests.  Just for kicks I added my JUnit
test class name to the LangScripts tests to be run to see what would happen;
 
 private static final String[] SQL_LANGUAGE_TESTS = {
  "case",
  "constantExpression",
  "MathTrigFunctionsTest"
  }; 
 
5) When I tried to run it using this command:
 
C:\derby_src\development_branch\trunk>java org.apache.derbyTesting.functionTests.harness.RunSuite derbylang
 
The _Script test failed, predictably since my test was not an SQL test, with this output in the derbylang_diff.txt file:
 
********* Diff file derbylang/derbylang/_Suite.diff
*** Start: _Suite jdk1.4.2_09 derbylang:derbylang 2006-08-30 15:14:30 ***
0 add
> ...F.....
> There was 1 failure:
> 1) MathTrigFunctionsTest(org.apache.derbyTesting.functionTests.tests.lang.LangScripts)junit.framework.AssertionFailedError: SQL script missing: org/apache/derbyTesting/functionTests/tests/lang/MathTrigFunctionsTest.sql
> FAILURES!!!
> Tests run: 8,  Failures: 1,  Errors: 0
Test Failed.
*** End:   _Suite jdk1.4.2_09 derbylang:derbylang 2006-08-30 15:14:57 ***
 
Does anyone know what I have to do to get my MathTrigFunctionsTest to run as part of the
test harness using the _Suite class?
 
Thanks,
 
Susan

----- Original Message ----
From: Daniel John Debrunner djd@apache.org

 
[snip]
 
> The following page has been changed by SusanCline:
> http://wiki.apache.org/db-derby/IntroToJUnit

This is good stuff Susan, Thanks.

The section on "JUnit tests and the Derby test harness" says the
information is valid as of 8/29 but it's actually out of date by a few
days. :-) Fast moving target. BaseJDBCTestCase now provides utilities
for a single connection, so a conn field is not needed, and the JUnit
test should be added to any existing _Suite, not directly to the old
harness suite runall files.

[snip]

Thanks,
Dan.

Re: Integrating a JUnit test into the test harness was: Re: [Db-derby Wiki] Update of "IntroToJUnit" by SusanCline

Posted by ho...@pacbell.net.
Hi Myrna,
 
That was the problem!  Thanks a lot for your help.  I removed the existing test output files and now
everything passes - derbylang, lang/MathTrigFunctionsTest and lang/_Suite.
 
Susan

----- Original Message ----
From: Myrna van Lunteren <m....@gmail.com>
To: derby-dev@db.apache.org
Sent: Wednesday, August 30, 2006 8:01:23 PM
Subject: Re: Integrating a JUnit test into the test harness was: Re: [Db-derby Wiki] Update of "IntroToJUnit" by SusanCline


On 8/30/06, Daniel John Debrunner <dj...@apache.org> wrote:
> Susan Cline wrote:
>
>
> > But when I try to run the entire derbylang suite the only test that fails is _Suite,
> > but I'm wondering if it really failed:
> >
> > java org.apache.derbyTesting.functionTests.harness.RunSuite derbylang
> >
> > derbylang_fail.txt:
> > derbylang/derbylang.fail:lang/_Suite.junit
> >
> > But derbylang_pass.txt shows this at the bottom of the output:
> > ...
> > derbylang/derbylang.pass:lang/_Suite.junit
> > /MathTrigFunctionsTest.pass:lang/MathTrigFunctionsTest.junit
> >
> > Is there something else I need to do to make sure that RunSuite derbylang reports that _Suite
> > passes?
>
> Can you submit a patch, that will be the easiest way to see what is
> going on.
>
> It looks like the derbylang.runall is messed up.
>
> Thanks,
> Dan
>
>
>
Just a thought - did you clean up / start in a clean directory when
you ran derbylang? I think if you have run a test in the same dir
previously, the functionTests test harness will look at all *fail.txt
files - or *pass.txt and pick up some items not normally part of the
suite.

Myrna

Re: Integrating a JUnit test into the test harness was: Re: [Db-derby Wiki] Update of "IntroToJUnit" by SusanCline

Posted by Myrna van Lunteren <m....@gmail.com>.
On 8/30/06, Daniel John Debrunner <dj...@apache.org> wrote:
> Susan Cline wrote:
>
>
> > But when I try to run the entire derbylang suite the only test that fails is _Suite,
> > but I'm wondering if it really failed:
> >
> > java org.apache.derbyTesting.functionTests.harness.RunSuite derbylang
> >
> > derbylang_fail.txt:
> > derbylang/derbylang.fail:lang/_Suite.junit
> >
> > But derbylang_pass.txt shows this at the bottom of the output:
> > ...
> > derbylang/derbylang.pass:lang/_Suite.junit
> > /MathTrigFunctionsTest.pass:lang/MathTrigFunctionsTest.junit
> >
> > Is there something else I need to do to make sure that RunSuite derbylang reports that _Suite
> > passes?
>
> Can you submit a patch, that will be the easiest way to see what is
> going on.
>
> It looks like the derbylang.runall is messed up.
>
> Thanks,
> Dan
>
>
>
Just a thought - did you clean up / start in a clean directory when
you ran derbylang? I think if you have run a test in the same dir
previously, the functionTests test harness will look at all *fail.txt
files - or *pass.txt and pick up some items not normally part of the
suite.

Myrna

Re: Integrating a JUnit test into the test harness was: Re: [Db-derby Wiki] Update of "IntroToJUnit" by SusanCline

Posted by Daniel John Debrunner <dj...@apache.org>.
Susan Cline wrote:


> But when I try to run the entire derbylang suite the only test that fails is _Suite,
> but I'm wondering if it really failed:
> 
> java org.apache.derbyTesting.functionTests.harness.RunSuite derbylang
> 
> derbylang_fail.txt:
> derbylang/derbylang.fail:lang/_Suite.junit
> 
> But derbylang_pass.txt shows this at the bottom of the output:
> ...
> derbylang/derbylang.pass:lang/_Suite.junit
> /MathTrigFunctionsTest.pass:lang/MathTrigFunctionsTest.junit
> 
> Is there something else I need to do to make sure that RunSuite derbylang reports that _Suite
> passes?

Can you submit a patch, that will be the easiest way to see what is
going on.

It looks like the derbylang.runall is messed up.

Thanks,
Dan



Re: Contribution of/repository for testing infrastructure tools (was Re: Running a Derby JUnit test using JUnit directly)

Posted by Daniel John Debrunner <dj...@apache.org>.
Ole Solberg wrote:


> I will start by moving the scripts into my Derby sandbox, e.g. under
> tools/testing/reporting as suggested, and start the cleanup.

Great.

> 
> I also have plans to make the failure analysis more "intelligent", but
> don't know yet how high on the priority list that ends up.

That's the point of making them open, you can throw out ideas and if you
can't get to them, maybe someone else can.

Thanks,
Dan.




Re: Contribution of/repository for testing infrastructure tools (was Re: Running a Derby JUnit test using JUnit directly)

Posted by Ole Solberg <Ol...@Sun.COM>.
Ole Solberg wrote:
> Andrew McIntyre wrote:
>> On 9/6/06, Kathey Marsden <km...@sbcglobal.net> wrote:
>>
>>>
>>> Actually I am curious about this tool and think maybe  the tool itself
>>> and other testing infrastructure tools might really be great
>>> contribution to the community.
>>
> 
> The internal tool we use for testing originated as a tool to handle HA
> database testing. It allows us to define test-rigs consisting of servers
> and clients, and run sets of tests on several test-rigs in parallel.
> Tests are defined in XML-files which essentially allow us to specify
> setups and teardowns, e.g. starting and stopping databases, and JUnit
> based test methods which are run from clients against the database(s).
> Results are reported to a test result database which eases creation of
> different kinds of test reports for testers, developers and managers.
> 
> 
> I am afraid this tool would need quite some work to be open-sourced.
> We would have to do both documentation and code cleanup, removing
> dependencies to other parts of our testing infrastructure, as well as
> resolution of legal issues. We would very much like to do this, but we
> do not have resources for it at the moment.
> 
> The reporting scripts, which has already been donated in DERBY-812 in an
> earlier version, is a different thing. These are built for creating
> reports from the Derby test harness results and are independent of the
> rest of our testing infrastructure. We have also made some simple
> interfacing scripts to extract results from our internal test
> infrastructure tool into these reports.
> 
> 
>>
>> +10 - definitely would be a great contribution to the community. It
>> would allow for collaboration and enhancement of the scripts to make
>> testing easier for everyone in the community.
> Thanks!! That's nice to hear!
> 
>>
>>> I am not sure exactly where these tools would be checked in, but are
>>> certainly worthy of a place.
>>
>>
>> Tools for testing should go somewhere under tools/testing. :-)  Maybe
>> tools/testing/reporting or tools/testing/tinderbox (if applicable) or
>> something similar.
>>
>> I could check in the scripts from DERBY-812, but maybe there's a newer
>> version that's more worthy of being committed?
> 
> The newer version of the reporting scripts which also attempts to do
> some failure analysis could in the short-term be uploaded as an update
> to DERBY-812.
> I would definitely like to put this into the repository so as to allow
> enhancements of the scripts by the community!
> Anyway, I would first like to go over them to generalize possible
> site-specific stuff which may have sneaked in.
> 
> I will start by moving the scripts into my Derby sandbox, e.g. under
> tools/testing/reporting as suggested, and start the cleanup.
> 

I have re-opened DERBY-812 and uploaded a patch with a newer,
cleaned-up, version of the scripts.

The new version goes into 'tools/testing/reporting/'.
The main difference since the previous version is the addition of
a simple failure analysis, and the possibility to create plots of
testsuite duration using gnuplot.

The patch contains README files explaining how to use the scripts.

> 
> I also have plans to make the failure analysis more "intelligent", but
> don't know yet how high on the priority list that ends up.
> 
>>
>> andrew
> 
> 


-- 
Ole Solberg, Database Technology Group,
Sun Microsystems, Trondheim, Norway

Re: Contribution of/repository for testing infrastructure tools (was Re: Running a Derby JUnit test using JUnit directly)

Posted by Ole Solberg <Ol...@Sun.COM>.
Andrew McIntyre wrote:
> On 9/6/06, Kathey Marsden <km...@sbcglobal.net> wrote:
> 
>>
>> Actually I am curious about this tool and think maybe  the tool itself
>> and other testing infrastructure tools might really be great
>> contribution to the community.
> 

The internal tool we use for testing originated as a tool to handle HA
database testing. It allows us to define test-rigs consisting of servers
and clients, and run sets of tests on several test-rigs in parallel.
Tests are defined in XML-files which essentially allow us to specify
setups and teardowns, e.g. starting and stopping databases, and JUnit
based test methods which are run from clients against the database(s).
Results are reported to a test result database which eases creation of
different kinds of test reports for testers, developers and managers.


I am afraid this tool would need quite some work to be open-sourced.
We would have to do both documentation and code cleanup, removing
dependencies to other parts of our testing infrastructure, as well as
resolution of legal issues. We would very much like to do this, but we
do not have resources for it at the moment.

The reporting scripts, which has already been donated in DERBY-812 in an
earlier version, is a different thing. These are built for creating
reports from the Derby test harness results and are independent of the
rest of our testing infrastructure. We have also made some simple
interfacing scripts to extract results from our internal test
infrastructure tool into these reports.


> 
> +10 - definitely would be a great contribution to the community. It
> would allow for collaboration and enhancement of the scripts to make
> testing easier for everyone in the community.
Thanks!! That's nice to hear!

> 
>> I am not sure exactly where these tools would be checked in, but are
>> certainly worthy of a place.
> 
> 
> Tools for testing should go somewhere under tools/testing. :-)  Maybe
> tools/testing/reporting or tools/testing/tinderbox (if applicable) or
> something similar.
> 
> I could check in the scripts from DERBY-812, but maybe there's a newer
> version that's more worthy of being committed?

The newer version of the reporting scripts which also attempts to do
some failure analysis could in the short-term be uploaded as an update
to DERBY-812.
I would definitely like to put this into the repository so as to allow
enhancements of the scripts by the community!
Anyway, I would first like to go over them to generalize possible 
site-specific stuff which may have sneaked in.

I will start by moving the scripts into my Derby sandbox, e.g. under 
tools/testing/reporting as suggested, and start the cleanup.


I also have plans to make the failure analysis more "intelligent", but 
don't know yet how high on the priority list that ends up.

> 
> andrew


-- 
Ole Solberg, Database Technology Group,
Sun Microsystems, Trondheim, Norway

Re: Contribution of/repository for testing infrastructure tools (was Re: Running a Derby JUnit test using JUnit directly)

Posted by Andrew McIntyre <mc...@gmail.com>.
On 9/6/06, Kathey Marsden <km...@sbcglobal.net> wrote:
>
> Actually I am curious about this tool and think maybe  the tool itself
> and other testing infrastructure tools might really be great
> contribution to the community.

+10 - definitely would be a great contribution to the community. It
would allow for collaboration and enhancement of the scripts to make
testing easier for everyone in the community.

> I am not sure exactly where these tools would be checked in, but are
> certainly worthy of a place.

Tools for testing should go somewhere under tools/testing. :-)  Maybe
tools/testing/reporting or tools/testing/tinderbox (if applicable) or
something similar.

I could check in the scripts from DERBY-812, but maybe there's a newer
version that's more worthy of being committed?

andrew

Re: Contribution of/repository for testing infrastructure tools (was Re: Running a Derby JUnit test using JUnit directly)

Posted by Mike Matrigali <mi...@sbcglobal.net>.
I second this, I really appreciate the latest test results being
posted.  It would be nice if I could use these tools to quickly
look at test results from my own machine.  It would be really helpful
to automatically know if an test failure is likely a known issue as
the current reports seem to automatically be able to determine.

Kathey Marsden wrote:
> Vemund Ostgaard wrote:
> 
>> a tool that we use internally to distribute files to remote machines 
>> for testing, and as such didn't seem interesting to the community.
> 
> 
> Actually I am curious about this tool and think maybe  the tool itself 
> and other testing infrastructure tools  might really be great 
> contribution to the community.    We all benefit from the testing 
> results of this the efficient QA efforts in Norway. I wonder  might you 
> consider contributing  these tools  so that they could be used in a more 
> general purpose way and enhanced by all for the general benefit of the 
> community?
> 
> I am not sure exactly where these tools would  be checked in,  but are 
> certainly worthy of a place.  I recall that at one point a snapshot was 
> made of the testing report scripts and then  copied and forked for the 
> IBM reports and then enhanced locally in Norway. Since they were not 
> checked in, they  they could not be enhanced open source style and used 
> generally.  I think if contributed, they could be enhanced ultimately it 
> would be easy for anyone  running tests to post them in the same format 
> and link them off:
> http://db.apache.org/derby/derby_tests.html
> 
> Kathey
> 
> 
> 
> 
> 
> 
> 
> 
> 


Contribution of/repository for testing infrastructure tools (was Re: Running a Derby JUnit test using JUnit directly)

Posted by Kathey Marsden <km...@sbcglobal.net>.
Vemund Ostgaard wrote:

> a tool that we use internally to distribute files to remote machines 
> for testing, and as such didn't seem interesting to the community.

Actually I am curious about this tool and think maybe  the tool itself 
and other testing infrastructure tools  might really be great 
contribution to the community.    We all benefit from the testing 
results of this the efficient QA efforts in Norway. I wonder  might you 
consider contributing  these tools  so that they could be used in a more 
general purpose way and enhanced by all for the general benefit of the 
community?

I am not sure exactly where these tools would  be checked in,  but are 
certainly worthy of a place.  I recall that at one point a snapshot was 
made of the testing report scripts and then  copied and forked for the 
IBM reports and then enhanced locally in Norway. Since they were not 
checked in, they  they could not be enhanced open source style and used 
generally.  I think if contributed, they could be enhanced ultimately it 
would be easy for anyone  running tests to post them in the same format 
and link them off:
http://db.apache.org/derby/derby_tests.html

Kathey








Re: Running a Derby JUnit test using JUnit directly

Posted by Vemund Ostgaard <Ve...@Sun.COM>.
Daniel John Debrunner wrote:

>Vemund Ostgaard wrote:
>
>  
>
>>For the jobs doing nightly testing on the 10.2 branch we did a short
>>term workaround by copying derbyTesting.jar to its old location, to
>>avoid other changes. So, thats why it hasn't failed in those tests.
>>    
>>
>
>It's good to report such problems, not just work-around them. That way
>others get to know and the issue can be fixed quicker.
>
>Or maybe I missed the e-mail discussing this?
>
Yes, I agree. The problem we had though was with a tool that we use 
internally to distribute files to remote machines for testing, and as 
such didn't seem interesting to the community. We didn't check if the 
problem hid other problems that were relevant for the community, which 
evidently was the case.

Vemund


Re: test/lib split in distribution - WAS Re: Running a Derby JUnit test using JUnit directly

Posted by Myrna van Lunteren <m....@gmail.com>.
On 9/1/06, Daniel John Debrunner <dj...@apache.org> wrote:
> Myrna van Lunteren wrote:
>
> > On 9/1/06, Daniel John Debrunner <dj...@apache.org> wrote:
> >
> >
[snip]
> > Now that we know of the problem, I have to say I prefer the jumble
> > approach, especially when the need arises to run on a number of
> > different machines.
>
> Why? Just trying to understand why you prefer it, you say you do but
> provide no reason why. :-) Kind of like a veto with no reason!

Apologies, I didn't imply to veto anything. I like the jumble of
course because of habit, but I find it convenient and logical when
having to run derbyall on a number of rarely used machines, to have
all derby*.jar of a specific version and jars in one dir, one level
deep, with a nice breezy dir name like '102b1'. Also when using
scripts and copying jars around it's just easy to use the derby*.jar.
It's really no big deal though.
>
[snip]

test/lib split in distribution - WAS Re: Running a Derby JUnit test using JUnit directly

Posted by Daniel John Debrunner <dj...@apache.org>.
Myrna van Lunteren wrote:

> On 9/1/06, Daniel John Debrunner <dj...@apache.org> wrote:
> 
>> Vemund Ostgaard wrote:
>>
>> > For the jobs doing nightly testing on the 10.2 branch we did a short
>> > term workaround by copying derbyTesting.jar to its old location, to
>> > avoid other changes. So, thats why it hasn't failed in those tests.
>>
>> It's good to report such problems, not just work-around them. That way
>> others get to know and the issue can be fixed quicker.
>>
>> Or maybe I missed the e-mail discussing this?
>> Dan.
>>
>>
> This is a good catch - I had just continued my practice from earlier
> versions to copy all derby*.jar files to one location and set my own
> classpath, I never thought about verifying with the split set-up.
> 
> I think the harness/policyfile should work either way...

The changes I'm making will make that so.

> 
> Now that we know of the problem, I have to say I prefer the jumble
> approach, especially when the need arises to run on a number of
> different machines.

Why? Just trying to understand why you prefer it, you say you do but
provide no reason why. :-) Kind of like a veto with no reason!

The reason I entered the improvement to have the split was so that users
of Derby who want to re-distribute it will have a clear separation as to
what was needed for the database "product" code and what was for the
tests. This becomes increasingly important in the future as more
non-derby jars are shipped with Derby, e.g. I could see in the future
having (assuming licencing is ok for any jar):

   - lucene jar for text indexing
   - oro jar for the harness (done today in test)
   - junit jar
   - apache commons jar to pick up soundex code

I believe that if all of these are lumped in lib or even lib/3rdparty
then it's really unclear which are just needed for the tests, and the
default action will be someone to ship all of it, and then complain
about the footprint.

I also believe that there should be a very easy setup for users to run
all the tests, something like the derbyrun we have today for ij etc. So
that any one can run the derby tests from a distribution doing something
 like:

     java -jar test/derbyTesting.jar

This ties into the split as it obviously requires Derby distribution to
contain all the jars required by the test runs.

This would be a default test setup run, the "common case", it would not
cater for all situations, such as the remote host running you do, or
testing running the 10.2 tests against 10.3, which are important but
less likely for users of Derby to do.

Thanks,
Dan.



Re: Running a Derby JUnit test using JUnit directly

Posted by "Susan L. Cline" <ho...@pacbell.net>.
--- Daniel John Debrunner <dj...@apache.org> wrote:

> Susan L. Cline wrote:
> 
> 
> > [ snip]
> > 
> > I'm still trying to figure out if there is a way to run a JUnit test standalone
> > against the jars.  What I am trying to do is to test the 10.2 beta release using
> > a derbyTesting.jar I built in the development branch (10.3).  I'm trying to use the
> > class I created to test the functionality of something in the 10.2 beta release
> > without having to check out the 10.2 branch(trunk? sorry I don't know the terminology
> > here.)
> 
> That's cutting edge technology :-)
> 
> The JUnit work for running tests standalone is a work in progress, I'm
> working in the trunk, Rick has been merging changes up to 10.2 but I
> haven't looked to see what state those changes are in the 10.2 branch
> and the beta release.
> 
[snip]
> 
> If this test is for submission to Derby the best thing to do is to
> contribute it for the trunk and then it will be merged up to the branch
> and become part of the 10.2 standard tests.
> 
> Thanks,
> Dan.

Okay, thanks Dan.  That is what I have done created the patch against the trunk,
so I'll consider this task complete.

Thanks,

Susan


Re: Running a Derby JUnit test using JUnit directly

Posted by Daniel John Debrunner <dj...@apache.org>.
Susan L. Cline wrote:


> [ snip]
> 
> I'm still trying to figure out if there is a way to run a JUnit test standalone
> against the jars.  What I am trying to do is to test the 10.2 beta release using
> a derbyTesting.jar I built in the development branch (10.3).  I'm trying to use the
> class I created to test the functionality of something in the 10.2 beta release
> without having to check out the 10.2 branch(trunk? sorry I don't know the terminology
> here.)

That's cutting edge technology :-)

The JUnit work for running tests standalone is a work in progress, I'm
working in the trunk, Rick has been merging changes up to 10.2 but I
haven't looked to see what state those changes are in the 10.2 branch
and the beta release.

I think the only requirement for 10.2 is that derbyall continues to run
successfully, I think it would be great if 10.2 and trunk were identical
in their Junit setup but that may not happen until after the first GA
release.

If this test is for submission to Derby the best thing to do is to
contribute it for the trunk and then it will be merged up to the branch
and become part of the 10.2 standard tests.

Thanks,
Dan.


Re: Running a Derby JUnit test using JUnit directly

Posted by "Susan L. Cline" <ho...@pacbell.net>.
--- Myrna van Lunteren <m....@gmail.com> wrote:

> On 9/1/06, Daniel John Debrunner <dj...@apache.org> wrote:
> > Vemund Ostgaard wrote:
> >
> > > For the jobs doing nightly testing on the 10.2 branch we did a short
> > > term workaround by copying derbyTesting.jar to its old location, to
> > > avoid other changes. So, thats why it hasn't failed in those tests.
> >
> > It's good to report such problems, not just work-around them. That way
> > others get to know and the issue can be fixed quicker.
> >
> > Or maybe I missed the e-mail discussing this?
> > Dan.
> >
> >
> This is a good catch - I had just continued my practice from earlier
> versions to copy all derby*.jar files to one location and set my own
> classpath, I never thought about verifying with the split set-up.
> 
> I think the harness/policyfile should work either way...
> 
[ snip]

I'm still trying to figure out if there is a way to run a JUnit test standalone
against the jars.  What I am trying to do is to test the 10.2 beta release using
a derbyTesting.jar I built in the development branch (10.3).  I'm trying to use the
class I created to test the functionality of something in the 10.2 beta release
without having to check out the 10.2 branch(trunk? sorry I don't know the terminology
here.)

So here's what I have;

lib directory with all of the derby jar files from the 10.2 release EXCEPT the derbyTesting.jar

I copied over the derbyTesting.jar I created from the 10.3 trunk to the lib directory

I've tried various combinations / permutations of running my JUnit test standalone and can not
succeed.  The wiki entry, http://wiki.apache.org/db-derby/DerbyJUnitTesting, says, 
'The classpath needs to include the junit.jar and the Derby classes.'

So is there anyway to run it just using the jar files and not the classes directory?

Some of the things I've tried are including the derby.system.home on the command line and
having a derby_tests.policy file in derby home, and not having the derby_tests.policy file
in derby.system.home.  I've passed the classpath on the command line, and set it as an
environment variable - sometimes I get 'NO SUITABLE DRIVER' errors, other times I don't.

Thanks,

Susan

Re: Running a Derby JUnit test using JUnit directly

Posted by Myrna van Lunteren <m....@gmail.com>.
On 9/1/06, Daniel John Debrunner <dj...@apache.org> wrote:
> Vemund Ostgaard wrote:
>
> > For the jobs doing nightly testing on the 10.2 branch we did a short
> > term workaround by copying derbyTesting.jar to its old location, to
> > avoid other changes. So, thats why it hasn't failed in those tests.
>
> It's good to report such problems, not just work-around them. That way
> others get to know and the issue can be fixed quicker.
>
> Or maybe I missed the e-mail discussing this?
> Dan.
>
>
This is a good catch - I had just continued my practice from earlier
versions to copy all derby*.jar files to one location and set my own
classpath, I never thought about verifying with the split set-up.

I think the harness/policyfile should work either way...

Now that we know of the problem, I have to say I prefer the jumble
approach, especially when the need arises to run on a number of
different machines.

Myrna

Re: Running a Derby JUnit test using JUnit directly

Posted by Daniel John Debrunner <dj...@apache.org>.
Vemund Ostgaard wrote:

> For the jobs doing nightly testing on the 10.2 branch we did a short
> term workaround by copying derbyTesting.jar to its old location, to
> avoid other changes. So, thats why it hasn't failed in those tests.

It's good to report such problems, not just work-around them. That way
others get to know and the issue can be fixed quicker.

Or maybe I missed the e-mail discussing this?
Dan.


Re: Running a Derby JUnit test using JUnit directly

Posted by Vemund Ostgaard <Ve...@Sun.COM>.
Daniel John Debrunner wrote:

>Michelle Caisse wrote:
>
>  
>
>>>>I was using 10.2.1.1.  
>>>>        
>>>>
>
>I see the same failure as you.
>
>It's because the policy file is not setup to handle derbyTesting.jar
>being in a different folder to derby.jar etc.
>
>It's actually nothing to do with JUnit, you will see problems running
>tests with the old harness.
>
>I'm very suprised no-one has seen this before, since I thought there
>have been several reports of derbyall passing against 10.2.1.1.
>  
>
For the jobs doing nightly testing on the 10.2 branch we did a short 
term workaround by copying derbyTesting.jar to its old location, to 
avoid other changes. So, thats why it hasn't failed in those tests.

Vemund

Re: Running a Derby JUnit test using JUnit directly

Posted by Daniel John Debrunner <dj...@apache.org>.
Michelle Caisse wrote:

>>> I was using 10.2.1.1.  

I see the same failure as you.

It's because the policy file is not setup to handle derbyTesting.jar
being in a different folder to derby.jar etc.

It's actually nothing to do with JUnit, you will see problems running
tests with the old harness.

I'm very suprised no-one has seen this before, since I thought there
have been several reports of derbyall passing against 10.2.1.1.

Dan.



Re: Running a Derby JUnit test using JUnit directly

Posted by Michelle Caisse <Mi...@Sun.COM>.
Daniel John Debrunner wrote:

>Michelle Caisse wrote:
>
>
>  
>
>>I was using 10.2.1.1.  Does the current reality require building from
>>the latest source?
>>    
>>
>
>Possibly, that's my itch. I haven't been keeping careful track of where
>the 10.2 line is relative to trunk.
>
>I think though that 10.2 should work if you remove the security manager
>stuff. One question though, did you copy the policy file into the
>current directory?
>
>Dan.
>
>  
>
Yes.  I also tried running without the security manager flags.  It's one 
of the three invocations I originally tried.

I will download a nightly build and try this.

-- Michelle

Re: Running a Derby JUnit test using JUnit directly

Posted by Daniel John Debrunner <dj...@apache.org>.
Michelle Caisse wrote:


> I was using 10.2.1.1.  Does the current reality require building from
> the latest source?

Possibly, that's my itch. I haven't been keeping careful track of where
the 10.2 line is relative to trunk.

I think though that 10.2 should work if you remove the security manager
stuff. One question though, did you copy the policy file into the
current directory?

Dan.


Re: Running a Derby JUnit test using JUnit directly

Posted by Michelle Caisse <Mi...@Sun.COM>.
Daniel John Debrunner wrote:

>Daniel John Debrunner wrote:
>
>  
>
>>Michelle Caisse wrote:
>>
>>
>>    
>>
>>>Hi Dan, Susan,
>>>
>>>I'm having trouble trying to run a Derby JUnit test outside of the
>>>harness. I've tried three ways of running a test based on the example
>>>and other information at
>>>http://wiki.apache.org/db-derby/DerbyJUnitTesting and in
>>>java/testing/README.htm. None works.  Here's what I get:
>>>      
>>>
>>    
>>
>>>c:/Program Files/Java/jdk1.6.0/bin/java -Djava.security.manager -Djava.security.policy=derby_tests.policy -Dderby.system.home=/cygdrive/c/derby/derby/qe/javasrc/webapps/jdbc4 -cp c:/derby/derby/qe/javasrc/webapps/jdbc4//build/WEB-INF/classes/;c:/httpunit-1.6/lib/httpunit.jar;c:/db-derby-10.2.1.1/lib/derbyclient.jar;c:/db-derby-10.2.1.1/lib/derbynet.jar;c:/db-derby-10.2.1.1/lib/derby.jar;c:/db-derby-10.2.1.1/test/derbyTesting.jar;c:/junit3.8.1/junit.jar junit.textui.TestRunner org.apache.derbyTesting.functionTests.tests.jdbcapi.ProcedureTest 
>>>      
>>>
>>Try removing the -Djava.security.manager  and
>>-Djava.security.policy=derby_tests.policy
>>
>>I was just about to update the wiki section about running Derby JUnit tests.
>>    
>>
>
>I've updated this page to refect currently reality, can you see if you
>follow it if you are successful.
>
>http://wiki.apache.org/db-derby/DerbyJUnitTesting
>
>Thanks,
>Dan.
>
>  
>
I was using 10.2.1.1.  Does the current reality require building from 
the latest source?

-- Michelle

Re: Running a Derby JUnit test using JUnit directly

Posted by Daniel John Debrunner <dj...@apache.org>.
Daniel John Debrunner wrote:

> Michelle Caisse wrote:
> 
> 
>>Hi Dan, Susan,
>>
>>I'm having trouble trying to run a Derby JUnit test outside of the
>>harness. I've tried three ways of running a test based on the example
>>and other information at
>>http://wiki.apache.org/db-derby/DerbyJUnitTesting and in
>>java/testing/README.htm. None works.  Here's what I get:
> 
> 
>>c:/Program Files/Java/jdk1.6.0/bin/java -Djava.security.manager -Djava.security.policy=derby_tests.policy -Dderby.system.home=/cygdrive/c/derby/derby/qe/javasrc/webapps/jdbc4 -cp c:/derby/derby/qe/javasrc/webapps/jdbc4//build/WEB-INF/classes/;c:/httpunit-1.6/lib/httpunit.jar;c:/db-derby-10.2.1.1/lib/derbyclient.jar;c:/db-derby-10.2.1.1/lib/derbynet.jar;c:/db-derby-10.2.1.1/lib/derby.jar;c:/db-derby-10.2.1.1/test/derbyTesting.jar;c:/junit3.8.1/junit.jar junit.textui.TestRunner org.apache.derbyTesting.functionTests.tests.jdbcapi.ProcedureTest 
> 
> 
> Try removing the -Djava.security.manager  and
> -Djava.security.policy=derby_tests.policy
> 
> I was just about to update the wiki section about running Derby JUnit tests.

I've updated this page to refect currently reality, can you see if you
follow it if you are successful.

http://wiki.apache.org/db-derby/DerbyJUnitTesting

Thanks,
Dan.


Re: Running a Derby JUnit test using JUnit directly

Posted by Daniel John Debrunner <dj...@apache.org>.
Michelle Caisse wrote:

> Hi Dan, Susan,
> 
> I'm having trouble trying to run a Derby JUnit test outside of the
> harness. I've tried three ways of running a test based on the example
> and other information at
> http://wiki.apache.org/db-derby/DerbyJUnitTesting and in
> java/testing/README.htm. None works.  Here's what I get:

> c:/Program Files/Java/jdk1.6.0/bin/java -Djava.security.manager -Djava.security.policy=derby_tests.policy -Dderby.system.home=/cygdrive/c/derby/derby/qe/javasrc/webapps/jdbc4 -cp c:/derby/derby/qe/javasrc/webapps/jdbc4//build/WEB-INF/classes/;c:/httpunit-1.6/lib/httpunit.jar;c:/db-derby-10.2.1.1/lib/derbyclient.jar;c:/db-derby-10.2.1.1/lib/derbynet.jar;c:/db-derby-10.2.1.1/lib/derby.jar;c:/db-derby-10.2.1.1/test/derbyTesting.jar;c:/junit3.8.1/junit.jar junit.textui.TestRunner org.apache.derbyTesting.functionTests.tests.jdbcapi.ProcedureTest 

Try removing the -Djava.security.manager  and
-Djava.security.policy=derby_tests.policy

I was just about to update the wiki section about running Derby JUnit tests.

Dan.


Running a Derby JUnit test using JUnit directly

Posted by Michelle Caisse <Mi...@Sun.COM>.
Hi Dan, Susan,

I'm having trouble trying to run a Derby JUnit test outside of the 
harness. I've tried three ways of running a test based on the example 
and other information at 
http://wiki.apache.org/db-derby/DerbyJUnitTesting and in 
java/testing/README.htm. None works.  Here's what I get:

[1]
c:/Program Files/Java/jdk1.6.0/bin/java -Djava.security.manager 
-Djava.security.policy=derby_tests.policy 
-Dderby.system.home=/cygdrive/c/derby/derby/qe/javasrc/webapps/jdbc4 -cp 
c:/derby/derby/qe/javasrc/webapps/jdbc4//build/WEB-INF/classes/;c:/httpunit-1.6/lib/httpunit.jar;c:/db-derby-10.2.1.1/lib/derbyclient.jar;c:/db-derby-10.2.1.1/lib/derbynet.jar;c:/db-derby-10.2.1.1/lib/derby.jar;c:/db-derby-10.2.1.1/test/derbyTesting.jar;c:/junit3.8.1/junit.jar 
junit.textui.TestRunner 
org.apache.derbyTesting.functionTests.tests.jdbcapi.ProcedureTest

Failed to invoke suite():java.lang.ExceptionInInitializerError

[2]
c:/Program Files/Java/jdk1.6.0/bin/java 
-Dderby.system.home=/cygdrive/c/derby/derby/qe/javasrc/webapps/jdbc4 -cp 
c:/derby/derby/qe/javasrc/webapps/jdbc4//build/WEB-INF/classes/;c:/httpunit-1.6/lib/httpunit.jar;c:/db-derby-10.2.1.1/lib/derbyclient.jar;c:/db-derby-10.2.1.1/lib/derbynet.jar;c:/db-derby-10.2.1.1/lib/derby.jar;c:/db-derby-10.2.1.1/test/derbyTesting.jar;c:/junit3.8.1/junit.jar 
junit.textui.TestRunner 
org.apache.derbyTesting.functionTests.tests.jdbcapi.ProcedureTest

.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.EEE
Time: 6.594
There were 29 errors:
1) 
testExecuteQueryWithNoDynamicResultSets(org.apache.derbyTesting.functionTests.tests.jdbcapi.ProcedureTest)java.sql.SQLException: 
Java exception: 'access denied (java.util.PropertyPermission user.dir 
read): java.security.AccessControlException'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown 
Source)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown 
Source)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown 
Source)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown 
Source)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown 
Source)
        at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 
Source)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 
Source)
        at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown 
Source)
        at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown 
Source)
        at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown 
Source)
        at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
        at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at 
org.apache.derbyTesting.junit.TestConfiguration.openConnection(Unknown 
Source)
        at 
org.apache.derbyTesting.junit.TestConfiguration.openDefaultConnection(Unknown 
Source)
        at 
org.apache.derbyTesting.junit.BaseJDBCTestCase.openDefaultConnection(Unknown 
Source)
        at 
org.apache.derbyTesting.junit.BaseJDBCTestCase.getConnection(Unknown Source)
        at 
org.apache.derbyTesting.functionTests.tests.jdbcapi.ProcedureTest.setUp(Unknown 
Source)
        at org.apache.derbyTesting.junit.BaseTestCase.runBare(Unknown 
Source)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
Caused by: java.sql.SQLException: Java exception: 'access denied 
(java.util.PropertyPermission user.dir read): 
java.security.AccessControlException'.
        ... 43 more
...
FAILURES!!!
Tests run: 27,  Failures: 0,  Errors: 29

[3]
c:/Program Files/Java/jdk1.6.0/bin/java -DnoSecurityManager=true 
-Dderby.system.home=/cygdrive/c/derby/derby/qe/javasrc/webapps/jdbc4 -cp 
c:/derby/derby/qe/javasrc/webapps/jdbc4//build/WEB-INF/classes/;c:/httpunit-1.6/lib/httpunit.jar;c:/db-derby-10.2.1.1/lib/derbyclient.jar;c:/db-derby-10.2.1.1/lib/derbynet.jar;c:/db-derby-10.2.1.1/lib/derby.jar;c:/db-derby-10.2.1.1/test/derbyTesting.jar;c:/junit
3.8.1/junit.jar junit.textui.TestRunner 
org.apache.derbyTesting.functionTests.tests.jdbcapi.ProcedureTest

.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.EEE
Time: 2.64
There were 29 errors:
1) 
testExecuteQueryWithNoDynamicResultSets(org.apache.derbyTesting.functionTests.tests.jdbcapi.ProcedureTest)java.sql.SQLException: 
Java exception: 'access denied (java.util.PropertyPermission user.dir 
read): java.security.AccessControlException'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown 
Source)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown 
Source)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown 
Source)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown 
Source)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown 
Source)
        at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 
Source)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 
Source)
        at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown 
Source)
        at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown 
Source)
        at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown 
Source)
        at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
        at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at 
org.apache.derbyTesting.junit.TestConfiguration.openConnection(Unknown 
Source)
        at 
org.apache.derbyTesting.junit.TestConfiguration.openDefaultConnection(Unknown 
Source)
        at 
org.apache.derbyTesting.junit.BaseJDBCTestCase.openDefaultConnection(Unknown 
Source)
        at 
org.apache.derbyTesting.junit.BaseJDBCTestCase.getConnection(Unknown Source)
        at 
org.apache.derbyTesting.functionTests.tests.jdbcapi.ProcedureTest.setUp(Unknown 
Source)
        at org.apache.derbyTesting.junit.BaseTestCase.runBare(Unknown 
Source)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
Caused by: java.sql.SQLException: Java exception: 'access denied 
(java.util.PropertyPermission user.dir read): 
java.security.AccessControlException'.
        ... 43 more
Caused by: java.sql.SQLException: Java exception: 'access denied 
(java.util.PropertyPermission user.dir read): 
java.security.AccessControlException'.
        ... 28 more

FAILURES!!!
Tests run: 27,  Failures: 0,  Errors: 29

Any ideas?

Thanks,
Michelle


Re: Integrating a JUnit test into the test harness was: Re: [Db-derby Wiki] Update of "IntroToJUnit" by SusanCline

Posted by Susan Cline <ho...@pacbell.net>.
--- Daniel John Debrunner <dj...@apache.org> wrote:

> home4slc@pacbell.net wrote:
> 
> > As Dan mentioned below my example about integrating a JUnit test into the Derby test harness
> > was not accurate.  I've changed the wiki page IntroToJUnit to point to the other JUnit wiki
> > pages which are more relevant to Derby for information about this.
> >  
> > However, I've spent some time trying to get my JUnit test that runs fine in stand-alone mode
> > to be integrated into the test harness.  
> >  
> > To be clear what I mean about stand-alone mode, I am successful with these two invocations
> > of the MathTrigFunctionsTest JUnit class:
> >  
> > C:\derby_src\development_branch\trunk>java junit.textui.TestRunner org.apache.de
> > rbyTesting.functionTests.tests.lang.MathTrigFunctionsTest
> > ................
> > Time: 21.231
> > OK (16 tests)
> >  
> > C:\derby_src\development_branch\trunk>java org.apache.derbyTesting.functionTests
> > .harness.RunTest lang/MathTrigFunctionsTest.junit
> > *** Start: MathTrigFunctionsTest jdk1.4.2_09 2006-08-30 14:24:08 ***
> > *** End:   MathTrigFunctionsTest jdk1.4.2_09 2006-08-30 14:24:48 ***
> >  
> > I'm not sure if I have enough time to get this working, or if someone else can help.  Here's
> what I've 
> > done so far, maybe someone has an idea of what needs to be done to get this to work.
> >  
> > 1) Created a class that extends the BaseJDBCTestCase class, which is in the 
> >     org.apache.derbyTesting.functionTests.tests.lang package.
> >     (I've removed the private Connection variable per Dan's suggestion below.)
> >  
> > 2) I created a suite() method shown below:
> >  
> >  public static Test suite() {
> >   TestSuite suite = new TestSuite();
> >   suite.addTestSuite(MathTrigFunctionsTest.class);
> >   TestSetup wrapper = new BaseJDBCTestSetup(suite) {
> >    public void setUp() throws Exception {
> >         // initialize variables
> >    }
> >    protected void tearDown() throws Exception {
> >     super.tearDown();
> >    }
> >   };
> >   return wrapper;
> >  }
> 
> You don't need to have the wrapper, I think what you have defined there
> is a new decorator class that does nothing.
> 
> BaseJDBCTestSetup is an abstract TestSetup class or decorator that can
> be used to build a concrete decorator that uses a JDBC connection.
> Decorators are used to wrap logic (setUp and tearDown) around a set or
> suite of tests. For example if all the cases (fixtures) in your test
> case used a fixed schema that could be created once, you would create it
> in a test decorator setUp and remove it in the tearDown, something like
> 
> >   TestSetup wrapper = new BaseJDBCTestSetup(suite) {
> >    public void setUp() throws Exception {
> >         Statement s = getConnection().createStatement();
>           s.execute("CREATE TABLE ...");
>           s.execute("CREATE INDEX ...");
>           ...
>           s.close();
> >    }
> >    protected void tearDown() throws Exception {
> >         Statement s = getConnection().createStatement();
>           s.execute("DROPTABLE ...");
>           ...
>           s.close();
> >     super.tearDown();
> >    }
> >   };

Oh, okay, thanks I did not know that.  I removed the wrapper and just have a separate
setup() and suite() method.

> 
> 
> > 3) I looked at the _Suite.java file in the lang package.  From what I can tell this adds the
> > suites from LangScripts class' suite.
> 
> It is meant to run all JUnit tests in the lang package, the LangScripts
> is one such test, others have yet to be added because they might need
> additional functionality.
> 
> >  
> > 4) Looking at the LangScripts class it runs only SQL tests.  Just for kicks I added my JUnit
> > test class name to the LangScripts tests to be run to see what would happen;
> >  
> >  private static final String[] SQL_LANGUAGE_TESTS = {
> >   "case",
> >   "constantExpression",
> >   "MathTrigFunctionsTest"
> >   }; 
> 
> LangScripts is a Junit test class that runs SQL scripts in the lang
> package, the array of names in SQL_LANGUAGE_TESTS are names of .sql
> files. It's not a general holder for langauge JUnit tests.
> 
> 
> > *** End:   _Suite jdk1.4.2_09 derbylang:derbylang 2006-08-30 15:14:57 ***
> >  
> > Does anyone know what I have to do to get my MathTrigFunctionsTest to run as part of the
> > test harness using the _Suite class?
> 
> Add a line like this to the tests.lang._Suite.suite() method
> 
>   suite.addTest(MathTrigFunctionsTest.suite());

I wondered about that, but thought that maybe the goal was to make it more modular,
and not just add individual tests this way.  So now I've done that and removed the 
entry from LangScripts and here is the results of running the tests;

No failures when running my test by itself:

java org.apache.derbyTesting.functionTests.harness.RunTest lang/MathTrigFunctionsTest.junit
*** Start: MathTrigFunctionsTest jdk1.4.2_09 2006-08-30 17:48:42 ***
*** End:   MathTrigFunctionsTest jdk1.4.2_09 2006-08-30 17:49:11 ***

No failures when running the _Suite by itself:

java org.apache.derbyTesting.functionTests.harness.RunTest lang/_Suite.junit
*** Start: _Suite jdk1.4.2_09 2006-08-30 17:49:45 ***
*** End:   _Suite jdk1.4.2_09 2006-08-30 17:50:27 ***

But when I try to run the entire derbylang suite the only test that fails is _Suite,
but I'm wondering if it really failed:

java org.apache.derbyTesting.functionTests.harness.RunSuite derbylang

derbylang_fail.txt:
derbylang/derbylang.fail:lang/_Suite.junit

But derbylang_pass.txt shows this at the bottom of the output:
...
derbylang/derbylang.pass:lang/_Suite.junit
/MathTrigFunctionsTest.pass:lang/MathTrigFunctionsTest.junit

Is there something else I need to do to make sure that RunSuite derbylang reports that _Suite
passes?
> 
> Thanks for trying this stuff out, it shows where I need to add more
> comments etc.

Sure, you're welcome.

> Dan.
> 
> 


Re: Integrating a JUnit test into the test harness was: Re: [Db-derby Wiki] Update of "IntroToJUnit" by SusanCline

Posted by Daniel John Debrunner <dj...@apache.org>.
home4slc@pacbell.net wrote:

> As Dan mentioned below my example about integrating a JUnit test into the Derby test harness
> was not accurate.  I've changed the wiki page IntroToJUnit to point to the other JUnit wiki
> pages which are more relevant to Derby for information about this.
>  
> However, I've spent some time trying to get my JUnit test that runs fine in stand-alone mode
> to be integrated into the test harness.  
>  
> To be clear what I mean about stand-alone mode, I am successful with these two invocations
> of the MathTrigFunctionsTest JUnit class:
>  
> C:\derby_src\development_branch\trunk>java junit.textui.TestRunner org.apache.de
> rbyTesting.functionTests.tests.lang.MathTrigFunctionsTest
> ................
> Time: 21.231
> OK (16 tests)
>  
> C:\derby_src\development_branch\trunk>java org.apache.derbyTesting.functionTests
> .harness.RunTest lang/MathTrigFunctionsTest.junit
> *** Start: MathTrigFunctionsTest jdk1.4.2_09 2006-08-30 14:24:08 ***
> *** End:   MathTrigFunctionsTest jdk1.4.2_09 2006-08-30 14:24:48 ***
>  
> I'm not sure if I have enough time to get this working, or if someone else can help.  Here's what I've 
> done so far, maybe someone has an idea of what needs to be done to get this to work.
>  
> 1) Created a class that extends the BaseJDBCTestCase class, which is in the 
>     org.apache.derbyTesting.functionTests.tests.lang package.
>     (I've removed the private Connection variable per Dan's suggestion below.)
>  
> 2) I created a suite() method shown below:
>  
>  public static Test suite() {
>   TestSuite suite = new TestSuite();
>   suite.addTestSuite(MathTrigFunctionsTest.class);
>   TestSetup wrapper = new BaseJDBCTestSetup(suite) {
>    public void setUp() throws Exception {
>         // initialize variables
>    }
>    protected void tearDown() throws Exception {
>     super.tearDown();
>    }
>   };
>   return wrapper;
>  }

You don't need to have the wrapper, I think what you have defined there
is a new decorator class that does nothing.

BaseJDBCTestSetup is an abstract TestSetup class or decorator that can
be used to build a concrete decorator that uses a JDBC connection.
Decorators are used to wrap logic (setUp and tearDown) around a set or
suite of tests. For example if all the cases (fixtures) in your test
case used a fixed schema that could be created once, you would create it
in a test decorator setUp and remove it in the tearDown, something like

>   TestSetup wrapper = new BaseJDBCTestSetup(suite) {
>    public void setUp() throws Exception {
>         Statement s = getConnection().createStatement();
          s.execute("CREATE TABLE ...");
          s.execute("CREATE INDEX ...");
          ...
          s.close();
>    }
>    protected void tearDown() throws Exception {
>         Statement s = getConnection().createStatement();
          s.execute("DROPTABLE ...");
          ...
          s.close();
>     super.tearDown();
>    }
>   };


> 3) I looked at the _Suite.java file in the lang package.  From what I can tell this adds the
> suites from LangScripts class' suite.

It is meant to run all JUnit tests in the lang package, the LangScripts
is one such test, others have yet to be added because they might need
additional functionality.

>  
> 4) Looking at the LangScripts class it runs only SQL tests.  Just for kicks I added my JUnit
> test class name to the LangScripts tests to be run to see what would happen;
>  
>  private static final String[] SQL_LANGUAGE_TESTS = {
>   "case",
>   "constantExpression",
>   "MathTrigFunctionsTest"
>   }; 

LangScripts is a Junit test class that runs SQL scripts in the lang
package, the array of names in SQL_LANGUAGE_TESTS are names of .sql
files. It's not a general holder for langauge JUnit tests.


> *** End:   _Suite jdk1.4.2_09 derbylang:derbylang 2006-08-30 15:14:57 ***
>  
> Does anyone know what I have to do to get my MathTrigFunctionsTest to run as part of the
> test harness using the _Suite class?

Add a line like this to the tests.lang._Suite.suite() method

  suite.addTest(MathTrigFunctionsTest.suite());

Thanks for trying this stuff out, it shows where I need to add more
comments etc.
Dan.