Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-02-16 13:02:47 +0000
committerSteffen Pingel2012-02-16 13:02:47 +0000
commit16011372b76e8a83264ff933f4ca99ad0a5f93c7 (patch)
tree48afc07c8c244457db61884d2d265bf1831d16fb /org.eclipse.mylyn.tests.util
parentec795572fe510451ddc2690fefe4aab8c8e3e9ac (diff)
downloadorg.eclipse.mylyn.tasks-16011372b76e8a83264ff933f4ca99ad0a5f93c7.tar.gz
org.eclipse.mylyn.tasks-16011372b76e8a83264ff933f4ca99ad0a5f93c7.tar.xz
org.eclipse.mylyn.tasks-16011372b76e8a83264ff933f4ca99ad0a5f93c7.zip
support running tests headless
Diffstat (limited to 'org.eclipse.mylyn.tests.util')
-rw-r--r--org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/InMemoryTaskDataCollector.java59
-rw-r--r--org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java8
2 files changed, 65 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/InMemoryTaskDataCollector.java b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/InMemoryTaskDataCollector.java
new file mode 100644
index 000000000..c69aeaef9
--- /dev/null
+++ b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/InMemoryTaskDataCollector.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tasktop Technologies and others.
+ * 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tests.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
+
+/**
+ * @author Steffen Pingel
+ */
+public class InMemoryTaskDataCollector extends TaskDataCollector {
+
+ public Map<String, IStatus> failureByTaskId;
+
+ public List<TaskData> results;
+
+ public InMemoryTaskDataCollector() {
+ reset();
+ }
+
+ @Override
+ public void accept(TaskData taskData) {
+ results.add(taskData);
+ }
+
+ @Override
+ public void failed(String taskId, IStatus status) {
+ failureByTaskId.put(taskId, status);
+ }
+
+ public Map<String, IStatus> getFailureByTaskId() {
+ return failureByTaskId;
+ }
+
+ public List<TaskData> getResults() {
+ return results;
+ }
+
+ public void reset() {
+ results = new ArrayList<TaskData>();
+ failureByTaskId = new HashMap<String, IStatus>();
+ }
+
+}
diff --git a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java
index b2e1021d2..a67515a9f 100644
--- a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java
+++ b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java
@@ -212,7 +212,9 @@ public abstract class TestFixture {
public TaskRepository singleRepository() {
TaskRepositoryManager manager = TasksUiPlugin.getRepositoryManager();
- manager.clearRepositories();
+ if (manager != null) {
+ manager.clearRepositories();
+ }
resetRepositories();
TaskRepository repository = new TaskRepository(connectorKind, repositoryUrl);
@@ -220,7 +222,9 @@ public abstract class TestFixture {
repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials(credentials.username,
credentials.password), true);
configureRepository(repository);
- manager.addRepository(repository);
+ if (manager != null) {
+ manager.addRepository(repository);
+ }
return repository;
}

Back to the top