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/02/18 23:23:51 UTC

svn commit: r1660750 - in /sling/trunk/tooling/ide: api/src/org/apache/sling/ide/osgi/impl/ api/src/org/apache/sling/ide/transport/ eclipse-test/src/org/apache/sling/ide/test/impl/ eclipse-test/src/org/apache/sling/ide/test/impl/helpers/ impl-vlt/src/o...

Author: rombert
Date: Wed Feb 18 22:23:50 2015
New Revision: 1660750

URL: http://svn.apache.org/r1660750
Log:
SLING-3783 - Capture command-related Events during test execution

Create a FailOnUnsuccessfulEventsRule and add it to all relevant
integration tests.

Added:
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/FailOnUnsuccessfulEventsRule.java
Modified:
    sling/trunk/tooling/ide/api/src/org/apache/sling/ide/osgi/impl/TracingOsgiClient.java
    sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/CommandExecutionProperties.java
    sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/TracingCommand.java
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/BundleDeploymentTest.java
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentImportTest.java
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrFullCoverageAggregatesDeploymentTest.java
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java
    sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/ListTreeCommand.java

Modified: sling/trunk/tooling/ide/api/src/org/apache/sling/ide/osgi/impl/TracingOsgiClient.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/api/src/org/apache/sling/ide/osgi/impl/TracingOsgiClient.java?rev=1660750&r1=1660749&r2=1660750&view=diff
==============================================================================
--- sling/trunk/tooling/ide/api/src/org/apache/sling/ide/osgi/impl/TracingOsgiClient.java (original)
+++ sling/trunk/tooling/ide/api/src/org/apache/sling/ide/osgi/impl/TracingOsgiClient.java Wed Feb 18 22:23:50 2015
@@ -75,8 +75,10 @@ public class TracingOsgiClient implement
                 osgiClient.installLocalBundle(explodedBundleLocation);
             }
             props.put(CommandExecutionProperties.RESULT_TEXT, "OK");
