Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2006-11-28 23:12:57 +0000
committerrelves2006-11-28 23:12:57 +0000
commit764175789411dbaaee6f125d60c412b846d9a649 (patch)
tree3f5b1859f976895018a70766c8b7a165c0d1f1a0 /org.eclipse.mylyn.bugzilla.tests
parent86fd512f03cb464919976a309df1331712162678 (diff)
downloadorg.eclipse.mylyn.tasks-764175789411dbaaee6f125d60c412b846d9a649.tar.gz
org.eclipse.mylyn.tasks-764175789411dbaaee6f125d60c412b846d9a649.tar.xz
org.eclipse.mylyn.tasks-764175789411dbaaee6f125d60c412b846d9a649.zip
NEW - bug 165498: Create unified abstract support for task submission to repository
https://bugs.eclipse.org/bugs/show_bug.cgi?id=165498
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests')
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java51
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java87
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskTest.java8
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestUtil.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/EncodingTest.java13
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java14
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java109
8 files changed, 156 insertions, 132 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
index 827a57ea1..13f39f6fb 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
@@ -11,24 +11,17 @@
package org.eclipse.mylar.bugzilla.tests;
-import java.io.UnsupportedEncodingException;
import java.util.Set;
-import javax.security.auth.login.LoginException;
-
import junit.framework.TestCase;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.mylar.context.tests.support.MylarTestUtils;
import org.eclipse.mylar.context.tests.support.MylarTestUtils.Credentials;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaException;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportSubmitForm;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaTask;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylar.internal.bugzilla.core.PossibleBugzillaFailureException;
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
@@ -110,7 +103,7 @@ public abstract class AbstractBugzillaTest extends TestCase {
}
protected BugzillaTask generateLocalTaskAndDownload(String taskNumber) throws CoreException {
- BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber, null);
+ BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertNotNull(task);
@@ -118,13 +111,19 @@ public abstract class AbstractBugzillaTest extends TestCase {
assertTrue(task.isDownloaded());
return task;
}
-
- protected BugzillaReportSubmitForm makeExistingBugPost(RepositoryTaskData taskData)
- throws UnsupportedEncodingException {
- return BugzillaReportSubmitForm.makeExistingBugPost(taskData, repository.getUrl(), repository.getUserName(),
- repository.getPassword(), repository.getCharacterEncoding());
+
+ protected void submit(RepositoryTaskData data) throws CoreException {
+ connector.getTaskDataHandler().postTaskData(repository, data);
+ data.setHasLocalChanges(false);
}
+// protected BugzillaReportSubmitForm makeExistingBugPost(RepositoryTaskData taskData)
+// throws UnsupportedEncodingException {
+// return BugzillaReportSubmitForm.makeExistingBugPost(taskData, repository.getUrl(), repository.getUserName(),
+// repository.getPassword(), repository.getCharacterEncoding());
+// }
+
+
protected void synchAndAssertState(Set<AbstractRepositoryTask> tasks, RepositoryTaskSyncState state) {
for (AbstractRepositoryTask task : tasks) {
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
@@ -132,17 +131,17 @@ public abstract class AbstractBugzillaTest extends TestCase {
}
}
- class MockBugzillaReportSubmitForm extends BugzillaReportSubmitForm {
-
- public MockBugzillaReportSubmitForm() {
- super();
- }
-
- @Override
- public String submitReportToRepository(BugzillaClient client) throws BugzillaException, LoginException,
- PossibleBugzillaFailureException {
- return "test-submit";
- }
-
- }
+// class MockBugzillaReportSubmitForm extends BugzillaReportSubmitForm {
+//
+// public MockBugzillaReportSubmitForm() {
+// super();
+// }
+//
+// @Override
+// public String submitReportToRepository(BugzillaClient client) throws BugzillaException, LoginException,
+// PossibleBugzillaFailureException {
+// return "test-submit";
+// }
+//
+// }
} \ No newline at end of file
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
index 2d3238034..3ade8b7bd 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
@@ -130,7 +130,7 @@ public class BugzillaConfigurationTest extends TestCase {
assertEquals(7, config.getSeverities().size());
assertTrue(config.getProducts().size() > 50);
assertEquals(4, config.getOpenStatusValues().size());
- assertEquals(11, config.getComponents("Mylar").size());
+ assertEquals(12, config.getComponents("Mylar").size());
assertEquals(22, config.getKeywords().size());
// assertEquals(10, config.getComponents("Hyades").size());
// assertEquals(1, config.getTargetMilestones("TestProduct").size());
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
index e73c66cc8..8ffa7fae9 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
@@ -33,13 +33,11 @@ import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaException;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaQueryHit;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportElement;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportSubmitForm;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryQuery;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaTask;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.internal.bugzilla.core.PossibleBugzillaFailureException;
import org.eclipse.mylar.internal.bugzilla.core.RepositoryConfiguration;
-import org.eclipse.mylar.internal.bugzilla.ui.editor.BugSubmissionHandler;
import org.eclipse.mylar.internal.tasks.core.SslProtocolSocketFactory;
import org.eclipse.mylar.internal.tasks.ui.search.SearchHitCollector;
import org.eclipse.mylar.tasks.core.AbstractQueryHit;
@@ -62,10 +60,10 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
public void testCreateTaskFromExistingId() throws Exception {
init222();
- BugzillaTask badId = (BugzillaTask) connector.createTaskFromExistingKey(repository, "bad-id", null);
+ BugzillaTask badId = (BugzillaTask) connector.createTaskFromExistingKey(repository, "bad-id");
assertNull(badId);
- BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "1", null);
+ BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "1");
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertNotNull(task);
assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
@@ -121,7 +119,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
public void testContextAttachFailure() throws Exception {
init218();
- BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "3", null);
+ BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "3");
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertNotNull(task.getTaskData());
@@ -145,7 +143,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
init222();
// Get the task
- BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "1", null);
+ BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "1");
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
TasksUiPlugin.getTaskListManager().getTaskList().moveToRoot(task);
@@ -166,13 +164,27 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
assertEquals(RepositoryTaskSyncState.OUTGOING, task.getSyncState());
// Submit changes
- MockBugzillaReportSubmitForm form = new MockBugzillaReportSubmitForm();
- form.setTaskData(task.getTaskData());
- new BugSubmissionHandler(connector).submitBugReport(form, null, true, true);
- // submit casuses a synch which should result in
- // a synchronized state (not incoming)
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
+
+ submit(task.getTaskData());
+// task.setTaskData(null);
+ TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
+ assertEquals(RepositoryTaskSyncState.INCOMING, task.getSyncState());
+ TasksUiPlugin.getSynchronizationManager().setTaskRead(task, true);
+ // Has no outgoing changes or conflicts yet needs synch
+ // because task doesn't have bug report (new query hit)
+ // Result: retrieved with no incoming status
+ //task.setSyncState(RepositoryTaskSyncState.SYNCHRONIZED);
+
+ RepositoryTaskData bugReport = task.getTaskData();
+ //repository.setSyncTimeStamp(bugReport.getLastModified());
+ // task.setTaskData(null);
+ TasksUiPlugin.getDefault().getTaskDataManager().remove(bugReport);
+ TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, false, null);
+ assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
+ assertNotNull(task.getTaskData());
+ assertEquals(task.getTaskData().getId(), bugReport.getId());
+
// TODO: Test that comment was appended
// ArrayList<Comment> comments = task.getTaskData().getComments();
// assertNotNull(comments);
@@ -195,16 +207,6 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
// CONFLICT with forcedSynch=true --> Update Local Copy dialog
- // Has no outgoing changes or conflicts yet needs synch
- // because task doesn't have bug report (new query hit)
- // Result: retrieved with no incoming status
- task.setSyncState(RepositoryTaskSyncState.SYNCHRONIZED);
- RepositoryTaskData bugReport = task.getTaskData();
- task.setTaskData(null);
- TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, false, null);
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
- assertNotNull(task.getTaskData());
- assertEquals(task.getTaskData().getId(), bugReport.getId());
}
public void testUniqueTaskObjects() {
@@ -279,7 +281,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
init222();
int bugId = 31;
String taskNumber = "" + bugId;
- BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber, null);
+ BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertNotNull(task);
@@ -316,7 +318,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
// assertFalse(attachmentHandler.uploadAttachment(attachment, repository.getUserName(), repository.getPassword(),
// Proxy.NO_PROXY));
assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
- task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber, null);
+ task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertEquals(numAttached, task.getTaskData().getAttachments().size());
@@ -332,7 +334,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
fail();
} catch (Exception e) {
}
- task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber, null);
+ task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertEquals(numAttached, task.getTaskData().getAttachments().size());
@@ -348,7 +350,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
} catch (Exception e) {
fail();
}
- task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber, null);
+ task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertEquals(numAttached + 1, task.getTaskData().getAttachments().size());
@@ -371,13 +373,13 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
assertEquals(5, Integer.parseInt(task5.getTaskData().getId()));
Set<AbstractRepositoryTask> tasks = new HashSet<AbstractRepositoryTask>();
- tasks.add(task4);
- tasks.add(task5);
+ tasks.add(task4);// 2006-11-28 14:32:59
+ tasks.add(task5);// 2006-11-28 14:33:06
TasksUiPlugin.getRepositoryManager().setSyncTime(repository, task5.getLastSyncDateStamp(),
TasksUiPlugin.getDefault().getRepositoriesFilePath());
- Set<AbstractRepositoryTask> changedTasks = connector.getOfflineTaskHandler().getChangedSinceLastSync(
+ Set<AbstractRepositoryTask> changedTasks = connector.getTaskDataHandler().getChangedSinceLastSync(
repository, tasks);
assertEquals(0, changedTasks.size());
@@ -402,14 +404,16 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
assertNotNull(repository.getUserName());
assertNotNull(repository.getPassword());
- BugzillaReportSubmitForm bugzillaReportSubmitForm;
-
- bugzillaReportSubmitForm = makeExistingBugPost(task4.getTaskData());
- bugzillaReportSubmitForm.submitReportToRepository(connector.getClientManager().getClient(repository));
- bugzillaReportSubmitForm = makeExistingBugPost(task5.getTaskData());
- bugzillaReportSubmitForm.submitReportToRepository(connector.getClientManager().getClient(repository));
+ submit(task4.getTaskData());
+ submit(task5.getTaskData());
+// BugzillaReportSubmitForm bugzillaReportSubmitForm;
+//
+// bugzillaReportSubmitForm = makeExistingBugPost(task4.getTaskData());
+// bugzillaReportSubmitForm.submitReportToRepository(connector.getClientManager().getClient(repository));
+// bugzillaReportSubmitForm = makeExistingBugPost(task5.getTaskData());
+// bugzillaReportSubmitForm.submitReportToRepository(connector.getClientManager().getClient(repository));
- changedTasks = connector.getOfflineTaskHandler().getChangedSinceLastSync(repository, tasks);
+ changedTasks = connector.getTaskDataHandler().getChangedSinceLastSync(repository, tasks);
assertEquals("Changed reports expected ", 2, changedTasks.size());
assertTrue(tasks.containsAll(changedTasks));
for (AbstractRepositoryTask task : changedTasks) {
@@ -465,9 +469,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
recentTaskData.setAttributeValue(BugzillaReportElement.PRIORITY.getKeyString(), priority);
}
- BugzillaReportSubmitForm bugzillaReportSubmitForm;
- bugzillaReportSubmitForm = makeExistingBugPost(recentTaskData);
- bugzillaReportSubmitForm.submitReportToRepository(connector.getClientManager().getClient(repository));
+ submit(recentTaskData);
TasksUiPlugin.getSynchronizationManager().synchronizeChanged(connector, repository);
assertEquals(RepositoryTaskSyncState.INCOMING, task7.getSyncState());
}
@@ -545,13 +547,10 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
if (enableDeadline)
bugtaskdata.setAttributeValue(BugzillaReportElement.DEADLINE.getKeyString(), deadline);
- BugzillaReportSubmitForm bugzillaReportSubmitForm;
-
for (AbstractRepositoryTask task : tasks) {
task.getTaskData().setAttributeValue(BugzillaReportElement.ADD_COMMENT.getKeyString(),
"New Estimate: " + estimatedTime + "\nNew Remaining: " + remainingTime + "\nAdd: " + addTime);
- bugzillaReportSubmitForm = makeExistingBugPost(task.getTaskData());
- bugzillaReportSubmitForm.submitReportToRepository(connector.getClientManager().getClient(repository));
+ submit(task.getTaskData());
}
// assertEquals("Changed reports expected ", 1,
@@ -617,7 +616,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
init222();
int bugId = 19;
String taskNumber = "" + bugId;
- BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber, null);
+ BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertNotNull(task);
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskTest.java
index 17c5d87de..34e76c1e3 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskTest.java
@@ -17,7 +17,7 @@ import junit.framework.TestCase;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaAttributeFactory;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaOfflineTaskHandler;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaTaskDataHandler;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportElement;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaTask;
@@ -35,12 +35,12 @@ public class BugzillaTaskTest extends TestCase {
private BugzillaAttributeFactory attributeFactory = new BugzillaAttributeFactory();
- private BugzillaOfflineTaskHandler offlineHandler;
+ private BugzillaTaskDataHandler offlineHandler;
@Override
protected void setUp() throws Exception {
super.setUp();
- offlineHandler = new BugzillaOfflineTaskHandler((BugzillaRepositoryConnector)TasksUiPlugin.getRepositoryManager().getRepositoryConnector(BugzillaCorePlugin.REPOSITORY_KIND), new TaskList());
+ offlineHandler = new BugzillaTaskDataHandler((BugzillaRepositoryConnector)TasksUiPlugin.getRepositoryManager().getRepositoryConnector(BugzillaCorePlugin.REPOSITORY_KIND), new TaskList());
}
@Override
@@ -56,7 +56,7 @@ public class BugzillaTaskTest extends TestCase {
assertNull(task.getCompletionDate());
Date now = new Date();
- String nowTimeStamp = BugzillaOfflineTaskHandler.comment_creation_ts_format.format(now);
+ String nowTimeStamp = BugzillaTaskDataHandler.comment_creation_ts_format.format(now);
TaskComment taskComment = new TaskComment(new BugzillaAttributeFactory(), 1);
RepositoryTaskAttribute attribute = attributeFactory.createAttribute(BugzillaReportElement.BUG_WHEN
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestUtil.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestUtil.java
index e35872d8b..6c274284b 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestUtil.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestUtil.java
@@ -23,7 +23,7 @@ import java.util.Date;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaAttributeFactory;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaOfflineTaskHandler;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaTaskDataHandler;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportElement;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaTask;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
@@ -75,7 +75,7 @@ public class BugzillaTestUtil {
TaskComment taskComment = new TaskComment(new BugzillaAttributeFactory(), 1);
RepositoryTaskAttribute attribute = attributeFactory.createAttribute(BugzillaReportElement.BUG_WHEN
.getKeyString());
- attribute.setValue(BugzillaOfflineTaskHandler.comment_creation_ts_format.format(new Date()));
+ attribute.setValue(BugzillaTaskDataHandler.comment_creation_ts_format.format(new Date()));
taskComment.addAttribute(BugzillaReportElement.BUG_WHEN.getKeyString(), attribute);
report.addComment(taskComment);
} else {
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/EncodingTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/EncodingTest.java
index e42ae82cb..aab817dce 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/EncodingTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/EncodingTest.java
@@ -22,7 +22,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaException;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportElement;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportSubmitForm;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaTask;
import org.eclipse.mylar.internal.bugzilla.core.PossibleBugzillaFailureException;
@@ -56,14 +55,14 @@ public class EncodingTest extends AbstractBugzillaTest {
public void testDifferentReportEncoding() throws CoreException {
init222();
repository.setCharacterEncoding("UTF-8");
- BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "57", null);
+ BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "57");
assertNotNull(task);
//TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertTrue(task.getSummary().equals("\u05D0"));
taskList.deleteTask(task);
connector.getClientManager().repositoryRemoved(repository);
repository.setCharacterEncoding("ISO-8859-1");
- task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "57", null);
+ task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "57");
assertNotNull(task);
//TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
// iso-8859-1 'incorrect' interpretation
@@ -73,7 +72,7 @@ public class EncodingTest extends AbstractBugzillaTest {
public void testProperEncodingUponPost() throws MalformedURLException, IOException, BugzillaException, PossibleBugzillaFailureException, GeneralSecurityException, CoreException {
init222();
repository.setCharacterEncoding("UTF-8");
- BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "57", null);
+ BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "57");
assertNotNull(task);
assertTrue(task.getSummary().equals("\u05D0"));
String priority = null;
@@ -85,11 +84,9 @@ public class EncodingTest extends AbstractBugzillaTest {
task.getTaskData().setAttributeValue(BugzillaReportElement.PRIORITY.getKeyString(), priority);
}
- BugzillaReportSubmitForm bugzillaReportSubmitForm;
- bugzillaReportSubmitForm = makeExistingBugPost(task.getTaskData());
- bugzillaReportSubmitForm.submitReportToRepository(connector.getClientManager().getClient(repository));
+ submit(task.getTaskData());
taskList.deleteTask(task);
- task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "57", null);
+ task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "57");
assertNotNull(task);
assertTrue(task.getSummary().equals("\u05D0"));
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java
index 8bf834657..e40ebc135 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java
@@ -18,12 +18,12 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.mylar.context.tests.support.MylarTestUtils;
import org.eclipse.mylar.context.tests.support.MylarTestUtils.Credentials;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaAttributeFactory;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportElement;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportSubmitForm;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylar.tasks.core.IOfflineTaskHandler;
+import org.eclipse.mylar.tasks.core.ITaskDataHandler;
import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute;
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
import org.eclipse.mylar.tasks.core.TaskRepository;
@@ -42,8 +42,8 @@ public class RepositoryReportFactoryTest extends TestCase {
BugzillaRepositoryConnector connector;
private RepositoryTaskData init(String taskId) throws CoreException {
- IOfflineTaskHandler handler = connector.getOfflineTaskHandler();
- RepositoryTaskData taskData = handler.downloadTaskData(repository, taskId);
+ ITaskDataHandler handler = connector.getTaskDataHandler();
+ RepositoryTaskData taskData = handler.getTaskData(repository, taskId);
return taskData;
}
@@ -441,15 +441,15 @@ public class RepositoryReportFactoryTest extends TestCase {
public void testDeltaTsTruncation() {
String ts1 = "2006-07-06 03:22:08 0900";
String ts1_truncated = "2006-07-06 03:22:08";
- assertEquals(ts1_truncated, BugzillaReportSubmitForm.stripTimeZone(ts1));
+ assertEquals(ts1_truncated, BugzillaClient.stripTimeZone(ts1));
String ts2 = "2006-07-06 03:22:08";
String ts2_truncated = "2006-07-06 03:22:08";
- assertEquals(ts2_truncated, BugzillaReportSubmitForm.stripTimeZone(ts2));
+ assertEquals(ts2_truncated, BugzillaClient.stripTimeZone(ts2));
String ts3 = "2006-07-06 03:22:08 PST";
String ts3_truncated = "2006-07-06 03:22:08";
- assertEquals(ts3_truncated, BugzillaReportSubmitForm.stripTimeZone(ts3));
+ assertEquals(ts3_truncated, BugzillaClient.stripTimeZone(ts3));
}
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java
index 544c35856..4a1be2d18 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java
@@ -22,17 +22,16 @@ import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryQuery;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.tasks.core.AbstractQueryHit;
-import org.eclipse.mylar.tasks.core.IOfflineTaskHandler;
+import org.eclipse.mylar.tasks.core.ITaskDataHandler;
import org.eclipse.mylar.tasks.core.QueryHitCollector;
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
import org.eclipse.mylar.tasks.core.TaskList;
import org.eclipse.mylar.tasks.core.TaskRepository;
-import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
+
+// import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
/**
- *
- * Runs headless (can be run as regular junit test without platform plugin
- * support).
+ * Example use of headless API (no ui dependencies)
*
* @author Rob Elves
* @author Nathan Hapke
@@ -40,22 +39,27 @@ import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
public class BugzillaQueryTest extends TestCase {
private TaskRepository repository;
+
private BugzillaRepositoryConnector connector;
- private IOfflineTaskHandler handler;
-
+
+ private ITaskDataHandler handler;
+
@Override
protected void setUp() throws Exception {
super.setUp();
-
- connector = (BugzillaRepositoryConnector) TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
- BugzillaCorePlugin.REPOSITORY_KIND);
- handler = connector.getOfflineTaskHandler();
+ //
+ // connector = (BugzillaRepositoryConnector)
+ // TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
+ // BugzillaCorePlugin.REPOSITORY_KIND);
+
+ connector = new BugzillaRepositoryConnector();
+ connector.init(new TaskList());
+ handler = connector.getTaskDataHandler();
repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
Credentials credentials = MylarTestUtils.readCredentials();
repository.setAuthenticationCredentials(credentials.username, credentials.password);
}
-
-
+
/**
* This is the first test so that the repository credentials are correctly
* set for the other tests
@@ -69,35 +73,10 @@ public class BugzillaQueryTest extends TestCase {
}
}
-// public void testValidateCredentials() throws IOException, BugzillaException, KeyManagementException,
-// GeneralSecurityException {
-// BugzillaClient.validateCredentials(null, repository.getUrl(), repository.getCharacterEncoding(),
-// repository.getUserName(), repository.getPassword());
-// }
-//
-// public void testValidateCredentialsInvalidProxy() throws IOException, BugzillaException, KeyManagementException,
-// GeneralSecurityException {
-// BugzillaClient.validateCredentials(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 12356)),
-// repository.getUrl(), repository.getCharacterEncoding(), repository.getUserName(), repository
-// .getPassword());
-// }
-
-// public void testCredentialsEncoding() throws IOException, BugzillaException, KeyManagementException,
-// GeneralSecurityException {
-// String poundSignUTF8 = BugzillaClient.addCredentials(IBugzillaConstants.TEST_BUGZILLA_222_URL, "UTF-8",
-// "testUser", "\u00A3");
-// assertTrue(poundSignUTF8.endsWith("password=%C2%A3"));
-// String poundSignISO = BugzillaClient.addCredentials(IBugzillaConstants.TEST_BUGZILLA_222_URL,
-// "ISO-8859-1", "testUser", "\u00A3");
-// assertFalse(poundSignISO.contains("%C2%A3"));
-// assertTrue(poundSignISO.endsWith("password=%A3"));
-// }
-
public void testGetBug() throws Exception {
- RepositoryTaskData taskData = handler.downloadTaskData(repository, "1");
+ RepositoryTaskData taskData = handler.getTaskData(repository, "1");
assertNotNull(taskData);
assertEquals("user@mylar.eclipse.org", taskData.getAssignedTo());
-
assertEquals("foo", taskData.getDescription());
// You can use the getAttributeValue to pull up the information on any
@@ -105,6 +84,23 @@ public class BugzillaQueryTest extends TestCase {
assertEquals("P1", taskData.getAttributeValue(BugzillaReportElement.PRIORITY.getKeyString()));
}
+ // README
+ // public void testPostBug() throws Exception {
+ // RepositoryTaskData taskData = handler.getTaskData(repository, "1");
+ // assertNotNull(taskData);
+ // assertEquals("user@mylar.eclipse.org", taskData.getAssignedTo());
+ // assertEquals("foo", taskData.getDescription());
+ // taskData.setSummary("New Summary");
+ // // post this modification back to the repository
+ // handler.postTaskData(repository, taskData);
+ //
+ // // You can use the getAttributeValue to pull up the information on any
+ // // part of the bug
+ // // assertEquals("P1",
+ // //
+ // taskData.getAttributeValue(BugzillaReportElement.PRIORITY.getKeyString()));
+ // }
+
public void testQueryViaConnector() throws Exception {
String queryUrlString = repository.getUrl()
+ "/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=search-match-test&product=TestProduct&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&deadlinefrom=&deadlineto=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=";
@@ -122,4 +118,37 @@ public class BugzillaQueryTest extends TestCase {
assertTrue(hit.getSummary().contains("search-match-test"));
}
}
-} \ No newline at end of file
+}
+
+// public void testValidateCredentials() throws IOException,
+// BugzillaException, KeyManagementException,
+// GeneralSecurityException {
+// BugzillaClient.validateCredentials(null, repository.getUrl(),
+// repository.getCharacterEncoding(),
+// repository.getUserName(), repository.getPassword());
+// }
+//
+// public void testValidateCredentialsInvalidProxy() throws IOException,
+// BugzillaException, KeyManagementException,
+// GeneralSecurityException {
+// BugzillaClient.validateCredentials(new Proxy(Proxy.Type.HTTP, new
+// InetSocketAddress("localhost", 12356)),
+// repository.getUrl(), repository.getCharacterEncoding(),
+// repository.getUserName(), repository
+// .getPassword());
+// }
+
+// public void testCredentialsEncoding() throws IOException,
+// BugzillaException, KeyManagementException,
+// GeneralSecurityException {
+// String poundSignUTF8 =
+// BugzillaClient.addCredentials(IBugzillaConstants.TEST_BUGZILLA_222_URL,
+// "UTF-8",
+// "testUser", "\u00A3");
+// assertTrue(poundSignUTF8.endsWith("password=%C2%A3"));
+// String poundSignISO =
+// BugzillaClient.addCredentials(IBugzillaConstants.TEST_BUGZILLA_222_URL,
+// "ISO-8859-1", "testUser", "\u00A3");
+// assertFalse(poundSignISO.contains("%C2%A3"));
+// assertTrue(poundSignISO.endsWith("password=%A3"));
+// } \ No newline at end of file

Back to the top