Hi Donald,
I like your idea of specifying (un)supportedDatabases, was also thinking about
something like this.
There is a small issue however. When you run TestMultipleSchemaNames with
PostgreSQL, it fails in setUp. This is because the setUnsupportedDatabases
creates an EntityManager which in turn tries to create tables for a schema not
yet created. PostgreSQL requires a schema being created up-front and this is
what createSchemas method does.
I suggest we either:
1. Modify the set(Un)supportedDatabases methods to not create EntityManager. It
is possible to determine the instance of DBDictionary just from
OpenJPAEntityManagerFactory(SPI). That would also have some minor positive
performance impact. An EntityManager would be needed if we wanted DBDictionary
properties be initialized from a connection (see TestXMLCustomerOrder for
example).
2. If for some reason the above is wrong, let's just try to move createSchemas
call before setUnsupportedDatabases call.
Regards,
Milosz
> Some updates I just checked into trunk as r813506 and r813519 under
> openjpa-persistence-jdbc which should make writing and maintaining
> testcases easier...
>
> For setUp() code (all can be used before super.setUp() is called):
> - Added new protected methods of setTestsDisabled()/isTestsDisabled() in
> AbstractPersistenceTestCase which is used by runTest() to automatically
> skip all tests. This keeps us from having to put our own if(skipTests)
> in each testXXX method for most cases (unless you need granular per test
> exclusion capabilities).
>
> setTestsDisabled(!dictionarySupportsXMLColumn());
> if (isTestsDisabled()) {
> return;
> }
>
> - Added new setSupportedDatabases()/setUnsupportedDatabases() methods in
> SingleEMFTestCase to set the testsDisabled flag in
> AbstractPersistenceTestCase, which allows you to exclude all tests based
> on the DB platform being used -
>
> setUnsupportedDatabases(
> org.apache.openjpa.jdbc.sql.MySQLDictionary.class,
> org.apache.openjpa.jdbc.sql.OracleDictionary.class,
> org.apache.openjpa.jdbc.sql.SQLServerDictionary.class);
> if (isTestsDisabled()) {
> return;
> }
>
>
> For general usage:
> - Added a getLog() method in SingleEMFTestCase class for everyone to
> use, instead of having a copy in your own tests. Also, you can now use
> logging before calling super.setUp(), as the getLog() will create a
> temporary EMF if needed.
>
>
>
> -Donald
>