+            props.put(CommandExecutionProperties.RESULT_STATUS, Boolean.TRUE);
         } catch (Throwable t) {
             props.put(CommandExecutionProperties.RESULT_TEXT, "FAILED");
+            props.put(CommandExecutionProperties.RESULT_STATUS, Boolean.FALSE);
             props.put(CommandExecutionProperties.RESULT_THROWABLE, t);
             if (t instanceof OsgiClientException) {
                 throw (OsgiClientException) t;

Modified: sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/CommandExecutionProperties.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/CommandExecutionProperties.java?rev=1660750&r1=1660749&r2=1660750&view=diff
==============================================================================
--- sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/CommandExecutionProperties.java (original)
+++ sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/CommandExecutionProperties.java Wed Feb 18 22:23:50 2015
@@ -28,6 +28,7 @@ public final class CommandExecutionPrope
     public static final String ACTION_FLAGS = "action.flags";
     public static final String ACTION_TARGET = "action.target";
     public static final String RESULT_TEXT = "result.txt";
+    public static final String RESULT_STATUS = "result.status";
     public static final String RESULT_THROWABLE = "result.throwable";
 
     private CommandExecutionProperties() {

Modified: sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/TracingCommand.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/TracingCommand.java?rev=1660750&r1=1660749&r2=1660750&view=diff
==============================================================================
--- sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/TracingCommand.java (original)
+++ sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/TracingCommand.java Wed Feb 18 22:23:50 2015
@@ -48,6 +48,7 @@ public class TracingCommand<T> implement
         if (eventAdmin != null) {
             Map<String, Object> props = new HashMap<String, Object>();
             props.put(CommandExecutionProperties.RESULT_TEXT, result.toString());
+            props.put(CommandExecutionProperties.RESULT_STATUS, result.isSuccess());
             try {
                 result.get();
             } catch (RepositoryException e) {

Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/BundleDeploymentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/BundleDeploymentTest.java?rev=1660750&r1=1660749&r2=1660750&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/BundleDeploymentTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/BundleDeploymentTest.java Wed Feb 18 22:23:50 2015
@@ -26,6 +26,7 @@ import org.apache.commons.httpclient.Htt
 import org.apache.sling.ide.eclipse.core.ISlingLaunchpadServer;
 import org.apache.sling.ide.test.impl.helpers.DisableDebugStatusHandlers;
 import org.apache.sling.ide.test.impl.helpers.ExternalSlingLaunchpad;
+import org.apache.sling.ide.test.impl.helpers.FailOnUnsuccessfulEventsRule;
 import org.apache.sling.ide.test.impl.helpers.LaunchpadConfig;
 import org.apache.sling.ide.test.impl.helpers.MavenDependency;
 import org.apache.sling.ide.test.impl.helpers.OsgiBundleManifest;
@@ -69,6 +70,9 @@ public class BundleDeploymentTest {
     @Rule
     public DisableDebugStatusHandlers disableDebugHandlers = new DisableDebugStatusHandlers();
 
+    @Rule
+    public FailOnUnsuccessfulEventsRule failOnEventsRule = new FailOnUnsuccessfulEventsRule();
+
     @Test
     public void deployBundleOnServer_localInstall() throws Exception {
 

Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java?rev=1660750&r1=1660749&r2=1660750&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java Wed Feb 18 22:23:50 2015
@@ -36,6 +36,7 @@ import org.apache.commons.httpclient.Htt
 import org.apache.commons.httpclient.URIException;
 import org.apache.sling.ide.test.impl.helpers.DisableDebugStatusHandlers;
 import org.apache.sling.ide.test.impl.helpers.ExternalSlingLaunchpad;
+import org.apache.sling.ide.test.impl.helpers.FailOnUnsuccessfulEventsRule;
 import org.apache.sling.ide.test.impl.helpers.LaunchpadConfig;
 import org.apache.sling.ide.test.impl.helpers.Poller;
 import org.apache.sling.ide.test.impl.helpers.ProjectAdapter;
@@ -72,6 +73,9 @@ public class ContentDeploymentTest {
     public TemporaryProject projectRule = new TemporaryProject();
 
     @Rule
+    public FailOnUnsuccessfulEventsRule failOnEventsRule = new FailOnUnsuccessfulEventsRule();
+
+    @Rule
     public DisableDebugStatusHandlers disableDebugHandlers = new DisableDebugStatusHandlers();
 
     @Test

Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentImportTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentImportTest.java?rev=1660750&r1=1660749&r2=1660750&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentImportTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentImportTest.java Wed Feb 18 22:23:50 2015
@@ -37,6 +37,7 @@ import org.apache.sling.ide.serializatio
 import org.apache.sling.ide.test.impl.helpers.DisableDebugStatusHandlers;
 import org.apache.sling.ide.test.impl.helpers.ExternalSlingLaunchpad;
 import org.apache.sling.ide.test.impl.helpers.FailOnModificationEventsRule;
+import org.apache.sling.ide.test.impl.helpers.FailOnUnsuccessfulEventsRule;
 import org.apache.sling.ide.test.impl.helpers.LaunchpadConfig;
 import org.apache.sling.ide.test.impl.helpers.ProjectAdapter;
 import org.apache.sling.ide.test.impl.helpers.RepositoryAccessor;
@@ -75,6 +76,9 @@ public class ContentImportTest {
     @Rule
     public FailOnModificationEventsRule deh = new FailOnModificationEventsRule();
 
+    @Rule
+    public FailOnUnsuccessfulEventsRule failOnEventsRule = new FailOnUnsuccessfulEventsRule();
+
     @Test
     public void importFilesAndFolders() throws Exception {
 

Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrFullCoverageAggregatesDeploymentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrFullCoverageAggregatesDeploymentTest.java?rev=1660750&r1=1660749&r2=1660750&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrFullCoverageAggregatesDeploymentTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrFullCoverageAggregatesDeploymentTest.java Wed Feb 18 22:23:50 2015
@@ -32,6 +32,7 @@ import javax.jcr.RepositoryException;
 
 import org.apache.sling.ide.test.impl.helpers.DisableDebugStatusHandlers;
 import org.apache.sling.ide.test.impl.helpers.ExternalSlingLaunchpad;
+import org.apache.sling.ide.test.impl.helpers.FailOnUnsuccessfulEventsRule;
 import org.apache.sling.ide.test.impl.helpers.LaunchpadConfig;
 import org.apache.sling.ide.test.impl.helpers.Poller;
 import org.apache.sling.ide.test.impl.helpers.ProjectAdapter;
@@ -70,6 +71,9 @@ public class JcrFullCoverageAggregatesDe
     @Rule
     public DisableDebugStatusHandlers disableDebugHandlers = new DisableDebugStatusHandlers();
 
+    @Rule
+    public FailOnUnsuccessfulEventsRule failOnEventsRule = new FailOnUnsuccessfulEventsRule();
+
     @Test
     public void deployNestedFullCoverageAggregate() throws Exception {
 

Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java?rev=1660750&r1=1660749&r2=1660750&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java Wed Feb 18 22:23:50 2015
@@ -32,6 +32,7 @@ import javax.jcr.RepositoryException;
 
 import org.apache.sling.ide.test.impl.helpers.DisableDebugStatusHandlers;
 import org.apache.sling.ide.test.impl.helpers.ExternalSlingLaunchpad;
+import org.apache.sling.ide.test.impl.helpers.FailOnUnsuccessfulEventsRule;
 import org.apache.sling.ide.test.impl.helpers.LaunchpadConfig;
 import org.apache.sling.ide.test.impl.helpers.Poller;
 import org.apache.sling.ide.test.impl.helpers.ProjectAdapter;
@@ -70,6 +71,9 @@ public class JcrPartialCoverageAggregate
     @Rule
     public DisableDebugStatusHandlers disableDebugHandlers = new DisableDebugStatusHandlers();
 
+    @Rule
+    public FailOnUnsuccessfulEventsRule failOnEventsRule = new FailOnUnsuccessfulEventsRule();
+
     @Test
     public void deploySlingFolder() throws Exception {
 

Added: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/FailOnUnsuccessfulEventsRule.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/FailOnUnsuccessfulEventsRule.java?rev=1660750&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/FailOnUnsuccessfulEventsRule.java (added)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/FailOnUnsuccessfulEventsRule.java Wed Feb 18 22:23:50 2015
@@ -0,0 +1,35 @@
+/*
+ * 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.helpers;
+
+import org.apache.sling.ide.transport.CommandExecutionProperties;
+import org.osgi.service.event.Event;
+
+/**
+ * The <tt>FailOnUnsuccessfulEventsRule</tt> fails the test if an unsuccesful event was found
+ *
+ */
+public class FailOnUnsuccessfulEventsRule extends AbstractFailOnUnexpectedEventsRule {
+
+    @Override
+    public void handleEvent(Event event) {
+        Boolean status = (Boolean) event.getProperty(CommandExecutionProperties.RESULT_STATUS);
+        if (!status) {
+            addUnexpectedEvent(event);
+        }
+    }
+}

Modified: sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/ListTreeCommand.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/ListTreeCommand.java?rev=1660750&r1=1660749&r2=1660750&view=diff
==============================================================================
--- sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/ListTreeCommand.java (original)
+++ sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/ListTreeCommand.java Wed Feb 18 22:23:50 2015
@@ -85,6 +85,7 @@ public class ListTreeCommand extends Jcr
     private void log(String text, long start, long end) {
         Map<String, Object> props = new HashMap<String, Object>();
         props.put(CommandExecutionProperties.RESULT_TEXT, text);
+        props.put(CommandExecutionProperties.RESULT_STATUS, Boolean.TRUE);
         props.put(CommandExecutionProperties.ACTION_TYPE, getClass().getSimpleName());
         props.put(CommandExecutionProperties.ACTION_TARGET, getPath());
         props.put(CommandExecutionProperties.TIMESTAMP_START, start);