(no commit message)
authorn.hoffmann <n.hoffmann@localhost>
Fri, 1 Apr 2011 13:17:16 +0000 (13:17 +0000)
committern.hoffmann <n.hoffmann@localhost>
Fri, 1 Apr 2011 13:17:16 +0000 (13:17 +0000)
12 files changed:
.gitattributes
eu.etaxonomy.taxeditor.test/.classpath [new file with mode: 0644]
eu.etaxonomy.taxeditor.test/.project [new file with mode: 0644]
eu.etaxonomy.taxeditor.test/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF [new file with mode: 0644]
eu.etaxonomy.taxeditor.test/build.properties [new file with mode: 0644]
eu.etaxonomy.taxeditor.test/ide/eclipse/EDITor Tests.launch [new file with mode: 0644]
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/AbstractEditorTest.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ClassificationTest.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ContextMenuHelper.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/LoginTest.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.test/src/test/java/log4j.xml [new file with mode: 0644]

index 8223093..11acf97 100644 (file)
@@ -1192,6 +1192,17 @@ eu.etaxonomy.taxeditor.store/src/test/resources/eu/etaxonomy/taxeditor/store/Cdm
 eu.etaxonomy.taxeditor.store/src/test/resources/eu/etaxonomy/taxeditor/store/ConcurrentSessionTest.xml -text
 eu.etaxonomy.taxeditor.store/src/test/resources/log4j.properties -text
 eu.etaxonomy.taxeditor.store/src/test/resources/unitils.properties -text
+eu.etaxonomy.taxeditor.test/.classpath -text
+eu.etaxonomy.taxeditor.test/.project -text
+eu.etaxonomy.taxeditor.test/.settings/org.eclipse.jdt.core.prefs -text
+eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF -text
+eu.etaxonomy.taxeditor.test/build.properties -text
+eu.etaxonomy.taxeditor.test/ide/eclipse/EDITor[!!-~]Tests.launch -text
+eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/AbstractEditorTest.java -text
+eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ClassificationTest.java -text
+eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ContextMenuHelper.java -text
+eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/LoginTest.java -text
+eu.etaxonomy.taxeditor.test/src/test/java/log4j.xml -text
 /pom.xml -text
 src/changes/changes.xml -text
 src/site/apt/download.apt -text
