You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2022/03/29 21:40:37 UTC

[sling-org-apache-sling-jcr-resource] 01/01: SLING-11229 - changing to only deal with adding limit

This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch SLING-11229
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resource.git

commit 38c5b8f2eaca953a94c8cdc64e48367c80507a79
Author: Dan Klco <kl...@adobe.com>
AuthorDate: Tue Mar 29 17:40:26 2022 -0400

    SLING-11229 - changing to only deal with adding limit
---
 .../resource/internal/helper/JcrResourceUtil.java  |  11 +-
 .../helper/jcr/BasicQueryLanguageProvider.java     |  17 ++-
 .../internal/helper/jcr/JcrResourceProvider.java   |  12 +-
 .../helper/jcr/LimitingQueryLanguageProvider.java  | 129 -------------------
 .../sling/jcr/resource/SimpleProviderContext.java  |  89 +++++++++++++
 .../JcrResourceListenerScalabilityTest.java        |  71 +----------
 .../helper/jcr/JcrResourceProviderQueryTest.java   | 140 +++++++++++++++++++++
 .../JcrResourceProviderSessionHandlingTest.java    |   2 +-
 .../helper/jcr/JcrResourceProviderTest.java        |   2 +-
 .../jcr/LimitingQueryLanguageProviderTest.java     | 112 -----------------
 10 files changed, 259 insertions(+), 326 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrResourceUtil.java b/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrResourceUtil.java
