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 Gokul Soundararajan <go...@gmail.com> on 2006/07/02 00:56:24 UTC

Running Tests

Hi all,

I'm working on improving the Cache Manager. I have a working trunk copy. I can
run the ij tool and create/access databases. I want to run some tests to verify
my new implementation. I saw that there were some unit tests for the cache
service but I can't seem to get it running properly. The error says that a
certain Class is not found UnitTestMain (I think). The wierdest thing is that I
can run the RunTest class so I'm pretty sure that UnitTestMain should be found.

In addition, when I make the derbyTesting package, I get several errors when
compiling JDBC related files.

Can someone point me to documentation on how to get the tests running? I don't
need to run all of them. Just testing the cache service is enough for now.

Thanks,

Gokul


Re: Running Tests

Posted by Andreas Korneliussen <An...@Sun.COM>.
Gokul Soundararajan wrote:
> Hi Kristian,
> 
> Sorry for the late reply. I noticed that my code had some problems that wouldn't
> allow me to run unit tests. Hopefully, all bugs are fixed now.
> 
> You were correct. JUnit was the problem and now the compile time errors are
> gone. I think I may be running the test incorrectly. I have posted the command
> that I use:
> 
> java 
> -cp $DERBY_HOME/classes/:
> $DERBY_HOME/tools/java/junit.jar:
> $DERBY_HOME/tools/java/jakarta-oro-2.0.8.jar 
> -Dframework=DerbyNetClient 
> org.apache.derbyTesting.functionTests.harness.RunTest unit/cacheService.unit
> 
> With this, I get the following error:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/derbyTesting/unitTests/harness/UnitTestMain
> 

You should also check that you have built all the test-classes:
What is the output of:
ls $DERBY_HOME/classes/org/apache/derbyTesting/unitTests/harness/

If there is no UnitTestMain.class in that directory, try to compile the 
tests with:
ant all

.. and since you have had compile problems, try to compile it from scratch:

ant clobber all buildjars

> Can you confirm/correct the way I'm running the test?
>

It seems correct, however it seems to not all classes have been compiled.

Andreas

> Thanks,
> 
> Gokul
> 
> 


Re: Running Tests

Posted by Kristian Waagan <Kr...@Sun.COM>.
Myrna van Lunteren wrote:
> On 7/10/06, Myrna van Lunteren <m....@gmail.com> wrote:
>> Hi Gokul,
>>
>> The test harness spawns off further java processes which may not
>> inherit the classpath if you use -cp. Please see what you get when you
>> add the classes dir, junit.jar and jakarta jar to an environment
>> variable, then run the test.
>>
>> Myrna
>>
> 
> I meant, add the following to the environment variable $CLASSPATH.
> (not just an environment variable) :
> "$DERBY_HOME/classes:$DERBY_HOME/tools/java/junit.jar:
> $DERBY_HOME/tools/java/jakarta-oro-2.0.8.jar"

Hi Myrna,

I can confirm that you found the problem, and that your suggestion works.

CLASSPATH=$DERBY_HOME/classes:$DERBY_HOME/tools/java/junit.jar:$DERBY_HOME/tools/java/jakarta-oro-2.0.8.jar 
java -Dframework=DerbyNetClient 
org.apache.derbyTesting.functionTests.harness.RunTest unit/cacheService.unit

I was just trying to figure this out myself, because I didn't see the 
reported failure as I run my tests with a script (which sets environment 
variables).

Thanks for giving us the solution :)



Regards,
-- 
Kristian

> 
> Myrna


Re: Running Tests

Posted by Myrna van Lunteren <m....@gmail.com>.
On 7/10/06, Myrna van Lunteren <m....@gmail.com> wrote:
> Hi Gokul,
>
> The test harness spawns off further java processes which may not
> inherit the classpath if you use -cp. Please see what you get when you
> add the classes dir, junit.jar and jakarta jar to an environment
> variable, then run the test.
>
> Myrna
>

I meant, add the following to the environment variable $CLASSPATH.
(not just an environment variable) :
"$DERBY_HOME/classes:$DERBY_HOME/tools/java/junit.jar:
$DERBY_HOME/tools/java/jakarta-oro-2.0.8.jar"

Myrna

Re: Running Tests

Posted by Myrna van Lunteren <m....@gmail.com>.
On 7/10/06, Gokul Soundararajan <go...@gmail.com> wrote:
> Hi Kristian,
>
> Sorry for the late reply. I noticed that my code had some problems that wouldn't
> allow me to run unit tests. Hopefully, all bugs are fixed now.
>
> You were correct. JUnit was the problem and now the compile time errors are
> gone. I think I may be running the test incorrectly. I have posted the command
> that I use:
>
> java
> -cp $DERBY_HOME/classes/:
> $DERBY_HOME/tools/java/junit.jar:
> $DERBY_HOME/tools/java/jakarta-oro-2.0.8.jar
> -Dframework=DerbyNetClient
> org.apache.derbyTesting.functionTests.harness.RunTest unit/cacheService.unit
>
> With this, I get the following error:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/derbyTesting/unitTests/harness/UnitTestMain
>
> Can you confirm/correct the way I'm running the test?
>
> Thanks,
>
> Gokul
>
>
>
Hi Gokul,

