cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r653109 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test: java/org/apache/cayenne/access/DataContextJoinAliasesTest.java resources/dml/access.DataContextJoinAliasesTest.xml
Date Sat, 03 May 2008 19:41:50 GMT
Author: aadamchik
Date: Sat May  3 12:41:49 2008
New Revision: 653109

URL: http://svn.apache.org/viewvc?rev=653109&view=rev
Log:
CAY-802  Split Expressions
(unit tests)

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

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextJoinAliasesTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextJoinAliasesTest.java?rev=653109&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextJoinAliasesTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextJoinAliasesTest.java
Sat May  3 12:41:49 2008
@@ -0,0 +1,70 @@
+/*****************************************************************
+ *   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.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.art.Artist;
+import org.apache.art.Gallery;
+import org.apache.cayenne.DataObjectUtils;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.unit.CayenneCase;
+
+public class DataContextJoinAliasesTest extends CayenneCase {
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        deleteTestData();
+    }
+
+    public void testMatchAll() throws Exception {
+        Map<String, Object> params = new HashMap<String, Object>();
+        Date now = new Date();
+        params.put("date1", now);
+        params.put("date2", now);
+        createTestData("testMatchAll", params);
+
+        // select all galleries that have exhibits by both Picasso and Dali...
+
+        ObjectContext context = createDataContext();
+
+        Artist picasso = DataObjectUtils.objectForPK(context, Artist.class, 1);
+        Artist dali = DataObjectUtils.objectForPK(context, Artist.class, 2);
+
+//        SelectQuery query = new SelectQuery(Gallery.class);
+//        String path = "exhibitArray.artistExhibitArray";
+//        query.aliasJoin("p", path);
+//        query.aliasJoin("d", path);
+//
+//        query.andQualifier(ExpressionFactory.matchExp("p.toArtist", picasso));
+//        query.andQualifier(ExpressionFactory.matchExp("d.toArtist", dali));
+//
+//        List<Gallery> galleries = context.performQuery(query);
+//
+//        assertEquals(1, galleries.size());
+//        assertEquals("G1", galleries.get(0).getGalleryName());
+    }
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.DataContextJoinAliasesTest.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.DataContextJoinAliasesTest.xml?rev=653109&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.DataContextJoinAliasesTest.xml
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.DataContextJoinAliasesTest.xml
Sat May  3 12:41:49 2008
@@ -0,0 +1,162 @@
+<?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 (1, 'Picasso')
+		</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 (2, 'Dali')
+		</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 (3, 'X')
+		</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 (4, 'Y')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="G1" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into GALLERY (GALLERY_ID, GALLERY_NAME) values (1, 'G1')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="G2" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into GALLERY (GALLERY_ID, GALLERY_NAME) values (2, 'G2')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="G3" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into GALLERY (GALLERY_ID, GALLERY_NAME) values (3, 'G3')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="E1" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into EXHIBIT (EXHIBIT_ID, GALLERY_ID, OPENING_DATE, CLOSING_DATE) values (1, 2,
#bind($date1 'TIMESTAMP'), #bind($date2 'TIMESTAMP'))
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="E2" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into EXHIBIT (EXHIBIT_ID, GALLERY_ID, OPENING_DATE, CLOSING_DATE) values (2, 2,
#bind($date1 'TIMESTAMP'), #bind($date2 'TIMESTAMP'))
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="E3" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into EXHIBIT (EXHIBIT_ID, GALLERY_ID, OPENING_DATE, CLOSING_DATE) values (3, 1,
#bind($date1 'TIMESTAMP'), #bind($date2 'TIMESTAMP'))
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="E4" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into EXHIBIT (EXHIBIT_ID, GALLERY_ID, OPENING_DATE, CLOSING_DATE) values (4, 1,
#bind($date1 'TIMESTAMP'), #bind($date2 'TIMESTAMP'))
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="E5" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into EXHIBIT (EXHIBIT_ID, GALLERY_ID, OPENING_DATE, CLOSING_DATE) values (5, 3,
#bind($date1 'TIMESTAMP'), #bind($date2 'TIMESTAMP'))
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="AE1" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into ARTIST_EXHIBIT (EXHIBIT_ID, ARTIST_ID) values (1, 1)
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="AE2" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into ARTIST_EXHIBIT (EXHIBIT_ID, ARTIST_ID) values (1, 3)
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="AE3" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into ARTIST_EXHIBIT (EXHIBIT_ID, ARTIST_ID) values (3, 1)
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="AE4" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into ARTIST_EXHIBIT (EXHIBIT_ID, ARTIST_ID) values (4, 2)
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="AE5" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into ARTIST_EXHIBIT (EXHIBIT_ID, ARTIST_ID) values (4, 4)
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="AE6" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.art.Gallery</value></constructor-arg>
+		<constructor-arg><value>
+		insert into ARTIST_EXHIBIT (EXHIBIT_ID, ARTIST_ID) values (5, 2)
+		</value></constructor-arg>
+	</bean>
+	
+
+	<!-- ======================================= -->
+	<!-- Data Sets -->
+	<!-- ======================================= -->	
+	
+	<bean id="testMatchAll" class="java.util.ArrayList">
+		<constructor-arg>
+			<list>
+				<ref bean="A1"/>
+				<ref bean="A2"/>
+				<ref bean="A3"/>
+				<ref bean="A4"/>
+				<ref bean="G1"/>
+				<ref bean="G2"/>
+				<ref bean="G3"/>
+				<ref bean="E1"/>
+				<ref bean="E2"/>
+				<ref bean="E3"/>
+				<ref bean="E4"/>
+				<ref bean="E5"/>
+				<ref bean="AE1"/>
+				<ref bean="AE2"/>
+				<ref bean="AE3"/>
+				<ref bean="AE4"/>
+				<ref bean="AE5"/>
+				<ref bean="AE6"/>
+			</list>
+		</constructor-arg>
+	</bean>
+	
+</beans>
\ No newline at end of file



Mime
View raw message