Search in sources :

Example 1 with Poller

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

the class MavenProjectUtilsTest method inferDefaultProvisioningModelDirectories.

@Test
public void inferDefaultProvisioningModelDirectories() throws Exception {
    IPath modelsDir = Path.fromPortableString("src/main/provisioning");
    // create project
    final IProject launchpadProject = projectRule.getProject();
    MavenProjectAdapter project = new MavenProjectAdapter(launchpadProject);
    project.createOrUpdateFile(Path.fromPortableString("pom.xml"), getClass().getResourceAsStream("slingstart-simple-pom.xml"));
    project.ensureDirectoryExists(modelsDir);
    project.convertToMavenProject();
    // conversion should enable the slingstart configurator and set the provisioning model path
    new Poller(TimeUnit.MINUTES.toMillis(1)).pollUntil(new Callable<IPath>() {

        @Override
        public IPath call() throws Exception {
            return ProjectUtil.getProvisioningModelPath(launchpadProject);
        }
    }, equalTo(modelsDir));
}
Also used : IPath(org.eclipse.core.runtime.IPath) MavenProjectAdapter(org.apache.sling.ide.eclipse.m2e.impl.helpers.MavenProjectAdapter) IProject(org.eclipse.core.resources.IProject) Poller(org.apache.sling.ide.test.impl.helpers.Poller) Test(org.junit.Test)

Example 2 with Poller

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

the class BundleDeploymentTest method deployBundleOnServer.

private void deployBundleOnServer(boolean installBundleLocally) throws Exception {
    wstServer.waitForServerToStart();
    // create faceted project
    IProject bundleProject = projectRule.getProject();
    ProjectAdapter project = new ProjectAdapter(bundleProject);
    project.addNatures(JavaCore.NATURE_ID, "org.eclipse.wst.common.project.facet.core.nature");
    // configure java project with dependencies
    MavenDependency slingApiDep = new MavenDependency().groupId("org.apache.sling").artifactId("org.apache.sling.api").version("2.2.0");
    MavenDependency servletApiDep = new MavenDependency().groupId("javax.servlet").artifactId("servlet-api").version("2.4");
    project.configureAsJavaProject(slingApiDep, servletApiDep);
    // create DS component class
    InputStream simpleServlet = getClass().getResourceAsStream("SimpleServlet.java.v1.txt");
    project.createOrUpdateFile(Path.fromPortableString("src/example/SimpleServlet.java"), simpleServlet);
    // create DS component descriptor
    InputStream servletDescriptor = getClass().getResourceAsStream("SimpleServlet.xml");
    project.createOrUpdateFile(Path.fromPortableString("src/OSGI-INF/SimpleServlet.xml"), servletDescriptor);
    // create manifest
    OsgiBundleManifest manifest = OsgiBundleManifest.symbolicName("test.bundle001").version("1.0.0.SNAPSHOT").name("Test bundle").serviceComponent("OSGI-INF/SimpleServlet.xml").importPackage("javax.servlet,org.apache.sling.api,org.apache.sling.api.servlets");
    project.createOsgiBundleManifest(manifest);
    // install bundle facet
    project.installFacet("sling.bundle", "1.0");
    ServerAdapter server = new ServerAdapter(wstServer.getServer());
    server.setAttribute(ISlingLaunchpadServer.PROP_INSTALL_LOCALLY, installBundleLocally);
    server.installModule(bundleProject);
    final RepositoryAccessor repo = new RepositoryAccessor(config);
    Poller poller = new Poller();
    poller.pollUntil(new Callable<Void>() {

        @Override
        public Void call() throws HttpException, IOException {
            repo.assertGetIsSuccessful("simple-servlet", "Version 1");
            return null;
        }
    }, nullValue(Void.class));
    // update DS component class
    InputStream simpleServlet2 = getClass().getResourceAsStream("SimpleServlet.java.v2.txt");
    project.createOrUpdateFile(Path.fromPortableString("src/example/SimpleServlet.java"), simpleServlet2);
    poller.pollUntil(new Callable<Void>() {

        @Override
        public Void call() throws HttpException, IOException {
            repo.assertGetIsSuccessful("simple-servlet", "Version 2");
            return null;
        }
    }, nullValue(Void.class));
}
Also used : ServerAdapter(org.apache.sling.ide.test.impl.helpers.ServerAdapter) RepositoryAccessor(org.apache.sling.ide.test.impl.helpers.RepositoryAccessor) InputStream(java.io.InputStream) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) OsgiBundleManifest(org.apache.sling.ide.test.impl.helpers.OsgiBundleManifest) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) HttpException(org.apache.commons.httpclient.HttpException) Poller(org.apache.sling.ide.test.impl.helpers.Poller) MavenDependency(org.apache.sling.ide.test.impl.helpers.MavenDependency)

Example 3 with Poller

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

the class ContentDeploymentTest method deployFileWithAttachedMetadata.

@Test
public void deployFileWithAttachedMetadata() 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");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.esp"), new ByteArrayInputStream("// not really javascript".getBytes()));
    // verify that file is created
    final RepositoryAccessor repo = new RepositoryAccessor(config);
    Poller poller = new Poller();
    assertThatNode(repo, poller, "/test/hello.esp", hasPrimaryType("nt:file"));
    InputStream contentXml = getClass().getResourceAsStream("file-custom-mimetype.xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.esp.dir/.content.xml"), contentXml);
    assertThatNode(repo, poller, "/test/hello.esp/jcr:content", hasPropertyValue("jcr:mimeType", "text/javascript"));
}
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 4 with Poller

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

the class ContentDeploymentTest method deployFileWithMissingParentFromRepository.

/**
     * This test validates that if the parent of a resource that does not exist in the repository the resource is
     * successfully created
     * 
     * @throws Exception
     */
@Test
public void deployFileWithMissingParentFromRepository() 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 file
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/demo/nested/structure/hello.txt"), new ByteArrayInputStream("hello, world".getBytes()));
    // verify that file is created
    final RepositoryAccessor repo = new RepositoryAccessor(config);
    Poller poller = new Poller();
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/test/demo/nested/structure/hello.txt");
        }
    }, hasFileContent("hello, world"));
}
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 5 with Poller

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

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