cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From and...@apache.org
Subject svn commit: r726039 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/ main/java/org/apache/cayenne/access/ test/java/org/apache/cayenne/ test/java/org/apache/cayenne/access/
Date Fri, 12 Dec 2008 15:21:03 GMT
Author: andrey
Date: Fri Dec 12 07:21:03 2008
New Revision: 726039

URL: http://svn.apache.org/viewvc?rev=726039&view=rev
Log:
CAY-1146 Move User properties API to ObjectContext & BaseContext

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/BaseContextTest.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ObjectContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/MockObjectContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java?rev=726039&r1=726038&r2=726039&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java
Fri Dec 12 07:21:03 2008
@@ -20,7 +20,9 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.cayenne.cache.MapQueryCache;
 import org.apache.cayenne.cache.QueryCache;
@@ -42,7 +44,7 @@
 
 /**
  * A common base superclass for Cayenne ObjectContext implementors.
- * 
+ *
  * @since 3.0
  */
 public abstract class BaseContext implements ObjectContext, DataChannel {
@@ -88,6 +90,13 @@
     protected transient DataChannel channel;
     protected QueryCache queryCache;
 
+    /**
+     * Stores user defined properties associated with this DataContext.
+     *
+     * @since 3.0
+     */
+    protected Map<String, Object> userProperties;
+
     public abstract void commitChanges();
 
     public abstract void commitChangesToParent();
@@ -256,7 +265,7 @@
                 }
             }
         }
-        
+
         return queryCache;
     }
 
@@ -266,16 +275,16 @@
     public synchronized void setQueryCache(QueryCache queryCache) {
         this.queryCache = queryCache;
     }
-    
+
     /**
      * Returns EventManager associated with the ObjectStore.
-     * 
+     *
      * @since 1.2
      */
     public EventManager getEventManager() {
         return channel != null ? channel.getEventManager() : null;
     }
-    
+
     public GraphDiff onSync(
             ObjectContext originatingContext,
             GraphDiff changes,
@@ -292,17 +301,17 @@
                         + syncType);
         }
     }
-    
+
     GraphDiff onContextRollback(ObjectContext originatingContext) {
         rollbackChanges();
         return new CompoundDiff();
     }
-    
+
     protected abstract GraphDiff onContextFlush(
             ObjectContext originatingContext,
             GraphDiff changes,
             boolean cascade);
-    
+
     /**
      * @since 1.2
      */
@@ -338,16 +347,51 @@
             manager.postEvent(e, DataChannel.GRAPH_CHANGED_SUBJECT);
         }
     }
-    
+
     /**
      * "Invalidates" a Collection of persistent objects. This operation would remove each
      * object's snapshot from cache and change object's state to HOLLOW. On the next
      * access to this object, it will be refetched.
-     * 
+     *
      * @see #unregisterObjects(Collection)
      * @see RefreshQuery
      */
     public void invalidateObjects(Collection objects) {
         performGenericQuery(new RefreshQuery(objects));
     }
+
+    /**
+     * Returns a map of user-defined properties associated with this DataContext.
+     *
+     * @since 3.0
+     */
+    protected Map<String, Object> getUserProperties() {
+        // as not all users will take advantage of properties, creating the
+        // map on demand to keep DataContext lean...
+        if (userProperties == null) {
+            userProperties = new HashMap<String, Object>();
+        }
+
+        return userProperties;
+    }
+
+    /**
+     * Returns a user-defined property previously set via 'setUserProperty'. Note that it
+     * is a caller responsibility to synchronize access to properties.
+     *
+     * @since 3.0
+     */
+    public Object getUserProperty(String key) {
+        return getUserProperties().get(key);
+    }
+
+    /**
+     * Sets a user-defined property. Note that it is a caller responsibility to
+     * synchronize access to properties.
+     *
+     * @since 3.0
+     */
+    public void setUserProperty(String key, Object value) {
+        getUserProperties().put(key, value);
+    }
 }
\ No newline at end of file

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ObjectContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ObjectContext.java?rev=726039&r1=726038&r2=726039&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ObjectContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ObjectContext.java
Fri Dec 12 07:21:03 2008
@@ -198,4 +198,20 @@
      * @see RefreshQuery
      */
     void invalidateObjects(Collection objects);
+
+    /**
+     * Returns a user-defined property previously set via 'setUserProperty'. Note that it
+     * is a caller responsibility to synchronize access to properties.
+     *
+     * @since 3.0
+     */
+    public Object getUserProperty(String key);
+
+    /**
+     * Sets a user-defined property. Note that it is a caller responsibility to
+     * synchronize access to properties.
+     *
+     * @since 3.0
+     */
+    public void setUserProperty(String key, Object value);
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java?rev=726039&r1=726038&r2=726039&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
Fri Dec 12 07:21:03 2008
@@ -25,7 +25,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -97,13 +96,6 @@
     ObjectContextGraphAction graphAction;
 
     /**
-     * Stores user defined properties associated with this DataContext.
-     * 
-     * @since 1.2
-     */
-    protected Map<String, Object> userProperties;
-
-    /**
      * Stores the name of parent DataDomain. Used to defer initialization of the parent
      * QueryEngine after deserialization. This helps avoid an issue with certain servlet
      * engines (e.g. Tomcat) where HttpSessions with DataContext's are deserialized at
@@ -113,7 +105,7 @@
 
     /**
      * Returns the DataContext bound to the current thread.
-     * 
+     *
      * @since 1.1
      * @return the DataContext associated with caller thread.
      * @throws IllegalStateException if there is no DataContext bound to the current
@@ -130,7 +122,7 @@
      * Binds a DataContext to the current thread. DataContext can later be retrieved by
      * users in the same thread by calling {@link DataContext#getThreadDataContext}. Using
      * null parameter will unbind currently bound DataContext.
-     * 
+     *
      * @since 1.1
      * @deprecated since 3.0, replaced by BaseContex#getThreadObjectContext().
      */
