db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohamed Nufail <nufai...@gmail.com>
Subject Re: Tests in Derby
Date Mon, 09 Jul 2012 15:16:21 GMT
Hi akshay,

On Mon, Jul 9, 2012 at 5:25 PM, akshay khatri <akshaykhatri161@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


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

View raw message