use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor in project sling by apache.
the class ContentImportTest method importFilesAndFoldersRespectsVltIgnore.
@Test
public void importFilesAndFoldersRespectsVltIgnore() throws Exception {
// 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");
wstServer.waitForServerToStart();
project.createVltFilterWithRoots("/content/test-root/en");
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.vltignore"), new ByteArrayInputStream("en\n".getBytes()));
ServerAdapter server = new ServerAdapter(wstServer.getServer());
server.installModule(contentProject);
deh.clearUnexpectedEventsAfterSettling();
// create server-side content
RepositoryAccessor repo = new RepositoryAccessor(config);
repo.createNode("/content/test-root/en", "nt:folder");
repo.createNode("/content/test-root/en/files", "nt:folder");
repo.createFile("/content/test-root/en/files/first.txt", "first file".getBytes());
runImport(contentProject);
assertThat(contentProject.findMember("jcr_root/content/test-root/en"), nullValue());
}
use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor 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")));
}
use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor in project sling by apache.
the class JcrPartialCoverageAggregatesDeploymentTest method deploySlingOrderedFolderWithJcrContentNode.
@Test
public void deploySlingOrderedFolderWithJcrContentNode() 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 nt:file at /content/test-root/file.txt
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/folder/file.txt"), new ByteArrayInputStream("hello, world".getBytes()));
// create a sling:OrderedFolder at /content/test-root
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.content.xml"), getClass().getResourceAsStream("sling-ordered-folder-with-children.xml"));
Matcher<Node> postConditions = allOf(hasPath("/content/test-root"), hasPrimaryType("sling:OrderedFolder"), hasChildrenNames("folder", "jcr:content"));
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);
// reorder the children of the /content/test-root node
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.content.xml"), getClass().getResourceAsStream("sling-ordered-folder-with-children-reordered.xml"));
postConditions = allOf(hasPath("/content/test-root"), hasPrimaryType("sling:OrderedFolder"), hasChildrenNames("jcr:content", "folder"));
poller.pollUntil(new Callable<Node>() {
@Override
public Node call() throws RepositoryException {
return repo.getNode("/content/test-root");
}
}, postConditions);
}
use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor in project sling by apache.
the class JcrPartialCoverageAggregatesDeploymentTest method deployNodeWithContentXmlInParentFolder_reverse.
@Test
public void deployNodeWithContentXmlInParentFolder_reverse() 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"));
// 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"));
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/folder");
}
}, hasPrimaryType("sling:Folder"));
// change the folder's node type to nt:unstructured and make sure it's covered by the parent
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/mapping/.content.xml"), getClass().getResourceAsStream("sling-mapping-with-unstructured-child.xml"));
// oh boy, where do I start ...
// this test keeps failing with issues which suggest concurrency problems, e.g. InvalidStateException
// I've tried to work around this issue by refreshing the session, serialising the executions with a
// SingleThreadExecutor, inspecting the before/after repo state ... but in the end only this
// 'harmless' sleep fixes the test. It will have to do for now, at least until SLING-4438 is fixed
Thread.sleep(1000);
// delete the sling folder node type since the serialization is now completely covered by
// the parent node
project.deleteMember(Path.fromPortableString("jcr_root/content/test-root/mapping/_jcr_content"));
// validate that the primary type has changed
poller.pollUntil(new Callable<Node>() {
@Override
public Node call() throws RepositoryException {
return repo.getNode("/content/test-root/mapping/jcr:content/par/folder");
}
}, hasPrimaryType("nt:unstructured"));
}
use of org.apache.sling.ide.test.impl.helpers.RepositoryAccessor in project sling by apache.
the class JcrFullCoverageAggregatesDeploymentTest method reorderNodesFromNestedFullCoverageAggregate.
@Test
public void reorderNodesFromNestedFullCoverageAggregate() 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 .content.xml structure
InputStream contentXml = getClass().getResourceAsStream("content-nested-structure.xml");
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en.xml"), contentXml);
Matcher<Node> postConditions = allOf(hasPath("/content/test-root/en"), hasPrimaryType("sling:Folder"), hasMixinTypes("mix:language"), hasChildrenNames("message", "error", "warning"));
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/en");
}
}, postConditions);
// update .content.xml structure
InputStream updatedContentXml = getClass().getResourceAsStream("content-nested-structure-reordered-nodes.xml");
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en.xml"), updatedContentXml);
// poll until we have the child nodes reordered
postConditions = allOf(hasPath("/content/test-root/en"), hasPrimaryType("sling:OrderedFolder"), hasMixinTypes("mix:language"), hasChildrenNames("message", "warning", "error"));
poller.pollUntil(new Callable<Node>() {
@Override
public Node call() throws RepositoryException {
return repo.getNode("/content/test-root/en");
}
}, postConditions);
}
Aggregations