Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Struckmann2015-06-03 08:37:10 +0000
committerSebastian Struckmann2015-06-03 08:38:03 +0000
commit3015443c5b8f5dc40357955f5688d647425a170a (patch)
tree6aa3779bc1306d35a090a9d9ccb60553febc1a3d /org.eclipse.jubula.client.toolkit.ui
parent2723b19cc65262539e68e2bcaffa037acf0eee38 (diff)
downloadorg.eclipse.jubula.core-3015443c5b8f5dc40357955f5688d647425a170a.tar.gz
org.eclipse.jubula.core-3015443c5b8f5dc40357955f5688d647425a170a.tar.xz
org.eclipse.jubula.core-3015443c5b8f5dc40357955f5688d647425a170a.zip
Sprint task - Provide a mechanism to compare all possible CAPs from a toolkit with actually executed CAPs
Diffstat (limited to 'org.eclipse.jubula.client.toolkit.ui')
-rw-r--r--org.eclipse.jubula.client.toolkit.ui/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.jubula.client.toolkit.ui/compare.xml133
-rw-r--r--org.eclipse.jubula.client.toolkit.ui/plugin.xml38
-rw-r--r--org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/ComponentActionPair.java60
-rw-r--r--org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/ExportActionsHandler.java114
-rw-r--r--org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/view/ToolkitOverView.java12
6 files changed, 349 insertions, 9 deletions
diff --git a/org.eclipse.jubula.client.toolkit.ui/META-INF/MANIFEST.MF b/org.eclipse.jubula.client.toolkit.ui/META-INF/MANIFEST.MF
index ecd334137..0dbd266b7 100644
--- a/org.eclipse.jubula.client.toolkit.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.jubula.client.toolkit.ui/META-INF/MANIFEST.MF
@@ -8,6 +8,7 @@ Bundle-Vendor: Eclipse Jubula
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.7.0,4.0.0)",
+ org.apache.commons.io;bundle-version="[2.0.0,3.0.0)",
org.eclipse.jubula.tools;bundle-version="[3.1.0,3.2.0)",
org.eclipse.jubula.toolkit.common;bundle-version="[3.1.0,3.2.0)",
org.eclipse.jubula.client.ui;bundle-version="[3.1.0,3.2.0)",
diff --git a/org.eclipse.jubula.client.toolkit.ui/compare.xml b/org.eclipse.jubula.client.toolkit.ui/compare.xml
new file mode 100644
index 000000000..0357ad4c8
--- /dev/null
+++ b/org.eclipse.jubula.client.toolkit.ui/compare.xml
@@ -0,0 +1,133 @@
+<!--
+ Copyright (c) 2015 BREDEX GmbH.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+ -->
+<project name="org.eclipse.jubula.client.toolkit.ui" default="run" basedir="."
+ xmlns:if="ant:if" xmlns:unless="ant:unless">
+
+ <target name="run">
+ <antcall target="compareAll">
+
+ <param name="expectedBase"
+ value="CAPs/expected"/>
+
+ <param name="executedBase"
+ value="/projects/guidancer/Workspace/hu_snapshot/current/Testenvironment/testresults"/>
+
+ <param name="target"
+ value="CAPs"/>
+
+ <param name="ignoreCommon"
+ value="true"/>
+
+ </antcall>
+ </target>
+
+ <target name="compareAll">
+ <fail unless="expectedBase" message="You have to specify where the lists of expected CAPs are located"/>
+ <fail unless="executedBase" message="You have to specify where the log files of executed CAPs are located"/>
+ <fail unless="target" message="You have to specify the target directory for creating the diffs"/>
+ <fail unless="ignoreCommon" message="You have to specify whether you want common CAPs from log and expectation in the diffs"/>
+
+ <property name="targetExecuted" value="${target}/executed"/>
+ <property name="targetDiff" value="${target}/diff"/>
+ <mkdir dir="${targetExecuted}"/>
+ <mkdir dir="${targetDiff}"/>
+ <script language="javascript">
+ <![CDATA[
+ var toolkits = ["javafx", "swing", "swt", "html"];
+ var platforms = ["GDWIN81", "GDWIN7", "gdcentos"];
+ for (var i = 0; i < toolkits.length; i++) {
+ var tk = toolkits[i];
+ var expectedCAPs = expectedBase + "/" + tk + "_expectedCAPs.txt";
+
+ sortExpectedTask = project.createTask("antcall");
+ sortExpectedTask.init();
+ sortExpectedTask.setTarget("sort");
+
+ sortExpectedTaskParam1 = sortExpectedTask.createParam();
+ sortExpectedTaskParam1.setName("unsorted");
+ sortExpectedTaskParam1.setValue(expectedCAPs);
+
+ sortExpectedTaskParam2 = sortExpectedTask.createParam();
+ sortExpectedTaskParam2.setName("sorted");
+ sortExpectedTaskParam2.setValue(expectedCAPs + ".tmp");
+
+ sortExpectedTask.execute();
+
+ for (var j = 0; j < platforms.length; j++) {
+ var pf = platforms[j];
+
+ sortTask = project.createTask("antcall");
+ sortTask.init();
+ sortTask.setTarget("sort");
+
+ sortTaskParam1 = sortTask.createParam();
+ sortTaskParam1.setName("unsorted");
+ sortTaskParam1.setValue(executedBase + "/" + pf + "/logs/rc_" + tk + "_ExecutedCaps.log");
+
+ var sortTarget = targetExecuted + "/rc_" + tk + "_" + pf + "_executedCAPs.log";
+
+ sortTaskParam2 = sortTask.createParam();
+ sortTaskParam2.setName("sorted");
+ sortTaskParam2.setValue(sortTarget);
+
+ sortTask.execute();
+
+ diffTask = project.createTask("antcall");
+ diffTask.init();
+ diffTask.setTarget("compareCAPs");
+
+ diffTaskParam1 = diffTask.createParam();
+ diffTaskParam1.setName("expected");
+ diffTaskParam1.setValue(expectedCAPs + ".tmp");
+
+ diffTaskParam2 = diffTask.createParam();
+ diffTaskParam2.setName("executed");
+ diffTaskParam2.setValue(sortTarget);
+
+ diffTaskParam3 = diffTask.createParam();
+ diffTaskParam3.setName("output");
+ diffTaskParam3.setValue(targetDiff + "/rc_" + tk + "_" + pf + ".log");
+
+ diffTask.execute();
+ }
+ }
+ ]]>
+ </script>
+ </target>
+
+ <target name="compareCAPs">
+ <fail unless="expected" />
+ <fail unless="executed" />
+ <fail unless="output" />
+ <echo message="Compare ${expected}" />
+ <echo message="with ${executed}" />
+ <exec executable="sdiff" output="${output}">
+ <arg value="-bBW"/>
+ <arg value="-s" if:true="${ignoreCommon}"/>
+ <arg value="-w"/>
+ <arg value="250"/>
+ <arg value="${expected}"/>
+ <arg value="${executed}"/>
+ </exec>
+ </target>
+
+ <target name="sort">
+ <fail unless="unsorted" />
+ <fail unless="sorted" />
+ <echo message="Sort ${unsorted}" />
+ <echo message="to ${sorted}" />
+ <property name="tmp.cmd" value="sort.sh" />
+ <echo message="cat ${unsorted} | sort -f -b -i | uniq > ${sorted}" file="${tmp.cmd}" append="false"/>
+ <exec executable="chmod">
+ <arg value="+x"/>
+ <arg value="${tmp.cmd}"/>
+ </exec>
+ <exec executable="${tmp.cmd}" />
+ <delete file="${tmp.cmd}" />
+ </target>
+</project> \ No newline at end of file
diff --git a/org.eclipse.jubula.client.toolkit.ui/plugin.xml b/org.eclipse.jubula.client.toolkit.ui/plugin.xml
index a05aff162..219127255 100644
--- a/org.eclipse.jubula.client.toolkit.ui/plugin.xml
+++ b/org.eclipse.jubula.client.toolkit.ui/plugin.xml
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
- <extension
- point="org.eclipse.ui.views">
+ <extension point="org.eclipse.ui.views">
<view
allowMultiple="true"
category="org.eclipse.jubula.client.views"
@@ -12,5 +11,38 @@
restorable="true">
</view>
</extension>
-
+
+ <extension point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.eclipse.jubula.client.ui.rcp.commands"
+ id="org.eclipse.jubula.client.ui.rcp.commands.ExportActionsCommand"
+ name="Export Actions"
+ description="Export list of supported actions to file">
+ </command>
+ </extension>
+
+ <extension point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="toolbar:org.eclipse.jubula.client.toolkit.ui.overView?after=additions">
+ <command
+ commandId="org.eclipse.jubula.client.ui.rcp.commands.ExportActionsCommand"
+ style="push">
+ </command>
+ </menuContribution>
+ </extension>
+
+ <extension point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.jubula.client.toolkit.ui.ExportActionsHandler"
+ commandId="org.eclipse.jubula.client.ui.rcp.commands.ExportActionsCommand">
+ </handler>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.commandImages">
+ <image
+ commandId="org.eclipse.jubula.client.ui.rcp.commands.ExportActionsCommand"
+ icon="platform:/plugin/org.eclipse.jubula.client.ui/icons/saveAsNew.gif">
+ </image>
+ </extension>
</plugin>
diff --git a/org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/ComponentActionPair.java b/org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/ComponentActionPair.java
new file mode 100644
index 000000000..f09bf6eb6
--- /dev/null
+++ b/org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/ComponentActionPair.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2015 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.toolkit.ui;
+
+
+/** @author BREDEX GmbH */
+public class ComponentActionPair implements Comparable<ComponentActionPair> {
+
+ /** component */
+ private String m_component;
+
+ /** action */
+ private String m_action;
+
+ /**
+ * @param component the component
+ * @param action the action
+ */
+ public ComponentActionPair(String component, String action) {
+ m_component = component;
+ m_action = action;
+ }
+
+ /**
+ * @return the component
+ */
+ public String getComponent() {
+ return m_component;
+ }
+
+ /**
+ * @return the action
+ */
+ public String getAction() {
+ return m_action;
+ }
+
+ @Override
+ public int compareTo(ComponentActionPair o) {
+ int componentComparison = m_component.toLowerCase().compareTo(
+ o.getComponent().toLowerCase());
+ return componentComparison != 0
+ ? componentComparison
+ : m_action.toLowerCase().compareTo(
+ o.getAction().toLowerCase());
+ }
+
+ @Override
+ public String toString() {
+ return m_component + " - " + m_action; //$NON-NLS-1$
+ }
+}
diff --git a/org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/ExportActionsHandler.java b/org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/ExportActionsHandler.java
new file mode 100644
index 000000000..938309530
--- /dev/null
+++ b/org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/ExportActionsHandler.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2015 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.toolkit.ui;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.apache.commons.io.IOUtils;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jubula.client.ui.handlers.AbstractHandler;
+import org.eclipse.jubula.client.ui.rcp.utils.Utils;
+import org.eclipse.jubula.toolkit.common.xml.businessprocess.ComponentBuilder;
+import org.eclipse.jubula.tools.internal.i18n.CompSystemI18n;
+import org.eclipse.jubula.tools.internal.utils.generator.CompSystemProcessor;
+import org.eclipse.jubula.tools.internal.utils.generator.ComponentInfo;
+import org.eclipse.jubula.tools.internal.utils.generator.ToolkitInfo;
+import org.eclipse.jubula.tools.internal.xml.businessmodell.Action;
+import org.eclipse.jubula.tools.internal.xml.businessmodell.Component;
+import org.eclipse.jubula.tools.internal.xml.businessmodell.ConcreteComponent;
+import org.eclipse.swt.widgets.DirectoryDialog;
+
+/**
+ * Generates list of supported actions from comp system
+ */
+public class ExportActionsHandler extends AbstractHandler {
+
+ @Override
+ protected Object executeImpl(ExecutionEvent event) {
+ DirectoryDialog dialog = new DirectoryDialog(getActiveShell());
+ dialog.setFilterPath(Utils.getLastDirPath());
+ String targetDir = dialog.open();
+ if (targetDir != null) {
+ Utils.storeLastDirPath(dialog.getFilterPath());
+ CompSystemProcessor processor = new CompSystemProcessor(
+ ComponentBuilder.getInstance().getCompSystem());
+
+ List<ToolkitInfo> toolkitInfos = processor.getToolkitInfos();
+
+ for (ToolkitInfo tkInfo : toolkitInfos) {
+ // Generate classes and interfaces toolkit by toolkit
+ SortedSet<ComponentActionPair> list =
+ new TreeSet<ComponentActionPair>();
+ String tkName = tkInfo.getShortType();
+ List<ComponentInfo> compInfos = processor.getCompInfos(
+ tkInfo.getType(), tkName, false);
+ for (ComponentInfo compInfo : compInfos) {
+ Component component = compInfo.getComponent();
+ if (!component.isConcrete()
+ || ((ConcreteComponent)component).getTesterClass()
+ == null) {
+ continue;
+ }
+ for (Action action : component.getActions()) {
+ list.add(new ComponentActionPair(component.getType(),
+ CompSystemI18n.getString(action.getName())));
+ }
+ }
+ writeListToFile(targetDir, list, tkName);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param dirPath path to directory
+ * @param list list of component action pairs
+ * @param tkName toolkitname
+ */
+ private static void writeListToFile(String dirPath,
+ SortedSet<ComponentActionPair> list, String tkName) {
+ StringBuffer content = new StringBuffer();
+ for (ComponentActionPair pair : list) {
+ content.append(pair.toString() + "\n"); //$NON-NLS-1$
+ }
+ File dir = new File(dirPath);
+ File file = new File(dirPath + "/" + tkName.toLowerCase() //$NON-NLS-1$
+ + "_expectedCAPs.txt"); //$NON-NLS-1$
+ createFile(dir, file, content.toString());
+ }
+
+ /** creates a file with given content in a given directory
+ * @param dir the directory
+ * @param file the file
+ * @param content the content
+ */
+ private static void createFile(File dir, File file, String content) {
+ try {
+ dir.mkdirs();
+ file.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ try (FileOutputStream fop = new FileOutputStream(file)) {
+ byte[] contentInBytes = content.getBytes();
+ IOUtils.write(contentInBytes, fop);
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/view/ToolkitOverView.java b/org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/view/ToolkitOverView.java
index 2467bf657..07ccfd0b0 100644
--- a/org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/view/ToolkitOverView.java
+++ b/org.eclipse.jubula.client.toolkit.ui/src/org/eclipse/jubula/client/toolkit/ui/view/ToolkitOverView.java
@@ -61,7 +61,7 @@ public class ToolkitOverView extends ViewPart {
final ToolkitDescriptor parentDescriptor = COMP_SYSTEM
.getToolkitDescriptor(parent);
if (parentDescriptor != null) {
- sb.append(" --> ");
+ sb.append(" --> "); //$NON-NLS-1$
sb.append(parentDescriptor.getName());
}
}
@@ -77,7 +77,7 @@ public class ToolkitOverView extends ViewPart {
final String componentClass =
concreteComponent.getComponentClass().getName();
if (!StringUtils.isBlank(componentClass)) {
- sb.append(" - ");
+ sb.append(" - "); //$NON-NLS-1$
sb.append(componentClass);
}
}
@@ -99,20 +99,20 @@ public class ToolkitOverView extends ViewPart {
Param param = (Param) element;
StringBuilder sb = new StringBuilder();
sb.append(CompSystemI18n.getString(param.getType()));
- sb.append(" : ");
+ sb.append(" : "); //$NON-NLS-1$
sb.append(sh.get(param.getName(), true));
if (param.hasValueSet()) {
- sb.append(" [");
+ sb.append(" ["); //$NON-NLS-1$
ParamValueSet valueSet = param.getValueSet();
Iterator<ValueSetElement> iterator = valueSet.iterator();
while (iterator.hasNext()) {
sb.append(CompSystemI18n.getString(iterator.next()
.getValue(), true));
if (iterator.hasNext()) {
- sb.append(", ");
+ sb.append(", "); //$NON-NLS-1$
}
}
- sb.append("]");
+ sb.append("]"); //$NON-NLS-1$
}
String description = param.getDescriptionKey();
if (description != null) {

Back to the top