Project

General

Profile

« Previous | Next » 

Revision 28b8707a

Added by Niels Hoffmann about 13 years ago

View differences:

.gitattributes
1192 1192
eu.etaxonomy.taxeditor.store/src/test/resources/eu/etaxonomy/taxeditor/store/ConcurrentSessionTest.xml -text
1193 1193
eu.etaxonomy.taxeditor.store/src/test/resources/log4j.properties -text
1194 1194
eu.etaxonomy.taxeditor.store/src/test/resources/unitils.properties -text
1195
eu.etaxonomy.taxeditor.test/.classpath -text
1196
eu.etaxonomy.taxeditor.test/.project -text
1197
eu.etaxonomy.taxeditor.test/.settings/org.eclipse.jdt.core.prefs -text
1198
eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF -text
1199
eu.etaxonomy.taxeditor.test/build.properties -text
1200
eu.etaxonomy.taxeditor.test/ide/eclipse/EDITor[!!-~]Tests.launch -text
1201
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/AbstractEditorTest.java -text
1202
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ClassificationTest.java -text
1203
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ContextMenuHelper.java -text
1204
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/LoginTest.java -text
1205
eu.etaxonomy.taxeditor.test/src/test/java/log4j.xml -text
1195 1206
/pom.xml -text
1196 1207
src/changes/changes.xml -text
1197 1208
src/site/apt/download.apt -text
eu.etaxonomy.taxeditor.test/.classpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src/test/java"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
eu.etaxonomy.taxeditor.test/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>eu.etaxonomy.taxeditor.test</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
	</buildSpec>
24
	<natures>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
	</natures>
28
</projectDescription>
eu.etaxonomy.taxeditor.test/.settings/org.eclipse.jdt.core.prefs
1
#Thu Mar 31 16:21:36 CEST 2011
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.5
eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: eu.etaxonomy.taxeditor.test
4
Bundle-SymbolicName: eu.etaxonomy.taxeditor.test;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-ActivationPolicy: lazy
7
Bundle-Vendor: EDIT
8
Bundle-RequiredExecutionEnvironment: J2SE-1.5
9
Require-Bundle: org.apache.log4j;bundle-version="1.2.13",
10
 org.eclipse.core.runtime;bundle-version="3.6.0",
11
 org.eclipse.swt;bundle-version="3.6.2",
12
 org.eclipse.swtbot.eclipse.core;bundle-version="2.0.4",
13
 org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.4",
14
 org.eclipse.swtbot.junit4_x;bundle-version="2.0.4",
15
 org.junit;bundle-version="4.8.1",
16
 org.eclipse.ui.ide;bundle-version="3.6.2",
17
 org.hamcrest;bundle-version="1.1.0"
eu.etaxonomy.taxeditor.test/build.properties
1
source.. = src_/
2
output.. = bin/
3
bin.includes = META-INF/,\
4
               .
eu.etaxonomy.taxeditor.test/ide/eclipse/EDITor Tests.launch
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<launchConfiguration type="org.eclipse.swtbot.eclipse.ui.launcher.JunitLaunchConfig">
3
<booleanAttribute key="append.args" value="true"/>
4
<booleanAttribute key="askclear" value="false"/>
5
<booleanAttribute key="automaticAdd" value="true"/>
6
<booleanAttribute key="automaticValidate" value="false"/>
7
<stringAttribute key="bootstrap" value=""/>
8
<stringAttribute key="checked" value="[NONE]"/>
9
<booleanAttribute key="clearConfig" value="true"/>
10
<booleanAttribute key="clearws" value="true"/>
11
<booleanAttribute key="clearwslog" value="true"/>
12
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
13
<booleanAttribute key="default" value="true"/>
14
<booleanAttribute key="includeOptional" value="true"/>
15
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
16
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
17
<listEntry value="/eu.etaxonomy.taxeditor.test/src/test/java"/>
18
</listAttribute>
19
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
20
<listEntry value="2"/>
21
</listAttribute>
22
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=eu.etaxonomy.taxeditor.test/src\/test\/java"/>
23
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
24
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
25
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
26
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
27
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
28
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="eu.etaxonomy.taxeditor.test"/>
29
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
30
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.5 -Xms256M -Xmx768M -XX:MaxPermSize=512M"/>
31
<stringAttribute key="pde.version" value="3.3"/>
32
<stringAttribute key="product" value="eu.etaxonomy.taxeditor.application.product"/>
33
<booleanAttribute key="show_selected_only" value="false"/>
34
<booleanAttribute key="tracing" value="false"/>
35
<booleanAttribute key="useCustomFeatures" value="false"/>
36
<booleanAttribute key="useDefaultConfig" value="true"/>
37
<booleanAttribute key="useDefaultConfigArea" value="false"/>
38
<booleanAttribute key="useProduct" value="true"/>
39
</launchConfiguration>
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/AbstractEditorTest.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.taxeditor.test;
5

  
6
import java.util.List;
7

  
8
import org.eclipse.swt.widgets.Tree;
9
import org.eclipse.swt.widgets.Widget;
10
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
11
import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
12
import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
13
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
14
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
15
import org.eclipse.swtbot.swt.finder.finders.ChildrenControlFinder;
16
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
17
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
18
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
19
import org.junit.Before;
20
import org.junit.runner.RunWith;
21

  
22
/**
23
 * @author n.hoffmann
24
 *
25
 */