index 986100d..46cabde 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrResourceUtil.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrResourceUtil.java
@@ -52,25 +52,26 @@ public class JcrResourceUtil {
      */
     public static QueryResult query(Session session, String query,
             String language) throws RepositoryException {
-        return query(session, query, language, 0, Long.MAX_VALUE);
+        QueryManager qManager = session.getWorkspace().getQueryManager();
+        Query q = qManager.createQuery(query, language);
+
+        return q.execute();
     }
 
     /**
-     * Helper method to execute a JCR query.
+     * Helper method to execute a JCR query with a limit
      * 
      * @param session  the session
      * @param query    the query
      * @param language the language
-     * @param offset   the offset to start at
      * @param limit    the limit to the number of results to return
      * @return the query's result
      * @throws RepositoryException if the {@link QueryManager} cannot be retrieved
      */
     public static QueryResult query(Session session, String query,
-            String language, long offset, long limit) throws RepositoryException {
+            String language, long limit) throws RepositoryException {
         QueryManager qManager = session.getWorkspace().getQueryManager();
         Query q = qManager.createQuery(query, language);
-        q.setOffset(offset);
         q.setLimit(limit);
         return q.execute();
     }
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/BasicQueryLanguageProvider.java b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/BasicQueryLanguageProvider.java
index 5acf880..a8c16b5 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/BasicQueryLanguageProvider.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/BasicQueryLanguageProvider.java
@@ -59,12 +59,25 @@ public class BasicQueryLanguageProvider implements QueryLanguageProvider<JcrProv
     /** The provider context. */
     private final ProviderContext providerContext;
 
+    private final long queryLimit;
+
     public BasicQueryLanguageProvider(final ProviderContext ctx) {
         this.providerContext = ctx;
+        queryLimit = -1;
     }
 
-    protected QueryResult query(final ResolveContext<JcrProviderState> ctx, final String query, final String language) throws RepositoryException{
-        return JcrResourceUtil.query(ctx.getProviderState().getSession(), query, language);
+    public BasicQueryLanguageProvider(final ProviderContext ctx, long queryLimit) {
+        this.providerContext = ctx;
+        this.queryLimit = queryLimit;
+    }
+
+    protected QueryResult query(final ResolveContext<JcrProviderState> ctx, final String query, final String language)
+            throws RepositoryException {
+        if (queryLimit > 0) {
+            return JcrResourceUtil.query(ctx.getProviderState().getSession(), query, language, queryLimit);
+        } else {
+            return JcrResourceUtil.query(ctx.getProviderState().getSession(), query, language);
+        }
     }
 
     @Override
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
index 16e39db..c7b75f4 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
@@ -107,11 +107,11 @@ public class JcrResourceProvider extends ResourceProvider<JcrProviderState> {
     @ObjectClassDefinition(name = "Apache Sling JCR Resource Provider", description = "Provides Sling resources based on the Java Content Repository")
     public @interface Config {
 
-        @AttributeDefinition(name = "Enable Query Limit", description = "If set to true, the JcrResourceProvider will support parsing query start and limits from comments in the queries and set a default limit for all other queries using the findResources methods")
+        @AttributeDefinition(name = "Enable Query Limit", description = "If set to true, the JcrResourceProvider will set a default limit for all other queries using the findResources / queryResources methods")
         boolean enable_query_limit() default false;
 
-        @AttributeDefinition(name = "Default Query Limit", description = "The default query limit for queries using the findResources methods")
-        long default_query_limit() default 10000L;
+        @AttributeDefinition(name = "Query Limit", description = "The default query limit for queries using the findResources / queryResources methods")
+        long query_limit() default 10000L;
     }
 
     @Reference(name = REPOSITORY_REFERNENCE_NAME, service = SlingRepository.class)
@@ -644,9 +644,9 @@ public class JcrResourceProvider extends ResourceProvider<JcrProviderState> {
     @Override
     public @Nullable QueryLanguageProvider<JcrProviderState> getQueryLanguageProvider() {
         final ProviderContext ctx = this.getProviderContext();
-        if ( ctx != null ) {
-            if(config.enable_query_limit()){
-                return new LimitingQueryLanguageProvider(ctx, config.default_query_limit());
+        if (ctx != null) {
+            if (config.enable_query_limit()) {
+                return new BasicQueryLanguageProvider(ctx, config.query_limit());
             }
             return new BasicQueryLanguageProvider(ctx);
         }
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/LimitingQueryLanguageProvider.java b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/LimitingQueryLanguageProvider.java
deleted file mode 100644
index be86ae6..0000000
--- a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/LimitingQueryLanguageProvider.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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.sling.jcr.resource.internal.helper.jcr;
-
-import java.io.IOException;
-import java.io.StreamTokenizer;
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.query.QueryResult;
-
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.ImmutableTriple;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.commons.lang3.tuple.Triple;
-import org.apache.sling.jcr.resource.internal.helper.JcrResourceUtil;
-import org.apache.sling.spi.resource.provider.ProviderContext;
-import org.apache.sling.spi.resource.provider.ResolveContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LimitingQueryLanguageProvider extends BasicQueryLanguageProvider {
-
-    private final Logger log = LoggerFactory.getLogger(LimitingQueryLanguageProvider.class);
-
-    /** The limit to set for queries */
-    private final long defaultLimit;
-
-    public LimitingQueryLanguageProvider(final ProviderContext ctx, long defaultLimit) {
-        super(ctx);
-        this.defaultLimit = defaultLimit;
-    }
-
-    @Override
-    protected QueryResult query(final ResolveContext<JcrProviderState> ctx, final String query, final String language)
-            throws RepositoryException {
-        Triple<String, Long, Long> settings = extractQuerySettings(query);
-        return JcrResourceUtil.query(ctx.getProviderState().getSession(), settings.getLeft(), language,
-                settings.getMiddle(), settings.getRight());
-    }
-
-    protected Triple<String, Long, Long> extractQuerySettings(String query) {
-        query = query.trim();
-        if (query.endsWith("*/")) {
-            Pair<Long, Long> settings = parseQueryComment(
-                    query.substring(query.lastIndexOf("/*") + 2, query.lastIndexOf("*/")));
-            return new ImmutableTriple<>(query.substring(0, query.lastIndexOf("/*")),
-                    settings.getLeft(), settings.getRight());
-        } else {
-            return new ImmutableTriple<>(query, 0L, defaultLimit);
-        }
-    }
-
-    private Pair<Long, Long> parseQueryComment(String query) {
-        Map<String, Object> parsed = new HashMap<>();
-        StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(query));
-        int currentToken;
-        try {
-            currentToken = tokenizer.nextToken();
-            boolean key = true;
-            Object current = null;
-            while (currentToken != StreamTokenizer.TT_EOF) {
-                if (tokenizer.ttype == StreamTokenizer.TT_NUMBER) {
-                    if (!key) {
-                        parsed.put((String) current, tokenizer.nval);
-                        key = true;
-                        current = null;
-                    } else {
-                        throw new IOException(
-                                "Encountered unexpected numeric key: " + tokenizer.toString());
-                    }
-                } else if (tokenizer.ttype == StreamTokenizer.TT_WORD) {
-                    if (!key) {
-                        parsed.put((String) current, tokenizer.nval);
-                        key = true;
-                    } else if (current == null) {
-                        current = tokenizer.sval;
-                    } else {
-                        throw new IOException(
-                                "Encountered unmatched key value pair: " + tokenizer.toString());
-                    }
-                } else if (((char) currentToken) == '=') {
-                    key = false;
-                } else if (((char) currentToken) == ',' || ((char) currentToken) == ';') {
-                    // nothing really required, just ignoring as it's a separator
-                } else {
-                    throw new IOException(
-                            "Encountered unexpected character parsing query comment: " + tokenizer.toString());
-                }
-                currentToken = tokenizer.nextToken();
-            }
-        } catch (Exception e) {
-            log.warn("Failed to parse query comment due to exception: {}", e.toString());
-            return new ImmutablePair<>(0L, defaultLimit);
-        }
-        return new ImmutablePair<>(getKeyAsLong(parsed, "slingQueryStart", 0L),
-                getKeyAsLong(parsed, "slingQueryLimit", defaultLimit));
-    }
-
-    private Long getKeyAsLong(Map<String, Object> parsed, String key, Long defaultVal) {
-        return Optional.ofNullable(parsed.get(key)).map(v -> {
-            if (v instanceof String) {
-                return Long.parseLong(v.toString());
-            } else {
-                return ((Double) v).longValue();
-            }
-        }).orElse(defaultVal);
-    }
-
-}
diff --git a/src/test/java/org/apache/sling/jcr/resource/SimpleProviderContext.java b/src/test/java/org/apache/sling/jcr/resource/SimpleProviderContext.java
new file mode 100644
index 0000000..059899b
--- /dev/null
+++ b/src/test/java/org/apache/sling/jcr/resource/SimpleProviderContext.java
@@ -0,0 +1,89 @@
+/*
+ * 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.sling.jcr.resource;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.sling.api.resource.observation.ResourceChange;
+import org.apache.sling.api.resource.observation.ResourceChange.ChangeType;
+import org.apache.sling.api.resource.path.PathSet;
+import org.apache.sling.spi.resource.provider.ObservationReporter;
+import org.apache.sling.spi.resource.provider.ObserverConfiguration;
+import org.apache.sling.spi.resource.provider.ProviderContext;
+
+public class SimpleProviderContext implements ProviderContext {
+    @Override
+    public ObservationReporter getObservationReporter() {
+        return new ObservationReporter() {
+
+            @Override
+            public void reportChanges(Iterable<ResourceChange> changes, boolean distribute) {
+            }
+
+            @Override
+            public void reportChanges(ObserverConfiguration config, Iterable<ResourceChange> changes,
+                    boolean distribute) {
+            }
+
+            @Override
+            public List<ObserverConfiguration> getObserverConfigurations() {
+                ObserverConfiguration config = new ObserverConfiguration() {
+
+                    @Override
+                    public boolean includeExternal() {
+                        return true;
+                    }
+
+                    @Override
+                    public PathSet getPaths() {
+                        return PathSet.fromStrings("/");
+                    }
+
+                    @Override
+                    public PathSet getExcludedPaths() {
+                        return PathSet.fromPaths();
+                    }
+
+                    @Override
+                    public Set<ChangeType> getChangeTypes() {
+                        return EnumSet.allOf(ChangeType.class);
+                    }
+
+                    @Override
+                    public boolean matches(String path) {
+                        return true;
+                    }
+
+                    @Override
+                    public Set<String> getPropertyNamesHint() {
+                        return new HashSet<String>();
+                    }
+                };
+                return Collections.singletonList(config);
+            }
+        };
+    }
+
+    @Override
+    public PathSet getExcludedPaths() {
+        return PathSet.fromPaths();
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerScalabilityTest.java b/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerScalabilityTest.java
index 9a896ed..c2c58c9 100644
--- a/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerScalabilityTest.java
+++ b/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerScalabilityTest.java
@@ -19,12 +19,6 @@ package org.apache.sling.jcr.resource.internal;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Workspace;
@@ -32,13 +26,9 @@ import javax.jcr.observation.Event;
 import javax.jcr.observation.EventIterator;
 import javax.jcr.observation.ObservationManager;
 
-import org.apache.sling.api.resource.observation.ResourceChange;
-import org.apache.sling.api.resource.observation.ResourceChange.ChangeType;
-import org.apache.sling.api.resource.path.PathSet;
 import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.resource.SimpleProviderContext;
 import org.apache.sling.jcr.resource.internal.helper.jcr.SlingRepositoryProvider;
-import org.apache.sling.spi.resource.provider.ObservationReporter;
-import org.apache.sling.spi.resource.provider.ObserverConfiguration;
 import org.apache.sling.spi.resource.provider.ProviderContext;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -98,63 +88,4 @@ public class JcrResourceListenerScalabilityTest {
             return "path-" + count++;
         }
     }
-
-    private static class SimpleProviderContext implements ProviderContext {
-        @Override
-        public ObservationReporter getObservationReporter() {
-            return new ObservationReporter() {
-
-                @Override
-                public void reportChanges(Iterable<ResourceChange> changes, boolean distribute) {
-                }
-
-                @Override
-                public void reportChanges(ObserverConfiguration config, Iterable<ResourceChange> changes,
-                        boolean distribute) {
-                }
-
-                @Override
-                public List<ObserverConfiguration> getObserverConfigurations() {
-                    ObserverConfiguration config = new ObserverConfiguration() {
-
-                        @Override
-                        public boolean includeExternal() {
-                            return true;
-                        }
-
-                        @Override
-                        public PathSet getPaths() {
-                            return PathSet.fromStrings("/");
-                        }
-
-                        @Override
-                        public PathSet getExcludedPaths() {
-                            return PathSet.fromPaths();
-                        }
-
-                        @Override
-                        public Set<ChangeType> getChangeTypes() {
-                            return EnumSet.allOf(ChangeType.class);
-                        }
-
-                        @Override
-                        public boolean matches(String path) {
-                            return true;
-                        }
-
-                        @Override
-                        public Set<String> getPropertyNamesHint() {
-                            return new HashSet<String>();
-                        }
-                    };
-                    return Collections.singletonList(config);
-                }
-            };
-        }
-
-        @Override
-        public PathSet getExcludedPaths() {
-            return PathSet.fromPaths();
-        }
-    }
 }
diff --git a/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderQueryTest.java b/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderQueryTest.java
new file mode 100644
index 0000000..e1db1f7
--- /dev/null
+++ b/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderQueryTest.java
@@ -0,0 +1,140 @@
+/*
+ * 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.sling.jcr.resource.internal.helper.jcr;
+
+import java.lang.annotation.Annotation;
+import java.util.Iterator;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.query.Query;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.jcr.resource.SimpleProviderContext;
+import org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.Config;
+import org.apache.sling.spi.resource.provider.ProviderContext;
+import org.apache.sling.spi.resource.provider.ResolveContext;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+
+import com.google.common.collect.Iterators;
+
+public class JcrResourceProviderQueryTest extends SlingRepositoryTestBase {
+
+    Session session;
+    private ComponentContext componentContext;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        // create the session
+        session = getSession();
+        Repository repo = getRepository();
+        componentContext = Mockito.mock(ComponentContext.class);
+        Mockito.when(componentContext.locateService(Mockito.anyString(), Mockito.any(ServiceReference.class)))
+                .thenReturn(repo);
+    }
+
+    private JcrResourceProvider getProvider(Config config) throws RepositoryException {
+        JcrResourceProvider jcrResourceProvider = new JcrResourceProvider();
+        jcrResourceProvider.activate(componentContext, config);
+        final ProviderContext pcontext = new SimpleProviderContext();
+        jcrResourceProvider.start(pcontext);
+        return jcrResourceProvider;
+    }
+
+    private ResolveContext<JcrProviderState> getResolveContext() {
+        ResolveContext<JcrProviderState> ctx = Mockito.mock(ResolveContext.class);
+        JcrProviderState state = new JcrProviderState(session, null, false);
+        Mockito.when(ctx.getProviderState()).thenReturn(state);
+        return ctx;
+    }
+
+    @Test
+    public void testQueryBelowLimit() throws RepositoryException {
+        runTest("below-limit", new SimpleConfig(true, 100), 99, 99);
+    }
+
+    @Test
+    public void testQueryAboveLimit() throws RepositoryException {
+        runTest("above-limit", new SimpleConfig(true, 100), 200, 100);
+    }
+
+    @Test
+    public void testDisabled() throws RepositoryException {
+        runTest("disabled", new SimpleConfig(false, 100), 200, 200);
+    }
+
+    @Test
+    public void testInvalid() throws RepositoryException {
+        runTest("invalid", new SimpleConfig(true, 0), 200, 200);
+    }
+
+    private void runTest(String name, Config config, int create, int expected) throws RepositoryException {
+
+        JcrResourceProvider jcrResourceProvider = null;
+        try {
+            jcrResourceProvider = getProvider(config);
+            Node parentNode = session.getRootNode().addNode("parent-" + name, NodeType.NT_UNSTRUCTURED);
+            for (int i = 0; i < create; i++) {
+                parentNode.addNode("child" + i, NodeType.NT_UNSTRUCTURED);
+            }
+            session.save();
+            ResolveContext<JcrProviderState> ctx = getResolveContext();
+            Iterator<Resource> resources = jcrResourceProvider.getQueryLanguageProvider().findResources(ctx,
+                    "SELECT * FROM [nt:unstructured] WHERE ISDESCENDANTNODE([" + parentNode.getPath() + "])",
+                    Query.JCR_SQL2);
+            assertEquals(expected, Iterators.size(resources));
+        } finally {
+            jcrResourceProvider.deactivate();
+        }
+    }
+
+    private static class SimpleConfig implements JcrResourceProvider.Config {
+        private final boolean enabled;
+        private final long limit;
+
+        public SimpleConfig(boolean enabled, long limit) {
+            this.enabled = enabled;
+            this.limit = limit;
+        }
+
+        @Override
+        public Class<? extends Annotation> annotationType() {
+            return null;
+        }
+
+        @Override
+        public boolean enable_query_limit() {
+            return enabled;
+        }
+
+        @Override
+        public long query_limit() {
+            return this.limit;
+        }
+
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderSessionHandlingTest.java b/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderSessionHandlingTest.java
index c52f271..2e2d4bb 100644
--- a/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderSessionHandlingTest.java
+++ b/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderSessionHandlingTest.java
@@ -247,7 +247,7 @@ public class JcrResourceProviderSessionHandlingTest {
                 return false;
             }
             @Override
-            public long default_query_limit() {
+            public long query_limit() {
                 return 0;
             }
         });
diff --git a/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderTest.java b/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderTest.java
index de99546..2fb00db 100644
--- a/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderTest.java
+++ b/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderTest.java
@@ -61,7 +61,7 @@ public class JcrResourceProviderTest extends SlingRepositoryTestBase {
                 return false;
             }
             @Override
-            public long default_query_limit() {
+            public long query_limit() {
                 return 0;
             }
         });
diff --git a/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/LimitingQueryLanguageProviderTest.java b/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/LimitingQueryLanguageProviderTest.java
deleted file mode 100644
index 77dd127..0000000
--- a/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/LimitingQueryLanguageProviderTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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.sling.jcr.resource.internal.helper.jcr;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.apache.commons.lang3.tuple.Triple;
-import org.apache.sling.spi.resource.provider.ProviderContext;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class LimitingQueryLanguageProviderTest {
-
-    @Parameters(name = "{0}")
-    public static Collection<Object[]> testCases() {
-        return Arrays.asList(new Object[][] {
-                testCase("JCR-SQL2 No Settings", "SELECT * FROM [nt:folder]", 10L,
-                        "SELECT * FROM [nt:folder]",
-                        0L, 10L),
-                testCase("JCR-SQL2 With Limit", "SELECT * FROM [nt:folder] /* slingQueryLimit=20 */", 10L,
-                        "SELECT * FROM [nt:folder] ",
-                        0L, 20L),
-                testCase("JCR-SQL2 With Limit", "SELECT * FROM [nt:folder] /* slingQueryStart=2, slingQueryLimit=20 */",
-                        10L,
-                        "SELECT * FROM [nt:folder] ",
-                        2L, 20L),
-                testCase("JCR-SQL2 With Limit", "SELECT * FROM [nt:folder] /* someotherkey=2, slingQueryLimit=20 */",
-                        10L,
-                        "SELECT * FROM [nt:folder] ",
-                        0L, 20L),
-                testCase("JCR-SQL2 With Limit", "SELECT * FROM [nt:folder] /* someotherkey=2, slingQueryLimit=20 */",
-                        10L,
-                        "SELECT * FROM [nt:folder] ",
-                        0L, 20L),
-                testCase("XPath With Limit",
-                        " /jcr:root/content//element(*, sling:Folder)[@sling:resourceType='x'] /* slingQueryStart=2, slingQueryLimit=20 */",
-                        10L,
-                        "/jcr:root/content//element(*, sling:Folder)[@sling:resourceType='x'] ",
-                        2L, 20L),
-                testCase("XPath With Invalid Key",
-                        " /jcr:root/content//element(*, sling:Folder)[@sling:resourceType='x'] /* 2=2, slingQueryLimit=20 */",
-                        10L,
-                        "/jcr:root/content//element(*, sling:Folder)[@sling:resourceType='x'] ",
-                        0L, 10L)
-        });
-    }
-
-    public static Object[] testCase(String name, String query, long defaultLimit, String expectedQuery,
-            long expectedStart,
-            long expectedLimit) {
-        return new Object[] {
-                name, query, defaultLimit, expectedQuery, expectedStart, expectedLimit
-        };
-
-    }
-
-    private String name;
-    private String query;
-    private Long defaultLimit;
-    private String expectedQuery;
-    private Long expectedStart;
-    private Long expectedLimit;
-
-    public LimitingQueryLanguageProviderTest(String name, String query, long defaultLimit,
-            String expectedQuery,
-            long expectedStart,
-            long expectedLimit) {
-        this.name = name;
-        this.query = query;
-        this.defaultLimit = defaultLimit;
-        this.expectedQuery = expectedQuery;
-        this.expectedStart = expectedStart;
-        this.expectedLimit = expectedLimit;
-    }
-
-    @Test
-    public void testQueryLanguageProvider() {
-        LimitingQueryLanguageProvider provider = new LimitingQueryLanguageProvider(mock(ProviderContext.class),
-                defaultLimit);
-
-        Triple<String, Long, Long> settings = provider.extractQuerySettings(query);
-
-        assertEquals(expectedQuery, settings.getLeft());
-        assertEquals(expectedStart, settings.getMiddle());
-        assertEquals(expectedLimit, settings.getRight());
-
-    }
-
-}