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