X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=test%2Fenterprise%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsupport%2Fpersistence%2Fpackage-info.java;h=979dde6f7c0189c5d4a53f709d610403218de996;hb=b57cbdcefda8db670154b97615af84bcada13349;hp=d38be5796fed215c5341d165ce549af23a5d4bbd;hpb=28a9820d1b2fe0dbf9a05aed5a84b79f96cde743;p=utils diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/package-info.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/package-info.java index d38be579..979dde6f 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/package-info.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/package-info.java @@ -42,7 +42,7 @@ * * *
- * See the design overview for a an overview of the design. + * See also the design overview. *
* * @@ -53,9 +53,13 @@ * Database db = DatabaseBuilder.getDatabase(); * DataSource dataSource = db.start(); * + ** If nothing is specified in the user's environment, an inmemory database is started (derby). - * Using the datasource is just standard JDBC now. - * Stopping the database + * Using the datasource is just standard JDBC now. + *
+ *+ * After a test it is good practice to stop the database: + *
** db.stop(); *@@ -72,6 +76,12 @@ * This also requires a number of environment variables or system properties to be set, * see {@link ExternalDatabase}. * + *
+ * However, the most convenient way to set the capabilities is usually to set a system property or environment
+ * variable see the javadocs of {@link DatabaseBuilder}. and
+ * specifically DatabaseBuilder.DB_CAPABILITIES_PROP
+ *
To work with DBUnit, {@link DatabaseUtils#createDbTester(org.dbunit.dataset.filter.ITableFilterSimple)} + *
To work with DBUnit,
+ * DatabaseUtils#createDbTester(org.dbunit.dataset.filter.ITableFilterSimple)
* must be used passing it in the tables to use in the form of a {@link org.dbunit.dataset.filter.ITableFilterSimple}
* object.
Second step is to make sure that all entities are listed explicitly in your - *
persistence.xml. Currently, class path scanning appears to fail when + *
persistence.xml
. Currently, class path scanning appears to fail when
* run from junit.
* Specifying all entities explicitly is not necessarily a bad thing as it is also more efficient.
*
@@ -162,8 +173,8 @@
* get them directly from the JPATester
after initializing it:
* * builder = jpaTester.getJpaBuilder(); - * dbtester = jpaTester.getDbUtils().createDbTester(new MyTables()); * dbutils = jpaTester.getDbUtils(); + * dbtester = dbutils.createDbTester(new MyTables()); ** * @@ -189,26 +200,50 @@ * * * - *
+ * {@link DatabaseProvider} uses java.util.ServiceLoader
to find all implementations
+ * of {@link DatabaseProvider} on the classpath. It then asks the database providers whether
+ * they support the required capabilities (by default inmemory), and the first provider that
+ * supports the capabilities is used to create the database.
+ *
+ * Note that the Database
interface is not intended to always create a database.
+ * It will do so for {@link DerbyDatabase} (inmemory), but with {@link ExternalDatabase}
+ * it simply connects to an external database based on system properties or environment
+ * variables.
+ *
JPATester
is responsible for: