cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1073777 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneDataObjectTest.java
Date Wed, 23 Feb 2011 15:25:39 GMT
Author: aadamchik
Date: Wed Feb 23 15:25:39 2011
New Revision: 1073777

URL: http://svn.apache.org/viewvc?rev=1073777&view=rev
Log:
tests cleanup

switching to DI

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneDataObjectTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneDataObjectTest.java?rev=1073777&r1=1073776&r2=1073777&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneDataObjectTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneDataObjectTest.java
Wed Feb 23 15:25:39 2011
@@ -22,25 +22,30 @@ package org.apache.cayenne;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.testdo.testmap.ArtistExhibit;
 import org.apache.cayenne.testdo.testmap.Painting;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 import org.apache.cayenne.unit.util.TestBean;
 
-public class CayenneDataObjectTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class CayenneDataObjectTest extends ServerCase {
+
+    @Inject
+    private ObjectContext context;
 
     public void testSetObjectId() throws Exception {
-        CayenneDataObject obj = new CayenneDataObject();
+        CayenneDataObject object = new CayenneDataObject();
         ObjectId oid = new ObjectId("T");
 
-        assertNull(obj.getObjectId());
+        assertNull(object.getObjectId());
 
-        obj.setObjectId(oid);
-        assertSame(oid, obj.getObjectId());
+        object.setObjectId(oid);
+        assertSame(oid, object.getObjectId());
     }
 
     public void testSetPersistenceState() throws Exception {
@@ -84,10 +89,9 @@ public class CayenneDataObjectTest exten
         assertEquals(TestBean.class, o1.readNestedProperty("o2.class"));
         assertEquals(TestBean.class.getName(), o1.readNestedProperty("o2.class.name"));
     }
-    
+
     public void testReadNestedPropertyToManyInMiddle() throws Exception {
-        DataContext context = createDataContext();
-        
+
         Artist a = context.newObject(Artist.class);
         ArtistExhibit ex = context.newObject(ArtistExhibit.class);
         Painting p1 = context.newObject(Painting.class);
@@ -97,20 +101,20 @@ public class CayenneDataObjectTest exten
         a.addToPaintingArray(p1);
         a.addToPaintingArray(p2);
         ex.setToArtist(a);
-        
-        List<String> names = (List<String>) a.readNestedProperty("paintingArray.paintingTitle");
+
+        List<String> names = (List<String>) a
+                .readNestedProperty("paintingArray.paintingTitle");
         assertEquals(names.size(), 2);
         assertEquals(names.get(0), "p1");
         assertEquals(names.get(1), "p2");
-        
-        List<String> names2 = (List<String>) 
-            ex.readNestedProperty("toArtist.paintingArray.paintingTitle");
+
+        List<String> names2 = (List<String>) ex
+                .readNestedProperty("toArtist.paintingArray.paintingTitle");
         assertEquals(names, names2);
     }
-    
+
     public void testReadNestedPropertyToManyInMiddle1() throws Exception {
-        DataContext context = createDataContext();
-        
+
         Artist a = context.newObject(Artist.class);
         ArtistExhibit ex = context.newObject(ArtistExhibit.class);
         Painting p1 = context.newObject(Painting.class);
@@ -120,22 +124,23 @@ public class CayenneDataObjectTest exten
         a.addToPaintingArray(p1);
         a.addToPaintingArray(p2);
         ex.setToArtist(a);
-        
-        List<String> names = (List<String>) a.readNestedProperty("paintingArray+.paintingTitle");
+
+        List<String> names = (List<String>) a
+                .readNestedProperty("paintingArray+.paintingTitle");
         assertEquals(names.size(), 2);
         assertEquals(names.get(0), "p1");
         assertEquals(names.get(1), "p2");
-        
-        List<String> names2 = (List<String>) 
-            ex.readNestedProperty("toArtist.paintingArray+.paintingTitle");
+
+        List<String> names2 = (List<String>) ex
+                .readNestedProperty("toArtist.paintingArray+.paintingTitle");
         assertEquals(names, names2);
     }
-    
+
     public void testFilterObjects() {
-        DataContext context = createDataContext();
-        List paintingList = new ArrayList();
-        Painting p1 = (Painting) context.newObject(Painting.class);
-        Artist a1 = (Artist) context.newObject(Artist.class);
+
+        List<Painting> paintingList = new ArrayList<Painting>();
+        Painting p1 = context.newObject(Painting.class);
+        Artist a1 = context.newObject(Artist.class);
         a1.setArtistName("dddAd");
         p1.setToArtist(a1);
 
@@ -143,6 +148,6 @@ public class CayenneDataObjectTest exten
         Expression exp = ExpressionFactory.likeExp("toArtist+.artistName", "d%");
 
         List<Painting> rezult = exp.filterObjects(paintingList);
-        assertEquals(a1,rezult.get(0).getToArtist());
+        assertEquals(a1, rezult.get(0).getToArtist());
     }
 }



Mime
View raw message