[
https://issues.apache.org/jira/browse/SLING-5028?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14803166#comment-14803166
]
Robert Munteanu commented on SLING-5028:
----------------------------------------
The following changes make your test work
{noformat}diff --git a/src/test/java/sandbox/SampleServiceTest.java
b/src/test/java/sandbox/SampleServiceTest.java
index 218b9fc..063a565 100644
--- a/src/test/java/sandbox/SampleServiceTest.java
+++ b/src/test/java/sandbox/SampleServiceTest.java
@@ -55,12 +55,13 @@ public class SampleServiceTest {
Resource content = context.resourceResolver().getResource("/content");
if (content == null) {
context.load().json("/sample-nodes.json","/content/sample-node-1");
+ context.resourceResolver().adaptTo(Session.class).save();
}
}
@Test
public void testQueryNoCondition() throws RepositoryException {
- int expectedResults = 1;
+ int expectedResults = 3;
String queryString = "SELECT * FROM [nt:unstructured] AS N";
List<String> actualResults =
executeQuery(context.resourceResolver(),queryString);
Assert.assertEquals("The number of results without parameter is
incorrect", expectedResults, actualResults.size());
{noformat}
The root issue here is that JCR queries only operate on persisted changes, so
you need a session.save() calls to make them visible to the query manager, even
when operating under the same session.
Therefore there's nothing to fix here IMO, resolving as not a problem.
> [Sling Mocks] Running a query with condition doesn't return any results
> -----------------------------------------------------------------------
>
> Key: SLING-5028
> URL: https://issues.apache.org/jira/browse/SLING-5028
> Project: Sling
> Issue Type: Bug
> Components: Testing
> Affects Versions: Testing Sling Mock 1.5.0
> Reporter: Daniel Platon
> Assignee: Robert Munteanu
>
> Running a query that uses a WHERE condition returns no results when using
> JCR_JACKRABBIT provider.
> The query
> {{SELECT * FROM [nt:unstructured] as N}} returns the correct number of
> results.
> However, running {{SELECT * FROM [nt:unstructured] as N WHERE
> ISDESCENDANTNODE(N,"/content')}} returns no results.
> I've set up a small project to illustrate this at
> https://github.com/dplaton/sling-testing
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)