You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mi...@apache.org on 2009/05/21 16:39:43 UTC

svn commit: r777135 [4/10] - in /openjpa/trunk: openjpa-kernel/src/test/java/org/apache/openjpa/meta/ openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/ openjpa-lib/src/test/java/org/apache/openjpa/lib/graph/ openjpa-lib/src/test/java/org/apache/op...

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDataCacheBehavesIdentical.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDataCacheBehavesIdentical.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDataCacheBehavesIdentical.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDataCacheBehavesIdentical.java Thu May 21 14:39:31 2009
@@ -27,8 +27,10 @@
 import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
 import org.apache.openjpa.persistence.StoreCache;
 import org.apache.openjpa.persistence.StoreCacheImpl;
-import org.apache.openjpa.persistence.cache.common.apps.BidirectionalOne2OneOwned;
-import org.apache.openjpa.persistence.cache.common.apps.BidirectionalOne2OneOwner;
+import org.apache.openjpa.persistence.cache.common.apps.
+        BidirectionalOne2OneOwned;
+import org.apache.openjpa.persistence.cache.common.apps.
+        BidirectionalOne2OneOwner;
 import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
 import org.apache.openjpa.persistence.datacache.common.apps.PObject;
 
@@ -48,477 +50,523 @@
  * 
  */
 public class TestDataCacheBehavesIdentical extends AbstractTestCase {
-	private static OpenJPAEntityManagerFactorySPI emfWithDataCache;
-	private static OpenJPAEntityManagerFactorySPI emfWithoutDataCache;
-	
-	private static final boolean WITH_DATACACHE = true;
-	private static final boolean CONSISTENT = true;
-	private static final boolean DIRTY = true;
-	private static final boolean REFRESH_FROM_DATACACHE = true;
-	private static final LockModeType NOLOCK = null;
-	private static final Class ENTITY_NOT_FOUND_ERROR = EntityNotFoundException.class;
-	private static final Class NO_ERROR = null;
-
-	private static final String MARKER_DATACACHE = "in DataCache";
-	private static final String MARKER_DATABASE  = "in Database";
-	private static final String MARKER_CACHE     = "in Object Cache";
-	private static final String MARKER_DIRTY_CACHE = "in Object Cache (dirty)";
-	private static long ID_COUNTER = System.currentTimeMillis();
-	
-
-	/**
-	 * Sets up two EntityManagerFactory: one with DataCache another without.
-	 */
-	public void setUp() throws Exception {
-		super.setUp();
-		if (emfWithDataCache == null) {
-			emfWithDataCache = createEMF(
-					"openjpa.jdbc.SynchronizeMappings",	"buildSchema", 
-					"openjpa.RuntimeUnenhancedClasses",	"unsupported", 
-					"openjpa.DataCache", "true",
-					"openjpa.RemoteCommitProvider", "sjvm",
-					"openjpa.jdbc.UpdateManager", "constraint",
-					PObject.class,
-					BidirectionalOne2OneOwner.class,
-					BidirectionalOne2OneOwned.class, CLEAR_TABLES);
-			emfWithoutDataCache = createEMF(
-					"openjpa.RuntimeUnenhancedClasses",	"unsupported", 
-					"openjpa.DataCache", "false",
-					"openjpa.jdbc.UpdateManager", "constraint",
-					PObject.class,
-					BidirectionalOne2OneOwned.class,
-					BidirectionalOne2OneOwner.class, CLEAR_TABLES);
-
-			assertNotNull(emfWithDataCache);
-			assertNotNull(emfWithoutDataCache);
-
-			// StoreCache is, by design, always non-null 
-			assertNotNull(emfWithDataCache.getStoreCache());
-			assertNotNull(emfWithoutDataCache.getStoreCache());
-
-			// however, following distinguishes whether DataCache is active  
-			assertTrue(isDataCacheActive(emfWithDataCache));
-			assertFalse(isDataCacheActive(emfWithoutDataCache));
-		}
-	}
-	
-	/**
-	 * Affirms via internal structures if the given factory is configured with
-	 * active DataCache. Because, even when DataCache is configured to be
-	 * false, a no-op StoreCache is instantiated by design.
-	 */
-	boolean isDataCacheActive(OpenJPAEntityManagerFactorySPI emf) {
-		return ((StoreCacheImpl) emf.getStoreCache()).getDelegate() != null
-		    && emf.getConfiguration()
-		          .getDataCacheManagerInstance()
-		          .getSystemDataCache() != null;
-	}
-
-	/**
-	 * Create one-to-one bidirectional relation (may or may not be consistent)
-	 * between two pairs of instances. Creates four instances Owner1, Owned1,
-	 * Owner2, Owned2. The first instance has the given id. The id of the other
-	 * instances monotonically increase by 1. The relationship is set either
-	 * consistently or inconsistently. Consistent relation is when Owner1 points
-	 * to Owned1 and Owned1 points back to Owner1. Inconsistent relation is when
-	 * Owner1 points to Owned1 but Owned1 points to Owner2 instead of Owner1.
-	 * 
-	 * 
-	 * @param em
-	 *            the entity manager to persist the instances
-	 * @param id
-	 *            the identifier of the first owner instance. The identifier for
-	 *            the other instances are sequential in order of creation.
-	 * @param consistent
-	 *            if true sets the relationship as consistent.
-	 */
-	public void createBidirectionalRelation(EntityManager em, long id,
-			boolean consistent) {
-		BidirectionalOne2OneOwner owner1 = new BidirectionalOne2OneOwner();
-		BidirectionalOne2OneOwned owned1 = new BidirectionalOne2OneOwned();
-		BidirectionalOne2OneOwner owner2 = new BidirectionalOne2OneOwner();
-		BidirectionalOne2OneOwned owned2 = new BidirectionalOne2OneOwned();
-		
-		owner1.setId(id++);
-		owned1.setId(id++);
-		owner2.setId(id++);
-		owned2.setId(id++);
-		
-		owner1.setName("Owner1");
-		owned1.setName("Owned1");
-		owned2.setName("Owned2");
-		owner2.setName("Owner2");
-
-		owner1.setOwned(owned1);
-		owner2.setOwned(owned2);
-
-		if (consistent) {
-			owned1.setOwner(owner1);
-			owned2.setOwner(owner2);
-		} else {
-			owned1.setOwner(owner2);
-			owned2.setOwner(owner1);
-		}
-
-		em.getTransaction().begin();
-		em.persist(owner1);
-		em.persist(owned1);
-		em.persist(owner2);
-		em.persist(owned2);
-		em.getTransaction().commit();
-		em.clear();
-	}
-
-	/**
-	 * Verifies that bidirectionally related objects can be persisted 
-	 * and later retrieved in a different transaction. 
-	 * 
-	 * Creates interrelated set of four instances.
-	 * Establish their relation either consistently or inconsistently based
-	 * on the given flag.
-	 * Persist them and then clear the context. 
-	 * Fetch the instances in memory again by their identifiers. 
-	 * Compare the interrelations between the fetched instances with the 
-	 * relations of the original instances (which can be consistent or 
-	 * inconsistent). 
-	 * 
-	 * The mapping specification is such that the bidirectional relation is 
-	 * stored in database by a single foreign key. Hence database relation
-	 * is always consistent. Hence the instances retrieved from database are
-	 * always consistently related irrespective of whether they were created
-	 * with consistent or inconsistent relation.
-	 * However, when the instances are retrieved from the data cache, data cache
-	 * will preserve the in-memory relations even when they are inconsistent.
-	 *    
-	 * @param useDataCache
-	 *            use DataCache
-	 * @param consistent
-	 *            assume that the relationship were created as consistent.
-	 */
-	public void verifyBidirectionalRelation(boolean useDataCache,
-			boolean createConsistent, boolean expectConsistent) {
-		EntityManager em = (useDataCache) 
-		                 ? emfWithDataCache.createEntityManager() 
-		                 : emfWithoutDataCache.createEntityManager();
-		                 
-		long id = ID_COUNTER++;
-		ID_COUNTER += 4;
-		createBidirectionalRelation(em, id, createConsistent);
-		
-		
-		BidirectionalOne2OneOwner owner1 = em.find(BidirectionalOne2OneOwner.class, id);
-		BidirectionalOne2OneOwned owned1 = em.find(BidirectionalOne2OneOwned.class, id + 1);
-		BidirectionalOne2OneOwner owner2 = em.find(BidirectionalOne2OneOwner.class, id + 2);
-		BidirectionalOne2OneOwned owned2 = em.find(BidirectionalOne2OneOwned.class, id + 3);
-
-		assertNotNull(owner1);
-		assertNotNull(owner2);
-		assertNotNull(owned1);
-		assertNotNull(owned2);
-
-		assertEquals(owner1, expectConsistent 
-					? owner1.getOwned().getOwner() 
-					: owner2.getOwned().getOwner());
-		assertEquals(owner2, expectConsistent 
-					? owner2.getOwned().getOwner() 
-				    : owner1.getOwned().getOwner());
-
-
-		assertEquals(owned1, owner1.getOwned());
-		assertEquals(expectConsistent ? owner1 : owner2, owned1.getOwner());
-		assertEquals(owned2, owner2.getOwned());
-		assertEquals(expectConsistent ? owner2 : owner1, owned2.getOwner());
-	}
-
-	public void testConsitentBidirectionalRelationIsPreservedWithDataCache() {
-		verifyBidirectionalRelation(WITH_DATACACHE, CONSISTENT, CONSISTENT);
-	}
-
-	public void testConsitentBidirectionalRelationIsPreservedWithoutDataCache() {
-		verifyBidirectionalRelation(!WITH_DATACACHE, CONSISTENT, CONSISTENT);
-	}
-
-	public void testInconsitentBidirectionalRelationIsPreservedWithDataCache() {
-		verifyBidirectionalRelation(WITH_DATACACHE, !CONSISTENT, !CONSISTENT);
-	}
-
-	public void testInconsitentBidirectionalRelationIsNotPreservedWithoutDataCache() {
-		verifyBidirectionalRelation(!WITH_DATACACHE, !CONSISTENT, CONSISTENT);
-	}
-	
-	/**
-	 * Verify that refresh() may fetch state from either the data cache or the
-	 * database based on different conditions. 
-	 * The conditions that impact are 
-	 * a) whether current lock is stronger than NONE 
-	 * b) whether the instance being refreshed is dirty
-	 * 
-	 * An instance is created with data cache marker and persisted. 
-	 * A native SQL is used to update the database record with database marker. 
-	 * The in-memory instance is not aware of this out-of-band update. 
-	 * Then the in-memory instance is refreshed. The marker of the refreshed 
-	 * instance tells whether the instance is refreshed from the data cache
-	 * of the database. 
-	 * 
-	 * @param useDataCache flags if data cache is active. if not, then surely
-	 * refresh always fetch state from the database.
-	 * 
-	 * @param datacache the marker for the copy of the data cached instance
-	 * @param database the marker for the database record
-	 * @param lock lock to be used
-	 * @param makeDirtyBeforeRefresh flags if the instance be dirtied before
-	 * refresh()
-	 * @param expected The expected marker i.e. where the state is refreshed 
-	 * from. This should be always <code>MARKER_DATABASE</code>.
-	 * a) whether DataCache is active
-	 * b) whether current Lock is stronger than NOLOCK
-	 * c) whether the object to be refreshed is dirty
-	 * 
-	 * The following truth table enumerates the possibilities
-	 * 
-	 * Use Cache?   Lock?   Dirty?     Target
-	 *    Y          Y       Y         Database
-	 *    Y          N       Y         Data Cache
-	 *    Y          Y       N         Data Cache
-	 *    Y          N       N         Data Cache
-	 *    
-	 *    N          Y       Y         Database
-	 *    N          N       Y         Database
-	 *    N          Y       N         Object Cache
-	 *    N          N       N         Object Cache
-
-	 */
-	public void verifyRefresh(boolean useDataCache, LockModeType lock, 
-			boolean makeDirtyBeforeRefresh, boolean refreshFromDataCache, 
-			String expected) {
-		OpenJPAEntityManagerFactorySPI emf = (useDataCache)
-			? emfWithDataCache : emfWithoutDataCache;
-		emf.getConfiguration().setRefreshFromDataCache(refreshFromDataCache);
-		OpenJPAEntityManagerSPI em = emf.createEntityManager();
-        
-		em.getTransaction().begin();
-		PObject pc = new PObject();
-		pc.setName(useDataCache ? MARKER_DATACACHE : MARKER_CACHE);
-		em.persist(pc);
-		em.getTransaction().commit();
-		
-		Object oid = pc.getId();
-		StoreCache dataCache = emf.getStoreCache();
-		assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
-		
-		// Modify the record in the database in a separate transaction using
-		// native SQL so that the in-memory instance is not altered 
-		em.getTransaction().begin();
-		String sql = "UPDATE POBJECT SET NAME='"+ MARKER_DATABASE +"' WHERE id="+oid;
-		em.createNativeQuery(sql).executeUpdate();
-		em.getTransaction().commit();
-		
-		assertEquals(useDataCache ? MARKER_DATACACHE : MARKER_CACHE, pc.getName());
-		
-		em.getTransaction().begin();
-		if (makeDirtyBeforeRefresh) {
-			pc.setName(MARKER_DIRTY_CACHE);
-		} 
-		assertEquals(makeDirtyBeforeRefresh, em.isDirty(pc));
-
-		if (lock != null) {
-			((EntityManagerImpl)em).getFetchPlan().setReadLockMode(lock);
-		}
-		em.refresh(pc);
-		
-		assertEquals(expected, pc.getName());
-		em.getTransaction().commit();
-	}
-	
-	/**
-	 * The expected marker i.e. where the state is refreshed from depends on
-	 * a) whether DataCache is active
-	 * b) whether current Lock is stronger than NOLOCK
-	 * c) whether the object to be refreshed is dirty
-	 * 
-	 * The following truth table enumerates the possibilities
-	 * 
-	 * Use Cache?   Lock?   Dirty?     Target
-	 *    Y          Y       Y         Database
-	 *    Y          N       Y         Data Cache
-	 *    Y          Y       N         Data Cache
-	 *    Y          N       N         Data Cache
-	 *    
-	 *    N          Y       Y         Database
-	 *    N          N       Y         Database
-	 *    N          Y       N         Object Cache
-	 *    N          N       N         Object Cache
-	 *    
-	 * @param datacache the marker for 
-	 * @param database
-	 * @param useDataCache
-	 * @param lock
-	 * @param makeDirtyBeforeRefresh
-	 * @return
-	 */
-	String getExpectedMarker(boolean useDataCache, LockModeType lock, 
-			boolean makeDirtyBeforeRefresh) {
-		if (useDataCache) {
-			return (lock != null) ? MARKER_DATABASE : MARKER_DATACACHE; 
-		} else {
-			return MARKER_DATABASE;
-		}
-	}
-	
-	public void testDirtyRefreshWithNoLockHitsDatabase() {
-		verifyRefresh(WITH_DATACACHE, NOLOCK, DIRTY, !REFRESH_FROM_DATACACHE, MARKER_DATACACHE);
-	}
-	
-	public void testDirtyRefreshWithNoLockHitsDataCache() {
-		verifyRefresh(WITH_DATACACHE, NOLOCK, DIRTY, REFRESH_FROM_DATACACHE, MARKER_DATACACHE);
-	}
-	
-	public void testCleanRefreshWithNoLockDoesNotHitDatabase() {
-		verifyRefresh(WITH_DATACACHE, NOLOCK, !DIRTY, !REFRESH_FROM_DATACACHE, MARKER_DATACACHE);
-	}
-	
-	public void testCleanRefreshWithNoLockHitsDataCache() {
-		verifyRefresh(WITH_DATACACHE, NOLOCK, !DIRTY, REFRESH_FROM_DATACACHE, MARKER_DATACACHE);
-	}
-	
-	public void testDirtyRefreshWithReadLockHitsDatabase() {
-		verifyRefresh(WITH_DATACACHE, LockModeType.READ, DIRTY, REFRESH_FROM_DATACACHE, MARKER_DATABASE);
-		verifyRefresh(WITH_DATACACHE, LockModeType.READ, DIRTY, !REFRESH_FROM_DATACACHE, MARKER_DATABASE);
-	}
-	
-	public void testCleanRefreshWithReadLockDoesNotHitDatabase() {
-		verifyRefresh(WITH_DATACACHE, LockModeType.READ, !DIRTY, REFRESH_FROM_DATACACHE, MARKER_DATACACHE);
-		verifyRefresh(WITH_DATACACHE, LockModeType.READ, !DIRTY, !REFRESH_FROM_DATACACHE, MARKER_DATACACHE);
-	}
-	
-	public void testDirtyRefreshWithWriteLockHitsDatabase() {
-		verifyRefresh(WITH_DATACACHE, LockModeType.WRITE, DIRTY, REFRESH_FROM_DATACACHE, MARKER_DATABASE);
-		verifyRefresh(WITH_DATACACHE, LockModeType.WRITE, DIRTY, !REFRESH_FROM_DATACACHE, MARKER_DATABASE);
-	}
-	
-	public void testCleanRefreshWithWriteLockDoesNotHitDatabase() {
-		verifyRefresh(WITH_DATACACHE, LockModeType.WRITE, !DIRTY, REFRESH_FROM_DATACACHE, MARKER_DATACACHE);
-		verifyRefresh(WITH_DATACACHE, LockModeType.WRITE, !DIRTY, !REFRESH_FROM_DATACACHE, MARKER_DATACACHE);
-	}
-	
-	public void testDirtyRefreshWithoutDataCacheAlwaysHitsDatabase() {
-		verifyRefresh(!WITH_DATACACHE, NOLOCK, DIRTY, REFRESH_FROM_DATACACHE, MARKER_DATABASE);
-		verifyRefresh(!WITH_DATACACHE, LockModeType.READ, DIRTY, REFRESH_FROM_DATACACHE, MARKER_DATABASE);
-		verifyRefresh(!WITH_DATACACHE, LockModeType.WRITE, DIRTY, REFRESH_FROM_DATACACHE, MARKER_DATABASE);
-		
-		verifyRefresh(!WITH_DATACACHE, NOLOCK, DIRTY, !REFRESH_FROM_DATACACHE, MARKER_DATABASE);
-		verifyRefresh(!WITH_DATACACHE, LockModeType.READ, DIRTY, !REFRESH_FROM_DATACACHE, MARKER_DATABASE);
-		verifyRefresh(!WITH_DATACACHE, LockModeType.WRITE, DIRTY, !REFRESH_FROM_DATACACHE, MARKER_DATABASE);
-	}
-	
-	public void testCleanRefreshWithoutDataCacheDoesNotHitDatabase() {
-		verifyRefresh(!WITH_DATACACHE, NOLOCK, !DIRTY, REFRESH_FROM_DATACACHE, MARKER_CACHE);
-		verifyRefresh(!WITH_DATACACHE, LockModeType.READ, !DIRTY, REFRESH_FROM_DATACACHE,  MARKER_CACHE);
-		verifyRefresh(!WITH_DATACACHE, LockModeType.WRITE, !DIRTY, REFRESH_FROM_DATACACHE,  MARKER_CACHE);
-		
-		verifyRefresh(!WITH_DATACACHE, NOLOCK, !DIRTY, !REFRESH_FROM_DATACACHE, MARKER_CACHE);
-		verifyRefresh(!WITH_DATACACHE, LockModeType.READ, !DIRTY, !REFRESH_FROM_DATACACHE, MARKER_CACHE);
-		verifyRefresh(!WITH_DATACACHE, LockModeType.WRITE, !DIRTY, !REFRESH_FROM_DATACACHE, MARKER_CACHE);
-	}
-	
-	/**
-	 * Verify behavior of refreshing an instance which has been deleted by
-	 * out-of-band process (e.g. a native SQL in a separate transaction).
-	 * The behavior differs when refresh() without a lock fetches the data from
-	 * DataCache even when the original database record is deleted.
-	 * 
-	 * @param useDataCache
-	 * @param lock
-	 */
-	public void verifyDeleteDetectionOnRefresh(boolean useDataCache, 
-			boolean dirty, LockModeType lock, Class expectedExceptionType) {
-		OpenJPAEntityManagerFactorySPI emf = (useDataCache)
-			? emfWithDataCache : emfWithoutDataCache;
-			
-		OpenJPAEntityManagerSPI em = emf.createEntityManager();
-        
-		em.getTransaction().begin();
-		PObject pc = new PObject();
-		pc.setName(useDataCache ? MARKER_DATACACHE : MARKER_CACHE);
-		em.persist(pc);
-		em.getTransaction().commit();
-		
-		Object oid = pc.getId();
-		StoreCache dataCache = emf.getStoreCache();
-		assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
-		
-		// delete the record in the database in a separate transaction using
-		// native SQL so that the in-memory instance is not altered 
-		em.getTransaction().begin();
-		String sql = "DELETE FROM POBJECT WHERE id="+oid;
-		em.createNativeQuery(sql).executeUpdate();
-		em.getTransaction().commit();
-		
-		// the object cache does not know that the record was deleted
-		assertTrue(em.contains(pc));
-		// nor does the data cache
-		assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
-		
-		/**
-		 * refresh behavior no more depends on current lock. Refresh
-		 * will always attempt to fetch the instance from database 
-		 * raising EntityNotFoundException.
-		 *   
-		 */
-		em.getTransaction().begin();
-		em.getFetchPlan().setReadLockMode(lock);
-		if (dirty) 
-			pc.setName("Dirty Name");
-		try {
-			em.refresh(pc);
-			if (expectedExceptionType != null) {
-				fail("expected " + expectedExceptionType.getSimpleName() + 
-						" for PObject:" + oid);
-			}
-		} catch (Exception ex) {
-			boolean expectedException = expectedExceptionType != null &&
-			    expectedExceptionType.isAssignableFrom(ex.getClass());
-			if (!expectedException) {
-				ex.printStackTrace();
-				String error = (expectedExceptionType == null) 
-					? "no exception" : expectedExceptionType.getName();
-				fail("expected " + error + " for PObject:" + oid);
-			}
-		} finally {
-			em.getTransaction().rollback();
-		}
-	}
-
-	public void testDeleteIsNotDetectedOnCleanRefreshWithoutLockWithDataCache() {
-		verifyDeleteDetectionOnRefresh(WITH_DATACACHE, !DIRTY, NOLOCK, NO_ERROR);
-	}
-	
-	public void testDeleteIsDetectedOnCleanRefreshWithLockWithDataCache() {
-		verifyDeleteDetectionOnRefresh(WITH_DATACACHE, !DIRTY, LockModeType.READ, ENTITY_NOT_FOUND_ERROR);
-		verifyDeleteDetectionOnRefresh(WITH_DATACACHE, !DIRTY, LockModeType.WRITE, ENTITY_NOT_FOUND_ERROR);
-	}
-
-	public void testDeleteIsNotDetectedOnDirtyRefreshWithoutLockWithDataCache() {
-		verifyDeleteDetectionOnRefresh(WITH_DATACACHE, DIRTY, NOLOCK, NO_ERROR);	
-	}
-	
-	public void testDeleteIsDetectedOnDirtyRefreshWithLockWithDataCache() {
-		verifyDeleteDetectionOnRefresh(WITH_DATACACHE, DIRTY, LockModeType.READ, ENTITY_NOT_FOUND_ERROR);
-		verifyDeleteDetectionOnRefresh(WITH_DATACACHE, DIRTY, LockModeType.WRITE, ENTITY_NOT_FOUND_ERROR);
-	}
-	
-	public void testDeleteIsDetectedOnDirtyRefreshWitDataCache() {
-		verifyDeleteDetectionOnRefresh(WITH_DATACACHE, DIRTY, LockModeType.READ, ENTITY_NOT_FOUND_ERROR);
-		verifyDeleteDetectionOnRefresh(WITH_DATACACHE, DIRTY, LockModeType.WRITE, ENTITY_NOT_FOUND_ERROR);
-	}
-	
-	public void testDeleteIsDetectedOnCleanRefreshWithoutLockWithoutDataCache() {
-		verifyDeleteDetectionOnRefresh(!WITH_DATACACHE, !DIRTY, NOLOCK, ENTITY_NOT_FOUND_ERROR);
-	}
-	
-	public void testDeleteIsDetectedOnCleanRefreshWithLockWithoutDataCache() {
-		verifyDeleteDetectionOnRefresh(!WITH_DATACACHE, !DIRTY, LockModeType.READ, ENTITY_NOT_FOUND_ERROR);
-		verifyDeleteDetectionOnRefresh(!WITH_DATACACHE, !DIRTY, LockModeType.WRITE, ENTITY_NOT_FOUND_ERROR);
-	}
+    private static OpenJPAEntityManagerFactorySPI emfWithDataCache;
+    private static OpenJPAEntityManagerFactorySPI emfWithoutDataCache;
+    
+    private static final boolean WITH_DATACACHE = true;
+    private static final boolean CONSISTENT = true;
+    private static final boolean DIRTY = true;
+    private static final boolean REFRESH_FROM_DATACACHE = true;
+    private static final LockModeType NOLOCK = null;
+    private static final Class ENTITY_NOT_FOUND_ERROR =
+        EntityNotFoundException.class;
+    private static final Class NO_ERROR = null;
+
+    private static final String MARKER_DATACACHE = "in DataCache";
+    private static final String MARKER_DATABASE  = "in Database";
+    private static final String MARKER_CACHE     = "in Object Cache";
+    private static final String MARKER_DIRTY_CACHE = "in Object Cache (dirty)";
+    private static long ID_COUNTER = System.currentTimeMillis();
+    
+
+    /**
+     * Sets up two EntityManagerFactory: one with DataCache another without.
+     */
+    public void setUp() throws Exception {
+        super.setUp();
+        if (emfWithDataCache == null) {
+            emfWithDataCache = createEMF(
+                    "openjpa.jdbc.SynchronizeMappings",    "buildSchema", 
+                    "openjpa.RuntimeUnenhancedClasses",    "unsupported", 
+                    "openjpa.DataCache", "true",
+                    "openjpa.RemoteCommitProvider", "sjvm",
+                    "openjpa.jdbc.UpdateManager", "constraint",
+                    PObject.class,
+                    BidirectionalOne2OneOwner.class,
+                    BidirectionalOne2OneOwned.class, CLEAR_TABLES);
+            emfWithoutDataCache = createEMF(
+                    "openjpa.RuntimeUnenhancedClasses",    "unsupported", 
+                    "openjpa.DataCache", "false",
+                    "openjpa.jdbc.UpdateManager", "constraint",
+                    PObject.class,
+                    BidirectionalOne2OneOwned.class,
+                    BidirectionalOne2OneOwner.class, CLEAR_TABLES);
+
+            assertNotNull(emfWithDataCache);
+            assertNotNull(emfWithoutDataCache);
+
+            // StoreCache is, by design, always non-null 
+            assertNotNull(emfWithDataCache.getStoreCache());
+            assertNotNull(emfWithoutDataCache.getStoreCache());
+
+            // however, following distinguishes whether DataCache is active  
+            assertTrue(isDataCacheActive(emfWithDataCache));
+            assertFalse(isDataCacheActive(emfWithoutDataCache));
+        }
+    }
+    
+    /**
+     * Affirms via internal structures if the given factory is configured with
+     * active DataCache. Because, even when DataCache is configured to be
+     * false, a no-op StoreCache is instantiated by design.
+     */
+    boolean isDataCacheActive(OpenJPAEntityManagerFactorySPI emf) {
+        return ((StoreCacheImpl) emf.getStoreCache()).getDelegate() != null
+            && emf.getConfiguration()
+                  .getDataCacheManagerInstance()
+                  .getSystemDataCache() != null;
+    }
+
+    /**
+     * Create one-to-one bidirectional relation (may or may not be consistent)
+     * between two pairs of instances. Creates four instances Owner1, Owned1,
+     * Owner2, Owned2. The first instance has the given id. The id of the other
+     * instances monotonically increase by 1. The relationship is set either
+     * consistently or inconsistently. Consistent relation is when Owner1 points
+     * to Owned1 and Owned1 points back to Owner1. Inconsistent relation is when
+     * Owner1 points to Owned1 but Owned1 points to Owner2 instead of Owner1.
+     * 
+     * 
+     * @param em
+     *            the entity manager to persist the instances
+     * @param id
+     *            the identifier of the first owner instance. The identifier for
+     *            the other instances are sequential in order of creation.
+     * @param consistent
+     *            if true sets the relationship as consistent.
+     */
+    public void createBidirectionalRelation(EntityManager em, long id,
+            boolean consistent) {
+        BidirectionalOne2OneOwner owner1 = new BidirectionalOne2OneOwner();
+        BidirectionalOne2OneOwned owned1 = new BidirectionalOne2OneOwned();
+        BidirectionalOne2OneOwner owner2 = new BidirectionalOne2OneOwner();
+        BidirectionalOne2OneOwned owned2 = new BidirectionalOne2OneOwned();
+        
+        owner1.setId(id++);
+        owned1.setId(id++);
+        owner2.setId(id++);
+        owned2.setId(id++);
+        
+        owner1.setName("Owner1");
+        owned1.setName("Owned1");
+        owned2.setName("Owned2");
+        owner2.setName("Owner2");
+
+        owner1.setOwned(owned1);
+        owner2.setOwned(owned2);
+
+        if (consistent) {
+            owned1.setOwner(owner1);
+            owned2.setOwner(owner2);
+        } else {
+            owned1.setOwner(owner2);
+            owned2.setOwner(owner1);
+        }
+
+        em.getTransaction().begin();
+        em.persist(owner1);
+        em.persist(owned1);
+        em.persist(owner2);
+        em.persist(owned2);
+        em.getTransaction().commit();
+        em.clear();
+    }
+
+    /**
+     * Verifies that bidirectionally related objects can be persisted 
+     * and later retrieved in a different transaction. 
+     * 
+     * Creates interrelated set of four instances.
+     * Establish their relation either consistently or inconsistently based
+     * on the given flag.
+     * Persist them and then clear the context. 
+     * Fetch the instances in memory again by their identifiers. 
+     * Compare the interrelations between the fetched instances with the 
+     * relations of the original instances (which can be consistent or 
+     * inconsistent). 
+     * 
+     * The mapping specification is such that the bidirectional relation is 
+     * stored in database by a single foreign key. Hence database relation
+     * is always consistent. Hence the instances retrieved from database are
+     * always consistently related irrespective of whether they were created
+     * with consistent or inconsistent relation.
+     * However, when the instances are retrieved from the data cache, data cache
+     * will preserve the in-memory relations even when they are inconsistent.
+     *    
+     * @param useDataCache
+     *            use DataCache
+     * @param consistent
+     *            assume that the relationship were created as consistent.
+     */
+    public void verifyBidirectionalRelation(boolean useDataCache,
+            boolean createConsistent, boolean expectConsistent) {
+        EntityManager em = (useDataCache) 
+                         ? emfWithDataCache.createEntityManager() 
+                         : emfWithoutDataCache.createEntityManager();
+                         
+        long id = ID_COUNTER++;
+        ID_COUNTER += 4;
+        createBidirectionalRelation(em, id, createConsistent);
+        
+        
+        BidirectionalOne2OneOwner owner1 =
+            em.find(BidirectionalOne2OneOwner.class, id);
+        BidirectionalOne2OneOwned owned1 =
+            em.find(BidirectionalOne2OneOwned.class, id + 1);
+        BidirectionalOne2OneOwner owner2 =
+            em.find(BidirectionalOne2OneOwner.class, id + 2);
+        BidirectionalOne2OneOwned owned2 =
+            em.find(BidirectionalOne2OneOwned.class, id + 3);
+
+        assertNotNull(owner1);
+        assertNotNull(owner2);
+        assertNotNull(owned1);
+        assertNotNull(owned2);
+
+        assertEquals(owner1, expectConsistent 
+                    ? owner1.getOwned().getOwner() 
+                    : owner2.getOwned().getOwner());
+        assertEquals(owner2, expectConsistent 
+                    ? owner2.getOwned().getOwner() 
+                    : owner1.getOwned().getOwner());
+
+
+        assertEquals(owned1, owner1.getOwned());
+        assertEquals(expectConsistent ? owner1 : owner2, owned1.getOwner());
+        assertEquals(owned2, owner2.getOwned());
+        assertEquals(expectConsistent ? owner2 : owner1, owned2.getOwner());
+    }
+
+    public void testConsitentBidirectionalRelationIsPreservedWithDataCache() {
+        verifyBidirectionalRelation(WITH_DATACACHE, CONSISTENT, CONSISTENT);
+    }
+
+    public void testConsitentBidirectionalRelationIsPreservedWithoutDataCache()
+    {
+        verifyBidirectionalRelation(!WITH_DATACACHE, CONSISTENT, CONSISTENT);
+    }
+
+    public void testInconsitentBidirectionalRelationIsPreservedWithDataCache() {
+        verifyBidirectionalRelation(WITH_DATACACHE, !CONSISTENT, !CONSISTENT);
+    }
+
+    public void
+        testInconsitentBidirectionalRelationIsNotPreservedWithoutDataCache() {
+        verifyBidirectionalRelation(!WITH_DATACACHE, !CONSISTENT, CONSISTENT);
+    }
+    
+    /**
+     * Verify that refresh() may fetch state from either the data cache or the
+     * database based on different conditions. 
+     * The conditions that impact are 
+     * a) whether current lock is stronger than NONE 
+     * b) whether the instance being refreshed is dirty
+     * 
+     * An instance is created with data cache marker and persisted. 
+     * A native SQL is used to update the database record with database marker. 
+     * The in-memory instance is not aware of this out-of-band update. 
+     * Then the in-memory instance is refreshed. The marker of the refreshed 
+     * instance tells whether the instance is refreshed from the data cache
+     * of the database. 
+     * 
+     * @param useDataCache flags if data cache is active. if not, then surely
+     * refresh always fetch state from the database.
+     * 
+     * @param datacache the marker for the copy of the data cached instance
+     * @param database the marker for the database record
+     * @param lock lock to be used
+     * @param makeDirtyBeforeRefresh flags if the instance be dirtied before
+     * refresh()
+     * @param expected The expected marker i.e. where the state is refreshed 
+     * from. This should be always <code>MARKER_DATABASE</code>.
+     * a) whether DataCache is active
+     * b) whether current Lock is stronger than NOLOCK
+     * c) whether the object to be refreshed is dirty
+     * 
+     * The following truth table enumerates the possibilities
+     * 
+     * Use Cache?   Lock?   Dirty?     Target
+     *    Y          Y       Y         Database
+     *    Y          N       Y         Data Cache
+     *    Y          Y       N         Data Cache
+     *    Y          N       N         Data Cache
+     *    
+     *    N          Y       Y         Database
+     *    N          N       Y         Database
+     *    N          Y       N         Object Cache
+     *    N          N       N         Object Cache
+
+     */
+    public void verifyRefresh(boolean useDataCache, LockModeType lock, 
+            boolean makeDirtyBeforeRefresh, boolean refreshFromDataCache, 
+            String expected) {
+        OpenJPAEntityManagerFactorySPI emf = (useDataCache)
+            ? emfWithDataCache : emfWithoutDataCache;
+        emf.getConfiguration().setRefreshFromDataCache(refreshFromDataCache);
+        OpenJPAEntityManagerSPI em = emf.createEntityManager();
+        
+        em.getTransaction().begin();
+        PObject pc = new PObject();
+        pc.setName(useDataCache ? MARKER_DATACACHE : MARKER_CACHE);
+        em.persist(pc);
+        em.getTransaction().commit();
+        
+        Object oid = pc.getId();
+        StoreCache dataCache = emf.getStoreCache();
+        assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
+        
+        // Modify the record in the database in a separate transaction using
+        // native SQL so that the in-memory instance is not altered 
+        em.getTransaction().begin();
+        String sql = "UPDATE POBJECT SET NAME='" + MARKER_DATABASE
+        + "' WHERE id=" + oid;
+        em.createNativeQuery(sql).executeUpdate();
+        em.getTransaction().commit();
+        
+        assertEquals(useDataCache ? MARKER_DATACACHE : MARKER_CACHE,
+                pc.getName());
+        
+        em.getTransaction().begin();
+        if (makeDirtyBeforeRefresh) {
+            pc.setName(MARKER_DIRTY_CACHE);
+        } 
+        assertEquals(makeDirtyBeforeRefresh, em.isDirty(pc));
+
+        if (lock != null) {
+            ((EntityManagerImpl)em).getFetchPlan().setReadLockMode(lock);
+        }
+        em.refresh(pc);
+        
+        assertEquals(expected, pc.getName());
+        em.getTransaction().commit();
+    }
+    
+    /**
+     * The expected marker i.e. where the state is refreshed from depends on
+     * a) whether DataCache is active
+     * b) whether current Lock is stronger than NOLOCK
+     * c) whether the object to be refreshed is dirty
+     * 
+     * The following truth table enumerates the possibilities
+     * 
+     * Use Cache?   Lock?   Dirty?     Target
+     *    Y          Y       Y         Database
+     *    Y          N       Y         Data Cache
+     *    Y          Y       N         Data Cache
+     *    Y          N       N         Data Cache
+     *    
+     *    N          Y       Y         Database
+     *    N          N       Y         Database
+     *    N          Y       N         Object Cache
+     *    N          N       N         Object Cache
+     *    
+     * @param datacache the marker for 
+     * @param database
+     * @param useDataCache
+     * @param lock
+     * @param makeDirtyBeforeRefresh
+     * @return
+     */
+    String getExpectedMarker(boolean useDataCache, LockModeType lock, 
+            boolean makeDirtyBeforeRefresh) {
+        if (useDataCache) {
+            return (lock != null) ? MARKER_DATABASE : MARKER_DATACACHE; 
+        } else {
+            return MARKER_DATABASE;
+        }
+    }
+    
+    public void testDirtyRefreshWithNoLockHitsDatabase() {
+        verifyRefresh(WITH_DATACACHE, NOLOCK, DIRTY, !REFRESH_FROM_DATACACHE,
+                MARKER_DATACACHE);
+    }
+    
+    public void testDirtyRefreshWithNoLockHitsDataCache() {
+        verifyRefresh(WITH_DATACACHE, NOLOCK, DIRTY, REFRESH_FROM_DATACACHE,
+                MARKER_DATACACHE);
+    }
+    
+    public void testCleanRefreshWithNoLockDoesNotHitDatabase() {
+        verifyRefresh(WITH_DATACACHE, NOLOCK, !DIRTY, !REFRESH_FROM_DATACACHE,
+                MARKER_DATACACHE);
+    }
+    
+    public void testCleanRefreshWithNoLockHitsDataCache() {
+        verifyRefresh(WITH_DATACACHE, NOLOCK, !DIRTY, REFRESH_FROM_DATACACHE,
+                MARKER_DATACACHE);
+    }
+    
+    public void testDirtyRefreshWithReadLockHitsDatabase() {
+        verifyRefresh(WITH_DATACACHE, LockModeType.READ, DIRTY,
+                REFRESH_FROM_DATACACHE, MARKER_DATABASE);
+        verifyRefresh(WITH_DATACACHE, LockModeType.READ, DIRTY,
+                !REFRESH_FROM_DATACACHE, MARKER_DATABASE);
+    }
+    
+    public void testCleanRefreshWithReadLockDoesNotHitDatabase() {
+        verifyRefresh(WITH_DATACACHE, LockModeType.READ, !DIRTY,
+                REFRESH_FROM_DATACACHE, MARKER_DATACACHE);
+        verifyRefresh(WITH_DATACACHE, LockModeType.READ, !DIRTY,
+                !REFRESH_FROM_DATACACHE, MARKER_DATACACHE);
+    }
+    
+    public void testDirtyRefreshWithWriteLockHitsDatabase() {
+        verifyRefresh(WITH_DATACACHE, LockModeType.WRITE, DIRTY,
+                REFRESH_FROM_DATACACHE, MARKER_DATABASE);
+        verifyRefresh(WITH_DATACACHE, LockModeType.WRITE, DIRTY,
+                !REFRESH_FROM_DATACACHE, MARKER_DATABASE);
+    }
+    
+    public void testCleanRefreshWithWriteLockDoesNotHitDatabase() {
+        verifyRefresh(WITH_DATACACHE, LockModeType.WRITE, !DIRTY,
+                REFRESH_FROM_DATACACHE, MARKER_DATACACHE);
+        verifyRefresh(WITH_DATACACHE, LockModeType.WRITE, !DIRTY,
+                !REFRESH_FROM_DATACACHE, MARKER_DATACACHE);
+    }
+    
+    public void testDirtyRefreshWithoutDataCacheAlwaysHitsDatabase() {
+        verifyRefresh(!WITH_DATACACHE, NOLOCK, DIRTY, REFRESH_FROM_DATACACHE,
+                MARKER_DATABASE);
+        verifyRefresh(!WITH_DATACACHE, LockModeType.READ, DIRTY,
+                REFRESH_FROM_DATACACHE, MARKER_DATABASE);
+        verifyRefresh(!WITH_DATACACHE, LockModeType.WRITE, DIRTY,
+                REFRESH_FROM_DATACACHE, MARKER_DATABASE);
+        
+        verifyRefresh(!WITH_DATACACHE, NOLOCK, DIRTY, !REFRESH_FROM_DATACACHE,
+                MARKER_DATABASE);
+        verifyRefresh(!WITH_DATACACHE, LockModeType.READ, DIRTY,
+                !REFRESH_FROM_DATACACHE, MARKER_DATABASE);
+        verifyRefresh(!WITH_DATACACHE, LockModeType.WRITE, DIRTY,
+                !REFRESH_FROM_DATACACHE, MARKER_DATABASE);
+    }
+    
+    public void testCleanRefreshWithoutDataCacheDoesNotHitDatabase() {
+        verifyRefresh(!WITH_DATACACHE, NOLOCK, !DIRTY, REFRESH_FROM_DATACACHE,
+                MARKER_CACHE);
+        verifyRefresh(!WITH_DATACACHE, LockModeType.READ, !DIRTY,
+                REFRESH_FROM_DATACACHE,  MARKER_CACHE);
+        verifyRefresh(!WITH_DATACACHE, LockModeType.WRITE, !DIRTY,
+                REFRESH_FROM_DATACACHE,  MARKER_CACHE);
+        
+        verifyRefresh(!WITH_DATACACHE, NOLOCK, !DIRTY, !REFRESH_FROM_DATACACHE,
+                MARKER_CACHE);
+        verifyRefresh(!WITH_DATACACHE, LockModeType.READ, !DIRTY,
+                !REFRESH_FROM_DATACACHE, MARKER_CACHE);
+        verifyRefresh(!WITH_DATACACHE, LockModeType.WRITE, !DIRTY,
+                !REFRESH_FROM_DATACACHE, MARKER_CACHE);
+    }
+    
+    /**
+     * Verify behavior of refreshing an instance which has been deleted by
+     * out-of-band process (e.g. a native SQL in a separate transaction).
+     * The behavior differs when refresh() without a lock fetches the data from
+     * DataCache even when the original database record is deleted.
+     * 
+     * @param useDataCache
+     * @param lock
+     */
+    public void verifyDeleteDetectionOnRefresh(boolean useDataCache, 
+            boolean dirty, LockModeType lock, Class expectedExceptionType) {
+        OpenJPAEntityManagerFactorySPI emf = (useDataCache)
+            ? emfWithDataCache : emfWithoutDataCache;
+            
+        OpenJPAEntityManagerSPI em = emf.createEntityManager();
+        
+        em.getTransaction().begin();
+        PObject pc = new PObject();
+        pc.setName(useDataCache ? MARKER_DATACACHE : MARKER_CACHE);
+        em.persist(pc);
+        em.getTransaction().commit();
+        
+        Object oid = pc.getId();
+        StoreCache dataCache = emf.getStoreCache();
+        assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
+        
+        // delete the record in the database in a separate transaction using
+        // native SQL so that the in-memory instance is not altered 
+        em.getTransaction().begin();
+        String sql = "DELETE FROM POBJECT WHERE id="+oid;
+        em.createNativeQuery(sql).executeUpdate();
+        em.getTransaction().commit();
+        
+        // the object cache does not know that the record was deleted
+        assertTrue(em.contains(pc));
+        // nor does the data cache
+        assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
+        
+        /**
+         * refresh behavior no more depends on current lock. Refresh
+         * will always attempt to fetch the instance from database 
+         * raising EntityNotFoundException.
+         *   
+         */
+        em.getTransaction().begin();
+        em.getFetchPlan().setReadLockMode(lock);
+        if (dirty) 
+            pc.setName("Dirty Name");
+        try {
+            em.refresh(pc);
+            if (expectedExceptionType != null) {
+                fail("expected " + expectedExceptionType.getSimpleName() + 
+                        " for PObject:" + oid);
+            }
+        } catch (Exception ex) {
+            boolean expectedException = expectedExceptionType != null &&
+                expectedExceptionType.isAssignableFrom(ex.getClass());
+            if (!expectedException) {
+                ex.printStackTrace();
+                String error = (expectedExceptionType == null) 
+                    ? "no exception" : expectedExceptionType.getName();
+                fail("expected " + error + " for PObject:" + oid);
+            }
+        } finally {
+            em.getTransaction().rollback();
+        }
+    }
+
+    public void testDeleteIsNotDetectedOnCleanRefreshWithoutLockWithDataCache()
+    {
+        verifyDeleteDetectionOnRefresh(WITH_DATACACHE, !DIRTY, NOLOCK,
+                NO_ERROR);
+    }
+    
+    public void testDeleteIsDetectedOnCleanRefreshWithLockWithDataCache() {
+        verifyDeleteDetectionOnRefresh(WITH_DATACACHE, !DIRTY,
+                LockModeType.READ, ENTITY_NOT_FOUND_ERROR);
+        verifyDeleteDetectionOnRefresh(WITH_DATACACHE, !DIRTY,
+                LockModeType.WRITE, ENTITY_NOT_FOUND_ERROR);
+    }
+
+    public void testDeleteIsNotDetectedOnDirtyRefreshWithoutLockWithDataCache()
+    {
+        verifyDeleteDetectionOnRefresh(WITH_DATACACHE, DIRTY, NOLOCK, NO_ERROR);
+    }
+    
+    public void testDeleteIsDetectedOnDirtyRefreshWithLockWithDataCache() {
+        verifyDeleteDetectionOnRefresh(WITH_DATACACHE, DIRTY, LockModeType.READ,
+                ENTITY_NOT_FOUND_ERROR);
+        verifyDeleteDetectionOnRefresh(WITH_DATACACHE, DIRTY,
+                LockModeType.WRITE, ENTITY_NOT_FOUND_ERROR);
+    }
+    
+    public void testDeleteIsDetectedOnDirtyRefreshWitDataCache() {
+        verifyDeleteDetectionOnRefresh(WITH_DATACACHE, DIRTY, LockModeType.READ,
+                ENTITY_NOT_FOUND_ERROR);
+        verifyDeleteDetectionOnRefresh(WITH_DATACACHE, DIRTY,
+                LockModeType.WRITE, ENTITY_NOT_FOUND_ERROR);
+    }
+    
+    public void testDeleteIsDetectedOnCleanRefreshWithoutLockWithoutDataCache()
+    {
+        verifyDeleteDetectionOnRefresh(!WITH_DATACACHE, !DIRTY, NOLOCK,
+                ENTITY_NOT_FOUND_ERROR);
+    }
+    
+    public void testDeleteIsDetectedOnCleanRefreshWithLockWithoutDataCache() {
+        verifyDeleteDetectionOnRefresh(!WITH_DATACACHE,
+                !DIRTY, LockModeType.READ, ENTITY_NOT_FOUND_ERROR);
+        verifyDeleteDetectionOnRefresh(!WITH_DATACACHE,
+                !DIRTY, LockModeType.WRITE, ENTITY_NOT_FOUND_ERROR);
+    }
 
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDataCacheScheduler.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDataCacheScheduler.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDataCacheScheduler.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDataCacheScheduler.java Thu May 21 14:39:31 2009
@@ -63,8 +63,8 @@
         throws Exception {
         String sched = MINUTES + " * * * *";
         Map propsMap = new HashMap();
-        propsMap
-            .put("openjpa.DataCache", "true(EvictionSchedule=\"" + sched + "\")");
+        propsMap.put("openjpa.DataCache", "true(EvictionSchedule=\"" + sched
+                + "\")");
         propsMap.put("openjpa.RemoteCommitProvider", "sjvm");
         propsMap.put("openjpa.FlushBeforeQueries", "true");
         propsMap.put("openjpa.BrokerImpl", CacheTestBroker.class.getName());

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDistributedKodoDataCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDistributedKodoDataCache.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDistributedKodoDataCache.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDistributedKodoDataCache.java Thu May 21 14:39:31 2009
@@ -156,9 +156,8 @@
             rcpType = "classes";
         }
         System.out.println("-------------------");
-        System.out
-            .println(
-                "2 PMFs created, acting as a cluster using ports 5636 and 6636");
+        System.out.println(
+            "2 PMFs created, acting as a cluster using ports 5636 and 6636");
         System.out.println("Testing scenario:");
         System.out
             .println("  1 Seed datastore with instances of RuntimeTest1 AND "
@@ -316,8 +315,8 @@
 
             propsMap = new HashMap();
             propsMap.put("openjpa.DataCache", "lru");
-            propsMap.put("openjpa.RemoteCommitProvider", Configurations.getPlugin(
-                providerClass.getName(), classProps1));
+            propsMap.put("openjpa.RemoteCommitProvider",
+                Configurations.getPlugin(providerClass.getName(), classProps1));
             propsMap.put("openjpa.FetchGroups", "differentiatingFetchGroup"
                 + _fetchGroupSerial);
         } else {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestEmbeddedCollection.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestEmbeddedCollection.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestEmbeddedCollection.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestEmbeddedCollection.java Thu May 21 14:39:31 2009
@@ -26,7 +26,8 @@
 import org.apache.openjpa.persistence.OpenJPAPersistence;
 import org.apache.openjpa.persistence.StoreCacheImpl;
 import org.apache.openjpa.persistence.datacache.common.apps.EmbeddedEntity;
-import org.apache.openjpa.persistence.datacache.common.apps.EmbeddingOwnerEntity;
+import org.apache.openjpa.persistence.datacache.common.apps.
+        EmbeddingOwnerEntity;
 import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 /**
@@ -47,10 +48,10 @@
 	 */
 	public void setUp() throws Exception {
 		if (emf == null) {
-			super.setUp("openjpa.jdbc.SynchronizeMappings", "buildSchema",
-					"openjpa.RuntimeUnenhancedClasses", "unsupported",
-					"openjpa.DataCache", "true", "openjpa.RemoteCommitProvider",
-					"sjvm", "openjpa.jdbc.UpdateManager", "constraint",
+            super.setUp("openjpa.jdbc.SynchronizeMappings", "buildSchema",
+                    "openjpa.RuntimeUnenhancedClasses", "unsupported",
+                    "openjpa.DataCache", "true", "openjpa.RemoteCommitProvider",
+                    "sjvm", "openjpa.jdbc.UpdateManager", "constraint",
 					EmbeddingOwnerEntity.class, 
 					EmbeddedEntity.class,
 					CLEAR_TABLES);
@@ -64,8 +65,8 @@
 	}
 
 	boolean isDataCacheActive(OpenJPAEntityManagerFactorySPI emf) {
-		return ((StoreCacheImpl) emf.getStoreCache()).getDelegate() != null
-				&& emf.getConfiguration().getDataCacheManagerInstance()
+        return ((StoreCacheImpl) emf.getStoreCache()).getDelegate() != null
+                && emf.getConfiguration().getDataCacheManagerInstance()
 						.getSystemDataCache() != null;
 	}
 	
@@ -88,7 +89,7 @@
 		Object id = OpenJPAPersistence.cast(em).getObjectId(owner);
 		em.clear();
 
-		EmbeddingOwnerEntity test = em.find(EmbeddingOwnerEntity.class, id);
+        EmbeddingOwnerEntity test = em.find(EmbeddingOwnerEntity.class, id);
 		assertNotNull(test);
 		List<EmbeddedEntity> members = test.getMembers();
 		assertNotNull(members);
@@ -101,7 +102,7 @@
 		EntityManager em = emf.createEntityManager();
 		em.getTransaction().begin();
 		List<EmbeddingOwnerEntity> result = em.createQuery(
-				"SELECT p FROM EmbeddingOwnerEntity p").getResultList();
+                "SELECT p FROM EmbeddingOwnerEntity p").getResultList();
 
 		assertNotNull(result);
 		assertFalse(result.isEmpty());
@@ -109,7 +110,8 @@
 		EmbeddingOwnerEntity owner = result.get(0);
 		Object id = owner.getId();
 		
-		assertTrue(emf.getStoreCache().contains(EmbeddingOwnerEntity.class, id));
+        assertTrue(emf.getStoreCache().contains(EmbeddingOwnerEntity.class,
+                id));
 		
 		List<EmbeddedEntity> members = owner.getMembers();
 		members.remove(0);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestFlushDataCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestFlushDataCache.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestFlushDataCache.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestFlushDataCache.java Thu May 21 14:39:31 2009
@@ -25,7 +25,8 @@
 import javax.persistence.EntityManagerFactory;
 
 
-import org.apache.openjpa.persistence.datacache.common.apps.FlushDataCacheObject;
+import org.apache.openjpa.persistence.datacache.common.apps.
+        FlushDataCacheObject;
 import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
 
 public class TestFlushDataCache
@@ -45,14 +46,20 @@
         propsMap.put("openjpa.RemoteCommitProvider", "sjvm");
         propsMap.put("openjpa.FlushBeforeQueries", "true");
         //propsMap.put("javax.jdo.option.IgnoreCache", "false");
-        //propsMap.put("openjpa.BrokerImpl", "kodo.datacache.CacheTestBroker");//CacheTestBroker.class.getName ());
+        //propsMap.put("openjpa.BrokerImpl", "kodo.datacache.CacheTestBroker");
+        //CacheTestBroker.class.getName ());
         EntityManagerFactory emf = getEmf(propsMap);
 
         try {
 
-            //assertEquals(Class.forName("openjpa.datacache.CacheTestBroker",true,emf.getClass().getClassLoader()).getClassLoader(),emf.getClass().getClassLoader());
-            //Thread.currentThread().setContextClassLoader(emf.getClass().getClassLoader());
-            Class.forName("org.apache.openjpa.persistence.datacache.CacheTestBroker", true,
+            //assertEquals(Class.forName("openjpa.datacache.CacheTestBroker",
+            //    true,emf.getClass().getClassLoader()).getClassLoader(),
+            //    emf.getClass().getClassLoader());
+            //Thread.currentThread().setContextClassLoader(
+            //    emf.getClass().getClassLoader());
+            Class.forName(
+                    "org.apache.openjpa.persistence.datacache.CacheTestBroker",
+                    true,
                 Thread.currentThread().getContextClassLoader());
         } catch (Exception e) {
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPACache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPACache.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPACache.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPACache.java Thu May 21 14:39:31 2009
@@ -157,7 +157,8 @@
      * <li>Any instance of CachedPerson from populate() is found in the cache
      * after calling evict(CachedPerson.class)</li>
      * <li>Any instance of CachedManager or CachedEmployee which previously
-     * existed in the cache was evicted after calling evict(CachedPerson.class)</li>
+     * existed in the cache was evicted after calling evict(CachedPerson.class)
+     * </li>
      * </ul>
      * 
      */

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPQL2ResultsAndResultClasses.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPQL2ResultsAndResultClasses.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPQL2ResultsAndResultClasses.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPQL2ResultsAndResultClasses.java Thu May 21 14:39:31 2009
@@ -29,7 +29,8 @@
 import org.apache.openjpa.persistence.datacache.common.apps.CacheObjectA;
 import org.apache.openjpa.persistence.datacache.common.apps.CacheObjectAChild1;
 import org.apache.openjpa.persistence.datacache.common.apps.CacheObjectB;
-import org.apache.openjpa.persistence.datacache.common.apps.CacheObjectWithExternalizedFields;
+import org.apache.openjpa.persistence.datacache.common.apps.
+        CacheObjectWithExternalizedFields;
 import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
 
 import org.apache.openjpa.kernel.Broker;

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPQLRelationProjections.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPQLRelationProjections.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPQLRelationProjections.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestJPQLRelationProjections.java Thu May 21 14:39:31 2009
@@ -28,7 +28,8 @@
 import org.apache.openjpa.persistence.datacache.common.apps.CacheObjectAChild1;
 import org.apache.openjpa.persistence.datacache.common.apps.CacheObjectE;
 import org.apache.openjpa.persistence.datacache.common.apps.CacheObjectJ;
-import org.apache.openjpa.persistence.datacache.common.apps.SelfReferencingCacheTestObject;
+import org.apache.openjpa.persistence.datacache.common.apps.
+        SelfReferencingCacheTestObject;
 import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
 
 import org.apache.openjpa.kernel.Broker;

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestMutableParameters.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestMutableParameters.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestMutableParameters.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestMutableParameters.java Thu May 21 14:39:31 2009
@@ -120,7 +120,8 @@
         Query q =
             broker.newQuery(JPQLParser.LANG_JPQL,
                     "select a from "+
-                    CacheObjectAChild1.class.getSimpleName()+ "a :p_ages.contains (age)");
+                    CacheObjectAChild1.class.getSimpleName() +
+                    "a :p_ages.contains (age)");
         Collection c_param;
         if (set)
             c_param = new HashSet();

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestOrderbyInDataCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestOrderbyInDataCache.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestOrderbyInDataCache.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestOrderbyInDataCache.java Thu May 21 14:39:31 2009
@@ -23,10 +23,11 @@
 import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 /**
- * Defined ordering is only applied when the collection is loaded from the datastore.
- * It is not maintained by Openjpa as you modify the collection in memory. 
- * Openjpa invalid data cache in case the persistence operation may result cache in wrong order.
- * This test suite tests various cases for the above problem.
+ * Defined ordering is only applied when the collection is loaded from the
+ * datastore. It is not maintained by Openjpa as you modify the collection in
+ * memory. Openjpa invalid data cache in case the persistence operation may
+ * result cache in wrong order. This test suite tests various cases for the
+ * above problem.
  */
 public class TestOrderbyInDataCache extends SingleEMFTestCase {
 	private long pid;

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestResultShapes.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestResultShapes.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestResultShapes.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestResultShapes.java Thu May 21 14:39:31 2009
@@ -164,7 +164,8 @@
         // single result that
         // we're looking
         // for.	It just happens that the // single result format we
-        // expect is an	Object[]. rawHelper(true, Object[].class, "age, name", true);
+        // expect is an	Object[]. rawHelper(true, Object[].class, "age, name",
+        //     true);
     }
 
     public void testUncachedQueryHasCorrectShape() {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/stats/TestStatistics.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/stats/TestStatistics.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/stats/TestStatistics.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/stats/TestStatistics.java Thu May 21 14:39:31 2009
@@ -36,11 +36,11 @@
 
 	public void setUp() {
 		super.setUp(CLEAR_TABLES, Customer.class, Order.class,
-				"openjpa.DataCache", "true", "openjpa.RemoteCommitProvider",
+                "openjpa.DataCache", "true", "openjpa.RemoteCommitProvider",
 				"sjvm");
 		startCaching(Customer.class);
 		startCaching(Order.class);
-		assertTrue(((EntityManagerImpl) emf.createEntityManager()).getBroker()
+        assertTrue(((EntityManagerImpl) emf.createEntityManager()).getBroker()
 				.getPopulateDataCache());
 		stats = emf.getStoreCache().getStatistics();
 		assertNotNull(stats);
@@ -48,7 +48,7 @@
 
 	void startCaching(Class<?> cls) {
 		ClassMetaData meta = emf.getConfiguration()
-				.getMetaDataRepositoryInstance().getMetaData(cls, null, true);
+                .getMetaDataRepositoryInstance().getMetaData(cls, null, true);
 		meta.setDataCacheName(DataCache.NAME_DEFAULT);
 	}
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestManualDelimId.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestManualDelimId.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestManualDelimId.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/delimited/identifiers/TestManualDelimId.java Thu May 21 14:39:31 2009
@@ -21,7 +21,8 @@
         // TODO: retest with DROP to figure out problem
 //        super.setUp(EntityF2.class,DROP_TABLES);
         super.setUp(
-            org.apache.openjpa.persistence.delimited.identifiers.EntityF.class);
+            org.apache.openjpa.persistence.delimited.identifiers.
+            EntityF.class);
         assertNotNull(emf);
         
         em = emf.createEntityManager();
@@ -45,26 +46,7 @@
         entityF.addDelimCollectionMap("yyy", "zzz");
     }
     
-    // TODO: temp - test on multiple DBs
-//    public void testDBCapability() {
-//        Connection conn = (Connection)em.getConnection();
-//        try {
-//            DatabaseMetaData meta = conn.getMetaData();
-//            System.out.println("LC - " + meta.storesLowerCaseIdentifiers());
-//            System.out.println("LCQ - " + meta.storesLowerCaseQuotedIdentifiers());
-//            System.out.println("MC - " + meta.storesMixedCaseIdentifiers());
-//            System.out.println("MCQ - " + meta.storesMixedCaseQuotedIdentifiers());
-//            System.out.println("UC - " + meta.storesUpperCaseIdentifiers());
-//            System.out.println("UCQ - " + meta.storesUpperCaseQuotedIdentifiers());
-//            System.out.println("");
-//            System.out.println("db product name - " + meta.getDatabaseProductName());
-//            System.out.println("db product version - " + meta.getDatabaseProductVersion());
-//            System.out.println("driver name - " + meta.getDriverName());
-//            System.out.println("driver version - " + meta.getDriverVersion());
-//        } catch (SQLException e) {
-//            e.printStackTrace();
-//        }
-//    }    
+
     
     public void testCreateF() {
         id++;
@@ -76,40 +58,7 @@
         
         System.out.println(super.toString(sql));
         
-//        getColumnInfo("\"primary_entityF\"", "\"f_name\"", "\"delim_id\"");
-//        getColumnInfo("\"primary entityF\"", null, "\"delim id\"");
-//        getColumnInfo("\"secondary entityF\"", null, "\"delim id\"");
     }
 
     // TODO: change to boolean return and remove assert
-//        private void getColumnInfo(String tableName, String columnName, String schemaName) {
-//            Connection conn = (Connection)em.getConnection();
-//            try {
-//                DatabaseMetaData meta = conn.getMetaData();
-//    //            tableName = "\"" + tableName + "\"";
-//                Column[] columns = dict.getColumns(meta, conn.getCatalog(), schemaName, tableName, columnName, conn);
-//                System.out.println("columns.length - " + columns.length); 
-//                
-////                assertEquals(1, columns.length);
-//                
-//                for (Column column : columns) {
-//                    System.out.println("column name - " + column.getName());
-//                    System.out.println("column fullName - " + column.getFullName());
-//                    System.out.println("column schemaName - " + column.getSchemaName());
-//                    System.out.println("column tableName - " + column.getTableName());
-//                    System.out.println("column description - " + column.getDescription());
-//                }
-//            } catch (SQLException e) {
-//                e.printStackTrace();
-//            }
-//            finally {
-//                try {
-//                    conn.commit();
-//                    conn.close();
-//                } catch (SQLException e) {
-//                    e.printStackTrace();
-//                    fail("problem closing connection");
-//                }
-//            }
-//        }
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/TestDetachNoCascade.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/TestDetachNoCascade.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/TestDetachNoCascade.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detach/TestDetachNoCascade.java Thu May 21 14:39:31 2009
@@ -79,9 +79,12 @@
             .getMetaDataRepositoryInstance();
         ClassMetaData meta = repos.getCachedMetaData(Entity1.class);
         assertNotNull(meta);
-        assertEquals(ValueMetaData.CASCADE_NONE, meta.getField("id").getCascadeDetach());
-        assertEquals(ValueMetaData.CASCADE_NONE, meta.getField("name").getCascadeDetach());
-        assertEquals(ValueMetaData.CASCADE_NONE, meta.getField("e14").getCascadeDetach());
+        assertEquals(ValueMetaData.CASCADE_NONE,
+                meta.getField("id").getCascadeDetach());
+        assertEquals(ValueMetaData.CASCADE_NONE,
+                meta.getField("name").getCascadeDetach());
+        assertEquals(ValueMetaData.CASCADE_NONE,
+                meta.getField("e14").getCascadeDetach());
     }
     
     // Test clear() to clear all entities.

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetach.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetach.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetach.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetach.java Thu May 21 14:39:31 2009
@@ -46,12 +46,16 @@
         MetaDataRepository repos = emf.getConfiguration()
                                       .getMetaDataRepositoryInstance();
         ClassMetaData meta = repos.getCachedMetaData(DMCustomer.class);
-        assertEquals(ValueMetaData.CASCADE_NONE, meta.getField("firstName").getCascadeDetach());
-        assertEquals(ValueMetaData.CASCADE_IMMEDIATE, meta.getField("customerInventories").getElement().getCascadeDetach());
+        assertEquals(ValueMetaData.CASCADE_NONE,
+                meta.getField("firstName").getCascadeDetach());
+        assertEquals(ValueMetaData.CASCADE_IMMEDIATE, meta.getField(
+                "customerInventories").getElement().getCascadeDetach());
         
         meta = repos.getCachedMetaData(DMCustomerInventory.class);
-        assertEquals(ValueMetaData.CASCADE_NONE, meta.getField("customer").getCascadeDetach());
-        assertEquals(ValueMetaData.CASCADE_NONE, meta.getField("item").getCascadeDetach());
+        assertEquals(ValueMetaData.CASCADE_NONE,
+                meta.getField("customer").getCascadeDetach());
+        assertEquals(ValueMetaData.CASCADE_NONE,
+                meta.getField("item").getCascadeDetach());
         
     }
     
@@ -119,7 +123,8 @@
             assertDetached(inventory);
         }
         
-        List<DMCustomerInventory> newInventories = new ArrayList<DMCustomerInventory>();
+        List<DMCustomerInventory> newInventories =
+            new ArrayList<DMCustomerInventory>();
         newInventories.addAll(inventories);
         DMCustomerInventory newInventory = new DMCustomerInventory();
         newInventory.setCustomer(detached);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachedEntityCascadePersist.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachedEntityCascadePersist.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachedEntityCascadePersist.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachedEntityCascadePersist.java Thu May 21 14:39:31 2009
@@ -56,7 +56,7 @@
         DMItem itemDetached = em.find(DMItem.class, item.getId());
         em.close();        
         em = emf.createEntityManager();
-        DMCustomer customer2 = em.find(DMCustomer.class, customer.getId());       
+        DMCustomer customer2 = em.find(DMCustomer.class, customer.getId());
         DMCustomerInventory customerInventory = new DMCustomerInventory();
         customerInventory.setCustomer(customer2);
         customerInventory.setItem(itemDetached);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestNoCascadeOneToManyMerge.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestNoCascadeOneToManyMerge.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestNoCascadeOneToManyMerge.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestNoCascadeOneToManyMerge.java Thu May 21 14:39:31 2009
@@ -34,7 +34,8 @@
     private int a_id;
 
     public void setUp() {
-        setUp(SimpleA.class, SimpleRef.class, SimpleB.class, SimpleC.class, CLEAR_TABLES);
+        setUp(SimpleA.class, SimpleRef.class, SimpleB.class, SimpleC.class,
+                CLEAR_TABLES);
         createEntities();
     }
 
@@ -89,8 +90,8 @@
 
     /**
      * This is the case for openjpa-231.
-     * When "B" and "C" are both newly added to a detached "A" and then merge "A",
-     * it couldn't find "B" because previous code assume B was detached.
+     * When "B" and "C" are both newly added to a detached "A" and then merge
+     * "A", it couldn't find "B" because previous code assume B was detached.
      */
     public void testMergeDetached () {
         EntityManager em = emf.createEntityManager();

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/DMCustomer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/DMCustomer.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/DMCustomer.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/DMCustomer.java Thu May 21 14:39:31 2009
@@ -38,7 +38,8 @@
     @OneToMany(mappedBy="customer", 
             fetch=FetchType.EAGER,
             cascade=CascadeType.ALL)
-            private List<DMCustomerInventory> customerInventories = new ArrayList<DMCustomerInventory>();
+            private List<DMCustomerInventory> customerInventories =
+                new ArrayList<DMCustomerInventory>();
 
     public DMCustomer() {
     }
@@ -71,7 +72,8 @@
         return customerInventories;
     }
 
-    public void setCustomerInventories(List<DMCustomerInventory> customerInventories) {
+    public void setCustomerInventories(
+            List<DMCustomerInventory> customerInventories) {
         this.customerInventories = customerInventories;
     }
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/SimpleB.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/SimpleB.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/SimpleB.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/SimpleB.java Thu May 21 14:39:31 2009
@@ -34,7 +34,8 @@
     protected String name;
 
     @ManyToOne
-    @JoinColumn(name="A_ID", referencedColumnName="A_ID", nullable = false, updatable = false)
+    @JoinColumn(name="A_ID", referencedColumnName="A_ID", nullable = false,
+            updatable = false)
     protected SimpleA parent;
 
     @OneToMany(cascade=CascadeType.ALL, mappedBy="parent")

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/SimpleC.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/SimpleC.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/SimpleC.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/SimpleC.java Thu May 21 14:39:31 2009
@@ -31,7 +31,8 @@
     protected String name;
 
     @ManyToOne(cascade=CascadeType.PERSIST)
-    @JoinColumn(name="B_ID", referencedColumnName="B_ID", nullable = false, updatable = false)
+    @JoinColumn(name="B_ID", referencedColumnName="B_ID", nullable = false,
+            updatable = false)
     protected SimpleB parent;
 
     public int getId() {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/CompanyXml.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/CompanyXml.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/CompanyXml.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/CompanyXml.java Thu May 21 14:39:31 2009
@@ -25,7 +25,8 @@
 
     int id;
 
-    Map<DivisionXml, VicePresidentXml> organization = new HashMap<DivisionXml, VicePresidentXml>();
+    Map<DivisionXml, VicePresidentXml> organization =
+        new HashMap<DivisionXml, VicePresidentXml>();
 
     public int getId() {
         return id;

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/ContactInfo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/ContactInfo.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/ContactInfo.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/ContactInfo.java Thu May 21 14:39:31 2009
@@ -30,7 +30,8 @@
             @JoinColumn(name="PHONE_ID", referencedColumnName="Number")
         
     )
-    List<PhoneNumber> phoneNumbers = new ArrayList<PhoneNumber>(); // Bidirectional
+    // Bidirectional
+    List<PhoneNumber> phoneNumbers = new ArrayList<PhoneNumber>();
     
     public List<PhoneNumber> getPhoneNumbers() {
         return phoneNumbers;

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Department3.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Department3.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Department3.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Department3.java Thu May 21 14:39:31 2009
@@ -35,7 +35,8 @@
     
     @OneToMany(mappedBy="department", fetch=FetchType.EAGER)
     @MapKey(name="name")
-    Map<EmployeeName3, Employee3> emps = new HashMap<EmployeeName3, Employee3>();
+    Map<EmployeeName3, Employee3> emps =
+        new HashMap<EmployeeName3, Employee3>();
     
     public int getDeptId() {
         return deptId;

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_MappedToOneCascadeDelete.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_MappedToOneCascadeDelete.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_MappedToOneCascadeDelete.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/Embed_MappedToOneCascadeDelete.java Thu May 21 14:39:31 2009
@@ -29,7 +29,8 @@
     protected String name2;
     protected String name3;
     
-    @OneToOne(mappedBy="entityA", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
+    @OneToOne(mappedBy="entityA", fetch = FetchType.EAGER, 
+        cascade = CascadeType.ALL)
     protected EntityB2 bm;
     
     

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_EmbedXml.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_EmbedXml.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_EmbedXml.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_Embed_EmbedXml.java Thu May 21 14:39:31 2009
@@ -23,8 +23,11 @@
 import java.util.List;
 
 /**
- * CREATE TABLE EntityA_Coll_Embed_Embed (id INTEGER NOT NULL, age INTEGER, name VARCHAR(30), PRIMARY KEY (id))
- * CREATE TABLE EntityA_Coll_Embed_Embed_embeds (ENTITYA_COLL_EMBED_EMBED_ID INTEGER, intVal1 INTEGER, intVal2 INTEGER, intVal3 INTEGER, IntVal1x INTEGER, IntVal2x INTEGER, IntVal3x INTEGER)
+ * CREATE TABLE EntityA_Coll_Embed_Embed (id INTEGER NOT NULL, age INTEGER,
+ *     name VARCHAR(30), PRIMARY KEY (id))
+ * CREATE TABLE EntityA_Coll_Embed_Embed_embeds (
+ *     ENTITYA_COLL_EMBED_EMBED_ID INTEGER, intVal1 INTEGER, intVal2 INTEGER,
+ *     intVal3 INTEGER, IntVal1x INTEGER, IntVal2x INTEGER, IntVal3x INTEGER)
  * @author faywang
  *
  */

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_StringXml.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_StringXml.java?rev=777135&r1=777134&r2=777135&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_StringXml.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/EntityA_Coll_StringXml.java Thu May 21 14:39:31 2009
@@ -23,13 +23,17 @@
 import java.util.Set;
 
 /**
- * CREATE TABLE EntityA_Coll_String (id INTEGER NOT NULL, age INTEGER, name VARCHAR(30), PRIMARY KEY (id))
- * CREATE TABLE NickNames_Tbl (ENTITYA_COLL_STRING_ID INTEGER, nicknames1 VARCHAR(20))
+ * CREATE TABLE EntityA_Coll_String (id INTEGER NOT NULL, age INTEGER,
+ *     name VARCHAR(30), PRIMARY KEY (id))
+ * CREATE TABLE NickNames_Tbl (ENTITYA_COLL_STRING_ID INTEGER,
+ *     nicknames1 VARCHAR(20))
  * CREATE INDEX I_NCKNTBL_ENTITYA_ ON NickNames_Tbl (ENTITYA_COLL_STRING_ID)
  * INSERT INTO EntityA_Coll_String (id, age, name) VALUES (?, ?, ?)
  * INSERT INTO NickNames_Tbl (ENTITYA_COLL_STRING_ID, nicknames1) VALUES (?, ?)
- * SELECT t0.age, t0.name FROM EntityA_Coll_String t0 WHERE t0.id = ?  optimize for 1 row
- * SELECT t0.nicknames1 FROM NickNames_Tbl t0 WHERE t0.ENTITYA_COLL_STRING_ID = ? 
+ * SELECT t0.age, t0.name FROM EntityA_Coll_String t0 WHERE t0.id = ? 
+ *     optimize for 1 row
+ * SELECT t0.nicknames1 FROM NickNames_Tbl t0
+ *     WHERE t0.ENTITYA_COLL_STRING_ID = ?
  * @author faywang
  */