cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r962635 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test: java/org/apache/cayenne/access/ java/org/apache/cayenne/unit/di/server/ resources/ resources/dml/
Date Fri, 09 Jul 2010 18:57:58 GMT
Author: aadamchik
Date: Fri Jul  9 18:57:57 2010
New Revision: 962635

URL: http://svn.apache.org/viewvc?rev=962635&view=rev
Log:
DI-enabled unit tests

* more tests converted

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-people.xml
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-relationships.xml
Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.DataContextEJBQLFlattenedRelationshipsTest.xml
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.DataContextEJBQLGroupByHavingTest.xml
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.DataContextEJBQLInheritanceTest.xml
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLFlattenedRelationshipsTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLInheritanceTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-default.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLFlattenedRelationshipsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLFlattenedRelationshipsTest.java?rev=962635&r1=962634&r2=962635&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLFlattenedRelationshipsTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLFlattenedRelationshipsTest.java
Fri Jul  9 18:57:57 2010
@@ -26,19 +26,65 @@ import java.util.Set;
 import org.apache.cayenne.Cayenne;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.Persistent;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.testdo.relationship.FlattenedTest1;
-import org.apache.cayenne.unit.RelationshipCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class DataContextEJBQLFlattenedRelationshipsTest extends RelationshipCase {
+@UseServerRuntime(ServerCase.RELATIONSHIPS_PROJECT)
+public class DataContextEJBQLFlattenedRelationshipsTest extends ServerCase {
+
+    @Inject
+    protected ObjectContext context;
+
+    @Inject
+    protected DBHelper dbHelper;
+
+    protected TableHelper ft1Helper;
+    protected TableHelper ft2Helper;
+    protected TableHelper ft3Helper;
+    protected TableHelper ft4Helper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+
+        dbHelper.deleteAll("FLATTENED_TEST_4");
+        dbHelper.deleteAll("FLATTENED_TEST_3");
+        dbHelper.deleteAll("FLATTENED_TEST_2");
+        dbHelper.deleteAll("FLATTENED_TEST_1");
+
+        ft1Helper = new TableHelper(dbHelper, "FLATTENED_TEST_1", "FT1_ID", "NAME");
+
+        ft2Helper = new TableHelper(dbHelper, "FLATTENED_TEST_2");
+        ft2Helper.setColumns("FT2_ID", "FT1_ID", "NAME");
+
+        ft3Helper = new TableHelper(dbHelper, "FLATTENED_TEST_3");
+        ft3Helper.setColumns("FT3_ID", "FT2_ID", "NAME");
+
+        ft4Helper = new TableHelper(dbHelper, "FLATTENED_TEST_4");
+        ft4Helper.setColumns("FT4_ID", "FT3_ID", "NAME");
+    }
+
+    private void createFt123() throws Exception {
+        ft1Helper.insert(1, "ft1").insert(2, "ft12");
+        ft2Helper.insert(1, 1, "ft2").insert(2, 2, "ft22");
+        ft3Helper.insert(1, 1, "ft3").insert(2, 2, "ft3-a").insert(3, 2, "ft3-b");
+    }
+
+    private void createFt1234() throws Exception {
+        createFt123();
+        ft4Helper.insert(1, 1, "ft4");
+    }
 
     public void testCollectionMemberOfThetaJoin() throws Exception {
-        createTestData("testCollectionMemberOfThetaJoin");
+        createFt123();
 
         String ejbql = "SELECT f FROM FlattenedTest3 f, FlattenedTest1 ft "
                 + "WHERE f MEMBER OF ft.ft3Array AND ft = :ft";
 
-        ObjectContext context = createDataContext();
         FlattenedTest1 ft = Cayenne.objectForPK(context, FlattenedTest1.class, 2);
         EJBQLQuery query = new EJBQLQuery(ejbql);
         query.setParameter("ft", ft);
@@ -53,15 +99,17 @@ public class DataContextEJBQLFlattenedRe
             ids.add(id);
         }
 
-        assertTrue(ids.contains(new Integer(2)));
-        assertTrue(ids.contains(new Integer(3)));
+        assertTrue(ids.contains(2));
+        assertTrue(ids.contains(3));
     }
