Search in sources :

Example 11 with ProjectAdapter

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

the class ContentImportTest method importFilesAndFolders.

@Test
public void importFilesAndFolders() 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);
    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());
    runImport(contentProject);
    assertThat(contentProject, hasFolder("jcr_root/content/test-root/en/files"));
    assertThat(contentProject, hasFile("jcr_root/content/test-root/en/files/first.txt", "first file".getBytes()));
}
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 12 with ProjectAdapter

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

the class ContentResourceTesterTest method slingContentProjectUnrelatedResourcesAreNotExportable.

@Test
public void slingContentProjectUnrelatedResourcesAreNotExportable() 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 bundle facet
    project.installFacet("sling.content", "1.0");
    project.createOrUpdateFile(Path.fromPortableString("res/hello.txt"), new ByteArrayInputStream("goodbye, world".getBytes()));
    assertThat("Dir not under content sync dir can not be exported", new ContentResourceTester().test(contentProject.findMember("res"), "canBeExported", null, null), equalTo(false));
    assertThat("File not under content sync dir can not be exported", new ContentResourceTester().test(contentProject.findMember("res/hello.txt"), "canBeExported", null, null), equalTo(false));
}
Also used : ContentResourceTester(org.apache.sling.ide.eclipse.core.internal.ContentResourceTester) ByteArrayInputStream(java.io.ByteArrayInputStream) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 13 with ProjectAdapter

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

the class ContentImportTest method importFilesAndFoldersRespectsVltIgnore.

@Test
public void importFilesAndFoldersRespectsVltIgnore() 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/.vltignore"), new ByteArrayInputStream("en\n".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());
    runImport(contentProject);
    assertThat(contentProject.findMember("jcr_root/content/test-root/en"), 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 14 with ProjectAdapter

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

the class JcrContentContentProviderTest method prepareProject.

@Before
public void prepareProject() throws Exception {
    contentProject = projectRule.getProject();
    project = new ProjectAdapter(contentProject);
    project.addNatures("org.eclipse.wst.common.project.facet.core.nature");
    // install content facet
    project.installFacet("sling.content", "1.0");
}
Also used : ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) Before(org.junit.Before)

Example 15 with ProjectAdapter

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

the class JcrPartialCoverageAggregatesDeploymentTest method deployNodeWithChildrenAndOrderableNodeTypes.

@Test
public void deployNodeWithChildrenAndOrderableNodeTypes() 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
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.content.xml"), getClass().getResourceAsStream("sling-folder-nodetype.xml"));
    // create a nt:unstructured at /content/test-root/nested
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/nested/.content.xml"), getClass().getResourceAsStream("nt-unstructured-nodetype.xml"));
    // create a nt:unstructured at /content/test-root/nested/nested
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/nested/nested/.content.xml"), getClass().getResourceAsStream("nt-unstructured-nodetype.xml"));
    Matcher<Node> postConditions = allOf(hasPath("/content/test-root/nested"), hasPrimaryType("nt:unstructured"), 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/nested");
        }
    }, postConditions);
    // update jcr:title for /content/test-root
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/nested/.content.xml"), getClass().getResourceAsStream("nt-unstructured-nodetype-with-title.xml"));
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/nested");
        }
    }, allOf(hasPath("/content/test-root/nested"), 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) 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