*
* 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 {
* 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;
-