Search in sources :

Example 21 with RepositoryAccessor

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

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

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

the class ContentImportTest method importFilesAndFoldersRespectsVltFilters.

@Test
public void importFilesAndFoldersRespectsVltFilters() throws Exception {
    // 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");
    wstServer.waitForServerToStart();
    project.createVltFilterWithRoots("/content/test-root/en");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en/hello.txt"), new ByteArrayInputStream("hello, world".getBytes()));
    ServerAdapter server = new ServerAdapter(wstServer.getServer());
    server.installModule(contentProject);
    // create server-side content
    RepositoryAccessor repo = new RepositoryAccessor(config);
    repo.createNode("/content/test-root/de", "nt:folder");
    repo.createNode("/content/test-root/de/files", "nt:folder");
    repo.createFile("/content/test-root/de/files/first.txt", "first file".getBytes());
    deh.clearUnexpectedEventsAfterSettling();
    runImport(contentProject);
    assertThat(contentProject.findMember("jcr_root/content/test-root/de"), nullValue());
}
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) Test(org.junit.Test)

Example 24 with RepositoryAccessor

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

the class ContentImportTest method importDeletesNoLongerPresentFile.

@Test
public void importDeletesNoLongerPresentFile() throws Exception {
    // 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");
    wstServer.waitForServerToStart();
    project.createVltFilterWithRoots("/content/test-root");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/hello.txt"), new ByteArrayInputStream("hello, world".getBytes()));
    ServerAdapter server = new ServerAdapter(wstServer.getServer());
    server.installModule(contentProject);
    deh.clearUnexpectedEventsAfterSettling();
    // create server-side content
    RepositoryAccessor repo = new RepositoryAccessor(config);
    repo.createNode("/content/test-root/en", "nt:folder");
    repo.createNode("/content/test-root/en/files", "nt:folder");
    repo.createFile("/content/test-root/en/files/first.txt", "first file".getBytes());
    repo.createFile("/content/test-root/en/files/second.txt", "second file".getBytes());
    // delete file since it was deployed when the module was added to the server
    repo.tryDeleteResource("/content/test-root/hello.txt");
    // run initial import
    runImport(contentProject);
    // first.txt and second.txt should be present
    assertThat(contentProject, hasFile("jcr_root/content/test-root/en/files/first.txt"));
    assertThat(contentProject, hasFile("jcr_root/content/test-root/en/files/second.txt"));
    // hello.txt is not present in the repo and should be deleted
    assertThat(contentProject, not(hasFile("jcr_root/content/test-root/hello.txt")));
}
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) Test(org.junit.Test)

Example 25 with RepositoryAccessor

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

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