On Thursday 06 January 2005 02:28 am, Janos Mucsi wrote:
> This is not a strictly Maven question.
> 
> Hi Jake
> This sounds very interesting. I have two questions:
> 1. Is testing against an in-process database a better
> idea than using mock-objects to fake Connection,
> ResultSet, etc? (I need to test some hand-coded JDBC
> DAOs which I will redevelop later with Hibernate, but
> I can not throw them away just yet.)

For unit testing, I think it is best to use mock objects to mock the layer 
below the code you're testing.  Mocking JDBC objects like Connection and 
ResultSet can be a lot of work, but it is well worth it because you can force 
exceptional behavior that is very difficult or impossible to reliably create in 
a testing environment with a real database.

For functional tests that are testing functionality with the database, then I 
use a real database.

> 2. Can you please tell me an example for dealing with
> SQL dialect differences. (I guess if you use
> Hibernate, this is taken care of with the dialect
> setting.)

For Schemas, I have 2 different ways of dealing with the differences:
1) Create a custom SQL loading script that replaces macros in the schema file 
with the correct text for that database.  For example, <%datetype%> in the 
schema file might get replaced to DATE in oracle and TIME in sqlserver.
2) Use an ER application like CASE Studio that can automatically generate 
different schema files for different databases.

The insert, select, update, and delete sql statements can just be written 
carefully enough that they work with all databases you support.  I haven't had 
any real problems with doing this.  However, if you are not aiming at database 
independence, then you will not be needlesly removing the ability to use 
specific optimizations with certain databases.


> Janos 
> 
> This is why and how we use HSQL for testing.
> 
> - It is much faster for developers who are in the
> habit of continuous 
> testing to use HSQL instead of (for example) Oracle.
> - We don't have enough Oracle resources (connections,
> accounts, cpu) to 
> support all the developers using it for continuous
> testing.
> - When running inside a debugger (like Eclipse or
> IntelliJ's), you can 
> step down all the way into the database to see exactly
> what the sql is 
> doing.
> 
> - HSQL is only used for developer testing. 
> Cruisecontrol and Maven and 
> QA and everything else use both Oracle and SqlServer.
> - The driver, uri, username, and password are all in
> configuration 
> files, so the same TestSetup is used for all
> databases.
> - The differences in the databases can be solved the
> same way as you 
> would solve compatibility issues between Oracle and
> SqlServer.
> 
> So developing against HSQL and going live against
> Oracle could have 
> some issues, all problems should be found and fixed by
> always running 
> against Oracle with infrastructure tools and in QA.
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to