cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r524591 - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test: java/org/apache/cayenne/access/DataContextEJBQLJoinsTest.java resources/dml/access.DataContextEJBQLJoinsTest.xml
Date Sun, 01 Apr 2007 13:33:07 GMT
Author: aadamchik
Date: Sun Apr  1 06:33:06 2007
New Revision: 524591

URL: http://svn.apache.org/viewvc?view=rev&rev=524591
Log:
CAY-452: EJB QL Cayenne Query
starting on the joins support - initial unit tests

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLJoinsTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextEJBQLJoinsTest.xml

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLJoinsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLJoinsTest.java?view=auto&rev=524591
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLJoinsTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLJoinsTest.java
Sun Apr  1 06:33:06 2007
@@ -0,0 +1,89 @@
+/*****************************************************************
+ *   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.access;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.art.Artist;
+import org.apache.cayenne.DataObjectUtils;
+import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.unit.CayenneCase;
+
+public class DataContextEJBQLJoinsTest extends CayenneCase {
+
+    protected void setUp() throws Exception {
+        deleteTestData();
+    }
+
+    public void testThetaJoins() throws Exception {
+        createTestData("testThetaJoins");
+
+//        String ejbql = "SELECT DISTINCT a "
+//                + "FROM Artist a, Painting b "
+//                + "WHERE a.artistName = b.paintingTitle";
+//
+//        List artists = createDataContext().performQuery(new EJBQLQuery(ejbql));
+//        assertEquals(2, artists.size());
+//
+//        Set names = new HashSet(2);
+//        Iterator it = artists.iterator();
+//        while (it.hasNext()) {
+//            Artist a = (Artist) it.next();
+//            names.add(a.getArtistName());
+//        }
+//
+//        assertTrue(names.contains("AA1"));
+//        assertTrue(names.contains("BB2"));
+    }
+
+    public void testInnerJoins() throws Exception {
+        createTestData("testInnerJoins");
+
+//        String ejbql = "SELECT a "
+//                + "FROM Artist a INNER JOIN a.paintingArray p "
+//                + "WHERE a.artistName = 'A1'";
+//
+//        List artists = createDataContext().performQuery(new EJBQLQuery(ejbql));
+//        assertEquals(1, artists.size());
+//        assertEquals(33001, DataObjectUtils.intPKForObject((Artist) artists.get(0)));
+    }
+
+    public void testOuterJoins() throws Exception {
+        createTestData("testInnerJoins");
+
+        // String ejbql = "SELECT a "
+        // + "FROM Artist a LEFT JOIN a.paintingArray p "
+        // + "WHERE a.artistName = 'A1'";
+        //
+        // List artists = createDataContext().performQuery(new EJBQLQuery(ejbql));
+        // assertEquals(2, artists.size());
+        // Set ids = new HashSet(2);
+        // Iterator it = artists.iterator();
+        // while (it.hasNext()) {
+        // Artist a = (Artist) it.next();
+        // ids.add(DataObjectUtils.pkForObject(a));
+        // }
+        //
+        //        assertTrue(ids.contains(new Integer(33001)));
+        //        assertTrue(ids.contains(new Integer(33005)));
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextEJBQLJoinsTest.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextEJBQLJoinsTest.xml?view=auto&rev=524591
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextEJBQLJoinsTest.xml
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextEJBQLJoinsTest.xml
Sun Apr  1 06:33:06 2007
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans default-lazy-init="true">	
+	<bean id="A1" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Artist</value></constructor-arg>
+		<constructor-arg><value>
+		insert into ARTIST (ARTIST_ID, ARTIST_NAME) values (33001, 'AA1')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="A2" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Artist</value></constructor-arg>
+		<constructor-arg><value>
+		insert into ARTIST (ARTIST_ID, ARTIST_NAME) values (33002, 'AA2')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="A3" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Artist</value></constructor-arg>
+		<constructor-arg><value>
+		insert into ARTIST (ARTIST_ID, ARTIST_NAME) values (33003, 'BB1')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="A4" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Artist</value></constructor-arg>
+		<constructor-arg><value>
+		insert into ARTIST (ARTIST_ID, ARTIST_NAME) values (33004, 'BB2')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="A5" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Artist</value></constructor-arg>
+		<constructor-arg><value>
+		insert into ARTIST (ARTIST_ID, ARTIST_NAME) values (33005, 'AA1')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="P11" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Painting</value></constructor-arg>
+		<constructor-arg><value>
+		INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ARTIST_ID, ESTIMATED_PRICE) VALUES (33001,
'P1', 33001, 3000)
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="P12" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Painting</value></constructor-arg>
+		<constructor-arg><value>
+		INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ARTIST_ID, ESTIMATED_PRICE) VALUES (33002,
'P2', 33002, 5000)
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="P13" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Painting</value></constructor-arg>
+		<constructor-arg><value>
+		INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ARTIST_ID, ESTIMATED_PRICE) VALUES (33003,
'AA1', 33001, 3000)
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="P23" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Painting</value></constructor-arg>
+		<constructor-arg><value>
+		INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ARTIST_ID, ESTIMATED_PRICE) VALUES (33004,
'BB2', 33002, 3000)
+		</value></constructor-arg>
+	</bean>
+	
+
+	<!-- ======================================= -->
+	<!-- Data Sets -->
+	<!-- ======================================= -->	
+	
+	<bean id="testThetaJoins" class="java.util.ArrayList">
+		<constructor-arg>
+			<list>
+				<ref bean="A1"/>
+				<ref bean="A2"/>
+				<ref bean="A3"/>
+				<ref bean="A4"/>
+				<ref bean="P11"/>
+				<ref bean="P12"/>
+				<ref bean="P13"/>
+				<ref bean="P23"/>
+			</list>
+		</constructor-arg>
+	</bean>
+	
+	<bean id="testInnerJoins" class="java.util.ArrayList">
+		<constructor-arg>
+			<list>
+				<ref bean="A1"/>
+				<ref bean="A5"/>
+				<ref bean="P11"/>
+			</list>
+		</constructor-arg>
+	</bean>
+</beans>
\ No newline at end of file



Mime
View raw message