Search in sources :

Example 6 with Poller

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

the class JcrPartialCoverageAggregatesDeploymentTest method deploySlingOrderedFolderWithJcrContentNode.

@Test
public void deploySlingOrderedFolderWithJcrContentNode() 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 nt:file at /content/test-root/file.txt
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/folder/file.txt"), new ByteArrayInputStream("hello, world".getBytes()));
    // create a sling:OrderedFolder at /content/test-root
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.content.xml"), getClass().getResourceAsStream("sling-ordered-folder-with-children.xml"));
    Matcher<Node> postConditions = allOf(hasPath("/content/test-root"), hasPrimaryType("sling:OrderedFolder"), hasChildrenNames("folder", "jcr:content"));
    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);
    // reorder the children of the /content/test-root node
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.content.xml"), getClass().getResourceAsStream("sling-ordered-folder-with-children-reordered.xml"));
    postConditions = allOf(hasPath("/content/test-root"), hasPrimaryType("sling:OrderedFolder"), hasChildrenNames("jcr:content", "folder"));
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root");
        }
    }, postConditions);
}
Also used : ServerAdapter(org.apache.sling.ide.test.impl.helpers.ServerAdapter) RepositoryAccessor(org.apache.sling.ide.test.impl.helpers.RepositoryAccessor) ByteArrayInputStream(java.io.ByteArrayInputStream) 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 7 with Poller

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

the class JcrPartialCoverageAggregatesDeploymentTest method deployNodeWithContentXmlInParentFolder_reverse.

@Test
public void deployNodeWithContentXmlInParentFolder_reverse() 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"));
    // 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"));
    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/folder");
        }
    }, hasPrimaryType("sling:Folder"));
    // change the folder's node type to nt:unstructured and make sure it's covered by the parent
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/mapping/.content.xml"), getClass().getResourceAsStream("sling-mapping-with-unstructured-child.xml"));
    // oh boy, where do I start ...
    // this test keeps failing with issues which suggest concurrency problems, e.g. InvalidStateException
    // I've tried to work around this issue by refreshing the session, serialising the executions with a
    // SingleThreadExecutor, inspecting the before/after repo state ... but in the end only this
    // 'harmless' sleep fixes the test. It will have to do for now, at least until SLING-4438 is fixed
    Thread.sleep(1000);
    // delete the sling folder node type since the serialization is now completely covered by
    // the parent node
    project.deleteMember(Path.fromPortableString("jcr_root/content/test-root/mapping/_jcr_content"));
    // validate that the primary type has changed
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/mapping/jcr:content/par/folder");
        }
    }, 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 8 with Poller

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

the class JcrFullCoverageAggregatesDeploymentTest method reorderNodesFromNestedFullCoverageAggregate.

@Test
public void reorderNodesFromNestedFullCoverageAggregate() 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"), hasChildrenNames("message", "error", "warning"));
    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-reordered-nodes.xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en.xml"), updatedContentXml);
    // poll until we have the child nodes reordered
    postConditions = allOf(hasPath("/content/test-root/en"), hasPrimaryType("sling:OrderedFolder"), hasMixinTypes("mix:language"), hasChildrenNames("message", "warning", "error"));
    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 9 with Poller

use of org.apache.sling.ide.test.impl.helpers.Poller 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 10 with Poller

use of org.apache.sling.ide.test.impl.helpers.Poller 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)

Aggregations

Poller (org.apache.sling.ide.test.impl.helpers.Poller)22 IProject (org.eclipse.core.resources.IProject)21 ProjectAdapter (org.apache.sling.ide.test.impl.helpers.ProjectAdapter)19 Test (org.junit.Test)19 RepositoryAccessor (org.apache.sling.ide.test.impl.helpers.RepositoryAccessor)18 ServerAdapter (org.apache.sling.ide.test.impl.helpers.ServerAdapter)18 Node (javax.jcr.Node)13 RepositoryException (javax.jcr.RepositoryException)13 InputStream (java.io.InputStream)10 ByteArrayInputStream (java.io.ByteArrayInputStream)8 IOException (java.io.IOException)3 CoreException (org.eclipse.core.runtime.CoreException)3 HttpException (org.apache.commons.httpclient.HttpException)2 MavenProjectAdapter (org.apache.sling.ide.eclipse.m2e.impl.helpers.MavenProjectAdapter)2 OsgiBundleManifest (org.apache.sling.ide.test.impl.helpers.OsgiBundleManifest)2 MavenDependency (org.apache.sling.ide.test.impl.helpers.MavenDependency)1 IMarker (org.eclipse.core.resources.IMarker)1 IPath (org.eclipse.core.runtime.IPath)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 EnableNatureAction (org.eclipse.m2e.core.ui.internal.actions.EnableNatureAction)1