use of org.apache.sling.ide.test.impl.helpers.ServerAdapter 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"));
}
use of org.apache.sling.ide.test.impl.helpers.ServerAdapter 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.ServerAdapter 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"));
}
Aggregations