26
@RunWith(SWTBotJunit4ClassRunner.class)
27
public abstract class AbstractEditorTest {
28
	
29
	protected SWTWorkbenchBot bot;
30
	
31
	@Before
32
	public void setup() {
33
		bot = new SWTWorkbenchBot();
34
		SWTBotPreferences.TIMEOUT = 300000;
35
		
36
		String activeText = bot.activeShell().getText();
37
		if(activeText.equals("Connecting to datasource: cdm")){
38
			bot.waitUntil(Conditions.shellIsActive("Login"));
39
			bot.button("Cancel").click();
40
		}
41
	}
42

  
43
	
44
	/**
45
	 * @return
46
	 * @throws WidgetNotFoundException
47
	 */
48
	public SWTBotTree tree(Widget widget) throws WidgetNotFoundException {
49
		List<Tree> controls = new ChildrenControlFinder(widget).findControls(WidgetMatcherFactory.widgetOfType(Tree.class));
50
		if (controls.isEmpty())
51
			throw new WidgetNotFoundException("Could not find any tree");
52
		SWTBotTree tree = new SWTBotTree((Tree) controls.get(0));
53
		return tree;
54
	}
55

  
56
	/**
57
	 * @return
58
	 * @throws WidgetNotFoundException
59
	 */
60
	public SWTBotView view(String title) throws WidgetNotFoundException {
61
		return bot.viewByTitle(title);
62
	}
63
	
64
	
65
}
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ClassificationTest.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.taxeditor.test;
5

  
6
import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
7
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
8
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
9
import org.junit.Test;
10

  
11
/**
12
 * @author n.hoffmann
13
 *
14
 */
15
public class ClassificationTest extends AbstractEditorTest {
16

  
17
	@Test
18
	public void canDeleteClassification() throws Exception {
19
		SWTBotView navigatorView = view("Taxon Navigator");
20
		SWTBotTree tree = tree(navigatorView.getWidget());
21
		tree.select(0);
22
		
23
		
24
//		SWTBotTreeItem treeItem = tree.getTreeItem("TestFolder 01").select();
25
		ContextMenuHelper.clickContextMenu(tree, "Delete");
26
		bot.waitUntil(Conditions.shellIsActive("Confirm Deletion"));
27
		bot.button("OK").click();
28
	}
29
}
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ContextMenuHelper.java
1
package eu.etaxonomy.taxeditor.test;
2

  
3
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
4
import static org.hamcrest.Matchers.allOf;
5
import static org.hamcrest.Matchers.instanceOf;
6

  
7
import java.util.Arrays;
8

  
9
import org.eclipse.swt.SWT;
10
import org.eclipse.swt.widgets.Control;
11
import org.eclipse.swt.widgets.Event;
12
import org.eclipse.swt.widgets.Menu;
13
import org.eclipse.swt.widgets.MenuItem;
14
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
15
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
16
import org.eclipse.swtbot.swt.finder.results.VoidResult;
17
import org.eclipse.swtbot.swt.finder.results.WidgetResult;
18
import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
19
import org.hamcrest.Matcher;
20

  
21
public class ContextMenuHelper {
22

  
23
	/**
24
	 * Clicks the context menu matching the text.
25
	 *
26
	 * @param text
27
	 * the text on the context menu.
28
	 * @throws WidgetNotFoundException
29
	 * if the widget is not found.
30
	 */
31
	public static void clickContextMenu(final AbstractSWTBot<?> bot,
32
			final String... texts) {
33

  
34
		// show
35
		final MenuItem menuItem = UIThreadRunnable
36
		.syncExec(new WidgetResult<MenuItem>() {
37
			public MenuItem run() {
38
				MenuItem menuItem = null;
39
				Control control = (Control) bot.widget;
40
				Menu menu = control.getMenu();
41
				for (String text : texts) {
42
					Matcher<?> matcher = allOf(instanceOf(MenuItem.class),
43
							withMnemonic(text));
44
					menuItem = show(menu, matcher);
45
					if (menuItem != null) {
46
						menu = menuItem.getMenu();
47
					} else {
48
						hide(menu);
49
						break;
50
					}
51
				}
52

  
53
				return menuItem;
54
			}
55
		});
56
		if (menuItem == null) {
57
			throw new WidgetNotFoundException("Could not find menu: "
58
					+ Arrays.asList(texts));
59
		}
60

  
61
		// click
62
		click(menuItem);
63

  
64
		// hide
65
		UIThreadRunnable.syncExec(new VoidResult() {
66
			public void run() {
67
				hide(menuItem.getParent());
68
			}
69
		});
70
	}
71

  
72
	private static MenuItem show(final Menu menu, final Matcher<?> matcher) {
73
		if (menu != null) {
74
			menu.notifyListeners(SWT.Show, new Event());
75
			MenuItem[] items = menu.getItems();
76
			for (final MenuItem menuItem : items) {
77
				if (matcher.matches(menuItem)) {
78
					return menuItem;
79
				}
80
			}
81
			menu.notifyListeners(SWT.Hide, new Event());
82
		}
83
		return null;
84
	}
85

  
86
	private static void click(final MenuItem menuItem) {
87
		final Event event = new Event();
88
		event.time = (int) System.currentTimeMillis();
89
		event.widget = menuItem;
90
		event.display = menuItem.getDisplay();
91
		event.type = SWT.Selection;
92

  
93
		UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() {
94
			public void run() {
95
				menuItem.notifyListeners(SWT.Selection, event);
96
			}
97
		});
98
	}
