Search in sources :

Example 16 with RepositoryAccessor

use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor in project sling by apache.

the class JcrFullCoverageAggregatesDeploymentTest method deleteAllNodesFromNestedFullCoverageAggreate.

@Test
@Ignore(value = "SLING-3591")
public void deleteAllNodesFromNestedFullCoverageAggreate() throws Exception {
    wstServer.waitForServerToStart();
    // create faceted project
    IProject contentProject = projectRule.getProject();
    ProjectAdapter project = new ProjectAdapter(contentProject);
    project.addNatures("org.eclipse.wst.common.project.facet.core.nature");
    // install content facet
    project.installFacet("sling.content", "1.0");
    ServerAdapter server = new ServerAdapter(wstServer.getServer());
    server.installModule(contentProject);
    // create .content.xml structure
    InputStream contentXml = getClass().getResourceAsStream("content-nested-structure.xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en.xml"), contentXml);
    Matcher<Node> postConditions = allOf(hasPath("/content/test-root/en"), hasPrimaryType("sling:Folder"), hasMixinTypes("mix:language"), hasChildrenCount(3));
    final RepositoryAccessor repo = new RepositoryAccessor(config);
    Poller poller = new Poller();
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/en");
        }
    }, postConditions);
    // update .content.xml structure
    InputStream updatedContentXml = getClass().getResourceAsStream("content-nested-structure-deleted-all-nodes.xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en.xml"), updatedContentXml);
    // poll until we only have no child nodes left
    postConditions = allOf(hasPath("/content/test-root/en"), hasPrimaryType("sling:Folder"), hasMixinTypes("mix:language"), hasChildrenCount(0));
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/en");
        }
    }, postConditions);
}
Also used : ServerAdapter(org.apache.sling.ide.test.impl.helpers.ServerAdapter) RepositoryAccessor(org.apache.sling.ide.test.impl.helpers.RepositoryAccessor) InputStream(java.io.InputStream) Node(javax.jcr.Node) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) RepositoryException(javax.jcr.RepositoryException) IProject(org.eclipse.core.resources.IProject) Poller(org.apache.sling.ide.test.impl.helpers.Poller) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with RepositoryAccessor

use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor in project sling by apache.

the class JcrFullCoverageAggregatesDeploymentTest method deployNestedFullCoverageAggregateAtFilterRoot.

@Test
public void deployNestedFullCoverageAggregateAtFilterRoot() throws Exception {
    wstServer.waitForServerToStart();
    // create faceted project
    IProject contentProject = projectRule.getProject();
    ProjectAdapter project = new ProjectAdapter(contentProject);
    project.addNatures("org.eclipse.wst.common.project.facet.core.nature");
    // install content facet
    project.installFacet("sling.content", "1.0");
    ServerAdapter server = new ServerAdapter(wstServer.getServer());
    server.installModule(contentProject);
    // create prerequisite data
    final RepositoryAccessor repo = new RepositoryAccessor(config);
    repo.createNode("/content", "sling:Folder");
    repo.createNode("/content/test-root", "sling:Folder");
    project.createVltFilterWithRoots("/content/test-root/en");
    // create .content.xml structure
    InputStream contentXml = getClass().getResourceAsStream("content-nested-structure.xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en.xml"), contentXml);
    Matcher<Node> postConditions = allOf(hasPath("/content/test-root/en"), hasPrimaryType("sling:Folder"), hasMixinTypes("mix:language"), hasChildrenCount(3));
    Poller poller = new Poller();
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/en");
        }
    }, postConditions);
}
Also used : ServerAdapter(org.apache.sling.ide.test.impl.helpers.ServerAdapter) RepositoryAccessor(org.apache.sling.ide.test.impl.helpers.RepositoryAccessor) InputStream(java.io.InputStream) Node(javax.jcr.Node) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) RepositoryException(javax.jcr.RepositoryException) IProject(org.eclipse.core.resources.IProject) Poller(org.apache.sling.ide.test.impl.helpers.Poller) Test(org.junit.Test)

