More javadoc.
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Mon, 5 Jul 2010 20:38:58 +0000 (20:38 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Mon, 5 Jul 2010 20:38:58 +0000 (20:38 +0000)
test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContextFactory.java
test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseBuilder.java
test/enterprise/src/main/java/org/wamblee/support/persistence/doc-files/Class_Diagram__org.wamblee.support.persistence__database.jpg [new file with mode: 0644]
test/enterprise/src/main/java/org/wamblee/support/persistence/doc-files/Class_Diagram__org.wamblee.support.persistence__jpatester.jpg [new file with mode: 0644]
test/enterprise/src/main/java/org/wamblee/support/persistence/package-info.java

index d65968a21e5e22e00aad4e5999fb06522d97ac88..158bd6d8b8d8048ff8928e6c844681c0e6fac262 100644 (file)
@@ -27,11 +27,17 @@ import javax.naming.spi.InitialContextFactory;
  * 
  * See {@link #bind(String, Object)} to resp. register the initial context.
  * 
- * To bind objects in the JNDI tree simply use the standard JNDI api: <code>
+ * To start mocking the JNDI tree, call {@link #register()}. 
+ * 
+ * To bind objects in the JNDI tree simply use the standard JNDI api: 
+ * <pre>
  *   InitialContext context = new InitialContext();
  *   MyClass myObj = ...; 
  *   context.bind("a/b", myObj); 
- * </code>
+ * </pre>
+ * 
+ * When finished with a test case, call {@link #unregister()} to unregister the 
+ * JNDI tree again. 
  */
 public class StubInitialContextFactory implements InitialContextFactory {
 
index 6f4956980856d2a0d7df4e06ac588a79d2957d3f..ae7cd28aa78259d08f395056e20b2ae830b07613 100644 (file)
@@ -60,7 +60,7 @@ public class DatabaseBuilder {
      * Environmment variable by which capabilities of the requested database can
      * be defined
      */
-    private static final String DB_CAPABILITIES_PROP = "TEST_DB_CAPABILITIES";
+    public static final String DB_CAPABILITIES_PROP = "TEST_DB_CAPABILITIES";
 
     private static ServiceLoader<DatabaseProvider> LOADER = 
         ServiceLoader.load(DatabaseProvider.class);
diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/doc-files/Class_Diagram__org.wamblee.support.persistence__database.jpg b/test/enterprise/src/main/java/org/wamblee/support/persistence/doc-files/Class_Diagram__org.wamblee.support.persistence__database.jpg
new file mode 100644 (file)
index 0000000..f8e6ced
Binary files /dev/null and b/test/enterprise/src/main/java/org/wamblee/support/persistence/doc-files/Class_Diagram__org.wamblee.support.persistence__database.jpg differ
diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/doc-files/Class_Diagram__org.wamblee.support.persistence__jpatester.jpg b/test/enterprise/src/main/java/org/wamblee/support/persistence/doc-files/Class_Diagram__org.wamblee.support.persistence__jpatester.jpg
new file mode 100644 (file)
index 0000000..965e92b
Binary files /dev/null and b/test/enterprise/src/main/java/org/wamblee/support/persistence/doc-files/Class_Diagram__org.wamblee.support.persistence__jpatester.jpg differ
index d38be5796fed215c5341d165ce549af23a5d4bbd..1ea78e255d6e9e6bb1c712431c4dac3085637de0 100644 (file)
  * This also requires a number of environment variables or system properties to be set, 
  * see {@link ExternalDatabase}. 
  * 
+ * <p>
+ * 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 {@link DatabaseBuilder#DB_CAPABILITIES_PROP}
+ * </p>
+ * 
  * 
  * <a name="db-utils">
  *   <h2>Executing code within a JDBC transaction</h2>
  * </p> 
  * 
  * <a name="design-overview">
- *   <h2>design overview</h2>
+ *   <h2>Design overview</h2>
  * </a>
  * 
- * <h3>Database transaparency</h3>
- * 
- * <h3>Testing using JDBC and DBUnit</h3> 
+ * <h3>Database transparency</h3>
  * 
+ * <br/>
+ * <img src="doc-files/Class_Diagram__org.wamblee.support.persistence__database.jpg"
+ *   alt="database"/>
+ * </br/>
+ * <p>
+ *   {@link DatabaseProvider} uses <code>java.util.ServiceLoader</code> 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. 
+ * </p>
+ * <p>
+ *   Note that the <code>Database</code> 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. 
+ * </p>
+ *  
  * <h3>JPA tester overview</h3>
  * 
+ * <br/>
+ * <img src="doc-files/Class_Diagram__org.wamblee.support.persistence__jpatester.jpg"
+ *   alt="database"/>
+ * </br/>
+ * 
+ * <p><code>JPATester</code> is responsible for:</p>
+ * <ul>
+ *   <li> Starting or connecting to a database, using {@link DatabaseBuilder}. 
+ *   </li>
+ *   <li>  Registering the acquired datasource in JNDI by first stubbing JNDI
+ *       using {@link org.wamblee.support.jndi.StubInitialContextFactory}. 
+ *   </li>
+ *   <li>  Creating the {@link JPABuilder} that will do the JPA heavy lifting. 
+ *   </li>
+ *   <li> Creating the {@link DatabaseUtils} for JDBC and DBUnit testing. 
+ *   </li>
+ * </ul> 
  * 
  * 
  */
 package org.wamblee.support.persistence;
 
-import static org.mockito.Mockito.*;
-
-import javax.persistence.EntityManager;
-
-import org.junit.Before;
-import org.wamblee.support.persistence.JpaBuilder.JpaUnitOfWork;
-import org.wamblee.support.persistence.TransactionProxyFactoryTestBase.Service;
-