99

  
100
	private static void hide(final Menu menu) {
101
		menu.notifyListeners(SWT.Hide, new Event());
102
		if (menu.getParentMenu() != null) {
103
			hide(menu.getParentMenu());
104
		}
105
	}
106
}
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/LoginTest.java
1
package eu.etaxonomy.taxeditor.test;
2

  
3
import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
4
import org.junit.Test;
5

  
6

  
7
public class LoginTest extends AbstractEditorTest{
8
		
9
	@Test
10
	public void canLoginAsAdmin() throws Exception {
11
		bot.menu("General").menu("Login").click();
12
		bot.waitUntil(Conditions.shellIsActive("Login"));
13
		bot.textWithLabel("Username").setText("admin");
14
		bot.textWithLabel("Password").setText("0000");
15
		bot.button("Cancel").click();
16
	}
17
	
18
}
eu.etaxonomy.taxeditor.test/src/test/java/log4j.xml
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
4
	debug="false">
5

  
6
	<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
7
		<param name="Target" value="System.out" />
8
		<layout class="org.apache.log4j.PatternLayout">
9
			<param name="ConversionPattern"
10
				value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) - %m%n" />
11
		</layout>
12
	</appender>
13

  
14
	<appender name="fileAppender" class="org.apache.log4j.FileAppender">
15
		<param name="File" value="/tmp/debug.log" />
16
		<param name="Append" value="false" />
17
		<layout class="org.apache.log4j.PatternLayout">
18
			<param name="ConversionPattern"
19
				value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) - %m%n" />
20
		</layout>
21
	</appender>
22

  
23
	<appender name="asyncAppender" class="org.apache.log4j.AsyncAppender">
24
		<!-- appender-ref ref="consoleAppender" / -->
25
		<appender-ref ref="fileAppender" />
26
	</appender>
27

  
28
	<!-- don't log matchers, this is very high amount of chatter -->
29
	<category name="org.eclipse.swtbot.swt.finder.matchers">
30
		<priority value="OFF" />
31
	</category>
32

  
33
	<!--
34
		don't log widget notification events, this is moderately high chatter
35
	-->
36
	<category name="org.eclipse.swtbot.swt.finder.widgets">
37
		<priority value="OFF" />
38
	</category>
39

  
40
	<!-- don't log finders, this is moderate chatter -->
41
	<category name="org.eclipse.swtbot.swt.finder.finders">
42
		<priority value="DEBUG" />
43
	</category>
44

  
45
	<category name="org.eclipse.swtbot.swt.finder.keyboard">
46
		<!-- set to a value higher than debug to turn on. -->
47
		<priority value="DEBUG" />
48
	</category>
49

  
50
	<category name="org.eclipse.swtbot">
51
		<priority value="ALL" />
52
	</category>
53

  
54
	<root>
55
		<priority value="INFO" />
56
		<appender-ref ref="consoleAppender" />
57
		<appender-ref ref="fileAppender" />
58
	</root>
59

  
60
</log4j:configuration>

Also available in: Unified diff