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 akshay khatri <ak...@gmail.com> on 2012/07/09 13:55:27 UTC

Tests in Derby

Hello

I have been learning derby and looked at derby code. I see that Derby has
tests written for most of its classes.
I see that Derby has implementations of most of the Java classes like
PreparedStatement, CallableStatement. But while testing the default
java.sql classes are used.

For example in the case of XAConnection, the test seem to be written in
XA_Test.java. But the XAConnection class used there is from java.sql
package rather than derby's own package.
So does that mean that XAConnection from Derby's package is not included in
test cases ? If that is so, what is the purpose of writing test cases in
that scenario.

How do you add basic unit tests to Derby if I want to contribute  like the
ones in derbyTesting.functionTests package. ? Is there a document for that ?

Re: Tests in Derby

Posted by siddharth srivastava <ak...@gmail.com>.
Hi Akshay

> Thankyou for your reply. Is there an easy way to navigate through the derby
> code. I generally use grep to search through and look around.

You can use any IDE of your choice to setup derby and navigate the code.
This tutorial[1] helps you setup Derby with Eclipse and Netbeans (or
you can use any other IDE using similar options)

[1]: http://wiki.apache.org/db-derby/BuildingDerby



-- 
Regards
Siddharth Srivastava

Re: Tests in Derby

Posted by akshay khatri <ak...@gmail.com>.
Thankyou for your reply. Is there an easy way to navigate through the derby
code. I generally use grep to search through and look around.

Re: Tests in Derby

Posted by Mohamed Nufail <nu...@gmail.com>.
Hi akshay,

On Mon, Jul 9, 2012 at 5:25 PM, akshay khatri <ak...@gmail.com>wrote:

> Hello
>
> I have been learning derby and looked at derby code. I see that Derby has
> tests written for most of its classes.
> I see that Derby has implementations of most of the Java classes like
> PreparedStatement, CallableStatement. But while testing the default
> java.sql classes are used.
>
> For example in the case of XAConnection, the test seem to be written in
> XA_Test.java. But the XAConnection class used there is from java.sql
> package rather than derby's own package.
> So does that mean that XAConnection from Derby's package is not included
> in test cases ? If that is so, what is the purpose of writing test cases in
> that scenario.
>

These tests make use of java inheritance. Actually what's used here are the
implementations of XAConnection from Derby. The java.sql package only has
an interface not a class. So actually it cannot be used.

Although it says java.sql package in the code, at runtime the created
objects are of those type which are in Derby packages. These happen to be
implementations of java.sql interfaces. So they can be assigned to those
interface types.

For example, getXADataSource() in line 88 of XATest.java will return a
Derby specific concrete implementation of XADataSource at runtime. Although
the assigned type is javax.sql.XADataSource the object will still be of
Derby specific types.


> How do you add basic unit tests to Derby if I want to contribute  like the
> ones in derbyTesting.functionTests package. ? Is there a document for that ?
>

[1] has a good collection of docs regarding this.


[1] http://wiki.apache.org/db-derby/DerbyTesting

Regards,
Nufail.
-- 

Mohamed Nufail
Undergraduate,
Department of Computer Science & Engineering,
University of Moratuwa.
Blog: http://www.nufailm.blogspot.com/