Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 5205 invoked from network); 12 Oct 2006 18:20:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 Oct 2006 18:20:05 -0000 Received: (qmail 72692 invoked by uid 500); 12 Oct 2006 18:20:05 -0000 Mailing-List: contact jdo-commits-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-commits@db.apache.org Received: (qmail 72677 invoked by uid 99); 12 Oct 2006 18:20:05 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Oct 2006 11:20:05 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Oct 2006 11:20:04 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 3E9B61A981D; Thu, 12 Oct 2006 11:19:44 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r463364 - /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/result/VariableInResult.java Date: Thu, 12 Oct 2006 18:19:44 -0000 To: jdo-commits@db.apache.org From: clr@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061012181944.3E9B61A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: clr Date: Thu Oct 12 11:19:43 2006 New Revision: 463364 URL: http://svn.apache.org/viewvc?view=rev&rev=463364 Log: JDO-344 Add new tests for projection of variables and fields of variables where the projected variables are mapped to one-to-many and many-to-many relationships. Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/result/VariableInResult.java Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/result/VariableInResult.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/result/VariableInResult.java?view=diff&rev=463364&r1=463363&r2=463364 ============================================================================== --- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/result/VariableInResult.java (original) +++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/result/VariableInResult.java Thu Oct 12 11:19:43 2006 @@ -39,6 +39,14 @@ * then the semantics of the contains clause that include the variable change. * In this case, all values of the variable * that satisfy the filter are included in the result. + * Result expressions begin with either an instance of the candidate class + * (with an explicit or implicit "this") or an instance of a variable + * (using the variable name). The candidate tuples are the cartesian product + * of the candidate class and all variables used in the result. The result + * tuples are the tuples of the candidate class and all variables used + * in the result that satisfy the filter. + * The result is the collection of result expressions projected from the + * result tuples. */ public class VariableInResult extends QueryTest { @@ -92,14 +100,80 @@ /*GROUP BY*/ null, /*ORDER BY*/ null, /*FROM*/ null, + /*TO*/ null), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "e", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e)", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "e, p", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e) && e.projects.contains(p)" + + "&& p.name == 'orange'", + /*VARIABLES*/ "Employee e; Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "e, p", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e) && e.projects.contains(p)", + /*VARIABLES*/ "Employee e; Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // SELECT e FROM Department WHERE deptid==2 & employees.contains(e) VARIABLES Employee e + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "e", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "deptid == 2 & employees.contains(e)", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, /*TO*/ null) }; /** * The expected results of valid queries. */ + private Object emp1 = getTransientCompanyModelInstance("emp1"); + private Object emp2 = getTransientCompanyModelInstance("emp2"); + private Object emp3 = getTransientCompanyModelInstance("emp3"); + private Object emp4 = getTransientCompanyModelInstance("emp4"); + private Object emp5 = getTransientCompanyModelInstance("emp5"); + private Object proj1 = getTransientCompanyModelInstance("proj1"); + private Object proj2 = getTransientCompanyModelInstance("proj2"); + private Object proj3 = getTransientCompanyModelInstance("proj3"); + private Object[] expectedResult = { - // this getTransientCompanyModelInstancesAsList( new String[]{"emp1","emp2","emp3","emp4","emp5"}), // Note: "orange" is not a bean name! @@ -107,7 +181,25 @@ Arrays.asList(new Object[]{ new Object[]{new Long(1), "orange"}, new Object[]{new Long(1), "orange"}, - new Object[]{new Long(1), "orange"}}) + new Object[]{new Long(1), "orange"}}), + getTransientCompanyModelInstancesAsList( + new String[]{"emp1","emp2","emp3","emp4","emp5"}), + new Object[] { + new Object[] {emp1, proj1}, + new Object[] {emp2, proj1}, + new Object[] {emp3, proj1} + }, + new Object[] { + new Object[] {emp1, proj1}, + new Object[] {emp2, proj1}, + new Object[] {emp3, proj1}, + new Object[] {emp2, proj2}, + new Object[] {emp3, proj2}, + new Object[] {emp4, proj3}, + new Object[] {emp5, proj3} + }, + getTransientCompanyModelInstancesAsList( + new String[]{"emp4","emp5"}) }; /** @@ -140,6 +232,42 @@ /** */ public void testNavigation() { int index = 2; + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResult[index]); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResult[index]); + } + + /** */ + public void testNoNavigation() { + int index = 3; + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResult[index]); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResult[index]); + } + + /** */ + public void testMultipleProjectionWithConstraints() { + int index = 4; + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResult[index]); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResult[index]); + } + + /** */ + public void testMultipleProjection() { + int index = 5; + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResult[index]); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResult[index]); + } + + /** */ + public void testProjectionWithConstraints() { + int index = 6; executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], expectedResult[index]); executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index],