Index: src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java =================================================================== --- src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java (revision 600426) +++ src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java (working copy) @@ -224,6 +224,20 @@ } + public void testGetObjectsAnywhereInPath() { + QueryManager queryManager = this.getQueryManager(); + Filter filter = queryManager.createFilter(Page.class); + filter.setScope("/folder/test/"); + + Query query = queryManager.createQuery(filter); + + ObjectContentManager ocm = this.getObjectContentManager(); + Collection result = ocm.getObjects(query); + // 4 Page objects under /folder/test and 1 Page object under + // /folder/test/test1 + assertEquals("Invalid number of objects", 5, result.size()); + } + public void testGetObjectsByClassNameAndPath() { try { ObjectContentManager ocm = this.getObjectContentManager(); @@ -232,7 +246,7 @@ Page[] pages = (Page[]) result.toArray(new Page[result.size()]); assertTrue("Invalid Page found", pages[0].getTitle().equals("Page Title")); - + result = ocm.getObjects(Page.class, "/folder/test"); assertEquals("Invalid number of objects", 4, result.size()); @@ -245,92 +259,105 @@ } } - private void importData() throws JcrMappingException - { + private void importData() throws JcrMappingException { try { - ObjectContentManager ocm = getObjectContentManager(); - - Page page = new Page(); - page.setPath("/test"); - page.setTitle("Page Title"); - - ArrayList paragraphs = new ArrayList(); - - paragraphs.add(new Paragraph("Para 1")); - paragraphs.add(new Paragraph("Para 2")); - paragraphs.add(new Paragraph("Para 3")); - paragraphs.add(new Paragraph("Another Para ")); - page.setParagraphs(paragraphs); - - ocm.insert(page); - - //add an extra node with other page objects - Node root = ocm.getSession().getRootNode(); - root.addNode("folder"); - page = new Page(); - page.setPath("/folder/test"); - page.setTitle("Page Title"); - - paragraphs = new ArrayList(); - - paragraphs.add(new Paragraph("Para 1.1")); - paragraphs.add(new Paragraph("Para 1.2")); - paragraphs.add(new Paragraph("Para 1.3")); - paragraphs.add(new Paragraph("1.Another Para ")); - page.setParagraphs(paragraphs); - - ocm.insert(page); + ObjectContentManager ocm = getObjectContentManager(); - page = new Page(); - page.setPath("/folder/test"); - page.setTitle("Page Title"); - - paragraphs = new ArrayList(); - - paragraphs.add(new Paragraph("Para 2.1")); - paragraphs.add(new Paragraph("Para 2.2")); - paragraphs.add(new Paragraph("Para 2.3")); - paragraphs.add(new Paragraph("2.Another Para ")); - page.setParagraphs(paragraphs); - - ocm.insert(page); + Page page = new Page(); + page.setPath("/test"); + page.setTitle("Page Title"); - page = new Page(); - page.setPath("/folder/test"); - page.setTitle("Page Title"); - - paragraphs = new ArrayList(); - - paragraphs.add(new Paragraph("Para 3.1")); - paragraphs.add(new Paragraph("Para 3.2")); - paragraphs.add(new Paragraph("Para 3.3")); - paragraphs.add(new Paragraph("3.Another Para ")); - page.setParagraphs(paragraphs); - - ocm.insert(page); + ArrayList paragraphs = new ArrayList(); - page = new Page(); - page.setPath("/folder/test"); - page.setTitle("Page Title"); - - paragraphs = new ArrayList(); - - paragraphs.add(new Paragraph("Para 4.1")); - paragraphs.add(new Paragraph("Para 4.2")); - paragraphs.add(new Paragraph("Para 4.3")); - paragraphs.add(new Paragraph("4.Another Para ")); - page.setParagraphs(paragraphs); - - ocm.insert(page); - - ocm.save(); - } - catch (Exception e) - { - fail("Impossible to create the data " + e); + paragraphs.add(new Paragraph("Para 1")); + paragraphs.add(new Paragraph("Para 2")); + paragraphs.add(new Paragraph("Para 3")); + paragraphs.add(new Paragraph("Another Para ")); + page.setParagraphs(paragraphs); + + ocm.insert(page); + + // add an extra node with other page objects + Node root = ocm.getSession().getRootNode(); + // Need to create all nodes here as object in test1 is saved before + // folder/test nodes were explicitly created. + root.addNode("folder"); + root.addNode("folder/test"); + root.addNode("folder/test/test1"); + page = new Page(); + page.setPath("/folder/test"); + page.setTitle("Page Title"); + + paragraphs = new ArrayList(); + + paragraphs.add(new Paragraph("Para 1.1")); + paragraphs.add(new Paragraph("Para 1.2")); + paragraphs.add(new Paragraph("Para 1.3")); + paragraphs.add(new Paragraph("1.Another Para ")); + page.setParagraphs(paragraphs); + + ocm.insert(page); + + page = new Page(); + page.setPath("/folder/test"); + page.setTitle("Page Title"); + + paragraphs = new ArrayList(); + + paragraphs.add(new Paragraph("Para 2.1")); + paragraphs.add(new Paragraph("Para 2.2")); + paragraphs.add(new Paragraph("Para 2.3")); + paragraphs.add(new Paragraph("2.Another Para ")); + page.setParagraphs(paragraphs); + + ocm.insert(page); + + page = new Page(); + page.setPath("/folder/test"); + page.setTitle("Page Title"); + + paragraphs = new ArrayList(); + + paragraphs.add(new Paragraph("Para 3.1")); + paragraphs.add(new Paragraph("Para 3.2")); + paragraphs.add(new Paragraph("Para 3.3")); + paragraphs.add(new Paragraph("3.Another Para ")); + page.setParagraphs(paragraphs); + + ocm.insert(page); + + page = new Page(); + page.setPath("/folder/test"); + page.setTitle("Page Title"); + + paragraphs = new ArrayList(); + + paragraphs.add(new Paragraph("Para 4.1")); + paragraphs.add(new Paragraph("Para 4.2")); + paragraphs.add(new Paragraph("Para 4.3")); + paragraphs.add(new Paragraph("4.Another Para ")); + page.setParagraphs(paragraphs); + + ocm.insert(page); + + page = new Page(); + page.setPath("/folder/test/test1"); + page.setTitle("Page Title"); + + paragraphs = new ArrayList(); + + paragraphs.add(new Paragraph("Para 4.1.1")); + paragraphs.add(new Paragraph("Para 4.2.1")); + paragraphs.add(new Paragraph("Para 4.3.1")); + paragraphs.add(new Paragraph("4.1.Another Para ")); + page.setParagraphs(paragraphs); + + ocm.insert(page); + + ocm.save(); + } catch (Exception e) { + fail("Impossible to create the data " + e); } - - } } \ No newline at end of file