1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*******************************************************************************
* Copyright (c) 2004, 2009 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:
* Jevgeni Holodkov - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.tasks.tests;
import junit.framework.TestCase;
/**
* @author Jevgeni Holodkov
*/
//FIXME fix test
public class TaskExportImportTest extends TestCase {
public void testRewriteTestCases() {
}
// private File destinationDir;
//
// @Override
// protected void setUp() throws Exception {
// TasksUi.getTaskActivityManager().deactivateActiveTask();
// super.setUp();
//
// // Create test export destination directory
// destinationDir = new File(TasksUiPlugin.getDefault().getDataDirectory(), "TestDir");
// CommonsTestUtil.deleteFolder(destinationDir);
// destinationDir.mkdir();
// assertTrue(destinationDir.exists());
// }
//
// @Override
// protected void tearDown() throws Exception {
// CommonsTestUtil.deleteFolder(destinationDir);
// super.tearDown();
// }
//
// public void testTaskContextExport() throws Exception {
//
// LocalTask task = TasksUiInternal.createNewLocalTask("Test local task");
// TaskList taskList = TasksUiPlugin.getTaskList();
// taskList.addTask(task, taskList.getDefaultCategory());
// assertTrue(taskList.getAllTasks().size() > 0);
//
// InteractionContext mockContext = (InteractionContext) ContextCorePlugin.getContextStore().loadContext(
// task.getHandleIdentifier());
//
// ContextCorePlugin.getContextManager().internalActivateContext(mockContext);
// InteractionEvent event = new InteractionEvent(InteractionEvent.Kind.EDIT, "structureKind", "handle", "originId");
// mockContext.parseEvent(event);
// ContextCore.getContextManager().deactivateContext(mockContext.getHandleIdentifier());
//
// assertTrue(ContextCorePlugin.getContextStore().getContextDirectory().exists());
// ContextCorePlugin.getContextStore().saveContext(mockContext);
// assertTrue(ContextCore.getContextManager().hasContext(task.getHandleIdentifier()));
//
// File outFile = new File(destinationDir + File.separator + "local-task.xml.zip");
// TasksUiPlugin.getTaskListWriter().writeTask(task, outFile);
// assertTrue(outFile.exists());
//
// // check the content of the archive
// List<String> files = new ArrayList<String>();
// ZipInputStream inputStream = new ZipInputStream(new FileInputStream(outFile));
// ZipEntry entry = null;
// while ((entry = inputStream.getNextEntry()) != null) {
// files.add(entry.getName());
// }
// inputStream.close();
//
// assertTrue("exported file contains a file with queries", files.contains(ITasksCoreConstants.OLD_TASK_LIST_FILE));
//
// String handleIdentifier = mockContext.getHandleIdentifier();
// String encoded = URLEncoder.encode(handleIdentifier, InteractionContextManager.CONTEXT_FILENAME_ENCODING);
// String contextName = encoded + InteractionContextManager.CONTEXT_FILE_EXTENSION_OLD;
// assertTrue("exported file contains a file with context", files.contains(contextName));
//
// // reset all data
// TaskTestUtil.resetTaskList();
// assertTrue(taskList.getAllTasks().size() == 0);
//
// ContextCore.getContextManager().deleteContext(handleIdentifier);
// assertFalse(ContextCore.getContextManager().hasContext(task.getHandleIdentifier()));
//
// // load data back
// List<AbstractTask> tasks = TasksUiPlugin.getTaskListWriter().readTasks(outFile);
// IInteractionContext loadedContext = ContextCore.getContextStore().importContext(task.getHandleIdentifier(),
// outFile);
//
// // check with original one
// assertEquals("There is 1 task loaded", 1, tasks.size());
// assertEquals("Loaded task is correct", task, tasks.get(0));
// assertEquals("Loaded context is correct", mockContext, loadedContext);
//
// // import data
// for (AbstractTask loadedTask : tasks) {
// taskList.addTask(loadedTask);
// }
// ContextCore.getContextStore().importContext(task.getHandleIdentifier(), outFile);
//// ContextCorePlugin.getContextStore().importContext(loadedContext);
//
// // check that context was imported and is the same as original one
// IInteractionContext savedContext = ContextCorePlugin.getContextStore().loadContext(task.getHandleIdentifier());
// assertEquals("Saved context is the same as original one", mockContext, savedContext);
// assertEquals("Saved task is the same as original one", task, taskList.getTask(task.getHandleIdentifier()));
//
// ContextCorePlugin.getContextManager().deactivateAllContexts();
// }
}
|