On Friday, February 15, 2013 1:25:07 PM UTC+1, Lukas Eder wrote: 2. Maintain your own JDBC implementation (infrequent changes that are > easy to maintain) >
How do I write a unit test that tests a piece of code with Java 5, 6 and 7? Each of these versions uses a different, incompatible JDBC API and I'm pretty sure that Java 8 will include JDBC 4.2. What's worse, I'm not at all interested in maintaining this code and these dependencies. I don't want every project that uses my jOOQ unit test framework to add 100 lines to their POMs so the correct dependency is added to the classpath depending on the Java VM version. I think I could put that into a parent POM, though. But in the end, it would be a lot more effort than hiding query execution behind an interface inside of jOOQ to cut any dependency on JDBC. I feel that you simply say "JDBC mock is much easier" because you never actually tried to build one. I wrote 3 JDBC drivers, I wrote patches to MockRunner and I wrote unit tests using MockRunner. The JDBC API, frankly, sucks. From all the Java APIs, it's the most complex by far, it's the most brittle and the one where they broke every rule regarding API evolution. JDBC is so complicated that it took Oracle more than 10 years to build a driver which doesn't have many major bugs like leaking Cursors when using BLOBs. If JDBC was written by you, it would be an option. But it's not. There is no good way to implement Connection without using a code generator at build time. I would even try to create mocks using Mockito but even then, I still need to write about 200-500 lines of code to implement a mock ResultSet when I just need to mock Cursor.fetch() and you won't let me do that. Just look at org.jooq.impl.FieldTypeHelper.getFromResultSet(ExecuteContext, Class<? extends T>, int) to get an idea how much of the ResultSet API I'd have to replicate. And even when I could mock Cursor.fetch(), ResultImpl is package private so I'd have to cut&paste these 1931 lines to implement Result unless putting my code into org.jooq.impl which I don't like. Regards, A. Digulla -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
