You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2016/08/02 13:12:57 UTC

svn commit: r1754912 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench: AbstractTckRunnerConfigurator.java TckDialog.java

Author: fmui
Date: Tue Aug  2 13:12:56 2016
New Revision: 1754912

URL: http://svn.apache.org/viewvc?rev=1754912&view=rev
Log:
Workbench: added hook for custom TCK tests and reports

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractTckRunnerConfigurator.java
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java

Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractTckRunnerConfigurator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractTckRunnerConfigurator.java?rev=1754912&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractTckRunnerConfigurator.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractTckRunnerConfigurator.java Tue Aug  2 13:12:56 2016
@@ -0,0 +1,63 @@
+/*
+ * 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.chemistry.opencmis.workbench;
+
+import org.apache.chemistry.opencmis.tck.runner.AbstractRunner;
+
+/**
+ * Abstract TCK runner configurator.
+ * 
+ * To add a runner configurator, derive a class from this class, create a file
+ * {@code META-INF/services/org.apache.chemistry.opencmis.workbench.AbstractTckRunnerConfigurator}
+ * , and put the name of the fully qualified name of your class into this file.
+ */
+public abstract class AbstractTckRunnerConfigurator {
+
+    /**
+     * Called at setup.
+     * 
+     * This method can be used to register custom TCK tests.
+     * 
+     * @param runner
+     *            the TCK runner object
+     */
+    public void configureRunner(AbstractRunner runner) throws Exception {
+        runner.loadDefaultTckGroups();
+    }
+
+    /**
+     * Called before the TCK test is started.
+     * 
+     * @param runner
+     *            the TCK runner object
+     */
+    public void beforeRun(AbstractRunner runner) {
+    }
+
+    /**
+     * Called after the TCK test has finished.
+     * 
+     * This method can be used to create a custom report.
+     * 
+     * @param runner
+     *            the TCK runner object
+     */
+    public void afterRun(AbstractRunner runner) {
+    }
+}

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java?rev=1754912&r1=1754911&r2=1754912&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java Tue Aug  2 13:12:56 2016
@@ -36,6 +36,7 @@ import java.io.Writer;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.ServiceLoader;
 
 import javax.swing.AbstractCellEditor;
 import javax.swing.BorderFactory;
@@ -84,6 +85,9 @@ import org.apache.chemistry.opencmis.wor
  */
 public class TckDialog {
 
+    private static final ServiceLoader<AbstractTckRunnerConfigurator> TCK_RUNNER_SERVICE_LOADER = ServiceLoader
+            .load(AbstractTckRunnerConfigurator.class);
+
     private final Frame owner;
     private final ClientModel model;
     private final TckDialogRunner runner;
@@ -108,7 +112,15 @@ public class TckDialog {
         status.put(CmisTestResultStatus.UNEXPECTED_EXCEPTION, 0);
 
         try {
-            runner.loadDefaultTckGroups();
+            boolean configured = false;
+            for (AbstractTckRunnerConfigurator configurator : TCK_RUNNER_SERVICE_LOADER) {
+                configurator.configureRunner(runner);
+                configured = true;
+            }
+
+            if (!configured) {
+                runner.loadDefaultTckGroups();
+            }
         } catch (Exception e) {
             JOptionPane.showMessageDialog(owner, "Error: " + e.getMessage(), "TCK Error", JOptionPane.ERROR_MESSAGE);
             return;
@@ -707,6 +719,10 @@ public class TckDialog {
 
         @Override
         public Void doInBackground() {
+            for (AbstractTckRunnerConfigurator configurator : TCK_RUNNER_SERVICE_LOADER) {
+                configurator.beforeRun(runner);
+            }
+
             try {
                 runner.run(new DialogProgressMonitor(runner.getGroups().size()));
             } catch (InterruptedException ie) {
@@ -725,6 +741,10 @@ public class TckDialog {
                 runner.cancel();
             }
 
+            for (AbstractTckRunnerConfigurator configurator : TCK_RUNNER_SERVICE_LOADER) {
+                configurator.afterRun(runner);
+            }
+
             try {
                 SwingReport report = new SwingReport(null, 700, 500);
                 report.createReport(runner.getParameters(), runner.getGroups(), (Writer) null);