Refine search
@Override protected void createTestIndexNode() throws Exception { Tree index = root.getTree("/"); Tree solrIndexNode = createTestIndexNode(index, SolrQueryIndex.TYPE); solrIndexNode.setProperty("pathRestrictions", true); solrIndexNode.setProperty("propertyRestrictions", true); solrIndexNode.setProperty("primaryTypes", true); solrIndexNode.setProperty("commitPolicy", "hard"); Tree server = solrIndexNode.addChild("server"); server.setProperty("solrServerType", "embedded"); server.setProperty("solrHomePath", "target/" + name.getMethodName()); root.commit(); }
Tree createUserTree() { Tree folder = root.getTree(getUserConfiguration().getParameters().getConfigValue(PARAM_USER_PATH, DEFAULT_USER_PATH)); Tree userTree = folder.addChild("userTree"); userTree.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_USER, Type.NAME); userTree.setProperty(JcrConstants.JCR_UUID, new UserProvider(root, ConfigurationParameters.EMPTY).getContentID(TEST_USER_ID)); return userTree; }
@Test public void oakIndexableSuccessful() throws IOException, CommitFailedException { registerNodeType(root, "oak3725-2.cnd"); Tree test = root.getTree("/").addChild("test"); test.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, NAME); test.setProperty(JCR_MIXINTYPES, of(MIX_INDEXABLE), Type.NAMES); test.addChild("oak:index").setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME); root.commit(); }
Tree createSystemUserTree() { Tree folder = root.getTree(getUserConfiguration().getParameters().getConfigValue(PARAM_USER_PATH, DEFAULT_USER_PATH)); Tree userTree = folder.addChild("systemUserTree"); userTree.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_SYSTEM_USER, Type.NAME); userTree.setProperty(JcrConstants.JCR_UUID, new UserProvider(root, ConfigurationParameters.EMPTY).getContentID(TEST_USER_ID)); return userTree; }
private static void setup(Root root) throws Exception { Tree tree = root.getTree("/"); tree.addChild("c").setProperty("p", "base"); root.commit(); }
@Override @Test public void testModifyRepExternalId() throws Exception { root.getTree(externalUserPath).setProperty(ExternalIdentityConstants.REP_EXTERNAL_ID, "anotherValue"); root.commit(); }
@Test public void testMultiAndEquals() throws Exception { Tree c = root.getTree("/").addChild("content"); c.addChild("one").setProperty("prop", "aaa"); c.addChild("two").setProperty("prop", ImmutableList.of("aaa", "bbb", "ccc"), Type.STRINGS); c.addChild("three").setProperty("prop", ImmutableList.of("aaa", "bbb"), Type.STRINGS); root.commit(); assertQuery("//*[(@prop = 'aaa' and @prop = 'bbb' and @prop = 'ccc')]", "xpath", ImmutableList.of("/content/two")); }
@Test public void testMultiAndLike() throws Exception { Tree c = root.getTree("/").addChild("content"); c.addChild("one").setProperty("prop", "aaaBoom"); c.addChild("two").setProperty("prop", ImmutableList.of("aaaBoom", "bbbBoom", "cccBoom"), Type.STRINGS); c.addChild("three").setProperty("prop", ImmutableList.of("aaaBoom", "bbbBoom"), Type.STRINGS); root.commit(); assertQuery("//*[(jcr:like(@prop, 'aaa%') and jcr:like(@prop, 'bbb%') and jcr:like(@prop, 'ccc%'))]", "xpath", ImmutableList.of("/content/two")); }
@Test public void testMultiNotEqual() throws Exception { Tree c = root.getTree("/").addChild("content"); c.addChild("one").setProperty("prop", "value"); c.addChild("two").setProperty("prop", ImmutableList.of("aaa", "value", "bbb"), Type.STRINGS); c.addChild("three").setProperty("prop", ImmutableList.of("aaa", "bbb", "ccc"), Type.STRINGS); root.commit(); assertQuery("//*[@prop != 'value']", "xpath", ImmutableList.of("/content/two", "/content/three")); }
@Test(expected = CommitFailedException.class) public void oakIndexableFailing() throws IOException, CommitFailedException { registerNodeType(root, "oak3725-1.cnd"); Tree test = root.getTree("/").addChild("test"); test.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, NAME); test.addChild("oak:index").setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME); root.commit(); }
@Test public void propertyExistenceQuery() throws Exception { Tree idx = createIndex("test1", of("propa", "propb")); idx.addChild(PROP_NODE).addChild("propa"); root.commit(); Tree test = root.getTree("/").addChild("test"); test.addChild("a").setProperty("propa", "a"); test.addChild("b").setProperty("propa", "c"); test.addChild("c").setProperty("propb", "e"); root.commit(); assertQuery("select [jcr:path] from [nt:base] where propa is not null", asList("/test/a", "/test/b")); }
@Test public void testNodeTypesDeep() throws Exception { Tree folder = root.getTree("/").addChild("myFolder"); folder.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, Type.NAME); Tree folder2 = folder.addChild("subfolder"); folder2.setProperty(JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME); Tree folder3 = folder2.addChild("subsubfolder"); folder3.setProperty(JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME); file(folder3, "file"); root.commit(); String xpath = "//element(*, nt:folder)[jcr:contains(., 'dog')]"; assertQuery(xpath, "xpath", ImmutableList.of("/myFolder")); }
@Test public void nativeQueries() throws Exception { Tree idx = createIndex("test1", of("propa", "propb")); idx.addChild(PROP_NODE).addChild("propa"); idx.setProperty(FulltextIndexConstants.FUNC_NAME, "foo"); root.commit(); Tree test = root.getTree("/").addChild("test"); test.addChild("a").setProperty("propa", "humpty"); test.addChild("b").setProperty("propa", "dumpty"); test.addChild("c").setProperty("propa", "humpy"); root.commit(); assertQuery("select [jcr:path] from [nt:base] where native('foo', 'propa:(humpty OR dumpty)')", asList("/test/a", "/test/b")); }
@Test public void testLowercaseOnArrays() throws Exception { // OAK-1829 Tree content = root.getTree("/").addChild("content"); content.setProperty("array", Arrays.asList("X", "Y"), Type.STRINGS); root.commit(); assertQuery("//*[jcr:like(fn:lower-case(@array), '%x%')]", "xpath", Arrays.asList("/content")); }
@Test public void containsPathNum() throws Exception { Tree test = root.getTree("/").addChild("test"); Tree a = test.addChild("a"); a.setProperty("name", "/segment1/segment2/segment3"); root.commit(); StringBuffer stmt = new StringBuffer(); stmt.append("//*[jcr:contains(., '/segment1/segment2')]"); assertQuery(stmt.toString(), "xpath", ImmutableList.of("/test/a")); }
@Test public void containsPath() throws Exception { Tree test = root.getTree("/").addChild("test"); test.addChild("a").setProperty("name", "/parent/child/node"); root.commit(); StringBuffer stmt = new StringBuffer(); stmt.append("//*[jcr:contains(., '/parent/child')]"); assertQuery(stmt.toString(), "xpath", ImmutableList.of("/test/a")); }
@Test public void indexDefinitionBelowRoot() throws Exception { Tree parent = root.getTree("/").addChild("test"); Tree idx = createIndex(parent, "test1", of("propa", "propb")); idx.setProperty(FulltextIndexConstants.EVALUATE_PATH_RESTRICTION, true); idx.addChild(PROP_NODE).addChild("propa"); root.commit(); Tree test = parent.addChild("test2"); test.addChild("a").setProperty("propa", "a"); root.commit(); assertQuery("select [jcr:path] from [nt:base] as s where ISDESCENDANTNODE(s, '/test') and propa = 'a'", asList("/test/test2/a")); }
@Test public void indexDefinitionBelowRoot3() throws Exception { Tree parent = root.getTree("/").addChild("test"); Tree idx = createIndex(parent, "test1", of("propa")); idx.addChild(PROP_NODE).addChild("propa"); root.commit(); parent.setProperty("propa", "a"); parent.addChild("test1").setProperty("propa", "a"); root.commit(); //asert that (1) result gets returned correctly, (2) parent isn't there, and (3) child is returned assertQuery("select [jcr:path] from [nt:base] as s where ISDESCENDANTNODE(s, '/test') and propa = 'a'", asList("/test/test1")); }