-    
-    public void testCollectionMemberOfThetaJoinLongRelationshipSequence() throws Exception
{
+
+    public void testCollectionMemberOfThetaJoinLongRelationshipSequence()
+            throws Exception {
+
+        createFt1234();
         String ejbql = "SELECT f FROM FlattenedTest4 f, FlattenedTest1 ft "
                 + "WHERE f MEMBER OF ft.ft4ArrayFor1 AND ft = :ft";
 
-        ObjectContext context = createDataContext();
         FlattenedTest1 ft = Cayenne.objectForPK(context, FlattenedTest1.class, 1);
         EJBQLQuery query = new EJBQLQuery(ejbql);
         query.setParameter("ft", ft);
@@ -77,8 +125,7 @@ public class DataContextEJBQLFlattenedRe
         }
 
         assertTrue(ids.contains(new Integer(1)));
-        
-        
+
         ft = Cayenne.objectForPK(context, FlattenedTest1.class, 2);
         query = new EJBQLQuery(ejbql);
         query.setParameter("ft", ft);
@@ -88,9 +135,10 @@ public class DataContextEJBQLFlattenedRe
     }
 
     public void testCollectionInnerJoin() throws Exception {
+
+        createFt123();
         String ejbql = "SELECT ft FROM FlattenedTest1 ft INNER JOIN ft.ft3Array f WHERE ft
= :ft";
 
-        ObjectContext context = createDataContext();
         FlattenedTest1 ft = Cayenne.objectForPK(context, FlattenedTest1.class, 1);
         EJBQLQuery query = new EJBQLQuery(ejbql);
         query.setParameter("ft", ft);
@@ -108,19 +156,20 @@ public class DataContextEJBQLFlattenedRe
         }
 
         assertTrue(ids.contains(new Integer(1)));
-        
+
     }
 
-    
     public void testCollectionAsInnerJoin() throws Exception {
+
+        createFt123();
+
         // this query is equivalent to the previous INNER JOIN example
         String ejbql = "SELECT OBJECT(ft) FROM FlattenedTest1 ft, IN(ft.ft3Array) f WHERE
ft = :ft";
 
-        ObjectContext context = createDataContext();
         FlattenedTest1 ft = Cayenne.objectForPK(context, FlattenedTest1.class, 1);
         EJBQLQuery query = new EJBQLQuery(ejbql);
         query.setParameter("ft", ft);
-        
+
         List<?> objects = context.performQuery(query);
         assertNotNull(objects);
         assertFalse(objects.isEmpty());
@@ -134,15 +183,16 @@ public class DataContextEJBQLFlattenedRe
         }
 
         assertTrue(ids.contains(new Integer(1)));
-        
+
     }
 
     public void testCollectionThetaJoin() throws Exception {
+        createFt123();
+
         String ejbql = "SELECT DISTINCT ft FROM FlattenedTest1 ft , FlattenedTest3 f3 WHERE
f3.toFT1 = ft";
 
-        ObjectContext context = createDataContext();
         EJBQLQuery query = new EJBQLQuery(ejbql);
-        
+
         List<?> objects = context.performQuery(query);
         assertNotNull(objects);
         assertFalse(objects.isEmpty());
@@ -160,9 +210,10 @@ public class DataContextEJBQLFlattenedRe
     }
 
     public void testCollectionIdentificationVariable() throws Exception {
+        createFt123();
+
         String ejbql = "SELECT ft.ft3Array FROM FlattenedTest1 ft WHERE ft = :ft";
 
-        ObjectContext context = createDataContext();
         FlattenedTest1 ft = Cayenne.objectForPK(context, FlattenedTest1.class, 2);
         EJBQLQuery query = new EJBQLQuery(ejbql);
         query.setParameter("ft", ft);
@@ -185,10 +236,10 @@ public class DataContextEJBQLFlattenedRe
     }
 
     public void testAssociationFieldSelect() throws Exception {
-        
+        createFt123();
+
         String ejbql = "SELECT ft3.toFT1 FROM FlattenedTest3 ft3 WHERE ft3.toFT1 = :ft";
-        
-        ObjectContext context = createDataContext();
+
         FlattenedTest1 ft = Cayenne.objectForPK(context, FlattenedTest1.class, 1);
         EJBQLQuery query = new EJBQLQuery(ejbql);
         query.setParameter("ft", ft);
@@ -206,43 +257,39 @@ public class DataContextEJBQLFlattenedRe
         assertTrue(ids.contains(new Integer(1)));
 
     }
