You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2020/09/24 13:22:26 UTC

[sling-org-apache-sling-graphql-core] branch master updated: SLING-9655 - add cache hash test with selectors

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

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-graphql-core.git


The following commit(s) were added to refs/heads/master by this push:
     new aef4e63  SLING-9655 - add cache hash test with selectors
aef4e63 is described below

commit aef4e63f12a9ce8ef8b902a75200e6b14a4eb4d9
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Sep 24 15:18:56 2020 +0200

    SLING-9655 - add cache hash test with selectors
---
 .../core/cache/SimpleGraphQLCacheProviderTest.java      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/test/java/org/apache/sling/graphql/core/cache/SimpleGraphQLCacheProviderTest.java b/src/test/java/org/apache/sling/graphql/core/cache/SimpleGraphQLCacheProviderTest.java
index 16fe357..d69c19e 100644
--- a/src/test/java/org/apache/sling/graphql/core/cache/SimpleGraphQLCacheProviderTest.java
+++ b/src/test/java/org/apache/sling/graphql/core/cache/SimpleGraphQLCacheProviderTest.java
@@ -30,12 +30,15 @@ import org.junit.Test;
 import com.codahale.metrics.MetricRegistry;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.util.UUID;
+
 public class SimpleGraphQLCacheProviderTest {
 
     @Rule
@@ -137,4 +140,18 @@ public class SimpleGraphQLCacheProviderTest {
         assertEquals("c", provider.getQuery(cHash, "a/b/c", null));
     }
 
+    @Test
+    public void testSelectors() {
+        context.registerInjectActivateService(new SimpleGraphQLCacheProvider(), "cacheSize", 2, "maxMemory", 40);
+        SimpleGraphQLCacheProvider provider = (SimpleGraphQLCacheProvider) context.getService(GraphQLCacheProvider.class);
+        assertNotNull(provider);
+
+        final String queryText = UUID.randomUUID().toString();
+        final String path = "testing/selectors";
+        final String selectors = UUID.randomUUID().toString();
+
+        String aHash = provider.cacheQuery(queryText, path, null);
+        String bHash = provider.cacheQuery(queryText, path, selectors);
+        assertEquals("Expecting the same hash for same query", aHash, bHash);
+    }
 }