use of org.apache.sling.ide.eclipse.ui.nav.model.SyncDir in project sling by apache.
the class SightlyNatureTesterTest method testOnProject.
private void testOnProject(boolean hasSightlyNature) throws CoreException {
if (hasSightlyNature) {
projectAdapter.installFacet("sightly", "1.1");
}
final IPath sightlyTemplatePath = Path.fromPortableString("/jcr_root/libs/my/component/html.html");
projectAdapter.createOrUpdateFile(sightlyTemplatePath, new ByteArrayInputStream(("<html />").getBytes()));
// test on resources directly
assertEquals("Test on project", hasSightlyNature, tester.test(projectRule.getProject(), "sightlyNature", new Object[0], null));
assertEquals("Test on folder", hasSightlyNature, tester.test(projectRule.getProject().getFolder("jcr_root"), "sightlyNature", new Object[0], null));
assertEquals("Test on file", hasSightlyNature, tester.test(projectRule.getProject().getFile(sightlyTemplatePath), "sightlyNature", new Object[0], null));
// directly create the root node
SyncDir syncDirNode = new SyncDir((IFolder) projectRule.getProject().findMember("jcr_root"));
assertEquals("Test on sync dir node", hasSightlyNature, tester.test(syncDirNode, "sightlyNature", new Object[0], null));
// test on jcr nodes
JcrContentContentProvider contentProvider = new JcrContentContentProvider();
JcrNode firstChild = (JcrNode) contentProvider.getChildren(syncDirNode)[0];
assertEquals("Test on jcr node", hasSightlyNature, tester.test(firstChild, "sightlyNature", new Object[0], null));
}
use of org.apache.sling.ide.eclipse.ui.nav.model.SyncDir in project sling by apache.
the class JcrContentContentProviderTest method listChildrenOnSyncDirIgnoresWebInfAndMetaInf.
@Test
public void listChildrenOnSyncDirIgnoresWebInfAndMetaInf() throws Exception {
project.ensureDirectoryExists(Path.fromPortableString("jcr_root/WEB-INF"));
project.ensureDirectoryExists(Path.fromPortableString("jcr_root/META-INF"));
project.ensureDirectoryExists(Path.fromPortableString("jcr_root/content"));
// directly create the root node
SyncDir syncDirNode = new SyncDir((IFolder) contentProject.findMember("jcr_root"));
// assertion
Object[] children = new JcrContentContentProvider().getChildren(syncDirNode);
assertThat(children.length, equalTo(1));
JcrNode child = (JcrNode) children[0];
assertThat(child.getName(), equalTo("content"));
}
use of org.apache.sling.ide.eclipse.ui.nav.model.SyncDir in project sling by apache.
the class JcrContentContentProviderTest method listChildrenWhenContentXmlIsBroken.
@Test
public void listChildrenWhenContentXmlIsBroken() throws Exception {
// create .content.xml structure
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/.content.xml"), new ByteArrayInputStream("invalid".getBytes()));
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/child1.txt"), new ByteArrayInputStream("hello, world".getBytes()));
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/child2.txt"), new ByteArrayInputStream("hello, world".getBytes()));
// directly create the root node
SyncDir syncDirNode = new SyncDir((IFolder) contentProject.findMember("jcr_root"));
// assertions
assertIsNavigableAndHasNoChildren(syncDirNode, "/content/child1.txt");
assertIsNavigableAndHasNoChildren(syncDirNode, "/content/child2.txt");
}
use of org.apache.sling.ide.eclipse.ui.nav.model.SyncDir in project sling by apache.
the class JcrContentContentProviderTest method listChildrenOnNtFolderIncludedUnderJcrContentNode.
@Test
public void listChildrenOnNtFolderIncludedUnderJcrContentNode() throws Exception {
// create .content.xml structure
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/.content.xml"), // TODO - rename xml file
getClass().getResourceAsStream("nt-unstructured-with-folder-child.xml"));
project.ensureDirectoryExists(Path.fromPortableString("jcr_root/content/_jcr_content/first-folder/second-folder"));
// directly create the root node
SyncDir syncDirNode = new SyncDir((IFolder) contentProject.findMember("jcr_root"));
// assertion
assertIsNavigableAndHasNoChildren(syncDirNode, "/content/jcr:content/first-folder/second-folder");
}
use of org.apache.sling.ide.eclipse.ui.nav.model.SyncDir in project sling by apache.
the class JcrContentContentProviderTest method listChildrenWithNestedContentXmlInEscapedDir.
@Test
public void listChildrenWithNestedContentXmlInEscapedDir() throws Exception {
// create .content.xml structure
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/.content.xml"), getClass().getResourceAsStream("sling-folder-nodetype.xml"));
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/_sling_stuff/.content.xml"), getClass().getResourceAsStream("nt-unstructured-nodetype.xml"));
// directly create the root node
SyncDir syncDirNode = new SyncDir((IFolder) contentProject.findMember("jcr_root"));
// assertion
assertIsNavigableAndHasNoChildren(syncDirNode, "/content/sling:stuff");
}
Aggregations