cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r645463 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextObjectIdQueryTest.java
Date Mon, 07 Apr 2008 11:20:48 GMT
Author: aadamchik
Date: Mon Apr  7 04:20:46 2008
New Revision: 645463

URL: http://svn.apache.org/viewvc?rev=645463&view=rev
Log:
a test case trying to reproduce a bug with ObjectIdQuery cache_refresh policy.. the bug is
NOT confirmed.
(more of the same)

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextObjectIdQueryTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextObjectIdQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextObjectIdQueryTest.java?rev=645463&r1=645462&r2=645463&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextObjectIdQueryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextObjectIdQueryTest.java
Mon Apr  7 04:20:46 2008
@@ -18,6 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.access;
 
+import java.util.Collections;
 import java.util.Date;
 
 import org.apache.art.Artist;
@@ -36,7 +37,7 @@
         deleteTestData();
     }
 
-    public void testRefreshNullifiedValues() {
+    public void testRefreshNullifiedValuesNew() {
 
         DataContext context = createDataContext();
 
@@ -55,6 +56,34 @@
                 "Artist",
                 Artist.ARTIST_ID_PK_COLUMN,
                 id), false, ObjectIdQuery.CACHE_REFRESH);
+
+        Artist a1 = (Artist) DataObjectUtils.objectForQuery(context, query);
+        assertNull(a1.getDateOfBirth());
+        assertEquals("X", a1.getArtistName());
+    }
+
+    public void testRefreshNullifiedValuesExisting() {
+
+        SQLTemplate insert = new SQLTemplate(
+                Artist.class,
+                "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) VALUES (44, 'X',
#bind($date 'DATE'))");
+        insert.setParameters(Collections.singletonMap("date", new Date()));
+
+        DataContext context = createDataContext();
+        context.performGenericQuery(insert);
+
+        Artist a = DataObjectUtils.objectForPK(context, Artist.class, 44l);
+        assertNotNull(a.getDateOfBirth());
+        assertEquals("X", a.getArtistName());
+
+        context.performGenericQuery(new SQLTemplate(
+                Artist.class,
+                "UPDATE ARTIST SET DATE_OF_BIRTH = NULL"));
+
+        ObjectIdQuery query = new ObjectIdQuery(new ObjectId(
+                "Artist",
+                Artist.ARTIST_ID_PK_COLUMN,
+                44l), false, ObjectIdQuery.CACHE_REFRESH);
 
         Artist a1 = (Artist) DataObjectUtils.objectForQuery(context, query);
         assertNull(a1.getDateOfBirth());



Mime
View raw message