-    
+
     public void testCollectionSubquery() throws Exception {
+
+        createFt123();
+
         String ejbql = "SELECT ft FROM FlattenedTest1 ft "
-        + "WHERE (SELECT COUNT(f) FROM ft.ft3Array f) = 1";
+                + "WHERE (SELECT COUNT(f) FROM ft.ft3Array f) = 1";
 
-        ObjectContext context = createDataContext();
         EJBQLQuery query = new EJBQLQuery(ejbql);
-        
+
         // TODO fails but not because of flattened relationship,
-        // the reason is that property "ft3Array" inside the subquery 
+        // the reason is that property "ft3Array" inside the subquery
         // parses as unmapped
-        /*List<?> objects = context.performQuery(query);
-        assertNotNull(objects);
-        assertFalse(objects.isEmpty());
-        assertEquals(1, objects.size());
-
-        Set<Object> ids = new HashSet<Object>();
-        Iterator<?> it = objects.iterator();
-        while (it.hasNext()) {
-            Object id = Cayenne.pkForObject((Persistent) it.next());
-            ids.add(id);
-        }
-
-        assertTrue(ids.contains(new Integer(2)));*/
-        
+        /*
+         * List<?> objects = context.performQuery(query); assertNotNull(objects);
+         * assertFalse(objects.isEmpty()); assertEquals(1, objects.size()); Set<Object>
+         * ids = new HashSet<Object>(); Iterator<?> it = objects.iterator();
while
+         * (it.hasNext()) { Object id = Cayenne.pkForObject((Persistent) it.next());
+         * ids.add(id); } assertTrue(ids.contains(new Integer(2)));
+         */
 
     }
-    
+
     public void testCollectionSubquery1() throws Exception {
+        createFt123();
+
         String ejbql = "SELECT ft FROM FlattenedTest1 ft "
-        + "WHERE (SELECT COUNT(f3) FROM FlattenedTest3 f3 WHERE f3 MEMBER OF ft.ft3Array)
> 1";
+                + "WHERE (SELECT COUNT(f3) FROM FlattenedTest3 f3 WHERE f3 MEMBER OF ft.ft3Array)
> 1";
 
-        ObjectContext context = createDataContext();
         EJBQLQuery query = new EJBQLQuery(ejbql);
-        
+
         List<?> objects = context.performQuery(query);
-        
+
         assertNotNull(objects);
         assertFalse(objects.isEmpty());
         assertEquals(1, objects.size());
@@ -257,12 +304,15 @@ public class DataContextEJBQLFlattenedRe
         assertTrue(ids.contains(new Integer(2)));
 
     }
