hello andy.

this is in context of sling-mock with an in-memory oak repository.
registering a CND files only loads the node type definitions, but does not 
create an index. normally oak should fall back to traversing the repository if 
no suitable index is present, not sure why it's not working here.
you can try to register some indexes definitions yourself in the test 
environment as in this example:
https://github.com/apache/sling-org-apache-sling-testing-sling-mock-oak/blob/4b997bef3f65c71c212802a99f6cf1f5402012aa/src/main/java/org/apache/sling/testing/mock/sling/oak/ExtraSlingContent.java#L53-L66

or directly using the helper methods from 
org.apache.jackrabbit.oak.plugins.index.IndexUtils

stefan

>-----Original Message-----
>From: Andreas Schaefer <schaef...@me.com.INVALID>
>Sent: Thursday, April 1, 2021 8:13 PM
>To: dev <dev@sling.apache.org>
>Subject: Query with Sling Context Loaded Resources
>
>Hi
>
>In the sub project org.apache.sling.ddr’s core in the sling-whiteboard I
>tried to use Sling Context to run the Unit Test for
>DeclarativeDynamicResourceManagerServiceTest.
>
>In there I register a new Node Type:
>
>@Rule
>public SlingContext context = new
>SlingContext(ResourceResolverType.JCR_OAK);
>
>try {
>
>NodeTypeDefinitionScanner.get().register(context.resourceResolver().adaptTo
>(Session.class),
>        ImmutableList.of("SLING-CONTENT/nodetypes/ddr.cnd"),
>        ResourceResolverType.JCR_OAK.getNodeTypeMode());
>}
>catch (RepositoryException ex) {
>    throw new RuntimeException("Unable to register namespaces.", ex);
>}
>
> then use the context to load my test resources into /conf:
>
>context.load().json("/ddr-sources/ddr-conf-settings.json", "/conf”);
>
>. The resource /conf/test/settings/dynamic has these properties (Resource
>sourceRoot = resourceResolver.getResource("/conf/test/settings/dynamic”):
>
>JcrNodeResource, type=sling:DDR, superType=null,
>path=/conf/test/settings/dynamic
>
>Then I do a query:
>
>Iterator<Resource> i = resourceResolver.findResources(
>    "SELECT * FROM [" + DDR_NODE_TYPE + "]",
>    Query.JCR_SQL2
>);
>
>But the iterator is empty.
>
>Is that not supported or did I do something wrong here.
>
>Thanks - Andy

Reply via email to