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"));
}
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")));
}
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"));
}
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);
}
}
});
}
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));
}
Aggregations