From graffito-commits-return-691-apmail-incubator-graffito-commits-archive=www.apache.org@incubator.apache.org Mon May 22 20:15:09 2006 Return-Path: Delivered-To: apmail-incubator-graffito-commits-archive@www.apache.org Received: (qmail 52415 invoked from network); 22 May 2006 20:15:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 May 2006 20:15:09 -0000 Received: (qmail 70454 invoked by uid 500); 22 May 2006 20:15:09 -0000 Mailing-List: contact graffito-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: graffito-dev@incubator.apache.org Delivered-To: mailing list graffito-commits@incubator.apache.org Received: (qmail 70443 invoked by uid 99); 22 May 2006 20:15:09 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 May 2006 13:15:09 -0700 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=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; Mon, 22 May 2006 13:15:08 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 8C6E51A983A; Mon, 22 May 2006 13:14:48 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r408744 - in /incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/querymanager: ./ QueryManagerTest.java Date: Mon, 22 May 2006 20:14:48 -0000 To: graffito-commits@incubator.apache.org From: clombart@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060522201448.8C6E51A983A@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: clombart Date: Mon May 22 13:14:47 2006 New Revision: 408744 URL: http://svn.apache.org/viewvc?rev=408744&view=rev Log: (empty) Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/querymanager/ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/querymanager/QueryManagerTest.java Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/querymanager/QueryManagerTest.java URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/querymanager/QueryManagerTest.java?rev=408744&view=auto ============================================================================== --- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/querymanager/QueryManagerTest.java (added) +++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/querymanager/QueryManagerTest.java Mon May 22 13:14:47 2006 @@ -0,0 +1,104 @@ +/* ======================================================================== + * Copyright 2004 The Apache Software Foundation + * + * Licensed 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.portals.graffito.jcr.querymanager; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.portals.graffito.jcr.RepositoryLifecycleTestSetup; +import org.apache.portals.graffito.jcr.TestBase; +import org.apache.portals.graffito.jcr.query.Filter; +import org.apache.portals.graffito.jcr.query.Query; +import org.apache.portals.graffito.jcr.query.QueryManager; +import org.apache.portals.graffito.jcr.testmodel.C; + + +/** + * Test QueryManagerImpl methods + * + * @author Christophe Lombart + */ +public class QueryManagerTest extends TestBase +{ + private final static Log log = LogFactory.getLog(QueryManagerTest.class); + + /** + *

Defines the test case name for junit.

+ * @param testName The test case name. + */ + public QueryManagerTest(String testName) throws Exception + { + super(testName); + } + + public static Test suite() + { + // All methods starting with "test" will be executed in the test suite. + return new RepositoryLifecycleTestSetup( + new TestSuite(QueryManagerTest.class)); + } + + public void testBuildExpression1() + { + try + { + QueryManager queryManager = this.getQueryManager(); + Filter filter = queryManager.createFilter(C.class); + filter.addEqualTo("name", "a test value") + .addEqualTo("id", new Integer(1)); + filter.setScope("/test//"); + + Query query = queryManager.createQuery(filter); + String jcrExpression = queryManager.buildJCRExpression(query); + assertNotNull("jcrExpression is null", jcrExpression); + assertTrue("Invalid JcrExpression", jcrExpression.equals("/jcr:root/test//element(*, graffito:C) [@graffito:name = 'a test value' and @graffito:id = 1]")); + } + catch (Exception e) + { + e.printStackTrace(); + fail("Exception occurs during the unit test : " + e); + } + + } + + public void testBuildExpression2() + { + + try + { + QueryManager queryManager = this.getQueryManager(); + Filter filter = queryManager.createFilter(C.class); + filter.addEqualTo("name", "a test value") + .addEqualTo("id", new Integer(1)); + + Query query = queryManager.createQuery(filter); + String jcrExpression = queryManager.buildJCRExpression(query); + assertNotNull("jcrExpression is null", jcrExpression); + assertTrue("Invalid JcrExpression", jcrExpression.equals("//element(*, graffito:C) [@graffito:name = 'a test value' and @graffito:id = 1]")); + } + catch (Exception e) + { + e.printStackTrace(); + fail("Exception occurs during the unit test : " + e); + } + + } + + +} \ No newline at end of file