From 2a588d6a2bcf8982dcc98aa0a8388740bfea8352 Mon Sep 17 00:00:00 2001 From: Pinaki Poddar Date: Thu, 3 Jul 2008 22:41:07 +0000 Subject: [PATCH] OPENJPA-652: Formatting to be published base TestCases git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@673855 13f79535-47bb-0310-9956-ffa450edef68 --- .../persistence/test/PersistenceTestCase.java | 20 +++++++++++++------ .../persistence/test/SingleEMFTestCase.java | 14 +++++++++++-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java index 0a3709c83..f20312eb0 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java @@ -43,10 +43,15 @@ public abstract class PersistenceTestCase extends TestCase { /** - * Marker object you an pass to {@link #setUp} to indicate that the - * database tables should be cleared. + * Marker object you pass to {@link #setUp} to indicate that the + * database table rows should be cleared. */ protected static final Object CLEAR_TABLES = new Object(); + + /** + * Marker object you pass to {@link #setUp} to indicate that the + * database table should be dropped and then recreated. + */ protected static final Object DROP_TABLES = new Object(); /** @@ -152,7 +157,8 @@ public abstract class PersistenceTestCase } /** - * Closes all open entity managers after first rolling back any open transactions + * Closes all open entity managers after first rolling back any open + * transactions. */ protected void closeAllOpenEMs(EntityManagerFactory emf) { if (emf == null || !emf.isOpen()) @@ -196,15 +202,17 @@ public abstract class PersistenceTestCase protected void clear(EntityManagerFactory emf) { if (emf == null) return; - clear(emf, true, ((OpenJPAEntityManagerFactorySPI) emf).getConfiguration(). - getMetaDataRepositoryInstance().getMetaDatas()); + clear(emf, true, ((OpenJPAEntityManagerFactorySPI) emf) + .getConfiguration() + .getMetaDataRepositoryInstance().getMetaDatas()); } /** * Delete all instances of the given types using bulk delete queries. * @param closeEMs TODO */ - private void clear(EntityManagerFactory emf, boolean closeEMs, ClassMetaData... types) { + private void clear(EntityManagerFactory emf, boolean closeEMs, + ClassMetaData... types) { if (emf == null || types.length == 0) return; diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java index 168c6dc6f..2814024eb 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java @@ -21,6 +21,17 @@ package org.apache.openjpa.persistence.test; import org.apache.openjpa.jdbc.meta.ClassMapping; import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI; +/** + * Base class for OpenJPA-specific Test Case. + * Provides utilities for configuration setup and persistent entity + * registration during setUp() method. + * Derived classes can access protected EntityManagerFactory to create + * EntityManager. The protected EntityManagerFactory is declared to be + * OpenJPA-extended SPI interface OpenJPAEntityManagerFactorySPI + * so that derived classes can access internal mapping/metadata/configuration + * and other structures. + * + */ public abstract class SingleEMFTestCase extends PersistenceTestCase { @@ -71,8 +82,7 @@ public abstract class SingleEMFTestCase /** * Get the class mapping for a given entity * - * @param name - * The Entity's name. + * @param name The Entity's name. * * @return If the entity is a known type the ClassMapping for the Entity * will be returned. Otherwise null