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 Myrna van Lunteren <m....@gmail.com> on 2006/05/26 10:07:43 UTC

junit tests; get*DataSource* methods in BaseJDBCTestCase causing trouble...

Hi,
With revision 389780 some methods were added into BaseJDBCTestCase.java:
"DERBY-1157: Helper methods in BaseJDBCTestCase for creating data sources

Adding getDataSource(), getConnectionPoolDataSource() and
getXADataSource() to BaseJDBCTestCase. The new methods call various
methods in TestUtil for creating the data sources. A minor adjustment
had to be made to TestUtil.getDataSource() in order to make it return
JDBC 4.0 DataSources."

However, this causes trouble with the j9 jvms. So, I need to move
these methods back out of BaseJDBCTestCase.

I can see 3 choices for their new home:

- util/TestConfiguration.java
- util/TestUtil.java
- util/<a new utility class specially for junit tests but I cannot
think of a good name>

My personal preference goes to TestUtil.java, but that looks like it
is at cross purposes with the contribution of 389780. Any input?

Thx,

Myrna

Re: junit tests; get*DataSource* methods in BaseJDBCTestCase causing trouble...

Posted by Andreas Korneliussen <An...@Sun.COM>.
Knut Anders Hatlen wrote:
> Myrna van Lunteren <m....@gmail.com> writes:
> 
>> Hi,
>> With revision 389780 some methods were added into BaseJDBCTestCase.java:
>> "DERBY-1157: Helper methods in BaseJDBCTestCase for creating data sources
>>
>> Adding getDataSource(), getConnectionPoolDataSource() and
>> getXADataSource() to BaseJDBCTestCase. The new methods call various
>> methods in TestUtil for creating the data sources. A minor adjustment
>> had to be made to TestUtil.getDataSource() in order to make it return
>> JDBC 4.0 DataSources."
>>
>> However, this causes trouble with the j9 jvms. So, I need to move
>> these methods back out of BaseJDBCTestCase.
> 
> Out of curiosity, what kind of trouble is it causing? If the method
> signatures cause trouble when the class is loaded, why isn't that the
> case for TestUtil?
> 

Maybe because the methods are not called, and no instance of TestUtil is 
  created (we do create instances of subclasses of BaseJDBCTestCase).

NoClassDefFoundError:
Thrown if the Java Virtual Machine or a ClassLoader instance tries to 
load in the definition of a class (as part of a normal method call or as 
part of creating a new instance using the new expression) and no 
definition of the class could be found.

> The methods don't add significant value, so I think it's OK to remove
> them from BaseJDBCTestCase and let the JUnit tests use the
> corresponding methods in TestUtil instead. If it is possible, we
> should try to keep getDefaultDataSourceProperties().
> 
I think getDefaultDataSourceProperties() could go into TestConfiguration.

What if you want to use them from a TestSetup ? Then you need to call 
BaseJDBCTestCase.getDefaultDataSourceProperties() instead of 
TestConfiguration.getDefaultDataSourceProperties().  I think the second 
alternative is better.

Andreas

Re: junit tests; get*DataSource* methods in BaseJDBCTestCase causing trouble...

Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
Myrna van Lunteren <m....@gmail.com> writes:

> Hi,
> With revision 389780 some methods were added into BaseJDBCTestCase.java:
> "DERBY-1157: Helper methods in BaseJDBCTestCase for creating data sources
>
> Adding getDataSource(), getConnectionPoolDataSource() and
> getXADataSource() to BaseJDBCTestCase. The new methods call various
> methods in TestUtil for creating the data sources. A minor adjustment
> had to be made to TestUtil.getDataSource() in order to make it return
> JDBC 4.0 DataSources."
>
> However, this causes trouble with the j9 jvms. So, I need to move
> these methods back out of BaseJDBCTestCase.

Out of curiosity, what kind of trouble is it causing? If the method
signatures cause trouble when the class is loaded, why isn't that the
case for TestUtil?

> I can see 3 choices for their new home:
>
> - util/TestConfiguration.java
> - util/TestUtil.java
> - util/<a new utility class specially for junit tests but I cannot
> think of a good name>
>
> My personal preference goes to TestUtil.java, but that looks like it
> is at cross purposes with the contribution of 389780. Any input?

The methods don't add significant value, so I think it's OK to remove
them from BaseJDBCTestCase and let the JUnit tests use the
corresponding methods in TestUtil instead. If it is possible, we
should try to keep getDefaultDataSourceProperties().

-- 
Knut Anders

Re: junit tests; get*DataSource* methods in BaseJDBCTestCase causing trouble...

Posted by Andreas Korneliussen <An...@Sun.COM>.
Myrna van Lunteren wrote:
> Hi,
> With revision 389780 some methods were added into BaseJDBCTestCase.java:
> "DERBY-1157: Helper methods in BaseJDBCTestCase for creating data sources
> 
> Adding getDataSource(), getConnectionPoolDataSource() and
> getXADataSource() to BaseJDBCTestCase. The new methods call various
> methods in TestUtil for creating the data sources. A minor adjustment
> had to be made to TestUtil.getDataSource() in order to make it return
> JDBC 4.0 DataSources."
> 
> However, this causes trouble with the j9 jvms. So, I need to move
> these methods back out of BaseJDBCTestCase.
> 
> I can see 3 choices for their new home:
> 
> - util/TestConfiguration.java

I think TestConfiguration should be a placeholder for configuration data 
of the test, and not contain utility methods to get connections / 
datasources.

> - util/TestUtil.java
> - util/<a new utility class specially for junit tests but I cannot
> think of a good name>
> 
> My personal preference goes to TestUtil.java, but that looks like it
> is at cross purposes with the contribution of 389780. Any input?
> 

If you put it into a new utility class, I would propose the name 
"DataSourceFactory" or "TestDataSourceFactory", since it lets you create 
different DataSource objects. It also limits the scope of that utility 
class (TestUtil seems to be very generic in terms of what it can be used 
for).

Andreas

> Thx,
> 
> Myrna