Example 18 with RepositoryAccessor

use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor in project sling by apache.

the class JcrPartialCoverageAggregatesDeploymentTest method deploySlingFolder.

@Test
public void deploySlingFolder() throws Exception {
    wstServer.waitForServerToStart();
    // create faceted project
    IProject contentProject = projectRule.getProject();
    ProjectAdapter project = new ProjectAdapter(contentProject);
    project.addNatures("org.eclipse.wst.common.project.facet.core.nature");
    // install content facet
    project.installFacet("sling.content", "1.0");
    ServerAdapter server = new ServerAdapter(wstServer.getServer());
    server.installModule(contentProject);
    // create filter.xml
    project.createVltFilterWithRoots("/content");
    // create a sling:Folder at /content/test-root
    InputStream contentXml = getClass().getResourceAsStream("sling-folder-nodetype.xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.content.xml"), contentXml);
    // create a sling:Folder at /content/test-root/nested
    InputStream childContentXml = getClass().getResourceAsStream("sling-folder-nodetype.xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/nested/.content.xml"), childContentXml);
    Matcher<Node> postConditions = allOf(hasPath("/content/test-root"), hasPrimaryType("sling:Folder"), hasChildrenCount(1));
    final RepositoryAccessor repo = new RepositoryAccessor(config);
    Poller poller = new Poller();
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root");
        }
    }, postConditions);
    // update jcr:title for /content/test-root
    InputStream updatedContentXml = getClass().getResourceAsStream("sling-folder-nodetype-with-title.xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.content.xml"), updatedContentXml);
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root");
        }
    }, allOf(hasPath("/content/test-root"), hasChildrenCount(1), hasPropertyValue("jcr:title", "Some Folder")));
}
Also used : ServerAdapter(org.apache.sling.ide.test.impl.helpers.ServerAdapter) RepositoryAccessor(org.apache.sling.ide.test.impl.helpers.RepositoryAccessor) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Node(javax.jcr.Node) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) RepositoryException(javax.jcr.RepositoryException) IProject(org.eclipse.core.resources.IProject) Poller(org.apache.sling.ide.test.impl.helpers.Poller) Test(org.junit.Test)

Example 19 with RepositoryAccessor

use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor in project sling by apache.

the class JcrPartialCoverageAggregatesDeploymentTest method deployNodeWithContentXmlInParentFolder.

@Test
public void deployNodeWithContentXmlInParentFolder() throws Exception {
    wstServer.waitForServerToStart();
    // create faceted project
    IProject contentProject = projectRule.getProject();
    ProjectAdapter project = new ProjectAdapter(contentProject);
    project.addNatures("org.eclipse.wst.common.project.facet.core.nature");
    // install content facet
    project.installFacet("sling.content", "1.0");
    ServerAdapter server = new ServerAdapter(wstServer.getServer());
    server.installModule(contentProject);
    // create filter.xml
    project.createVltFilterWithRoots("/content");
    // the expected repository structure is
    // mapping [sling:Mapping]
    // \- jcr:content [nt:unstructured]
    //  \- par [nt:unstructured]
    //   \- folder [sling:Folder] 
    // first create the local structure where the content is completely serialized inside the .content.xml file
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/mapping/.content.xml"), getClass().getResourceAsStream("sling-mapping-with-folder-child.xml"));
    final RepositoryAccessor repo = new RepositoryAccessor(config);
    Poller poller = new Poller();
    // wait until the structure is published
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/mapping/jcr:content/par");
        }
    }, hasPrimaryType("nt:unstructured"));
    // now create the folder and its associated .content.xml file ; this will cause
    // intermediate folders to be created whose serialization data is present in the
    // parent's .content.xml file
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/mapping/_jcr_content/par/folder/.content.xml"), getClass().getResourceAsStream("sling-folder-nodetype.xml"));
    // first wait until the sling:Folder child node is created, to ensure that all changes are processed
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/mapping/jcr:content/par/folder");
        }
    }, hasPrimaryType("sling:Folder"));
    // then, verify that the nt:unstructured node is correctly written
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/mapping/jcr:content/par");
        }
    }, hasPrimaryType("nt:unstructured"));
}
Also used : ServerAdapter(org.apache.sling.ide.test.impl.helpers.ServerAdapter) RepositoryAccessor(org.apache.sling.ide.test.impl.helpers.RepositoryAccessor) Node(javax.jcr.Node) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) RepositoryException(javax.jcr.RepositoryException) IProject(org.eclipse.core.resources.IProject) Poller(org.apache.sling.ide.test.impl.helpers.Poller) Test(org.junit.Test)

