use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter 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.ProjectAdapter 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.ProjectAdapter in project sling by apache.
the class ProjectHelperTest method inferContentProjectContentMissingFilter.
@Test
public void inferContentProjectContentMissingFilter() throws CoreException, InterruptedException {
// 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");
// create files
project.createOrUpdateFile(Path.fromPortableString("src/main/content/jcr_root/test/hello.txt"), new ByteArrayInputStream("goodbye, world".getBytes()));
assertThat(ProjectHelper.getInferredContentProjectContentRoot(contentProject), CoreMatchers.nullValue());
}
use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.
the class ProjectHelperTest method inferContentProjectContentRootNested.
@Test
public void inferContentProjectContentRootNested() throws CoreException, InterruptedException {
// 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");
// create files
project.createOrUpdateFile(Path.fromPortableString("src/main/content/jcr_root/test/hello.txt"), new ByteArrayInputStream("goodbye, world".getBytes()));
project.createOrUpdateFile(Path.fromPortableString("src/main/content/META-INF/vault/filter.xml"), new ByteArrayInputStream("<workspaceFilter version=\"1.0\"/>".getBytes()));
assertThat(ProjectHelper.getInferredContentProjectContentRoot(contentProject), CoreMatchers.<IContainer>equalTo(contentProject.getFolder("src/main/content")));
}
use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.
the class ProjectHelperTest method inferContentProjectContentRootAtTheTopLevel.
@Test
public void inferContentProjectContentRootAtTheTopLevel() throws CoreException, InterruptedException {
// 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");
// create files
project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.txt"), new ByteArrayInputStream("goodbye, world".getBytes()));
project.createOrUpdateFile(Path.fromPortableString("META-INF/vault/filter.xml"), new ByteArrayInputStream("<workspaceFilter version=\"1.0\"/>".getBytes()));
assertThat(ProjectHelper.getInferredContentProjectContentRoot(contentProject), CoreMatchers.<IContainer>equalTo(contentProject));
}
Aggregations