+
     public void testGroupByFlattenedRelationship() throws Exception {
+
+        createFt123();
+
         String ejbql = "SELECT COUNT(ft3), ft3.toFT1 FROM FlattenedTest3 ft3  GROUP BY ft3.toFT1
";
-  
-         ObjectContext context = createDataContext();
-         EJBQLQuery query = new EJBQLQuery(ejbql);
-         List<?> objects = context.performQuery(query);
-         assertEquals(2, objects.size());
+
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        List<?> objects = context.performQuery(query);
+        assertEquals(2, objects.size());
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java?rev=962635&r1=962634&r2=962635&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java
Fri Jul  9 18:57:57 2010
@@ -24,28 +24,98 @@ import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.test.junit.AssertExtras;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.testdo.testmap.Gallery;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class DataContextEJBQLGroupByHavingTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextEJBQLGroupByHavingTest extends ServerCase {
+
+    @Inject
+    protected ObjectContext context;
+
+    @Inject
+    protected DBHelper dbHelper;
+
+    protected TableHelper tArtist;
+    protected TableHelper tPainting;
+    protected TableHelper tGallery;
 
     @Override
-    protected void setUp() throws Exception {
-        deleteTestData();
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST");
+        dbHelper.deleteAll("EXHIBIT");
+        dbHelper.deleteAll("GALLERY");
+
+        tArtist = new TableHelper(dbHelper, "ARTIST");
+        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
+
+        tPainting = new TableHelper(dbHelper, "PAINTING");
+        tPainting.setColumns(
+                "PAINTING_ID",
+                "ARTIST_ID",
+                "GALLERY_ID",
+                "PAINTING_TITLE",
+                "ESTIMATED_PRICE");
+
+        tGallery = new TableHelper(dbHelper, "GALLERY");
+        tGallery.setColumns("GALLERY_ID", "GALLERY_NAME");
+    }
+
+    private void createFivePaintings() throws Exception {
+        tPainting.insert(33001, null, null, "PX", 1);
+        tPainting.insert(33002, null, null, "PY", 2);
+        tPainting.insert(33003, null, null, "PY", 2);
+        tPainting.insert(33004, null, null, "PZ", 1);
+        tPainting.insert(33005, null, null, "PZ", 1);
+    }
+
+    private void createFourArtistsAndTwoPaintings() throws Exception {
+        tArtist.insert(33001, "AA1");
+        tArtist.insert(33002, "AA2");
+        tArtist.insert(33003, "BB1");
+        tArtist.insert(33004, "BB2");
+        tPainting.insert(33007, 33001, null, "P1", 3000);
+        tPainting.insert(33008, 33002, null, "P2", 5000);
+    }
+
+    private void createArtistsPaintingGalleries() throws Exception {
+        tArtist.insert(33001, "AA1");
+        tArtist.insert(33002, "AA2");
+        tArtist.insert(33003, "BB1");
+        tArtist.insert(33004, "BB2");
+
+        tGallery.insert(33001, "gallery1");
+        tGallery.insert(33002, "gallery2");
+
+        tPainting.insert(33001, null, null, "PX", 1);
+        tPainting.insert(33002, null, null, "PY", 2);
+        tPainting.insert(33003, null, null, "PY", 2);
+        tPainting.insert(33007, 33001, null, "P1", 3000);
+        tPainting.insert(33008, 33002, null, "P2", 5000);
+        tPainting.insert(33009, 33002, 33001, "P111", 5000);
+        tPainting.insert(33010, 33001, 33002, "P112", 5000);
     }
 
     public void testGroupBy() throws Exception {
-        createTestData("prepare");
+        createFivePaintings();
 
         String ejbql = "SELECT p.estimatedPrice, count(p) FROM Painting p"
                 + " GROUP BY p.estimatedPrice"
                 + " ORDER BY p.estimatedPrice";
         EJBQLQuery query = new EJBQLQuery(ejbql);
 
-        List data = createDataContext().performQuery(query);
+        List<?> data = context.performQuery(query);
         assertEquals(2, data.size());
         assertTrue(data.get(0) instanceof Object[]);
 
@@ -59,14 +129,14 @@ public class DataContextEJBQLGroupByHavi
     }
 
     public void testGroupByMultipleItems() throws Exception {
-        createTestData("prepare");
+        createFivePaintings();
 
         String ejbql = "SELECT p.estimatedPrice, p.paintingTitle, count(p) FROM Painting
p"
                 + " GROUP BY p.estimatedPrice, p.paintingTitle"
                 + " ORDER BY p.estimatedPrice, p.paintingTitle";
         EJBQLQuery query = new EJBQLQuery(ejbql);
 
-        List data = createDataContext().performQuery(query);
+        List<?> data = context.performQuery(query);
         assertEquals(3, data.size());
         assertTrue(data.get(0) instanceof Object[]);
 
@@ -88,14 +158,14 @@ public class DataContextEJBQLGroupByHavi
 
     public void testGroupByRelatedEntity() throws Exception {
 
-        createTestData("testGroupByRelatedEntity");
+        createFourArtistsAndTwoPaintings();
 
         String ejbql = "SELECT COUNT(p), a, a.artistName "
                 + "FROM Painting p INNER JOIN p.toArtist a GROUP BY a, a.artistName "
                 + "ORDER BY a.artistName";
         EJBQLQuery query = new EJBQLQuery(ejbql);
 
-        List data = createDataContext().performQuery(query);
+        List<?> data = context.performQuery(query);
         assertEquals(2, data.size());
 
         assertTrue(data.get(0) instanceof Object[]);
@@ -107,12 +177,12 @@ public class DataContextEJBQLGroupByHavi
     }
 
     public void testGroupByIdVariable() throws Exception {
-        createTestData("prepare");
+        createFivePaintings();
 
         String ejbql = "SELECT count(p), p FROM Painting p GROUP BY p";
         EJBQLQuery query = new EJBQLQuery(ejbql);
 
-        List data = createDataContext().performQuery(query);
+        List<?> data = context.performQuery(query);
         assertEquals(5, data.size());
 
         // TODO: andrus, 8/3/2007 the rest of the unit test fails as currently Cayenne
@@ -127,14 +197,14 @@ public class DataContextEJBQLGroupByHavi
     }
 
     public void testGroupByHavingOnColumn() throws Exception {
-        createTestData("prepare");
+        createFivePaintings();
 
         String ejbql = "SELECT p.estimatedPrice, count(p) FROM Painting p"
                 + " GROUP BY p.estimatedPrice"
                 + " HAVING p.estimatedPrice > 1";
         EJBQLQuery query = new EJBQLQuery(ejbql);
 
-        List data = createDataContext().performQuery(query);
+        List<?> data = context.performQuery(query);
         assertEquals(1, data.size());
         assertTrue(data.get(0) instanceof Object[]);
 
@@ -144,14 +214,14 @@ public class DataContextEJBQLGroupByHavi
     }
 
     public void testGroupByHavingOnAggregate() throws Exception {
-        createTestData("prepare");
+        createFivePaintings();
 
         String ejbql = "SELECT p.estimatedPrice, count(p) FROM Painting p"
                 + " GROUP BY p.estimatedPrice"
                 + " HAVING count(p) > 2";
         EJBQLQuery query = new EJBQLQuery(ejbql);
 
-        List data = createDataContext().performQuery(query);
+        List<?> data = context.performQuery(query);
         assertEquals(1, data.size());
         assertTrue(data.get(0) instanceof Object[]);
 
@@ -161,14 +231,14 @@ public class DataContextEJBQLGroupByHavi
     }
 
     public void testGroupByHavingOnAggregateMultipleConditions() throws Exception {
-        createTestData("prepare");
+        createFivePaintings();
 
         String ejbql = "SELECT p.estimatedPrice, count(p) FROM Painting p"
                 + " GROUP BY p.estimatedPrice"
                 + " HAVING count(p) > 2 AND p.estimatedPrice < 10";
         EJBQLQuery query = new EJBQLQuery(ejbql);
 
-        List data = createDataContext().performQuery(query);
+        List<?> data = context.performQuery(query);
         assertEquals(1, data.size());
         assertTrue(data.get(0) instanceof Object[]);
 
@@ -178,10 +248,11 @@ public class DataContextEJBQLGroupByHavi
     }
 
     public void testGroupByJoinedRelatedEntities() throws Exception {
-        createTestData("testGroupByRelatedEntity");
+        createFourArtistsAndTwoPaintings();
+
         EJBQLQuery query = new EJBQLQuery(
                 "SELECT COUNT(p), p.toArtist FROM Painting p GROUP BY p.toArtist ");
-        List<Object[]> data = createDataContext().performQuery(query);
+        List<Object[]> data = context.performQuery(query);
         assertNotNull(data);
         assertEquals(2, data.size());
 
@@ -201,15 +272,15 @@ public class DataContextEJBQLGroupByHavi
     }
 
     public void testGroupByJoinedEntities() throws Exception {
-        createTestData("testGroupByEntities");
+        createArtistsPaintingGalleries();
         EJBQLQuery query = new EJBQLQuery(
                 "SELECT COUNT(p), p.toArtist, p.toGallery FROM Painting p "
                         + "GROUP BY p.toGallery, p.toArtist ");
-        List<Object[]> data = createDataContext().performQuery(query);
+        List<Object[]> data = context.performQuery(query);
         assertNotNull(data);
         assertEquals(2, data.size());
 
-        HashSet<List> expectedResults = new HashSet<List>();
+        HashSet<List<?>> expectedResults = new HashSet<List<?>>();
         expectedResults.add(Arrays.asList(1L, "AA2", "gallery1"));
         expectedResults.add(Arrays.asList(1L, "AA1", "gallery2"));
 
@@ -223,16 +294,17 @@ public class DataContextEJBQLGroupByHavi
     }
 
     public void testGroupByJoinedEntityInCount() throws Exception {
-        createTestData("testGroupByEntities");
+        createArtistsPaintingGalleries();
+
         EJBQLQuery query = new EJBQLQuery(
                 "SELECT COUNT(p.toArtist), p.paintingTitle FROM Painting p "
                         + "GROUP BY p.paintingTitle "
                         + "HAVING p.paintingTitle LIKE 'P1%'");
-        List<Object[]> data = createDataContext().performQuery(query);
+        List<Object[]> data = context.performQuery(query);
         assertNotNull(data);
         assertEquals(3, data.size());
 
-        HashSet<List> expectedResults = new HashSet<List>();
+        HashSet<List<?>> expectedResults = new HashSet<List<?>>();
         expectedResults.add(Arrays.asList(1L, "P1"));
         expectedResults.add(Arrays.asList(1L, "P111"));
         expectedResults.add(Arrays.asList(1L, "P112"));
@@ -243,17 +315,17 @@ public class DataContextEJBQLGroupByHavi
     }
 
     public void testGroupByChainedJoins() throws Exception {
-        createTestData("prepare");
+        createFivePaintings();
 
         String ejbql = "SELECT p.painting.toArtist.paintingArray FROM PaintingInfo p"
                 + " GROUP BY p.painting.toArtist.paintingArray";
         EJBQLQuery query = new EJBQLQuery(ejbql);
-        List data = createDataContext().performQuery(query);
+        context.performQuery(query);
 
         ejbql = "SELECT p.painting.toArtist FROM PaintingInfo p"
                 + " GROUP BY p.painting.toArtist";
         query = new EJBQLQuery(ejbql);
-        createDataContext().performQuery(query);
+        context.performQuery(query);
     }
 
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLInheritanceTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLInheritanceTest.java?rev=962635&r1=962634&r2=962635&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLInheritanceTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLInheritanceTest.java
Fri Jul  9 18:57:57 2010
@@ -21,29 +21,45 @@ package org.apache.cayenne.access;
 import java.util.List;
 
 import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.testdo.inherit.CustomerRepresentative;
 import org.apache.cayenne.testdo.inherit.Employee;
 import org.apache.cayenne.testdo.inherit.Manager;
-import org.apache.cayenne.unit.PeopleCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class DataContextEJBQLInheritanceTest extends PeopleCase {
+@UseServerRuntime(ServerCase.PEOPLE_PROJECT)
+public class DataContextEJBQLInheritanceTest extends ServerCase {
+
+    @Inject
+    protected ObjectContext context;
+
+    @Inject
+    protected DBHelper dbHelper;
 
     @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        deleteTestData();
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PERSON");
+
+        TableHelper person = new TableHelper(dbHelper, "PERSON");
+        person.setColumns("PERSON_ID", "NAME", "PERSON_TYPE", "SALARY");
+
+        person.insert(1, "a", "EE", 20000);
+        person.insert(2, "b", "EE", 25000);
+        person.insert(4, "c", "EM", 30000);
+        person.insert(5, "d", "EM", 40000);
+        person.insert(6, "e", "C", null);
     }
 
     public void testSelect() throws Exception {
-        createTestData("testSelect");
-
-        ObjectContext context = createDataContext();
 
         EJBQLQuery superclass = new EJBQLQuery(
                 "select p from AbstractPerson p ORDER BY p.name");
 
-        List superclassResult = context.performQuery(superclass);
+        List<?> superclassResult = context.performQuery(superclass);
         assertEquals(5, superclassResult.size());
 
         assertEquals(Employee.class.getName(), superclassResult
@@ -69,7 +85,7 @@ public class DataContextEJBQLInheritance
 
         EJBQLQuery subclass = new EJBQLQuery("select e from Employee e ORDER BY e.name");
 
-        List subclassResult = context.performQuery(subclass);
+        List<?> subclassResult = context.performQuery(subclass);
         assertEquals(4, subclassResult.size());
 
         assertEquals(Employee.class.getName(), subclassResult.get(0).getClass().getName());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java?rev=962635&r1=962634&r2=962635&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
Fri Jul  9 18:57:57 2010
@@ -32,6 +32,8 @@ public class ServerCase extends DICase {
     public static final String INHERTITANCE_SINGLE_TABLE1_PROJECT = "cayenne-inheritance-single-table1.xml";
     public static final String INHERTITANCE_VERTICAL_PROJECT = "cayenne-inheritance-vertical.xml";
     public static final String QUOTED_IDENTIFIERS_PROJECT = "cayenne-quoted-identifiers.xml";
+    public static final String PEOPLE_PROJECT = "cayenne-people.xml";
+    public static final String RELATIONSHIPS_PROJECT = "cayenne-relationships.xml";
     public static final String TESTMAP_PROJECT = "cayenne-testmap.xml";
 
     private static final Injector injector;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-default.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-default.xml?rev=962635&r1=962634&r2=962635&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-default.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-default.xml
Fri Jul  9 18:57:57 2010
@@ -5,9 +5,7 @@
 	<map name="locking"/>
 	<map name="map-db1"/>
 	<map name="map-db2"/>
-	<map name="people"/>
 	<map name="qualified"/>
-	<map name="relationships"/>
 	<map name="sus-map"/>
 </domain>
 

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-people.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-people.xml?rev=962635&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-people.xml
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-people.xml
Fri Jul  9 18:57:57 2010
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="6">
+	<map name="people"/>
+</domain>
+

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-relationships.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-relationships.xml?rev=962635&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-relationships.xml
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne-relationships.xml
Fri Jul  9 18:57:57 2010
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="6">
+	<map name="relationships"/>
+</domain>
+



Mime
View raw message