jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r794323 - in /jackrabbit/trunk: jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/ jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/
Date Wed, 15 Jul 2009 16:41:18 GMT
Author: reschke
Date: Wed Jul 15 16:41:17 2009
New Revision: 794323

URL: http://svn.apache.org/viewvc?rev=794323&view=rev
Log:
JCR-2208: fix regression introduced by r794294 (query was executed using an incorrect session,
leading to unexpected results), also make more XPath tests conditional

Modified:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/ElementTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TextNodeTest.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java?rev=794323&r1=794322&r2=794323&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java
Wed Jul 15 16:41:17 2009
@@ -135,28 +135,29 @@
     /**
      * Creates a {@link Query} for the given statement in the requested
      * language, treating optional languages gracefully
-     *
-     * @param statement the query should be created for
-     * @param language  query language to be used for Query creation
-     * @return
-     *
      * @throws RepositoryException
      */
-    protected Query createQuery(String statement, String language)
-        throws RepositoryException, NotExecutableException {
+    protected Query createQuery(String statement, String language) throws RepositoryException,
NotExecutableException {
+        return createQuery(superuser, statement, language);
+    }
+
+    /**
+     * Creates a {@link Query} for the given statement in the requested
+     * language, treating optional languages gracefully
+     * @throws RepositoryException
+     */
+    protected Query createQuery(Session session, String statement, String language) throws
RepositoryException, NotExecutableException {
         log.println("Creating query: " + statement);
         try {
-            return qm.createQuery(statement, language);
-        }
-        catch (InvalidQueryException ex) {
-            
-            // if language is optional and not reported as "supported" -> 
+            return session.getWorkspace().getQueryManager().createQuery(statement, language);
+        } catch (InvalidQueryException ex) {
+
+            // if language is optional and not reported as "supported" ->
             // demote to NotExecutableException
-            
-            if (! isSupportedLanguage(language) && ! Query.JCR_SQL2.equals(language))
{
+
+            if (!isSupportedLanguage(language) && !Query.JCR_SQL2.equals(language))
{
                 throw new NotExecutableException("Repository does not support " + language
+ " query syntax");
-            }
-            else {
+            } else {
                 throw ex;
             }
         }
@@ -302,10 +303,11 @@
      * @param session the session to use for the query.
      * @param xpath the xpath query.
      * @param nodes the expected result nodes.
+     * @throws NotExecutableException 
      */
     protected void executeXPathQuery(Session session, String xpath, Node[] nodes)
-            throws RepositoryException {
-        QueryResult res = session.getWorkspace().getQueryManager().createQuery(xpath, Query.XPATH).execute();
+            throws RepositoryException, NotExecutableException {
+        QueryResult res = createQuery(session, xpath, Query.XPATH).execute();
         checkResult(res, nodes);
     }
 
@@ -319,7 +321,7 @@
      */
     protected void executeSqlQuery(Session session, String sql, Node[] nodes)
             throws RepositoryException, NotExecutableException {
-        QueryResult res = createQuery(sql, Query.SQL).execute();
+        QueryResult res = createQuery(session, sql, Query.SQL).execute();
         checkResult(res, nodes);
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/ElementTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/ElementTest.java?rev=794323&r1=794322&r2=794323&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/ElementTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/ElementTest.java
Wed Jul 15 16:41:17 2009
@@ -43,8 +43,9 @@
 
     /**
      * Tests the element test without arguments.
+     * @throws NotExecutableException 
      */
-    public void testElementTest() throws RepositoryException {
+    public void testElementTest() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
         Node n2 = testRootNode.addNode(nodeName2, ntBase);
         Node n3 = testRootNode.addNode(nodeName3, testNodeType);
@@ -56,8 +57,9 @@
 
     /**
      * Tests the element test with one any node argument.
+     * @throws NotExecutableException 
      */
-    public void testElementTestAnyNode() throws RepositoryException {
+    public void testElementTestAnyNode() throws RepositoryException, NotExecutableException
{
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
         Node n2 = testRootNode.addNode(nodeName2, ntBase);
         Node n3 = testRootNode.addNode(nodeName3, testNodeType);
@@ -70,8 +72,9 @@
     /**
      * Tests the element test with an any node argument and a type argument
      * that matches all nodes (nt:base).
+     * @throws NotExecutableException 
      */
-    public void testElementTestAnyNodeNtBase() throws RepositoryException {
+    public void testElementTestAnyNodeNtBase() throws RepositoryException, NotExecutableException
{
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
         Node n2 = testRootNode.addNode(nodeName2, ntBase);
         Node n3 = testRootNode.addNode(nodeName3, testNodeType);
@@ -84,8 +87,9 @@
     /**
      * Tests the element test with an any node argument and a type argument
      * that matches only certain child nodes.
+     * @throws NotExecutableException 
      */
-    public void testElementTestAnyNodeSomeNT() throws RepositoryException {
+    public void testElementTestAnyNodeSomeNT() throws RepositoryException, NotExecutableException
{
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
         testRootNode.addNode(nodeName2, ntBase);
         Node n3 = testRootNode.addNode(nodeName3, testNodeType);
@@ -97,8 +101,9 @@
 
     /**
      * Tests the element test with one single name test argument.
+     * @throws NotExecutableException 
      */
-    public void testElementTestNameTest() throws RepositoryException {
+    public void testElementTestNameTest() throws RepositoryException, NotExecutableException
{
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
         testRootNode.addNode(nodeName2, ntBase);
         testRootNode.addNode(nodeName3, testNodeType);
@@ -111,8 +116,9 @@
     /**
      * Tests the element test with a name test argument and a type argument that
      * matches all nodes (nt:base).
+     * @throws NotExecutableException 
      */
-    public void testElementTestNameTestNtBase() throws RepositoryException {
+    public void testElementTestNameTestNtBase() throws RepositoryException, NotExecutableException
{
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
         testRootNode.addNode(nodeName2, ntBase);
         testRootNode.addNode(nodeName3, testNodeType);
@@ -125,8 +131,9 @@
     /**
      * Tests the element test with a name test argument and a type argument that
      * matches only certain child nodes.
+     * @throws NotExecutableException 
      */
-    public void testElementTestNameTestSomeNT() throws RepositoryException {
+    public void testElementTestNameTestSomeNT() throws RepositoryException, NotExecutableException
{
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
         testRootNode.addNode(nodeName2, ntBase);
         testRootNode.addNode(nodeName3, testNodeType);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TextNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TextNodeTest.java?rev=794323&r1=794322&r2=794323&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TextNodeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TextNodeTest.java
Wed Jul 15 16:41:17 2009
@@ -59,8 +59,9 @@
 
     /**
      * Tests if text() node test is equivalent with jcr:xmltext.
+     * @throws NotExecutableException 
      */
-    public void testTextNodeTest() throws RepositoryException {
+    public void testTextNodeTest() throws RepositoryException, NotExecutableException {
         Node text1 = testRootNode.addNode(jcrXMLText);
         text1.setProperty(jcrXMLCharacters, "foo");
         testRootNode.save();
@@ -71,8 +72,9 @@
     /**
      * Tests if text() node test is equivalent with jcr:xmltext and will select
      * multiple nodes with name jcr:xmltext.
+     * @throws NotExecutableException 
      */
-    public void testTextNodeTestMultiNodes() throws RepositoryException {
+    public void testTextNodeTestMultiNodes() throws RepositoryException, NotExecutableException
{
         Node text1 = testRootNode.addNode(jcrXMLText);
         text1.setProperty(jcrXMLCharacters, "foo");
         Node text2 = testRootNode.addNode(nodeName1, testNodeType).addNode(jcrXMLText);
@@ -85,8 +87,9 @@
     /**
      * Tests if text() node test is equivalent with jcr:xmltext and jcr:contains
      * matches content in jcr:xmlcharacters property.
+     * @throws NotExecutableException 
      */
-    public void testTextNodeTestContains() throws RepositoryException {
+    public void testTextNodeTestContains() throws RepositoryException, NotExecutableException
{
         Node text1 = testRootNode.addNode(jcrXMLText);
         text1.setProperty(jcrXMLCharacters, "the quick brown fox jumps over the lazy dog.");
         Node text2 = testRootNode.addNode(nodeName1, testNodeType).addNode(jcrXMLText);

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java?rev=794323&r1=794322&r2=794323&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java
Wed Jul 15 16:41:17 2009
@@ -15,6 +15,7 @@
  */
 package org.apache.jackrabbit.jcr2spi.query;
 
+import org.apache.jackrabbit.test.NotExecutableException;
 import org.apache.jackrabbit.test.api.query.AbstractQueryTest;
 
 import javax.jcr.RepositoryException;
@@ -31,8 +32,9 @@
 
     /**
      * Queries the child nodes of the root node.
+     * @throws NotExecutableException 
      */
-    public void testQueryChildNodesOfRoot() throws RepositoryException {
+    public void testQueryChildNodesOfRoot() throws RepositoryException, NotExecutableException
{
         List nodes = new ArrayList();
         for (NodeIterator it = superuser.getRootNode().getNodes(); it.hasNext(); ) {
             nodes.add(it.nextNode());
@@ -41,7 +43,7 @@
         executeXPathQuery(superuser, "/jcr:root/*", children);
     }
 
-    public void testRemappedNamespace() throws RepositoryException {
+    public void testRemappedNamespace() throws RepositoryException, NotExecutableException
{
         String namespaceURI = "http://jackrabbit.apache.org/spi/test";
         String defaultPrefix = "spiTest";
 



Mime
View raw message