jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r783688 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/ ...
Date Thu, 11 Jun 2009 08:16:36 GMT
Author: mreutegg
Date: Thu Jun 11 08:16:35 2009
New Revision: 783688

URL: http://svn.apache.org/viewvc?rev=783688&view=rev
Log:
JCR-2085: test case (TCK) maintenance for JCR 2.0
- more order by tests
- setLimit and setOffset covered
- spi2jcr now uses JCRTestSuite as is (with known issues in pom.xml)

Added:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/OrderByDecimalTest.java
  (with props)
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/OrderByURITest.java
  (with props)
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SetLimitTest.java
  (with props)
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SetOffsetTest.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java
    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/TestAll.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AbstractQOMTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java
    jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml
    jackrabbit/trunk/jackrabbit-spi2jcr/src/test/java/org/apache/jackrabbit/test/TestAll.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java?rev=783688&r1=783687&r2=783688&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
Thu Jun 11 08:16:35 2009
@@ -89,7 +89,7 @@
     /**
      * The maximum result size
      */
-    private long limit;
+    private long limit = -1;
 
     /**
      * The offset in the total result set
@@ -256,6 +256,9 @@
      * @param limit new maximum size of the result set
      */
     public void setLimit(long limit) {
+        if (limit < 0) {
+            throw new IllegalArgumentException("limit must not be negativ");
+        }
         this.limit = limit;
     }
 