@@ -156,7 +148,7 @@
      * {@link DataContext#createDataContext(String, boolean)} must be used instead.
      * ObjectStore associated with newly created DataContext will have a cache stack
      * configured according to the specified policy, overriding a parent domain setting.
-     * 
+     *
      * @since 1.1
      */
     public static DataContext createDataContext(boolean useSharedCache) {
@@ -181,7 +173,7 @@
      * Creates and returns new DataContext that will use a named DataDomain as its parent.
      * ObjectStore associated with newly created DataContext will have a cache stack
      * configured according to the specified policy, overriding a parent domain setting.
-     * 
+     *
      * @since 1.1
      */
     public static DataContext createDataContext(String domainName, boolean useSharedCache)
{
@@ -202,7 +194,7 @@
 
     /**
      * Creates a new DataContext with parent DataChannel and ObjectStore.
-     * 
+     *
      * @since 1.2
      */
     public DataContext(DataChannel channel, ObjectStore objectStore) {
@@ -226,7 +218,7 @@
      * Returns {@link QueryCache} used by this DataContext, creating it on the fly if
      * needed. Uses parent DataDomain {@link QueryCacheFactory} to initialize the cache
      * for the first time.
-     * 
+     *
      * @since 3.0
      */
     @Override
@@ -240,23 +232,8 @@
     }
 
     /**
-     * Returns a map of user-defined properties associated with this DataContext.
-     * 
-     * @since 1.2
-     */
-    protected Map<String, Object> getUserProperties() {
-        // as not all users will take advantage of properties, creating the
-        // map on demand to keep DataContext lean...
-        if (userProperties == null) {
-            userProperties = new HashMap<String, Object>();
-        }
-
-        return userProperties;
-    }
-
-    /**
      * Creates and returns a new child ObjectContext.
-     * 
+     *
      * @since 3.0
      */
     public ObjectContext createChildContext() {
@@ -265,7 +242,7 @@
 
     /**
      * Creates and returns a new child DataContext.
-     * 
+     *
      * @since 1.2
      * @deprecated since 3.0 use {@link #createChildContext()}.
      */
@@ -287,26 +264,6 @@
     }
 
     /**
-     * Returns a user-defined property previously set via 'setUserProperty'. Note that it
-     * is a caller responsibility to synchronize access to properties.
-     * 
-     * @since 1.2
-     */
-    public Object getUserProperty(String key) {
-        return getUserProperties().get(key);
-    }
-
-    /**
-     * Sets a user-defined property. Note that it is a caller responsibility to
-     * synchronize access to properties.
-     * 
-     * @since 1.2
-     */
-    public void setUserProperty(String key, Object value) {
-        getUserProperties().put(key, value);
-    }
-
-    /**
      * @since 1.2
      */
     public void setChannel(DataChannel channel) {
@@ -359,7 +316,7 @@
      * Returns a DataDomain used by this DataContext. DataDomain is looked up in the
      * DataChannel hierarchy. If a channel is not a DataDomain or a DataContext, null is
      * returned.
-     * 
+     *
      * @return DataDomain that is a direct or indirect parent of this DataContext in the
      *         DataChannel hierarchy.
      * @since 1.1
@@ -389,7 +346,7 @@
     /**
      * Sets a DataContextDelegate for this context. Delegate is notified of certain events
      * in the DataContext lifecycle and can customize DataContext behavior.
-     * 
+     *
      * @since 1.1
      */
     public void setDelegate(DataContextDelegate delegate) {
@@ -398,7 +355,7 @@
 
     /**
      * Returns a delegate currently associated with this DataContext.
-     * 
+     *
      * @since 1.1
      */
     public DataContextDelegate getDelegate() {
@@ -459,7 +416,7 @@
 
     /**
      * Returns a collection of all uncommitted registered objects.
-     * 
+     *
      * @since 1.2
      */
     @Override
@@ -496,7 +453,7 @@
      * temporary ids. DO NOT USE this method if you expect a DataRow to represent a
      * complete object state.
      * </p>
-     * 
+     *
      * @since 1.1
      */
     public DataRow currentSnapshot(final Persistent object) {
@@ -603,7 +560,7 @@
 
     /**
      * Converts a list of data rows to a list of DataObjects.
-     * 
+     *
      * @since 1.1
      * @deprecated since 3.0 as refreshing and resolvingInheritanceHierarchy flags are
      *             deprecated. Use {@link #objectsFromDataRows(ClassDescriptor, List)}
@@ -624,7 +581,7 @@
     /**
      * Converts a list of DataRows to a List of DataObject registered with this
      * DataContext.
-     * 
+     *
      * @since 3.0
      */
     public List objectsFromDataRows(
@@ -637,7 +594,7 @@
     /**
      * Converts a list of DataRows to a List of DataObject registered with this
      * DataContext.
-     * 
+     *
      * @deprecated since 3.0 as refresh and resolveInheritanceHierarchy flags are
      *             deprecated. Use {@link #objectsFromDataRows(ClassDescriptor, List)}
      *             instead.
@@ -663,7 +620,7 @@
 
     /**
      * Creates a DataObject from DataRow.
-     * 
+     *
      * @see DataRow
      */
     public <T extends DataObject> T objectFromDataRow(
@@ -686,7 +643,7 @@
     /**
      * Creates a DataObject from DataRow. This variety of the 'objectFromDataRow' method
      * is normally used for generic classes.
-     * 
+     *
      * @see DataRow
      * @since 3.0
      */
@@ -711,7 +668,7 @@
 
     /**
      * Creates and registers a new persistent object.
-     * 
+     *
      * @since 1.2
      */
     @Override
@@ -735,7 +692,7 @@
      * <p/>
      * <i>Note: in most cases {@link #newObject(Class)} method should be used, however
      * this method is helpful when generic persistent classes are used.</i>
-     * 
+     *
      * @since 3.0
      */
     public Persistent newObject(String entityName) {
@@ -776,7 +733,7 @@
     /**
      * Instantiates new object and registers it with itself. Object class must have a
      * default constructor.
-     * 
+     *
      * @since 1.1
      * @deprecated since 3.0, use {@link #newObject(Class)} instead.
      */
@@ -801,7 +758,7 @@
      * <p/>
      * <i>Note that since 3.0 this method takes Object as an argument instead of a
      * {@link DataObject}.</i>
-     * 
+     *
      * @param object new object that needs to be made persistent.
      */
     @Override
@@ -914,7 +871,7 @@
      * Unregisters a Collection of DataObjects from the DataContext and the underlying
      * ObjectStore. This operation also unsets DataContext and ObjectId for each object
      * and changes its state to TRANSIENT.
-     * 
+     *
      * @see #invalidateObjects(Collection)
      */
     public void unregisterObjects(Collection dataObjects) {
@@ -932,7 +889,7 @@
      * to-many relationship with nullify delete rule may result in objects being removed
      * from collection.
      * </p>
-     * 
+     *
      * @since 1.2
      */
     public void deleteObjects(Collection objects) {
@@ -952,7 +909,7 @@
      * persistence state is changed to PersistenceState.DELETED; objects related to this
      * object are processed according to delete rules, i.e. relationships can be unset
      * ("nullify" rule), deletion operation is cascaded (cascade rule).
-     * 
+     *
      * @param object a persistent object that we want to delete.
      * @throws DeleteDenyException if a DENY delete rule is applicable for object
      *             deletion.
@@ -967,7 +924,7 @@
      * Refetches object data for ObjectId. This method is used internally by Cayenne to
      * resolve objects in state <code>PersistenceState.HOLLOW</code>. It can
also be used
      * to refresh certain objects.
-     * 
+     *
      * @throws CayenneRuntimeException if object id doesn't match any records, or if there
      *             is more than one object is fetched.
      * @deprecated since 3.0 use {@link ObjectIdQuery} with appropriate refresh settings.
@@ -1009,7 +966,7 @@
     /**
      * If the parent channel is a DataContext, reverts local changes to make this context
      * look like the parent, if the parent channel is a DataDomain, reverts all changes.
-     * 
+     *
      * @since 1.2
      */
     @Override
@@ -1059,7 +1016,7 @@
      * update. If it is a DataDomain (the most common case), the changes are written to
      * the database. To cause cascading commit all the way to the database, one must use
      * {@link #commitChanges()}.
-     * 
+     *
      * @since 1.2
      * @see #commitChanges()
      */
@@ -1103,7 +1060,7 @@
 
     /**
      * Synchronizes with the parent channel, performing a flush or a commit.
-     * 
+     *
      * @since 1.2
      */
     GraphDiff flushToParent(boolean cascade) {
@@ -1237,7 +1194,7 @@
 
     /**
      * Runs an iterated query in transactional context provided by the caller.
-     * 
+     *
      * @since 1.2
      */
     ResultIterator internalPerformIteratedQuery(Query query) throws CayenneException {
@@ -1250,7 +1207,7 @@
 
     /**
      * Executes a query returning a generic response.
-     * 
+     *
      * @since 1.2
      */
     @Override
@@ -1284,7 +1241,7 @@
      * <p>
      * <i>Since 1.2 takes any Query parameter, not just GenericSelectQuery</i>
      * </p>
-     * 
+     *
      * @return A list of DataObjects or a DataRows, depending on the value returned by
      *         {@link QueryMetadata#isFetchingDataRows()}.
      */
@@ -1303,7 +1260,7 @@
     /**
      * An implementation of a {@link DataChannel} method that is used by child contexts to
      * execute queries. Not intended for direct use.
-     * 
+     *
      * @since 1.2
      */
     public QueryResponse onQuery(ObjectContext context, Query query) {
@@ -1313,7 +1270,7 @@
     /**
      * Performs a single database query that does not select rows. Returns an array of
      * update counts.
-     * 
+     *
      * @since 1.1
      */
     public int[] performNonSelectingQuery(Query query) {
@@ -1324,7 +1281,7 @@
     /**
      * Performs a named mapped query that does not select rows. Returns an array of update
      * counts.
-     * 
+     *
      * @since 1.1
      */
     public int[] performNonSelectingQuery(String queryName) {
@@ -1334,7 +1291,7 @@
     /**
      * Performs a named mapped non-selecting query using a map of parameters. Returns an
      * array of update counts.
-     * 
+     *
      * @since 1.1
      */
     public int[] performNonSelectingQuery(String queryName, Map<String, ?> parameters)
{
@@ -1345,7 +1302,7 @@
      * Returns a list of objects or DataRows for a named query stored in one of the
      * DataMaps. Internally Cayenne uses a caching policy defined in the named query. If
      * refresh flag is true, a refresh is forced no matter what the caching policy is.
-     * 
+     *
      * @param queryName a name of a GenericSelectQuery defined in one of the DataMaps. If
      *            no such query is defined, this method will throw a
      *            CayenneRuntimeException.
@@ -1361,7 +1318,7 @@
      * Returns a list of objects or DataRows for a named query stored in one of the
      * DataMaps. Internally Cayenne uses a caching policy defined in the named query. If
      * refresh flag is true, a refresh is forced no matter what the caching policy is.
-     * 
+     *
      * @param queryName a name of a GenericSelectQuery defined in one of the DataMaps. If
      *            no such query is defined, this method will throw a
      *            CayenneRuntimeException.
@@ -1392,7 +1349,7 @@
     /**
      * Returns <code>true</code> if the ObjectStore uses shared cache of a parent
      * DataDomain.
-     * 
+     *
      * @since 1.1
      */
     public boolean isUsingSharedSnapshotCache() {
@@ -1402,7 +1359,7 @@
     /**
      * Returns whether this DataContext performs object validation before commit is
      * executed.
-     * 
+     *
      * @since 1.1
      */
     public boolean isValidatingObjectsOnCommit() {
@@ -1412,7 +1369,7 @@
     /**
      * Sets the property defining whether this DataContext should perform object
      * validation before commit is executed.
-     * 
+     *
      * @since 1.1
      */
     public void setValidatingObjectsOnCommit(boolean flag) {
@@ -1524,7 +1481,7 @@
 
     /**
      * Returns this context's ObjectStore.
-     * 
+     *
      * @since 1.2
      */
     @Override
@@ -1540,7 +1497,7 @@
      * In case you pass a non-null second parameter, you are responsible for setting
      * correct persistence state of the returned local object, as generally there is no
      * way for Cayenne to determine the resulting local object state.
-     * 
+     *
      * @since 1.2
      */
     @Override
@@ -1617,7 +1574,7 @@
             }
         }
     }
-    
+
     protected void fireDataChannelChanged(Object postedBy, GraphDiff changes) {
         super.fireDataChannelChanged(postedBy, changes);
     }

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/BaseContextTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/BaseContextTest.java?rev=726039&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/BaseContextTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/BaseContextTest.java
Fri Dec 12 07:21:03 2008
@@ -0,0 +1,35 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne;
+
+import java.util.Map;
+
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.unit.CayenneCase;
+
+public class BaseContextTest extends CayenneCase {
+    public void testUserPropertiesLazyInit() {
+        DataContext context = createDataContext();
+        assertNull(context.userProperties);
+
+        Map properties = context.getUserProperties();
+        assertNotNull(properties);
+        assertSame(properties, context.getUserProperties());
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/MockObjectContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/MockObjectContext.java?rev=726039&r1=726038&r2=726039&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/MockObjectContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/MockObjectContext.java
Fri Dec 12 07:21:03 2008
@@ -28,7 +28,7 @@
 
 /**
  * A noop ObjectContext used for unit testing.
- * 
+ *
  */
 public class MockObjectContext implements ObjectContext {
 
@@ -93,7 +93,7 @@
 
     public void deleteObject(Object object) {
     }
-    
+
     public void registerNewObject(Object object) {
     }
 
@@ -103,7 +103,7 @@
     @Deprecated
     public void prepareForAccess(Persistent persistent, String property) {
     }
-    
+
     public void prepareForAccess(Persistent object, String property, boolean lazyFaulting)
{
     }
 
@@ -148,4 +148,11 @@
 
     public void invalidateObjects(Collection objects) {
     }
+
+    public Object getUserProperty(String key) {
+        return null;
+    }
+
+    public void setUserProperty(String key, Object value) {
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java?rev=726039&r1=726038&r2=726039&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java
Fri Dec 12 07:21:03 2008
@@ -22,7 +22,6 @@
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.art.Artist;
 import org.apache.art.Painting;
@@ -45,7 +44,7 @@
 /**
  * "Lightweight" test cases for DataContext. These tests do not require any additional
  * database setup.
- * 
+ *
  */
 public class DataContextExtrasTest extends CayenneCase {
 
@@ -101,15 +100,6 @@
         }
     }
 
-    public void testUserPropertiesLazyInit() {
-        DataContext context = createDataContext();
-        assertNull(context.userProperties);
-
-        Map properties = context.getUserProperties();
-        assertNotNull(properties);
-        assertSame(properties, context.getUserProperties());
-    }
-
     public void testUserProperties() {
         DataContext context = createDataContext();
 
@@ -172,7 +162,7 @@
         row.put("ARTIST_ID", new Integer(123456));
         row.put("ARTIST_NAME", "ArtistXYZ");
         row.put("DATE_OF_BIRTH", new Date());
-        Artist obj = (Artist) context.objectFromDataRow(Artist.class, row, false);
+        Artist obj = context.objectFromDataRow(Artist.class, row, false);
 
         assertTrue(context.getGraphManager().registeredNodes().contains(obj));
         assertEquals(PersistenceState.COMMITTED, obj.getPersistenceState());
@@ -192,7 +182,7 @@
                     throws Exception {
                 throw new CayenneRuntimeException("Synthetic error....");
             }
-            
+
             @Override
             public Object generatePk(DataNode node, DbAttribute pk)
                     throws Exception {



Mime
View raw message