diff --git a/eu.etaxonomy.taxeditor.test/.classpath b/eu.etaxonomy.taxeditor.test/.classpath
new file mode 100644 (file)
index 0000000..0d32042
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src/test/java"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/eu.etaxonomy.taxeditor.test/.project b/eu.etaxonomy.taxeditor.test/.project
new file mode 100644 (file)
index 0000000..ef718ad
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>eu.etaxonomy.taxeditor.test</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/eu.etaxonomy.taxeditor.test/.settings/org.eclipse.jdt.core.prefs b/eu.etaxonomy.taxeditor.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..b61e872
--- /dev/null
@@ -0,0 +1,8 @@
+#Thu Mar 31 16:21:36 CEST 2011\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5\r
+org.eclipse.jdt.core.compiler.compliance=1.5\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.5\r
diff --git a/eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF b/eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..da9867a
--- /dev/null
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: eu.etaxonomy.taxeditor.test
+Bundle-SymbolicName: eu.etaxonomy.taxeditor.test;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor: EDIT
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.apache.log4j;bundle-version="1.2.13",
+ org.eclipse.core.runtime;bundle-version="3.6.0",
+ org.eclipse.swt;bundle-version="3.6.2",
+ org.eclipse.swtbot.eclipse.core;bundle-version="2.0.4",
+ org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.4",
+ org.eclipse.swtbot.junit4_x;bundle-version="2.0.4",
+ org.junit;bundle-version="4.8.1",
+ org.eclipse.ui.ide;bundle-version="3.6.2",
+ org.hamcrest;bundle-version="1.1.0"
diff --git a/eu.etaxonomy.taxeditor.test/build.properties b/eu.etaxonomy.taxeditor.test/build.properties
new file mode 100644 (file)
index 0000000..dbd5f74
--- /dev/null
@@ -0,0 +1,4 @@
+source.. = src_/
+output.. = bin/
+bin.includes = META-INF/,\
+               .
diff --git a/eu.etaxonomy.taxeditor.test/ide/eclipse/EDITor Tests.launch b/eu.etaxonomy.taxeditor.test/ide/eclipse/EDITor Tests.launch
new file mode 100644 (file)
index 0000000..b162532
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<launchConfiguration type="org.eclipse.swtbot.eclipse.ui.launcher.JunitLaunchConfig">\r
+<booleanAttribute key="append.args" value="true"/>\r
+<booleanAttribute key="askclear" value="false"/>\r
+<booleanAttribute key="automaticAdd" value="true"/>\r
+<booleanAttribute key="automaticValidate" value="false"/>\r
+<stringAttribute key="bootstrap" value=""/>\r
+<stringAttribute key="checked" value="[NONE]"/>\r
+<booleanAttribute key="clearConfig" value="true"/>\r
+<booleanAttribute key="clearws" value="true"/>\r
+<booleanAttribute key="clearwslog" value="true"/>\r
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>\r
+<booleanAttribute key="default" value="true"/>\r
+<booleanAttribute key="includeOptional" value="true"/>\r
+<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>\r
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">\r
+<listEntry value="/eu.etaxonomy.taxeditor.test/src/test/java"/>\r
+</listAttribute>\r
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">\r
+<listEntry value="2"/>\r
+</listAttribute>\r
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=eu.etaxonomy.taxeditor.test/src\/test\/java"/>\r
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>\r
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>\r
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>\r
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>\r
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>\r
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="eu.etaxonomy.taxeditor.test"/>\r
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>\r
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.5 -Xms256M -Xmx768M -XX:MaxPermSize=512M"/>\r
+<stringAttribute key="pde.version" value="3.3"/>\r
+<stringAttribute key="product" value="eu.etaxonomy.taxeditor.application.product"/>\r
+<booleanAttribute key="show_selected_only" value="false"/>\r
+<booleanAttribute key="tracing" value="false"/>\r
+<booleanAttribute key="useCustomFeatures" value="false"/>\r
+<booleanAttribute key="useDefaultConfig" value="true"/>\r
+<booleanAttribute key="useDefaultConfigArea" value="false"/>\r
+<booleanAttribute key="useProduct" value="true"/>\r
+</launchConfiguration>\r
diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/AbstractEditorTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/AbstractEditorTest.java
new file mode 100644 (file)
index 0000000..ff28acb
--- /dev/null
@@ -0,0 +1,65 @@
+/**\r
+ * \r
+ */\r
+package eu.etaxonomy.taxeditor.test;\r
+\r
+import java.util.List;\r
+\r
+import org.eclipse.swt.widgets.Tree;\r
+import org.eclipse.swt.widgets.Widget;\r
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;\r
+import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;\r
+import org.eclipse.swtbot.eclipse.finder.waits.Conditions;\r
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;\r
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;\r
+import org.eclipse.swtbot.swt.finder.finders.ChildrenControlFinder;\r
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;\r
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;\r
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;\r
+import org.junit.Before;\r
+import org.junit.runner.RunWith;\r
+\r
+/**\r
+ * @author n.hoffmann\r
+ *\r
+ */\r
+@RunWith(SWTBotJunit4ClassRunner.class)\r
+public abstract class AbstractEditorTest {\r
+       \r
+       protected SWTWorkbenchBot bot;\r
+       \r
+       @Before\r
+       public void setup() {\r
+               bot = new SWTWorkbenchBot();\r
+               SWTBotPreferences.TIMEOUT = 300000;\r
+               \r
+               String activeText = bot.activeShell().getText();\r
+               if(activeText.equals("Connecting to datasource: cdm")){\r
+                       bot.waitUntil(Conditions.shellIsActive("Login"));\r
+                       bot.button("Cancel").click();\r
+               }\r
+       }\r
+\r
+       \r
+       /**\r
+        * @return\r
+        * @throws WidgetNotFoundException\r
+        */\r
+       public SWTBotTree tree(Widget widget) throws WidgetNotFoundException {\r
+               List<Tree> controls = new ChildrenControlFinder(widget).findControls(WidgetMatcherFactory.widgetOfType(Tree.class));\r
+               if (controls.isEmpty())\r
+                       throw new WidgetNotFoundException("Could not find any tree");\r
+               SWTBotTree tree = new SWTBotTree((Tree) controls.get(0));\r
+               return tree;\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws WidgetNotFoundException\r
+        */\r
+       public SWTBotView view(String title) throws WidgetNotFoundException {\r
+               return bot.viewByTitle(title);\r
+       }\r
+       \r
+       \r
+}\r
diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ClassificationTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ClassificationTest.java
new file mode 100644 (file)
index 0000000..3d82661
--- /dev/null
@@ -0,0 +1,29 @@
+/**\r
+ * \r
+ */\r
+package eu.etaxonomy.taxeditor.test;\r
+\r
+import org.eclipse.swtbot.eclipse.finder.waits.Conditions;\r
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;\r
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;\r
+import org.junit.Test;\r
+\r
+/**\r
+ * @author n.hoffmann\r
+ *\r
+ */\r
+public class ClassificationTest extends AbstractEditorTest {\r
+\r
+       @Test\r
+       public void canDeleteClassification() throws Exception {\r
+               SWTBotView navigatorView = view("Taxon Navigator");\r
+               SWTBotTree tree = tree(navigatorView.getWidget());\r
+               tree.select(0);\r
+               \r
+               \r
+//             SWTBotTreeItem treeItem = tree.getTreeItem("TestFolder 01").select();\r
+               ContextMenuHelper.clickContextMenu(tree, "Delete");\r
+               bot.waitUntil(Conditions.shellIsActive("Confirm Deletion"));\r
+               bot.button("OK").click();\r
+       }\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ContextMenuHelper.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ContextMenuHelper.java
new file mode 100644 (file)
index 0000000..37371d0
--- /dev/null
@@ -0,0 +1,106 @@
+package eu.etaxonomy.taxeditor.test;\r
+\r
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;\r
+import static org.hamcrest.Matchers.allOf;\r
+import static org.hamcrest.Matchers.instanceOf;\r
+\r
+import java.util.Arrays;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Menu;\r
+import org.eclipse.swt.widgets.MenuItem;\r
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;\r
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;\r
+import org.eclipse.swtbot.swt.finder.results.VoidResult;\r
+import org.eclipse.swtbot.swt.finder.results.WidgetResult;\r
+import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;\r
+import org.hamcrest.Matcher;\r
+\r
+public class ContextMenuHelper {\r
+\r
+       /**\r
+        * Clicks the context menu matching the text.\r
+        *\r
+        * @param text\r
+        * the text on the context menu.\r
+        * @throws WidgetNotFoundException\r
+        * if the widget is not found.\r
+        */\r
+       public static void clickContextMenu(final AbstractSWTBot<?> bot,\r
+                       final String... texts) {\r
+\r
+               // show\r
+               final MenuItem menuItem = UIThreadRunnable\r
+               .syncExec(new WidgetResult<MenuItem>() {\r
+                       public MenuItem run() {\r
+                               MenuItem menuItem = null;\r
+                               Control control = (Control) bot.widget;\r
+                               Menu menu = control.getMenu();\r
+                               for (String text : texts) {\r
+                                       Matcher<?> matcher = allOf(instanceOf(MenuItem.class),\r
+                                                       withMnemonic(text));\r
+                                       menuItem = show(menu, matcher);\r
+                                       if (menuItem != null) {\r
+                                               menu = menuItem.getMenu();\r
+                                       } else {\r
+                                               hide(menu);\r
+                                               break;\r
+                                       }\r
+                               }\r
+\r
+                               return menuItem;\r
+                       }\r
+               });\r
+               if (menuItem == null) {\r
+                       throw new WidgetNotFoundException("Could not find menu: "\r
+                                       + Arrays.asList(texts));\r
+               }\r
+\r
+               // click\r
+               click(menuItem);\r
+\r
+               // hide\r
+               UIThreadRunnable.syncExec(new VoidResult() {\r
+                       public void run() {\r
+                               hide(menuItem.getParent());\r
+                       }\r
+               });\r
+       }\r
+\r
+       private static MenuItem show(final Menu menu, final Matcher<?> matcher) {\r
+               if (menu != null) {\r
+                       menu.notifyListeners(SWT.Show, new Event());\r
+                       MenuItem[] items = menu.getItems();\r
+                       for (final MenuItem menuItem : items) {\r
+                               if (matcher.matches(menuItem)) {\r
+                                       return menuItem;\r
+                               }\r
+                       }\r
+                       menu.notifyListeners(SWT.Hide, new Event());\r
+               }\r
+               return null;\r
+       }\r
+\r
+       private static void click(final MenuItem menuItem) {\r
+               final Event event = new Event();\r
+               event.time = (int) System.currentTimeMillis();\r
+               event.widget = menuItem;\r
+               event.display = menuItem.getDisplay();\r
+               event.type = SWT.Selection;\r
+\r
+               UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() {\r
+                       public void run() {\r
+                               menuItem.notifyListeners(SWT.Selection, event);\r
+                       }\r
+               });\r
+       }\r
+\r
+       private static void hide(final Menu menu) {\r
+               menu.notifyListeners(SWT.Hide, new Event());\r
+               if (menu.getParentMenu() != null) {\r
+                       hide(menu.getParentMenu());\r
+               }\r
+       }\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/LoginTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/LoginTest.java
new file mode 100644 (file)
index 0000000..e9ac066
--- /dev/null
@@ -0,0 +1,18 @@
+package eu.etaxonomy.taxeditor.test;\r
+\r
+import org.eclipse.swtbot.eclipse.finder.waits.Conditions;\r
+import org.junit.Test;\r
+\r
+\r
+public class LoginTest extends AbstractEditorTest{\r
+               \r
+       @Test\r
+       public void canLoginAsAdmin() throws Exception {\r
+               bot.menu("General").menu("Login").click();\r
+               bot.waitUntil(Conditions.shellIsActive("Login"));\r
+               bot.textWithLabel("Username").setText("admin");\r
+               bot.textWithLabel("Password").setText("0000");\r
+               bot.button("Cancel").click();\r
+       }\r
+       \r
+}\r
diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/log4j.xml b/eu.etaxonomy.taxeditor.test/src/test/java/log4j.xml
new file mode 100644 (file)
index 0000000..ea16d13
--- /dev/null
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
+       debug="false">
+
+       <appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
+               <param name="Target" value="System.out" />
+               <layout class="org.apache.log4j.PatternLayout">
+                       <param name="ConversionPattern"
+                               value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) - %m%n" />
+               </layout>
+       </appender>
+
+       <appender name="fileAppender" class="org.apache.log4j.FileAppender">
+               <param name="File" value="/tmp/debug.log" />
+               <param name="Append" value="false" />
+               <layout class="org.apache.log4j.PatternLayout">
+                       <param name="ConversionPattern"
+                               value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) - %m%n" />
+               </layout>
+       </appender>
+
+       <appender name="asyncAppender" class="org.apache.log4j.AsyncAppender">
+               <!-- appender-ref ref="consoleAppender" / -->
+               <appender-ref ref="fileAppender" />
+       </appender>
+
+       <!-- don't log matchers, this is very high amount of chatter -->
+       <category name="org.eclipse.swtbot.swt.finder.matchers">
+               <priority value="OFF" />
+       </category>
+
+       <!--
+               don't log widget notification events, this is moderately high chatter
+       -->
+       <category name="org.eclipse.swtbot.swt.finder.widgets">
+               <priority value="OFF" />
+       </category>
+
+       <!-- don't log finders, this is moderate chatter -->
+       <category name="org.eclipse.swtbot.swt.finder.finders">
+               <priority value="DEBUG" />
+       </category>
+
+       <category name="org.eclipse.swtbot.swt.finder.keyboard">
+               <!-- set to a value higher than debug to turn on. -->
+               <priority value="DEBUG" />
+       </category>
+
+       <category name="org.eclipse.swtbot">
+               <priority value="ALL" />
+       </category>
+
+       <root>
+               <priority value="INFO" />
+               <appender-ref ref="consoleAppender" />
+               <appender-ref ref="fileAppender" />
+       </root>
+
+</log4j:configuration>
\ No newline at end of file