Search in sources :

Example 16 with Poller

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

Example 17 with Poller

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

the class JcrFullCoverageAggregatesDeploymentTest method deleteFullCoverageAggregate.

@Test
public void deleteFullCoverageAggregate() 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);
    final String baseName = "com.example.some.Component";
    // create filter.xml
    project.createVltFilterWithRoots("/content");
    // create .content.xml structure
    InputStream contentXml = getClass().getResourceAsStream(baseName + ".xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/" + baseName + ".xml"), contentXml);
    Matcher<Node> postConditions = allOf(hasPath("/content/test-root/" + baseName), hasPrimaryType("sling:OsgiConfig"));
    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/" + baseName);
        }
    }, postConditions);
    // Remove file from disk
    project.deleteMember(Path.fromPortableString("jcr_root/content/test-root/" + baseName + ".xml"));
    // poll until the node no longer exists
    poller.pollUntil(new Callable<Boolean>() {

        @Override
        public Boolean call() throws RepositoryException {
            return repo.hasNode("/content/test-root/" + baseName);
        }
    }, equalTo(false));
}
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 Poller

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

the class JcrFullCoverageAggregatesDeploymentTest method deployNestedFullCoverageAggregate.

@Test
public void deployNestedFullCoverageAggregate() 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);
}
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 19 with Poller

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

the class ContentDeploymentTest method changeNodePrimaryType.

@Test
public void changeNodePrimaryType() 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 bundle facet
    project.installFacet("sling.content", "1.0");
    ServerAdapter server = new ServerAdapter(wstServer.getServer());
    server.installModule(contentProject);
    // create filter.xml
    project.createVltFilterWithRoots("/test");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.txt"), new ByteArrayInputStream("hello, world".getBytes()));
    // verifications
    final RepositoryAccessor repo = new RepositoryAccessor(config);
    Poller poller = new Poller();
    assertThatNode(repo, poller, "/test", allOf(hasPath("/test"), hasPrimaryType("nt:folder"), hasChildrenCount(1)));
    // change node type to sling:Folder
    InputStream contentXml = getClass().getResourceAsStream("sling-folder-nodetype.xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/.content.xml"), contentXml);
    // verifications (2)
    assertThatNode(repo, poller, "/test", allOf(hasPath("/test"), hasPrimaryType("sling:Folder"), hasChildrenCount(1)));
}
Also used : ServerAdapter(org.apache.sling.ide.test.impl.helpers.ServerAdapter) RepositoryAccessor(org.apache.sling.ide.test.impl.helpers.RepositoryAccessor) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) IProject(org.eclipse.core.resources.IProject) Poller(org.apache.sling.ide.test.impl.helpers.Poller) Test(org.junit.Test)

Example 20 with Poller

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

the class ContentDeploymentTest method filedDeployedWithFullCoverageSiblingDoesNotCauseSpuriousDeletion.

@Test
public void filedDeployedWithFullCoverageSiblingDoesNotCauseSpuriousDeletion() throws Exception {
    wstServer.waitForServerToStart();
    // create faceted project
    IProject contentProject = projectRule.getProject();
    ProjectAdapter project = new ProjectAdapter(contentProject);
    project.addNatures(JavaCore.NATURE_ID, "org.eclipse.wst.common.project.facet.core.nature");
    // install bundle facet
    project.installFacet("sling.content", "1.0");
    ServerAdapter server = new ServerAdapter(wstServer.getServer());
    server.installModule(contentProject);
    // create filter.xml
    project.createVltFilterWithRoots("/test");
    // create sling:Folder at /test/folder
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/.content.xml"), getClass().getResourceAsStream("sling-folder-nodetype.xml"));
    // create nt:file at /test/folder/hello.esp
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/hello.esp"), new ByteArrayInputStream("// not really javascript".getBytes()));
    // create sling:OsgiConfig at /test/folder/config.xml
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/config.xml"), getClass().getResourceAsStream("com.example.some.Component.xml"));
    // verify that config node is created
    final RepositoryAccessor repo = new RepositoryAccessor(config);
    Poller poller = new Poller();
    assertThatNode(repo, poller, "/test/folder/config", hasPrimaryType("sling:OsgiConfig"));
    // update file at /test/folder/hello.esp
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/hello.esp"), new ByteArrayInputStream("// maybe javascript".getBytes()));
    // wait until the file is updated
    assertThatNode(repo, poller, "/test/folder/hello.esp", hasFileContent("// maybe javascript"));
    // verify that the sling:OsgiConfig node is still present
    assertThatNode(repo, poller, "/test/folder/config", hasPrimaryType("sling:OsgiConfig"));
}
Also used : ServerAdapter(org.apache.sling.ide.test.impl.helpers.ServerAdapter) RepositoryAccessor(org.apache.sling.ide.test.impl.helpers.RepositoryAccessor) ByteArrayInputStream(java.io.ByteArrayInputStream) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) 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