Author: rombert
Date: Wed Oct 1 15:20:18 2014
New Revision: 1628733
URL: http://svn.apache.org/r1628733
Log:
SLING-3988- Content Navigator does not show nodes with escaped names
Added some test cases for the JcrContentContentProvider
- 1 basic test for navigating a nested content structure
- 1 test which demonstrates the problem scenario for this bug, currently
@Ignored
Added:
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrContentContentProviderTest.java
Modified:
sling/trunk/tooling/ide/eclipse-test/META-INF/MANIFEST.MF
sling/trunk/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF
Modified: sling/trunk/tooling/ide/eclipse-test/META-INF/MANIFEST.MF
URL:
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/META-INF/MANIFEST.MF?rev=1628733&r1=1628732&r2=1628733&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/META-INF/MANIFEST.MF (original)
+++ sling/trunk/tooling/ide/eclipse-test/META-INF/MANIFEST.MF Wed Oct 1
15:20:18 2014
@@ -12,6 +12,7 @@ Require-Bundle: org.junit,
org.eclipse.jdt.launching,
org.eclipse.wst.server.core,
org.apache.sling.ide.eclipse-core,
+ org.apache.sling.ide.eclipse-ui,
org.apache.sling.ide.api,
org.apache.sling.ide.artifacts,
org.eclipse.debug.core,
@@ -25,8 +26,6 @@ Require-Bundle: org.junit,
Import-Package: javax.jcr,
javax.jcr.nodetype,
org.apache.jackrabbit.util,
- org.apache.sling.ide.eclipse.core.internal,
- org.apache.sling.ide.eclipse.ui.internal,
org.apache.sling.ide.jcr
Bundle-Activator: org.apache.sling.ide.test.impl.Activator
Bundle-ActivationPolicy: lazy
Added:
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrContentContentProviderTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrContentContentProviderTest.java?rev=1628733&view=auto
==============================================================================
---
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrContentContentProviderTest.java
(added)
+++
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrContentContentProviderTest.java
Wed Oct 1 15:20:18 2014
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.ide.test.impl;
+
+import static org.junit.Assert.assertThat;
+
+import java.io.InputStream;
+
+import org.apache.sling.ide.eclipse.ui.nav.JcrContentContentProvider;
+import org.apache.sling.ide.eclipse.ui.nav.model.JcrNode;
+import org.apache.sling.ide.eclipse.ui.nav.model.SyncDir;
+import org.apache.sling.ide.test.impl.helpers.DisableDebugStatusHandlers;
+import org.apache.sling.ide.test.impl.helpers.ProjectAdapter;
+import org.apache.sling.ide.test.impl.helpers.TemporaryProject;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Path;
+import org.hamcrest.CoreMatchers;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class JcrContentContentProviderTest {
+
+ @Rule
+ public TemporaryProject projectRule = new TemporaryProject();
+
+ @Rule
+ public DisableDebugStatusHandlers disableDebugHandlers = new
DisableDebugStatusHandlers();
+
+ @Test
+ public void listChildrenInNestedStructure() throws Exception {
+
+ // 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 .content.xml structure
+ InputStream contentXml =
getClass().getResourceAsStream("content-nested-structure.xml");
+
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en.xml"),
contentXml);
+
+ // instantiate the content provider
+ JcrContentContentProvider contentProvider = new
JcrContentContentProvider();
+
+ // directly create the root node
+ SyncDir syncDirNode = new SyncDir((IFolder)
contentProject.findMember("jcr_root"));
+
+ // test children of '/'
+ Object[] children = contentProvider.getChildren(syncDirNode);
+ assertChildrenHavePaths(children, "/content");
+
+ // test children of '/content'
+ JcrNode contentNode = (JcrNode) children[0];
+ Object[] children2 = contentProvider.getChildren(contentNode);
+ assertChildrenHavePaths(children2, "/content/test-root");
+
+ // test children of '/content/test-root'
+ JcrNode testRootNode = (JcrNode) children2[0];
+ Object[] children3 = contentProvider.getChildren(testRootNode);
+ assertChildrenHavePaths(children3, "/content/test-root/en");
+
+ // test children of '/content/test-root/en'
+ JcrNode enNode = (JcrNode) children3[0];
+ Object[] children4 = contentProvider.getChildren(enNode);
+ assertChildrenHavePaths(children4, "/content/test-root/en/message",
"/content/test-root/en/error",
+ "/content/test-root/en/warning");
+
+ // test children of '/content/test-root/en/message'
+ JcrNode messageNode = (JcrNode) children4[0];
+ Object[] children5 = contentProvider.getChildren(messageNode);
+ assertChildrenHavePaths(children5); // no children
+ }
+
+ @Test
+ @Ignore("SLING-3988")
+ public void listChildrenWithNestedContentXmlInEscapedDir() throws
Exception {
+
+ // 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 .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"));
+
+ // instantiate the content provider
+ JcrContentContentProvider contentProvider = new
JcrContentContentProvider();
+
+ // directly create the root node
+ SyncDir syncDirNode = new SyncDir((IFolder)
contentProject.findMember("jcr_root"));
+
+ // test children of '/'
+ Object[] children = contentProvider.getChildren(syncDirNode);
+ assertChildrenHavePaths(children, "/content");
+
+ // test children of '/content'
+ JcrNode contentNode = (JcrNode) children[0];
+ Object[] children2 = contentProvider.getChildren(contentNode);
+ assertChildrenHavePaths(children2, "/content/sling:stuff");
+
+ }
+
+ private void assertChildrenHavePaths(Object[] children, String... paths) {
+ assertThat("Unexpected number of children found", children.length,
CoreMatchers.equalTo(paths.length));
+ for (int i = 0; i < children.length; i++) {
+
+ Object child = children[i];
+ assertThat("Unexpected type of child", child,
CoreMatchers.instanceOf(JcrNode.class));
+
+ JcrNode node = (JcrNode) child;
+ assertThat("Unexpected path for child at index " + i,
node.getJcrPath(), CoreMatchers.equalTo(paths[i]));
+ }
+ }
+
+}
Modified: sling/trunk/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF
URL:
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF?rev=1628733&r1=1628732&r2=1628733&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF (original)
+++ sling/trunk/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF Wed Oct 1 15:20:18
2014
@@ -89,8 +89,11 @@ Require-Bundle: org.eclipse.wst.common.p
org.eclipse.ui.editors,
org.eclipse.swt
Service-Component: OSGI-INF/*.xml
-Export-Package: org.apache.sling.ide.eclipse.ui,org.apache.sling.ide.e
- clipse.ui.console,org.apache.sling.ide.eclipse.ui.internal;x-friends:
- ="org.apache.sling.ide.eclipse-test",org.apache.sling.ide.eclipse.ui.
- propertyPages,org.apache.sling.ide.eclipse.ui.views,org.apache.sling.
- ide.eclipse.ui.wizards
+Export-Package: org.apache.sling.ide.eclipse.ui,
+ org.apache.sling.ide.eclipse.ui.console,
+
org.apache.sling.ide.eclipse.ui.internal;x-friends:="org.apache.sling.ide.eclipse-test",
+
org.apache.sling.ide.eclipse.ui.nav;x-friends:="org.apache.sling.ide.eclipse-test",
+
org.apache.sling.ide.eclipse.ui.nav.model;x-friends:="org.apache.sling.ide.eclipse-test",
+ org.apache.sling.ide.eclipse.ui.propertyPages,
+ org.apache.sling.ide.eclipse.ui.views,
+ org.apache.sling.ide.eclipse.ui.wizards