You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2015/10/13 14:10:43 UTC

svn commit: r1708364 - in /sling/trunk/tooling/ide/eclipse-test: META-INF/MANIFEST.MF src/org/apache/sling/ide/test/impl/sightly/ src/org/apache/sling/ide/test/impl/sightly/SightlyNatureTest.java

Author: rombert
Date: Tue Oct 13 12:10:43 2015
New Revision: 1708364

URL: http://svn.apache.org/viewvc?rev=1708364&view=rev
Log:
SLING-4189 - Add basic code completion for Sightly 

Added tests for validation markers when the Sightly nature is enabled.

Added:
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/sightly/
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/sightly/SightlyNatureTest.java
Modified:
    sling/trunk/tooling/ide/eclipse-test/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=1708364&r1=1708363&r2=1708364&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/META-INF/MANIFEST.MF (original)
+++ sling/trunk/tooling/ide/eclipse-test/META-INF/MANIFEST.MF Tue Oct 13 12:10:43 2015
@@ -13,6 +13,7 @@ Require-Bundle: org.junit,
  org.eclipse.wst.server.core,
  org.apache.sling.ide.eclipse-core,
  org.apache.sling.ide.eclipse-ui,
+ org.apache.sling.ide.eclipse-sightly-core,
  org.apache.sling.ide.api,
  org.apache.sling.ide.artifacts,
  org.eclipse.debug.core,
@@ -27,6 +28,7 @@ Import-Package: javax.jcr,
  javax.jcr.nodetype,
  org.apache.jackrabbit.util,
  org.apache.sling.ide.jcr,
+ org.eclipse.wst.validation,
  org.osgi.service.event;version="1.3.0"
 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/sightly/SightlyNatureTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/sightly/SightlyNatureTest.java?rev=1708364&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/sightly/SightlyNatureTest.java (added)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/sightly/SightlyNatureTest.java Tue Oct 13 12:10:43 2015
@@ -0,0 +1,80 @@
+/*
+ * 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.sightly;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import java.io.ByteArrayInputStream;
+
+import org.apache.sling.ide.test.impl.helpers.ProjectAdapter;
+import org.apache.sling.ide.test.impl.helpers.TemporaryProject;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.validation.ValidationFramework;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class SightlyNatureTest {
+
+    @Rule
+    public TemporaryProject projectRule = new TemporaryProject();
+    
+    @Test
+    public void slyTagDoesNotCreateProblemMarker() throws Exception {
+
+        testValidationMarkers(false);
+    }
+    
+    private void testValidationMarkers(boolean invalidTag) throws Exception {
+        
+        final IProject project = projectRule.getProject();
+        
+        // create faceted project
+        ProjectAdapter projectAdapter = new ProjectAdapter(project);
+        projectAdapter.addNatures("org.eclipse.wst.common.project.facet.core.nature");
+        projectAdapter.installFacet("sling.content", "1.0");
+        projectAdapter.installFacet("sightly", "1.1");
+        
+        final IPath sightlyTemplatePath = Path.fromPortableString("/jcr_root/libs/my/component/html.html");
+        String tagName = invalidTag ? "invalid-tag" : "sly";
+        projectAdapter.createOrUpdateFile(sightlyTemplatePath, new ByteArrayInputStream(("<" + tagName + " />").getBytes()));
+        
+        ValidationFramework.getDefault().join(new NullProgressMonitor());
+        
+        IMarker[] markers = project.findMember(sightlyTemplatePath).findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO);
+        
+        if ( invalidTag ) {
+            assertThat("markers.length", markers.length, equalTo(1));
+            // might be overspecifying
+            assertThat(markers[0].getAttribute(IMarker.MESSAGE, ""), equalTo("Unknown tag (invalid-tag)."));
+        } else {
+            assertThat("markers.length", markers.length, equalTo(0));
+        }
+        
+    }
+
+    @Test
+    public void invalidTagDoesCreatesProblemMarker() throws Exception {
+        
+        testValidationMarkers(false);
+    }
+}