Search in sources :

Example 11 with Poller

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

the class ServiceComponentHeaderValidatorTest method createJavaProject.

private void createJavaProject(String serviceComponentHeader) throws CoreException, IOException, InterruptedException {
    project = new ProjectAdapter(projectRule.getProject());
    project.addNatures(JavaCore.NATURE_ID);
    project.configureAsJavaProject();
    OsgiBundleManifest mf = new OsgiBundleManifest("com.example.bundle001").version("1.0.0").serviceComponent(serviceComponentHeader);
    project.createOsgiBundleManifest(mf);
    poller = new Poller();
    poller.pollUntil(new Callable<IProject>() {

        @Override
        public IProject call() throws Exception {
            return projectRule.getProject();
        }
    }, hasFile("bin/META-INF/MANIFEST.MF"));
}
Also used : ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) OsgiBundleManifest(org.apache.sling.ide.test.impl.helpers.OsgiBundleManifest) Poller(org.apache.sling.ide.test.impl.helpers.Poller) IProject(org.eclipse.core.resources.IProject) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException)

Example 12 with Poller

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

the class JcrPartialCoverageAggregatesDeploymentTest method deploySlingFolder.

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

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

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

the class JcrPartialCoverageAggregatesDeploymentTest method deployNodeWithContentXmlInParentFolder.

@Test
public void deployNodeWithContentXmlInParentFolder() 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");
    // the expected repository structure is
    // mapping [sling:Mapping]
    // \- jcr:content [nt:unstructured]
    //  \- par [nt:unstructured]
    //   \- folder [sling:Folder] 
    // first create the local structure where the content is completely serialized inside the .content.xml file
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/mapping/.content.xml"), getClass().getResourceAsStream("sling-mapping-with-folder-child.xml"));
    final RepositoryAccessor repo = new RepositoryAccessor(config);
    Poller poller = new Poller();
    // wait until the structure is published
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/mapping/jcr:content/par");
        }
    }, hasPrimaryType("nt:unstructured"));
    // now create the folder and its associated .content.xml file ; this will cause
    // intermediate folders to be created whose serialization data is present in the
    // parent's .content.xml file
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/mapping/_jcr_content/par/folder/.content.xml"), getClass().getResourceAsStream("sling-folder-nodetype.xml"));
    // first wait until the sling:Folder child node is created, to ensure that all changes are processed
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/mapping/jcr:content/par/folder");
        }
    }, hasPrimaryType("sling:Folder"));
    // then, verify that the nt:unstructured node is correctly written
    poller.pollUntil(new Callable<Node>() {

        @Override
        public Node call() throws RepositoryException {
            return repo.getNode("/content/test-root/mapping/jcr:content/par");
        }
    }, hasPrimaryType("nt:unstructured"));
}
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)

Example 14 with Poller

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

the class LegacyMavenBundleProjectTest method testLegacyMavenBundleProjectHasErrorMarker.

@Test
public void testLegacyMavenBundleProjectHasErrorMarker() throws Exception {
    // create project
    final IProject bundleProject = projectRule.getProject();
    MavenProjectAdapter project = new MavenProjectAdapter(bundleProject);
    project.createOrUpdateFile(Path.fromPortableString("pom.xml"), getClass().getResourceAsStream("legacy-pom.xml"));
    project.convertToMavenProject();
    // wait up to 1 minute for the build to succeed due to time needed to retrieve dependencies
    Poller markerPoller = new Poller(TimeUnit.MINUTES.toMillis(1));
    markerPoller.pollUntilSuccessful(new Runnable() {

        @Override
        public void run() {
            try {
                IMarker[] markers = bundleProject.findMarkers(null, true, IResource.DEPTH_ONE);
                for (IMarker marker : markers) {
                    if (marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO) != IMarker.SEVERITY_ERROR) {
                        continue;
                    }
                    if (marker.getAttribute(IMarker.MESSAGE, "").startsWith("Missing m2e incremental build support")) {
                        return;
                    }
                }
                throw new RuntimeException("Did not find error message starting with 'Missing m2e incremental support'");
            } catch (CoreException e) {
                throw new RuntimeException(e);
            }
        }
    });
}
Also used : MavenProjectAdapter(org.apache.sling.ide.eclipse.m2e.impl.helpers.MavenProjectAdapter) CoreException(org.eclipse.core.runtime.CoreException) IMarker(org.eclipse.core.resources.IMarker) IProject(org.eclipse.core.resources.IProject) Poller(org.apache.sling.ide.test.impl.helpers.Poller) Test(org.junit.Test)

Example 15 with Poller

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

the class MavenProjectAdapter method convertToMavenProject.

/**
     * Converts the wrapped project to a Maven project
     * 
     * <p>It waits for for the conversion to succeed, and fails with an unchecked exception
     * if the conversion does not succeed in the allocated time.</p>
     * 
     * @throws CoreException
     * @throws InterruptedException
     */
public void convertToMavenProject() throws CoreException, InterruptedException {
    EnableNatureAction action = new EnableNatureAction();
    action.selectionChanged(null, new StructuredSelection(getProject()));
    action.run(null);
    new Poller().pollUntil(new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            return getProject().hasNature(IMavenConstants.NATURE_ID);
        }
    }, CoreMatchers.equalTo(true));
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) EnableNatureAction(org.eclipse.m2e.core.ui.internal.actions.EnableNatureAction) Poller(org.apache.sling.ide.test.impl.helpers.Poller) CoreException(org.eclipse.core.runtime.CoreException)

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