Search in sources :

Example 21 with ProjectAdapter

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

the class ProjectHelperTest method projectWithInstalledFacetIsCandidate.

@Test
public void projectWithInstalledFacetIsCandidate() throws CoreException, InterruptedException {
    // create faceted project
    IProject contentProject = projectRule.getProject();
    ProjectAdapter project = new ProjectAdapter(contentProject);
    project.addNatures("org.eclipse.wst.common.project.facet.core.nature");
    // create files
    project.createOrUpdateFile(Path.fromPortableString("src/main/content/jcr_root/test/hello.txt"), new ByteArrayInputStream("goodbye, world".getBytes()));
    project.createOrUpdateFile(Path.fromPortableString("src/main/content/META-INF/vault/filter.xml"), new ByteArrayInputStream("<workspaceFilter version=\"1.0\"/>".getBytes()));
    assertThat(ProjectHelper.isPotentialContentProject(contentProject), CoreMatchers.equalTo(true));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 22 with ProjectAdapter

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

the class ProjectHelperTest method projectWithoutInstalledFacetIsNotCandidate.

@Test
public void projectWithoutInstalledFacetIsNotCandidate() throws CoreException, InterruptedException {
    // 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");
    // create files
    project.createOrUpdateFile(Path.fromPortableString("src/main/content/jcr_root/test/hello.txt"), new ByteArrayInputStream("goodbye, world".getBytes()));
    project.createOrUpdateFile(Path.fromPortableString("src/main/content/META-INF/vault/filter.xml"), new ByteArrayInputStream("<workspaceFilter version=\"1.0\"/>".getBytes()));
    assertThat(ProjectHelper.isPotentialContentProject(contentProject), CoreMatchers.equalTo(false));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 23 with ProjectAdapter

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

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

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

ProjectAdapter (org.apache.sling.ide.test.impl.helpers.ProjectAdapter)48 IProject (org.eclipse.core.resources.IProject)45 Test (org.junit.Test)40 ByteArrayInputStream (java.io.ByteArrayInputStream)28 ServerAdapter (org.apache.sling.ide.test.impl.helpers.ServerAdapter)28 RepositoryAccessor (org.apache.sling.ide.test.impl.helpers.RepositoryAccessor)27 Poller (org.apache.sling.ide.test.impl.helpers.Poller)19 RepositoryException (javax.jcr.RepositoryException)16 Node (javax.jcr.Node)15 InputStream (java.io.InputStream)11 Before (org.junit.Before)5 ContentResourceTester (org.apache.sling.ide.eclipse.core.internal.ContentResourceTester)4 IOException (java.io.IOException)3 Session (javax.jcr.Session)3 HttpException (org.apache.commons.httpclient.HttpException)2 SlingContentModuleFactory (org.apache.sling.ide.eclipse.core.internal.SlingContentModuleFactory)2 OsgiBundleManifest (org.apache.sling.ide.test.impl.helpers.OsgiBundleManifest)2 IPath (org.eclipse.core.runtime.IPath)2 IModule (org.eclipse.wst.server.core.IModule)2 IModuleResource (org.eclipse.wst.server.core.model.IModuleResource)2