Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListStandaloneTest.java2
-rw-r--r--org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java4
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataExportTest.java78
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskExportImportTest.java34
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListBackupManagerTest.java16
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListDropAdapterTest.java5
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskTestUtil.java4
8 files changed, 53 insertions, 94 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListStandaloneTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListStandaloneTest.java
index 66c7ac9b5..891ce4915 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListStandaloneTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListStandaloneTest.java
@@ -103,7 +103,7 @@ public class TaskListStandaloneTest extends TestCase {
assertNull(task.getCompletionDate());
task.setCompletionDate(creation);
- assertEquals(start, task.getCompletionDate());
+ assertEquals(creation, task.getCompletionDate());
assertEquals(1, TasksUiPlugin.getTaskList().getRootElements().size());
TasksUiPlugin.getExternalizationManager().requestSave();
diff --git a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
index cb9f7f359..558e371db 100644
--- a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
@@ -10,6 +10,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.junit,
org.eclipse.mylyn.context.core,
org.eclipse.mylyn.context.tests,
+ org.eclipse.mylyn.commons.tests,
org.eclipse.jdt.core,
org.eclipse.core.resources,
org.eclipse.ui,
@@ -32,7 +33,8 @@ Bundle-ActivationPolicy: lazy
Bundle-ClassPath: mylyn-tasklist-tests.jar
Export-Package: org.eclipse.mylyn.tasks.tests;x-internal:=true,
org.eclipse.mylyn.tasks.tests.connector;x-internal:=true,
- org.eclipse.mylyn.tasks.tests.data,
+ org.eclipse.mylyn.tasks.tests.core;x-internal:=true,
+ org.eclipse.mylyn.tasks.tests.data;x-internal:=true,
org.eclipse.mylyn.tasks.tests.performance;x-internal:=true,
org.eclipse.mylyn.tasks.tests.ui;x-internal:=true,
org.eclipse.mylyn.tasks.tests.ui.editor;x-internal:=true,
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java
index f20a66028..4dd86d4f2 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java
@@ -52,9 +52,10 @@ public class TaskActivityTimingTest extends TestCase {
@Override
protected void setUp() throws Exception {
- super.setUp();
activityManager = (TaskActivityManager) TasksUi.getTaskActivityManager();
taskList = TasksUiInternal.getTaskList();
+ TaskTestUtil.resetTaskListAndRepositories();
+ TaskTestUtil.saveAndReadTasklist();
ContextCorePlugin.getContextManager().getActivityMetaContext().reset();
ContextCorePlugin.getContextManager().saveActivityMetaContext();
TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
@@ -64,7 +65,6 @@ public class TaskActivityTimingTest extends TestCase {
protected void tearDown() throws Exception {
ContextCorePlugin.getContextManager().getActivityMetaContext().reset();
TaskTestUtil.resetTaskList();
- super.tearDown();
}
public void testLoadCorruptContext() throws Exception {
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataExportTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataExportTest.java
index b4eb5c748..e1e88a0bc 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataExportTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataExportTest.java
@@ -14,15 +14,16 @@ package org.eclipse.mylyn.tasks.tests;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import org.eclipse.mylyn.commons.tests.support.CommonsTestUtil;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.tests.AbstractContextTest;
import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.context.core.InteractionContext;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
-import org.eclipse.mylyn.internal.tasks.ui.TaskListBackupManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.internal.tasks.ui.wizards.Messages;
@@ -39,13 +40,13 @@ import org.eclipse.swt.widgets.Shell;
*/
public class TaskDataExportTest extends AbstractContextTest {
- private TaskDataExportWizard wizard = null;
+ private TaskDataExportWizard wizard;
- private TaskDataExportWizardPage wizardPage = null;
+ private TaskDataExportWizardPage wizardPage;
- private File destinationDir = null;
+ private File destinationDir;
- private AbstractTask task1 = null;
+ private AbstractTask task1;
private InteractionContext mockContext;
@@ -53,9 +54,6 @@ public class TaskDataExportTest extends AbstractContextTest {
protected void setUp() throws Exception {
super.setUp();
- removeFiles(new File(TasksUiPlugin.getDefault().getDataDirectory()));
-// ContextCore.getContextStore().init();
-
// Create the export wizard
wizard = new TaskDataExportWizard();
wizard.addPages();
@@ -64,22 +62,19 @@ public class TaskDataExportTest extends AbstractContextTest {
assertNotNull(wizardPage);
// Create test export destination directory
- destinationDir = new File(TasksUiPlugin.getDefault().getDataDirectory() + File.separator + "TestDir");
- if (destinationDir.exists()) {
- removeFiles(destinationDir);
- } else {
- destinationDir.mkdir();
- }
+ destinationDir = new File(TasksUiPlugin.getDefault().getDataDirectory(), "TestDir");
+ CommonsTestUtil.deleteFolder(destinationDir);
+ destinationDir.mkdir();
assertTrue(destinationDir.exists());
// Create a task and context with an interaction event to be saved
task1 = TasksUiInternal.createNewLocalTask("Export Test Task");
TasksUiPlugin.getTaskList().addTask(task1);
+
+ // Save the context file and check that it exists
mockContext = (InteractionContext) ContextCorePlugin.getContextStore().loadContext(task1.getHandleIdentifier());
InteractionEvent event = new InteractionEvent(InteractionEvent.Kind.EDIT, "structureKind", "handle", "originId");
mockContext.parseEvent(event);
-
- // Save the context file and check that it exists
ContextCorePlugin.getContextStore().saveContext(mockContext);
File taskFile = ContextCorePlugin.getContextStore().getFileForContext(task1.getHandleIdentifier());
assertTrue(ContextCore.getContextManager().hasContext(task1.getHandleIdentifier()));
@@ -92,47 +87,36 @@ public class TaskDataExportTest extends AbstractContextTest {
@Override
protected void tearDown() throws Exception {
ContextCore.getContextManager().deactivateContext(mockContext.getHandleIdentifier());
- removeFiles(destinationDir);
- destinationDir.delete();
- assertFalse(destinationDir.exists());
+ CommonsTestUtil.deleteFolder(destinationDir);
super.tearDown();
}
/**
- * Tests the wizard when it has been asked to export all task data to a zip file
+ * Tests the wizard when it has been asked to export all task data to a zip file.
*/
public void testExportAllToZip() throws Exception {
-
- // Set parameters in the wizard to simulate a user setting them and
- // clicking "Finish"
+ // set parameters in the wizard to simulate a user setting them and clicking "Finish"
wizardPage.setParameters(true, true, true, true, true, destinationDir.getPath());
wizard.performFinish();
- // Check that the task list file was exported
- File destZipFile = new File(destinationDir + File.separator + TaskListBackupManager.getBackupFileName());
- assertTrue(destZipFile.exists());
- ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(destZipFile));
- ArrayList<String> entries = new ArrayList<String>();
-
- ZipEntry entry = zipInputStream.getNextEntry();
- while (entry != null) {
- entries.add(entry.getName());
- entry = zipInputStream.getNextEntry();
- }
- zipInputStream.close();
- assertEquals(3, entries.size());
- assertTrue(entries.contains("tasklist.xml.zip"));
- assertTrue(entries.contains("contexts/local-1.xml.zip"));
- }
-
- private void removeFiles(File root) {
- if (root.isDirectory()) {
- for (File file : root.listFiles()) {
- if (file.isDirectory()) {
- removeFiles(file);
- }
- file.delete();
+ // check that the task list file was exported
+ File[] files = destinationDir.listFiles();
+ assertEquals(1, files.length);
+ ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(files[0]));
+ try {
+ ArrayList<String> entries = new ArrayList<String>();
+ ZipEntry entry = zipInputStream.getNextEntry();
+ while (entry != null) {
+ entries.add(entry.getName());
+ entry = zipInputStream.getNextEntry();
}
+ assertEquals(3, entries.size());
+ Collections.sort(entries);
+ assertEquals("contexts/local-1.xml.zip", entries.get(0));
+ assertEquals("repositories.xml.zip", entries.get(1));
+ assertEquals("tasks.xml.zip", entries.get(2));
+ } finally {
+ zipInputStream.close();
}
}
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskExportImportTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskExportImportTest.java
index fe992efdd..6646605d7 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskExportImportTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskExportImportTest.java
@@ -19,6 +19,7 @@ import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import org.eclipse.mylyn.commons.tests.support.CommonsTestUtil;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContext;
import org.eclipse.mylyn.context.tests.AbstractContextTest;
@@ -40,32 +41,23 @@ import org.eclipse.mylyn.tasks.ui.TasksUi;
*/
public class TaskExportImportTest extends AbstractContextTest {
- private File dest;
+ private File destinationDir;
@Override
protected void setUp() throws Exception {
TasksUi.getTaskActivityManager().deactivateActiveTask();
super.setUp();
- removeFiles(new File(TasksUiPlugin.getDefault().getDataDirectory()));
-// ContextCore.getContextStore().init();
// Create test export destination directory
- dest = new File(TasksUiPlugin.getDefault().getDataDirectory() + File.separator + "TestDir");
- if (dest.exists()) {
- removeFiles(dest);
- } else {
- dest.mkdir();
- }
- assertTrue(dest.exists());
-
+ destinationDir = new File(TasksUiPlugin.getDefault().getDataDirectory(), "TestDir");
+ CommonsTestUtil.deleteFolder(destinationDir);
+ destinationDir.mkdir();
+ assertTrue(destinationDir.exists());
}
@Override
protected void tearDown() throws Exception {
- removeFiles(dest);
- dest.delete();
- assertFalse(dest.exists());
-
+ CommonsTestUtil.deleteFolder(destinationDir);
super.tearDown();
}
@@ -88,7 +80,7 @@ public class TaskExportImportTest extends AbstractContextTest {
ContextCorePlugin.getContextStore().saveContext(mockContext);
assertTrue(ContextCore.getContextManager().hasContext(task.getHandleIdentifier()));
- File outFile = new File(dest + File.separator + "local-task.xml.zip");
+ File outFile = new File(destinationDir + File.separator + "local-task.xml.zip");
TasksUiPlugin.getTaskListWriter().writeTask(task, outFile);
assertTrue(outFile.exists());
@@ -140,14 +132,4 @@ public class TaskExportImportTest extends AbstractContextTest {
ContextCorePlugin.getContextManager().deactivateAllContexts();
}
- private void removeFiles(File root) {
- if (root.isDirectory()) {
- for (File file : root.listFiles()) {
- if (file.isDirectory()) {
- removeFiles(file);
- }
- file.delete();
- }
- }
- }
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListBackupManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListBackupManagerTest.java
index 0b304d03a..50cf9b8e4 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListBackupManagerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListBackupManagerTest.java
@@ -15,6 +15,7 @@ import java.io.File;
import junit.framework.TestCase;
+import org.eclipse.mylyn.commons.tests.support.CommonsTestUtil;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.LocalTask;
import org.eclipse.mylyn.internal.tasks.ui.TaskListBackupManager;
@@ -29,14 +30,10 @@ public class TaskListBackupManagerTest extends TestCase {
private TaskListBackupManager backupManager;
- private File backupFileFolder;
-
@Override
protected void setUp() throws Exception {
backupManager = TasksUiPlugin.getBackupManager();
- backupFileFolder = new File(TasksUiPlugin.getDefault().getBackupFolderPath());
-
- deleteBackupFolder(backupFileFolder);
+ CommonsTestUtil.deleteFolder(new File(TasksUiPlugin.getDefault().getBackupFolderPath()));
TaskTestUtil.resetTaskList();
}
@@ -69,13 +66,4 @@ public class TaskListBackupManagerTest extends TestCase {
assertEquals(1, backupManager.getBackupFiles().size());
}
- private void deleteBackupFolder(File backupFileFolder) {
- if (backupFileFolder.exists()) {
- for (File file : backupFileFolder.listFiles()) {
- file.delete();
- }
- backupFileFolder.delete();
- }
- }
-
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListDropAdapterTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListDropAdapterTest.java
index 11f05c69c..abe361e7c 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListDropAdapterTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListDropAdapterTest.java
@@ -34,8 +34,7 @@ public class TaskListDropAdapterTest extends TestCase {
@Override
protected void setUp() throws Exception {
- TaskTestUtil.resetTaskList();
- TasksUiPlugin.getDefault().getLocalTaskRepository();
+ TaskTestUtil.resetTaskListAndRepositories();
TreeViewer viewer = TaskListView.getFromActivePerspective().getViewer();
assertNotNull(viewer);
@@ -60,7 +59,7 @@ public class TaskListDropAdapterTest extends TestCase {
public void testUrlDrop() {
assertEquals(0, taskList.getDefaultCategory().getChildren().size());
String url = "http://eclipse.org/mylyn";
- String title = "Mylar Technology Project";
+ String title = "Mylyn Project";
String urlData = url + "\n" + title;
dropAdapter.performDrop(urlData);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskTestUtil.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskTestUtil.java
index f2e7293e3..e56c3e819 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskTestUtil.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskTestUtil.java
@@ -76,6 +76,10 @@ public class TaskTestUtil {
public static void resetTaskList() throws Exception {
TasksUi.getTaskActivityManager().deactivateActiveTask();
TasksUiPlugin.getTaskListExternalizationParticipant().resetTaskList();
+ TaskListView view = TaskListView.getFromActivePerspective();
+ if (view != null) {
+ view.refresh();
+ }
}
/**

Back to the top