The test harness spawns off further java processes which may not
inherit the classpath if you use -cp. Please see what you get when you
add the classes dir, junit.jar and jakarta jar to an environment
variable, then run the test.

Myrna

Re: Running Tests

Posted by Gokul Soundararajan <go...@gmail.com>.
Hi Kristian,

Sorry for the late reply. I noticed that my code had some problems that wouldn't
allow me to run unit tests. Hopefully, all bugs are fixed now.

You were correct. JUnit was the problem and now the compile time errors are
gone. I think I may be running the test incorrectly. I have posted the command
that I use:

java 
-cp $DERBY_HOME/classes/:
$DERBY_HOME/tools/java/junit.jar:
$DERBY_HOME/tools/java/jakarta-oro-2.0.8.jar 
-Dframework=DerbyNetClient 
org.apache.derbyTesting.functionTests.harness.RunTest unit/cacheService.unit

With this, I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/derbyTesting/unitTests/harness/UnitTestMain

Can you confirm/correct the way I'm running the test?

Thanks,

Gokul



Re: Running Tests

Posted by Kristian Waagan <Kr...@Sun.COM>.
Gokul Soundararajan wrote:
> Øystein Grøvlen <Oy...@...> writes:
>
>   
>> Gokul Soundararajan wrote:
>>
>>     
>>> 1. 1st set related to BaseJDBCTestCase with method assertTrue()
>>> 2. 2nd set related to BaseJDBCTestCase.java/ScrollResultSetTest.java with
>>> methods assertEquals(), assertTrue(), and assertFalse()
>>>
>>> These errors seem related. Also, I get the same errors if I build from
>>> ${derby.home} by running "ant testing". Please see below for the error
>>>       
> printouts.
>   
>> Do you get the errors if you do "ant all"?
>>     
>
> I get the similar errors in the testing files only for files in the directory,
> org/apache/derbyTesting/functionTests/tests/jdbcapi/. The files mentioned in my
> earlier post, BaseJDBCTestCase and ScrollResultSetTest are in this directory.
>   
Hello Gokul,

The errors you are getting seem related to JUnit.
What version of JUnit have you put in your $DERBY_HOME/tools/java? Derby 
is using 3.8.1. Don't know how far you get if you are using 4.1 instead.
Also, the file BaseJDBCTestCase should be in 
testing/org/apache/derbyTesting/functionTests/util. I guess 
ScrollResultSetTest is extending this class.

According to the JUnit (v. 3.8.1) JavaDoc, the methods that cause 
compilation errors are valid members of the Assert class. Verify that 
the junit.jar file is valid/working.
You should be able to build the classes in java/testing by doing 'ant 
testing' from $DERBY_HOME, and if you are using jars you must also 
remember to build the testing jar.

I can also confirm that I was able to compile Derby and run the test 
unit/cacheService.unit with revision 418240.



Regards,
-- 
Kristian
>   
>> What happens if you try to run class files in your classpath instead of 
>> jars?  (i.e, CLASSPATH=$DERBY_HOME/classes)
>>     
>
> Same errors.
>
> Thanks for your help.
>
> Gokul
>
>
>
>   


Re: Running Tests

Posted by Gokul Soundararajan <go...@gmail.com>.
Øystein Grøvlen <Oy...@...> writes:

> 
> Gokul Soundararajan wrote:
> 
> > 1. 1st set related to BaseJDBCTestCase with method assertTrue()
> > 2. 2nd set related to BaseJDBCTestCase.java/ScrollResultSetTest.java with
> > methods assertEquals(), assertTrue(), and assertFalse()
> > 
> > These errors seem related. Also, I get the same errors if I build from
> > ${derby.home} by running "ant testing". Please see below for the error
printouts.
> 
> Do you get the errors if you do "ant all"?

I get the similar errors in the testing files only for files in the directory,
org/apache/derbyTesting/functionTests/tests/jdbcapi/. The files mentioned in my
earlier post, BaseJDBCTestCase and ScrollResultSetTest are in this directory.

> What happens if you try to run class files in your classpath instead of 
> jars?  (i.e, CLASSPATH=$DERBY_HOME/classes)

Same errors.

Thanks for your help.

Gokul




Re: Running Tests

Posted by Øystein Grøvlen <Oy...@Sun.COM>.
Gokul Soundararajan wrote:

> 1. 1st set related to BaseJDBCTestCase with method assertTrue()
> 2. 2nd set related to BaseJDBCTestCase.java/ScrollResultSetTest.java with
> methods assertEquals(), assertTrue(), and assertFalse()
> 
> These errors seem related. Also, I get the same errors if I build from
> ${derby.home} by running "ant testing". Please see below for the error printouts.