Example 20 with RepositoryAccessor

use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor in project sling by apache.

the class JcrFullCoverageAggregatesDeploymentTest method deleteNodeFromNestedFullCoverageAggreate.

@Test
public void deleteNodeFromNestedFullCoverageAggreate() throws Exception {
    wstServer.waitForServerToStart();
    // create faceted project
    IProject contentProject = projectRule.getProject();
    ProjectAdapter project = new ProjectAdapter(contentProject);
    project.addNatures("org.eclipse.wst.common.project.facet.core.nature");
    // install content facet
    project.installFacet("sling.content", "1.0");
    ServerAdapter server = new ServerAdapter(wstServer.getServer());
    server.installModule(contentProject);
    // create filter.xml
    project.createVltFilterWithRoots("/content");
    // create .content.xml structure
    InputStream contentXml = getClass().getResourceAsStream("content-nested-structure.xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en.xml"), contentXml);
    Matcher<Node> postConditions = allOf(hasPath("/content/test-root/en"), hasPrimaryType("sling:Folder"), hasMixinTypes("mix:language"), hasChildrenCount(3));
    final RepositoryAccessor repo = new RepositoryAccessor(config);
    Poller poller = new Poller();
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/en");
        }
    }, postConditions);
    // update .content.xml structure
    InputStream updatedContentXml = getClass().getResourceAsStream("content-nested-structure-deleted-node.xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en.xml"), updatedContentXml);
    // poll until we only have 2 child nodes left
    postConditions = allOf(hasPath("/content/test-root/en"), hasPrimaryType("sling:Folder"), hasMixinTypes("mix:language"), hasChildrenCount(2));
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/en");
        }
    }, postConditions);
}
Also used : ServerAdapter(org.apache.sling.ide.test.impl.helpers.ServerAdapter) RepositoryAccessor(org.apache.sling.ide.test.impl.helpers.RepositoryAccessor) InputStream(java.io.InputStream) Node(javax.jcr.Node) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) RepositoryException(javax.jcr.RepositoryException) IProject(org.eclipse.core.resources.IProject) Poller(org.apache.sling.ide.test.impl.helpers.Poller) Test(org.junit.Test)

Aggregations

RepositoryAccessor (org.apache.sling.ide.test.impl.helpers.RepositoryAccessor)28 ProjectAdapter (org.apache.sling.ide.test.impl.helpers.ProjectAdapter)27 ServerAdapter (org.apache.sling.ide.test.impl.helpers.ServerAdapter)27 IProject (org.eclipse.core.resources.IProject)27 Test (org.junit.Test)26 Poller (org.apache.sling.ide.test.impl.helpers.Poller)18 ByteArrayInputStream (java.io.ByteArrayInputStream)17 RepositoryException (javax.jcr.RepositoryException)16 Node (javax.jcr.Node)15 InputStream (java.io.InputStream)10 Session (javax.jcr.Session)3 IOException (java.io.IOException)2 HttpException (org.apache.commons.httpclient.HttpException)2 ValueFactory (javax.jcr.ValueFactory)1 MavenDependency (org.apache.sling.ide.test.impl.helpers.MavenDependency)1 OsgiBundleManifest (org.apache.sling.ide.test.impl.helpers.OsgiBundleManifest)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1