Search in sources :

Example 6 with SyncDir

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));
}
Also used : JcrContentContentProvider(org.apache.sling.ide.eclipse.ui.nav.JcrContentContentProvider) JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode) IPath(org.eclipse.core.runtime.IPath) ByteArrayInputStream(java.io.ByteArrayInputStream) SyncDir(org.apache.sling.ide.eclipse.ui.nav.model.SyncDir)

Example 7 with SyncDir

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"));
}
Also used : JcrContentContentProvider(org.apache.sling.ide.eclipse.ui.nav.JcrContentContentProvider) JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode) SyncDir(org.apache.sling.ide.eclipse.ui.nav.model.SyncDir) Test(org.junit.Test)

Example 8 with SyncDir

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");
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) SyncDir(org.apache.sling.ide.eclipse.ui.nav.model.SyncDir) Test(org.junit.Test)

Example 9 with SyncDir

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");
}
Also used : SyncDir(org.apache.sling.ide.eclipse.ui.nav.model.SyncDir) Test(org.junit.Test)

Example 10 with SyncDir

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");
}
Also used : SyncDir(org.apache.sling.ide.eclipse.ui.nav.model.SyncDir) Test(org.junit.Test)

Aggregations

SyncDir (org.apache.sling.ide.eclipse.ui.nav.model.SyncDir)10 Test (org.junit.Test)5 JcrNode (org.apache.sling.ide.eclipse.ui.nav.model.JcrNode)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)2 JcrContentContentProvider (org.apache.sling.ide.eclipse.ui.nav.JcrContentContentProvider)2 IFolder (org.eclipse.core.resources.IFolder)2 IProject (org.eclipse.core.resources.IProject)2 Point (org.eclipse.swt.graphics.Point)2 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 UpdateHandler (org.apache.sling.ide.eclipse.ui.nav.model.UpdateHandler)1 ProjectAdapter (org.apache.sling.ide.test.impl.helpers.ProjectAdapter)1 ServerAdapter (org.apache.sling.ide.test.impl.helpers.ServerAdapter)1 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)1 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)1 CellLabelProvider (org.eclipse.jface.viewers.CellLabelProvider)1 CellNavigationStrategy (org.eclipse.jface.viewers.CellNavigationStrategy)1