Do you get the errors if you do "ant all"?

> To run the tests, I wrote a script which runs sysinfo first and then the
> cacheService unit test. It doesn't run any tests. I get the error message:
>  Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/derbyTesting/unitTests/harness/UnitTestMain

What happens if you try to run class files in your classpath instead of 
jars?  (i.e, CLASSPATH=$DERBY_HOME/classes)

--
Øystein


Re: Running Tests

Posted by Gokul Soundararajan <go...@gmail.com>.
Hi Andrew,

Thanks for your help.

> The testing readme is in java/testing/README.htm.

I'm using this document as a guide.

> If you post the errors you are receiving at compile time and run time,
> I can help you track the problem down further.

I'm running ant inside java/testing/. I get 2 sets of compile time errors:

1. 1st set related to BaseJDBCTestCase with method assertTrue()
2. 2nd set related to BaseJDBCTestCase.java/ScrollResultSetTest.java with
methods assertEquals(), assertTrue(), and assertFalse()

These errors seem related. Also, I get the same errors if I build from
${derby.home} by running "ant testing". Please see below for the error printouts.

To run the tests, I wrote a script which runs sysinfo first and then the
cacheService unit test. It doesn't run any tests. I get the error message:
 Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/derbyTesting/unitTests/harness/UnitTestMain

For more details and error messages, please see below.

Thanks,

Gokul

====================================
TESTING SCRIPT
====================================

#!/bin/bash
DERBY_HOME=/home/gokul/code/soc/derby/
DERBY_TESTING=/home/gokul/code/soc/derby/java/testing/

echo "Running system diagnostics"
java -cp
$DERBY_HOME/jars/sane/derbyTesting.jar:
$DERBY_HOME/jars/sane/derby.jar:
$DERBY_HOME/jars/sane/derbytools.jar:
$DERBY_HOME/jars/sane/derbynet.jar:
$DERBY_HOME/jars/sane/derbyclient.jar:
$DERBY_HOME/tools/java/junit.jar:
$DERBY_HOME/tools/java/jakarta-oro-2.0.8.jar
 -Dframework=DerbyNetClient org.apache.derby.tools.sysinfo

java -cp
$DERBY_HOME/jars/sane/derbyTesting.jar:
$DERBY_HOME/jars/sane/derby.jar:
$DERBY_HOME/jars/sane/derbytools.jar:
$DERBY_HOME/jars/sane/derbynet.jar:
$DERBY_HOME/jars/sane/derbyclient.jar:
$DERBY_HOME/jars/sane/derbyrun.jar:
$DERBY_HOME/tools/java/junit.jar:
$DERBY_HOME/tools/java/jakarta-oro-2.0.8.jar  
-Dframework=embedded
org.apache.derbyTesting.functionTests.harness.RunTest unit/cacheService.unit

echo "Done"

==========================================
COMPILE TIME ERRORS - a sample
==========================================

    [javac]
/home/gokul/code/soc/trunk/java/testing/org/apache/derbyTesting/
functionTests/util/BaseJDBCTestCase.java:143:
cannot resolve 
symbol
    [javac] symbol  : method assertTrue (java.lang.String,boolean)
    [javac] location: class
org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase
    [javac]             assertTrue("The expected SQL state must be five
characters long",
    [javac]             ^
    [javac]
/home/gokul/code/soc/trunk/java/testing/org/apache/derbyTesting/
functionTests/util/BaseJDBCTestCase.java:146:
cannot resolve 
symbol
    [javac] symbol  : method assertEquals
(java.lang.String,java.lang.String,java.lang.String)
    [javac] location: class
org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase
    [javac]         assertEquals(message, expected, state);
    [javac]         ^
    [javac] Compile failed; see the compiler error output for details.
    [javac] 4 errors

============================================
RUN TIME ERRORS
============================================

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/derby/tools/sysinfo
Framework: embedded
*** Start: cacheService jdk1.4.2_11 2006-07-02 12:48:59 ***
1 del
< -- Unit Test T_CacheService starting
2 del
< -- Unit Test T_CacheService finished
2 add
> Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/derbyTesting/unitTests/harness/UnitTestMain
Test Failed.
*** End:   cacheService jdk1.4.2_11 2006-07-02 12:49:00 ***






Re: Running Tests

Posted by Andrew McIntyre <mc...@gmail.com>.
On 7/1/06, Gokul Soundararajan <go...@gmail.com> wrote:
>
> In addition, when I make the derbyTesting package, I get several errors when
> compiling JDBC related files.
>
> Can someone point me to documentation on how to get the tests running? I don't
> need to run all of them. Just testing the cache service is enough for now.

The testing readme is in java/testing/README.htm.

If you post the errors you are receiving at compile time and run time,
I can help you track the problem down further.

andrew