@@ -265,6 +268,9 @@
      * @param offset new start offset of the result set
      */
     public void setOffset(long offset) {
+        if (offset < 0) {
+            throw new IllegalArgumentException("offset must not be negativ");
+        }
         this.offset = offset;
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java?rev=783688&r1=783687&r2=783688&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
Thu Jun 11 08:16:35 2009
@@ -124,7 +124,7 @@
     private final long offset;
 
     /**
-     * The maximum size of this result if limit > 0
+     * The maximum size of this result if limit >= 0
      */
     private final long limit;
 
@@ -265,7 +265,7 @@
         long maxResultSize = size;
 
         // is there any limit?
-        if (limit > 0) {
+        if (limit >= 0) {
             maxResultSize = limit;
         }
 
@@ -442,7 +442,7 @@
                 return -1;
             }
             long size = total - offset;
-            if (limit > 0 && size > limit) {
+            if (limit >= 0 && size > limit) {
                 return limit;
             } else {
                 return size;

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java?rev=783688&r1=783687&r2=783688&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java
Thu Jun 11 08:16:35 2009
@@ -20,6 +20,8 @@
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.Repository;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.qom.QueryObjectModel;
@@ -32,6 +34,7 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.ArrayList;
+import java.math.BigDecimal;
 
 /**
  * Abstract base class for all order by tests. Provides utility methods.
@@ -41,7 +44,7 @@
     /** If <code>true</code> this repository supports sql queries */
     protected boolean checkSQL;
 
-    protected QueryObjectModelFactory qf;
+    protected ValueFactory vf;
 
     private String[] nodeNames;
 
@@ -49,7 +52,7 @@
         super.setUp();
         checkSQL = isSupported(Repository.OPTION_QUERY_SQL_SUPPORTED);
         nodeNames = new String[]{nodeName1, nodeName2, nodeName3, nodeName4};
-        qf = superuser.getWorkspace().getQueryManager().getQOMFactory();
+        vf = superuser.getValueFactory();
     }
 
     /**
@@ -63,7 +66,24 @@
             Node node = testRootNode.addNode(nodeNames[i], testNodeType);
             node.setProperty(propertyName1, values[i]);
         }
-        testRootNode.save();
+        superuser.save();
+    }
+
+    /**
+     * Populates the workspace with child nodes under <code>testroot</code> with
+     * each node has a value set in property with name
+     * <code>propertyname1</code>. The actual value is created by using the
+     * sessions value factory and the given <code>type</code>.
+     *
+     * @param values the String values.
+     * @param type a JCR property type.
+     */
+    protected void populate(String[] values, int type) throws RepositoryException {
+        for (int i = 0; i < values.length; i++) {
+            Node node = testRootNode.addNode(nodeNames[i], testNodeType);
+            node.setProperty(propertyName1, vf.createValue(values[i], type));
+        }
+        superuser.save();
     }
 
     /**
@@ -77,7 +97,7 @@
             Node node = testRootNode.addNode(nodeNames[i], testNodeType);
             node.setProperty(propertyName1, values[i]);
         }
-        testRootNode.save();
+        superuser.save();
     }
 
     /**
@@ -91,7 +111,7 @@
             Node node = testRootNode.addNode(nodeNames[i], testNodeType);
             node.setProperty(propertyName1, values[i]);
         }
-        testRootNode.save();
+        superuser.save();
     }
 
     /**
@@ -105,7 +125,21 @@
             Node node = testRootNode.addNode(nodeNames[i], testNodeType);
             node.setProperty(propertyName1, values[i]);
         }
-        testRootNode.save();
+        superuser.save();
+    }
+
+    /**
+     * Populates the workspace with child nodes under <code>testroot</code> with
+     * each node has a decimal value set in property with name
+     * <code>propertyname1</code>.
+     * @param values the decimal values.
+     */
+    protected void populate(BigDecimal[] values) throws RepositoryException {
+        for (int i = 0; i < values.length; i++) {
+            Node node = testRootNode.addNode(nodeNames[i], testNodeType);
+            node.setProperty(propertyName1, values[i]);
+        }
+        superuser.save();
     }
 
     /**

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=783688&r1=783687&r2=783688&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
Thu Jun 11 08:16:35 2009
@@ -22,6 +22,8 @@
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.RowIterator;
 import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.qom.QueryObjectModelFactory;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.Node;
@@ -64,6 +66,11 @@
     protected String jcrDeref;
 
     /**
+     * The query object model factory for {@link #superuser}.
+     */
+    protected QueryObjectModelFactory qf;
+
+    /**
      * Set-up the configuration values used for the test. Per default retrieves
      * a session, configures testRoot, and nodetype and checks if the query
      * language for the current language is available.<br>
@@ -75,6 +82,8 @@
         jcrRoot = superuser.getNamespacePrefix(NS_JCR_URI) + ":root";
         jcrContains = superuser.getNamespacePrefix(NS_JCR_URI) + ":contains";
         jcrDeref = superuser.getNamespacePrefix(NS_JCR_URI) + ":deref";
+        QueryManager qm = superuser.getWorkspace().getQueryManager();
+        qf = qm.getQOMFactory();
     }
 
     /**

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/OrderByDecimalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/OrderByDecimalTest.java?rev=783688&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/OrderByDecimalTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/OrderByDecimalTest.java
Thu Jun 11 08:16:35 2009
@@ -0,0 +1,32 @@
+/*
+ * 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.jackrabbit.test.api.query;
+
+import java.math.BigDecimal;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>OrderByDecimalTest</code> tests order by queries with decimal properties.
+ */
+public class OrderByDecimalTest extends AbstractOrderByTest {
+
+    public void testDecimal() throws RepositoryException {
+        populate(new BigDecimal[]{new BigDecimal(0), new BigDecimal(-1), new BigDecimal(1),
new BigDecimal(5)});
+        checkOrder(new String[]{nodeName2, nodeName1, nodeName3, nodeName4});
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/OrderByDecimalTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/OrderByURITest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/OrderByURITest.java?rev=783688&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/OrderByURITest.java
(added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/OrderByURITest.java
Thu Jun 11 08:16:35 2009
@@ -0,0 +1,33 @@
+/*
+ * 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.jackrabbit.test.api.query;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.PropertyType;
+
+/**
+ * <code>OrderByURITest</code> tests order by queries with URI properties.
+ */
+public class OrderByURITest extends AbstractOrderByTest {
+
+    private static final String BASE_URI = "http://example.com/";
+
+    public void testURI() throws RepositoryException {
+        populate(new String[]{BASE_URI + "a", BASE_URI + "b", BASE_URI + "c", BASE_URI +
"d"}, PropertyType.URI);
+        checkOrder(new String[]{nodeName1, nodeName2, nodeName3, nodeName4});
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/OrderByURITest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SetLimitTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SetLimitTest.java?rev=783688&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SetLimitTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SetLimitTest.java
Thu Jun 11 08:16:35 2009
@@ -0,0 +1,45 @@
+/*
+ * 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.jackrabbit.test.api.query;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.query.Query;
+
+/**
+ * <code>SetLimitTest</code> contains test cases for the method Query.setLimit().
+ */
+public class SetLimitTest extends AbstractQueryTest {
+
+    public void testSetLimit() throws RepositoryException {
+        testRootNode.addNode(nodeName1, testNodeType);
+        testRootNode.addNode(nodeName2, testNodeType);
+        testRootNode.addNode(nodeName3, testNodeType);
+        superuser.save();
+        for (int i = 0; i < 5; i++) {
+            Query query = qf.createQuery(
+                    qf.selector(testNodeType, "s"),
+                    qf.descendantNode("s", testRoot),
+                    null, 
+                    null
+            );
+            query.setLimit(i);
+            long expected = Math.min(i, 3);
+            assertEquals("Wrong numer of results", expected,
+                    getSize(query.execute().getNodes()));
+        }
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SetLimitTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SetOffsetTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SetOffsetTest.java?rev=783688&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SetOffsetTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SetOffsetTest.java
Thu Jun 11 08:16:35 2009
@@ -0,0 +1,45 @@
+/*
+ * 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.jackrabbit.test.api.query;
+
+import javax.jcr.query.Query;
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>SetOffsetTest</code> contains test cases for the method Query.setOffset().
+ */
+public class SetOffsetTest extends AbstractQueryTest {
+
+    public void testSetOffset() throws RepositoryException {
+        testRootNode.addNode(nodeName1, testNodeType);
+        testRootNode.addNode(nodeName2, testNodeType);
+        testRootNode.addNode(nodeName3, testNodeType);
+        superuser.save();
+        for (int i = 0; i < 5; i++) {
+            Query query = qf.createQuery(
+                    qf.selector(testNodeType, "s"),
+                    qf.descendantNode("s", testRoot),
+                    null,
+                    null
+            );
+            query.setOffset(i);
+            long expected = Math.max(3 - i, 0);
+            assertEquals("Wrong numer of results", expected,
+                    getSize(query.execute().getNodes()));
+        }
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SetOffsetTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TestAll.java?rev=783688&r1=783687&r2=783688&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/TestAll.java
Thu Jun 11 08:16:35 2009
@@ -73,6 +73,10 @@
         suite.addTestSuite(OrderByNameTest.class);
         suite.addTestSuite(OrderByLowerCaseTest.class);
         suite.addTestSuite(OrderByUpperCaseTest.class);
+        suite.addTestSuite(OrderByDecimalTest.class);
+        suite.addTestSuite(OrderByURITest.class);
+        suite.addTestSuite(SetLimitTest.class);
+        suite.addTestSuite(SetOffsetTest.class);
 
         return suite;
     }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AbstractQOMTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AbstractQOMTest.java?rev=783688&r1=783687&r2=783688&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AbstractQOMTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AbstractQOMTest.java
Thu Jun 11 08:16:35 2009
@@ -24,11 +24,9 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.Row;
 import javax.jcr.query.RowIterator;
-import javax.jcr.query.qom.QueryObjectModelFactory;
 
 import org.apache.jackrabbit.test.api.query.AbstractQueryTest;
 
@@ -37,14 +35,6 @@
  */
 public class AbstractQOMTest extends AbstractQueryTest {
 
-    protected QueryObjectModelFactory qf;
-
-    protected void setUp() throws Exception {
-        super.setUp();
-        QueryManager qm = superuser.getWorkspace().getQueryManager();
-        qf = qm.getQOMFactory();
-    }
-
     /**
      * Binds the given <code>value</code> to the variable named
      * <code>var</code>.

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java?rev=783688&r1=783687&r2=783688&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java
Thu Jun 11 08:16:35 2009
@@ -17,11 +17,13 @@
 package org.apache.jackrabbit.test.api.query.qom;
 
 import java.util.Calendar;
+import java.math.BigDecimal;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
+import javax.jcr.PropertyType;
 import javax.jcr.query.Query;
 import javax.jcr.query.qom.QueryObjectModelConstants;
 
@@ -40,6 +42,10 @@
 
     private static final Calendar DATE_VALUE = Calendar.getInstance();
 
+    private static final BigDecimal DECIMAL_VALUE = new BigDecimal(LONG_VALUE);
+
+    private static final String URI_VALUE = "http://example.com/";
+
     private Query query;
 
     private ValueFactory vf;
@@ -77,7 +83,7 @@
     public void testString() throws RepositoryException {
         Node n = testRootNode.addNode(nodeName1, testNodeType);
         n.setProperty(propertyName1, STRING_VALUE);
-        testRootNode.save();
+        superuser.save();
 
         bindVariableValue(query, "v", vf.createValue(STRING_VALUE));
         checkResult(query.execute(), new Node[]{n});
@@ -86,7 +92,7 @@
     public void testDate() throws RepositoryException {
         Node n = testRootNode.addNode(nodeName1, testNodeType);
         n.setProperty(propertyName1, DATE_VALUE);
-        testRootNode.save();
+        superuser.save();
 
         bindVariableValue(query, "v", vf.createValue(DATE_VALUE));
         checkResult(query.execute(), new Node[]{n});
@@ -95,7 +101,7 @@
     public void testLong() throws RepositoryException {
         Node n = testRootNode.addNode(nodeName1, testNodeType);
         n.setProperty(propertyName1, LONG_VALUE);
-        testRootNode.save();
+        superuser.save();
 
         bindVariableValue(query, "v", vf.createValue(LONG_VALUE));
         checkResult(query.execute(), new Node[]{n});
@@ -104,7 +110,7 @@
     public void testDouble() throws RepositoryException {
         Node n = testRootNode.addNode(nodeName1, testNodeType);
         n.setProperty(propertyName1, DOUBLE_VALUE);
-        testRootNode.save();
+        superuser.save();
 
         bindVariableValue(query, "v", vf.createValue(DOUBLE_VALUE));
         checkResult(query.execute(), new Node[]{n});
@@ -113,17 +119,17 @@
     public void testBoolean() throws RepositoryException {
         Node n = testRootNode.addNode(nodeName1, testNodeType);
         n.setProperty(propertyName1, BOOLEAN_VALUE);
-        testRootNode.save();
+        superuser.save();
 
         bindVariableValue(query, "v", vf.createValue(BOOLEAN_VALUE));
         checkResult(query.execute(), new Node[]{n});
     }
 
     public void testName() throws RepositoryException {
-        Value name = vf.createValue(STRING_VALUE);
+        Value name = vf.createValue(STRING_VALUE, PropertyType.NAME);
         Node n = testRootNode.addNode(nodeName1, testNodeType);
         n.setProperty(propertyName1, name);
-        testRootNode.save();
+        superuser.save();
 
         bindVariableValue(query, "v", name);
         checkResult(query.execute(), new Node[]{n});
@@ -131,9 +137,9 @@
 
     public void testPath() throws RepositoryException {
         Node n = testRootNode.addNode(nodeName1, testNodeType);
-        Value path = vf.createValue(n.getPath());
+        Value path = vf.createValue(n.getPath(), PropertyType.PATH);
         n.setProperty(propertyName1, path);
-        testRootNode.save();
+        superuser.save();
 
         bindVariableValue(query, "v", path);
         checkResult(query.execute(), new Node[]{n});
@@ -141,14 +147,14 @@
 
     public void testReference() throws RepositoryException {
         Node n = testRootNode.addNode(nodeName1, testNodeType);
-        testRootNode.save();
+        superuser.save();
 
         if (!n.isNodeType(mixReferenceable)) {
             n.addMixin(mixReferenceable);
-            n.save();
+            superuser.save();
         }
         n.setProperty(propertyName1, n);
-        n.save();
+        superuser.save();
 
 
         bindVariableValue(query, "v", vf.createValue(n));
@@ -156,14 +162,38 @@
     }
 
     public void testWeakReference() throws RepositoryException {
-        // TODO
+        Node n = testRootNode.addNode(nodeName1, testNodeType);
+        superuser.save();
+
+        if (!n.isNodeType(mixReferenceable)) {
+            n.addMixin(mixReferenceable);
+            superuser.save();
+        }
+        n.setProperty(propertyName1, vf.createValue(n, true));
+        superuser.save();
+
+
+        bindVariableValue(query, "v", vf.createValue(n, true));
+        checkResult(query.execute(), new Node[]{n});
     }
 
     public void testURI() throws RepositoryException {
-        // TODO
+        Value value = vf.createValue(URI_VALUE, PropertyType.URI);
+        Node n = testRootNode.addNode(nodeName1, testNodeType);
+        n.setProperty(propertyName1, value);
+        superuser.save();
+
+        bindVariableValue(query, "v", value);
+        checkResult(query.execute(), new Node[]{n});
     }
 
     public void testDecimal() throws RepositoryException {
-        // TODO
+        Value value = vf.createValue(DECIMAL_VALUE);
+        Node n = testRootNode.addNode(nodeName1, testNodeType);
+        n.setProperty(propertyName1, value);
+        superuser.save();
+
+        bindVariableValue(query, "v", value);
+        checkResult(query.execute(), new Node[]{n});
     }
 }

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml?rev=783688&r1=783687&r2=783688&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml Thu Jun 11 08:16:35 2009
@@ -79,6 +79,12 @@
                 org.apache.jackrabbit.test.api.query.OrderByLowerCaseTest
                 org.apache.jackrabbit.test.api.query.OrderByNameTest
                 org.apache.jackrabbit.test.api.query.OrderByUpperCaseTest
+                org.apache.jackrabbit.test.api.query.OrderByDecimalTest
+                org.apache.jackrabbit.test.api.query.OrderByURITest
+                org.apache.jackrabbit.test.api.query.SetLimitTest
+                org.apache.jackrabbit.test.api.query.SetOffsetTest
+                org.apache.jackrabbit.test.api.query.qom
+                org.apache.jackrabbit.test.api.version.simple
               </value>
             </property>
           </systemProperties>

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/test/java/org/apache/jackrabbit/test/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/test/java/org/apache/jackrabbit/test/TestAll.java?rev=783688&r1=783687&r2=783688&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/test/java/org/apache/jackrabbit/test/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/test/java/org/apache/jackrabbit/test/TestAll.java
Thu Jun 11 08:16:35 2009
@@ -18,25 +18,11 @@
 
 import junit.framework.TestCase;
 import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.apache.jackrabbit.test.JCRTestSuite;
 
 public class TestAll extends TestCase {
 
     public static Test suite() {
         return new JCRTestSuite();
     }
-
-    private static class JCRTestSuite extends TestSuite {
-
-        private JCRTestSuite() {
-            super("JCR API tests");
-            addTest(org.apache.jackrabbit.test.api.TestAll.suite());
-            addTest(org.apache.jackrabbit.test.api.query.TestAll.suite());
-            addTest(org.apache.jackrabbit.test.api.nodetype.TestAll.suite());
-            addTest(org.apache.jackrabbit.test.api.util.TestAll.suite());
-            addTest(org.apache.jackrabbit.test.api.lock.TestAll.suite());
-            addTest(org.apache.jackrabbit.test.api.version.TestAll.suite());
-            addTest(org.apache.jackrabbit.test.api.observation.TestAll.suite());
-        }
-    }
 }



Mime
View raw message