Search in sources :

Example 21 with Poller

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

the class ContentDeploymentTest method deployFile.

@Test
public void deployFile() throws CoreException, InterruptedException, URIException, HttpException, IOException {
    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.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<Void>() {

        @Override
        public Void call() throws HttpException, IOException {
            repo.assertGetIsSuccessful("test/hello.txt", "hello, world");
            return null;
        }
    }, nullValue(Void.class));
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.txt"), new ByteArrayInputStream("goodbye, world".getBytes()));
    // verify that file is updated
    poller.pollUntil(new Callable<Void>() {

        @Override
        public Void call() throws HttpException, IOException {
            repo.assertGetIsSuccessful("test/hello.txt", "goodbye, world");
            return null;
        }
    }, nullValue(Void.class));
    project.deleteMember(Path.fromPortableString("jcr_root/test/hello.txt"));
    // verify that file is deleted
    poller.pollUntil(new Callable<Void>() {

        @Override
        public Void call() throws HttpException, IOException {
            repo.assertGetReturns404("test/hello.txt");
            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) ByteArrayInputStream(java.io.ByteArrayInputStream) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) HttpException(org.apache.commons.httpclient.HttpException) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) Poller(org.apache.sling.ide.test.impl.helpers.Poller) Test(org.junit.Test)

Example 22 with Poller

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

the class ContentDeploymentTest method fileDeployedBeforeAddingModuleToServerIsPublished.

@Test
public void fileDeployedBeforeAddingModuleToServerIsPublished() throws Throwable {
    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");
    // create filter.xml
    project.createVltFilterWithRoots("/test");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.txt"), new ByteArrayInputStream("hello, world".getBytes()));
    // install bundle facet
    project.installFacet("sling.content", "1.0");
    ServerAdapter server = new ServerAdapter(wstServer.getServer());
    server.installModule(contentProject);
    // 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/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)

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