Workbench: added hook for custom TCK tests and reports
git-svn-id: https://svn.apache.org/repos/asf/chemistry/opencmis/trunk@1754912 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractTckRunnerConfigurator.java b/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractTckRunnerConfigurator.java
new file mode 100644
index 0000000..d7ceba8
--- /dev/null
+++ b/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractTckRunnerConfigurator.java
@@ -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) {
+ }
+}
diff --git a/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java b/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
index 0d136f8..d2e6ece 100644
--- a/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
+++ b/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
@@ -36,6 +36,7 @@
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 @@
*/
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 @@
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 @@
@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 @@
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);