Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-03-02 19:35:11 +0000
committerDavid Green2012-03-02 19:35:11 +0000
commit2befecfd0c9ea65a84504ad94eea486e317407cf (patch)
treed8ae786d9caa90e9abcf7ea5a6978637e207d8ff /org.eclipse.mylyn.tasks.index.tests
parent20cefdff005db68155f001f06733accae2382a1c (diff)
downloadorg.eclipse.mylyn.tasks-2befecfd0c9ea65a84504ad94eea486e317407cf.tar.gz
org.eclipse.mylyn.tasks-2befecfd0c9ea65a84504ad94eea486e317407cf.tar.xz
org.eclipse.mylyn.tasks-2befecfd0c9ea65a84504ad94eea486e317407cf.zip
bug 372725: handle changes to task data directory
https://bugs.eclipse.org/bugs/show_bug.cgi?id=372725 Change-Id: I24cc1a042b41a0fc83c28638b78c25fb74a818f1
Diffstat (limited to 'org.eclipse.mylyn.tasks.index.tests')
-rw-r--r--org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java65
1 files changed, 53 insertions, 12 deletions
diff --git a/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java b/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java
index 34a71db1c..c647c3d59 100644
--- a/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java
+++ b/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java
@@ -82,17 +82,30 @@ public class TaskListIndexTest {
@Before
public void setup() throws IOException {
- tempDir = File.createTempFile(TaskListIndexTest.class.getSimpleName(), ".tmp");
+ tempDir = createTmpDir();
+
+ context = new MockTestContext();
+ }
+
+ private File createTmpDir() throws IOException {
+ File tempDir = File.createTempFile(TaskListIndexTest.class.getSimpleName(), ".tmp");
tempDir.delete();
tempDir.mkdirs();
assertTrue(tempDir.exists() && tempDir.isDirectory());
-
- context = new MockTestContext();
+ return tempDir;
}
@After
public void tearDown() {
+ disposeIndex();
+ if (tempDir != null) {
+ delete(tempDir);
+ assertFalse(tempDir.exists());
+ }
+ }
+
+ private void disposeIndex() {
if (index != null) {
try {
index.waitUntilIdle();
@@ -102,10 +115,6 @@ public class TaskListIndexTest {
index.close();
index = null;
}
- if (tempDir != null) {
- delete(tempDir);
- assertFalse(tempDir.exists());
- }
}
private void delete(File file) {
@@ -218,11 +227,7 @@ public class TaskListIndexTest {
index.setDefaultField(FIELD_SUMMARY);
- TestTaskCollector collector = new TestTaskCollector();
- index.find(task.getSummary(), collector, 1000);
-
- assertEquals(1, collector.getTasks().size());
- assertTrue(collector.getTasks().contains(task));
+ assertCanFindTask(task);
}
@Test
@@ -412,4 +417,40 @@ public class TaskListIndexTest {
+ index.escapeFieldValue(repositoryTask.getHandleIdentifier())));
}
+ @Test
+ public void testSetLocation() throws InterruptedException, IOException {
+ setupIndex();
+ index.setDefaultField(FIELD_SUMMARY);
+
+ ITask task = context.createLocalTask();
+
+ index.waitUntilIdle();
+
+ assertCanFindTask(task);
+
+ File newLocation = createTmpDir();
+ try {
+ assertEquals(0, newLocation.list().length);
+
+ index.setLocation(newLocation);
+
+ index.waitUntilIdle();
+ assertCanFindTask(task);
+
+ assertFalse(newLocation.list().length == 0);
+ } finally {
+ disposeIndex();
+ delete(newLocation);
+ assertFalse(newLocation.exists());
+ }
+ }
+
+ private void assertCanFindTask(ITask task) {
+ TestTaskCollector collector = new TestTaskCollector();
+ index.find(task.getSummary(), collector, 1000);
+
+ assertEquals(1, collector.getTasks().size());
+ assertTrue(collector.getTasks().contains(task));
+ }
+
} \ No newline at end of file

Back to the top