Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests/src/org')
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java157
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java57
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java231
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java101
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java659
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchDialogTest.java68
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchEngineTest.java125
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskListManagerTest.java232
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskTest.java81
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestPlugin.java96
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestUtil.java51
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/DuplicateDetetionTest.java271
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/EncodingTest.java86
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java79
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java180
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java452
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryTaskHandleTest.java74
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskEditorTest.java79
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListNotificationManagerTest.java134
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListStandaloneTest.java208
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskReportGeneratorTest.java186
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java175
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaTaskHistoryTest.java161
23 files changed, 0 insertions, 3943 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
deleted file mode 100644
index 517bb6b48..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.context.tests.support.TestUtil;
-import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
-import org.eclipse.mylyn.tasks.core.AbstractTask;
-import org.eclipse.mylyn.tasks.core.ITaskFactory;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
-import org.eclipse.mylyn.tasks.core.TaskList;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.TaskRepositoryManager;
-import org.eclipse.mylyn.tasks.core.AbstractTask.RepositoryTaskSyncState;
-import org.eclipse.mylyn.tasks.ui.TaskFactory;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-
-/**
- * @author Mik Kersten
- * @author Rob Elves
- * @author Nathan Hapke
- */
-public abstract class AbstractBugzillaTest extends TestCase {
-
- static final String DEFAULT_KIND = BugzillaCorePlugin.REPOSITORY_KIND;
-
- protected BugzillaRepositoryConnector connector;
-
- protected TaskRepositoryManager manager;
-
- protected TaskRepository repository;
-
- protected TaskList taskList;
-
- protected ITaskFactory taskFactory;
-
- public AbstractBugzillaTest() {
- super();
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- TasksUiPlugin.getTaskDataManager().clear();
- manager = TasksUiPlugin.getRepositoryManager();
- TasksUiPlugin.getTaskListManager().getTaskList().reset();
- manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- TasksUiPlugin.getTaskListManager().resetTaskList();
- manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
- }
-
- protected void init222() {
- init(IBugzillaConstants.TEST_BUGZILLA_222_URL);
- }
-
- protected void init2201() {
- init(IBugzillaConstants.TEST_BUGZILLA_2201_URL);
- }
-
- protected void init220() {
- init(IBugzillaConstants.TEST_BUGZILLA_220_URL);
- }
-
- protected void init218() {
- init(IBugzillaConstants.TEST_BUGZILLA_218_URL);
- }
-
- @SuppressWarnings("deprecation")
- protected void init(String url) {
- repository = new TaskRepository(DEFAULT_KIND, url);
- Credentials credentials = TestUtil.readCredentials();
- repository.setAuthenticationCredentials(credentials.username, credentials.password);
-
- repository.setTimeZoneId("Canada/Eastern");
- assertNotNull(manager);
- manager.addRepository(repository, TasksUiPlugin.getDefault().getRepositoriesFilePath());
-
- taskList = TasksUiPlugin.getTaskListManager().getTaskList();
-
- AbstractRepositoryConnector abstractRepositoryClient = manager.getRepositoryConnector(DEFAULT_KIND);
-
- assertEquals(abstractRepositoryClient.getConnectorKind(), DEFAULT_KIND);
-
- connector = (BugzillaRepositoryConnector) abstractRepositoryClient;
-
- taskFactory = new TaskFactory(repository);
-// connector.setForceSynchExecForTesting(true);
- TasksUiPlugin.getSynchronizationManager().setForceSyncExec(true);
- }
-
- protected BugzillaTask generateLocalTaskAndDownload(String taskNumber) throws CoreException {
- BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingId(repository, taskNumber,
- new NullProgressMonitor());
- TasksUiPlugin.getSynchronizationManager().setTaskRead(task, true);
- assertNotNull(task);
- TasksUiPlugin.getTaskListManager().getTaskList().moveToContainer(task,
- TasksUiPlugin.getTaskListManager().getTaskList().getDefaultCategory());
-
- return task;
- }
-
- protected void submit(AbstractTask task, RepositoryTaskData taskData) throws CoreException {
- connector.getTaskDataHandler().postTaskData(repository, taskData, new NullProgressMonitor());
- task.setSubmitting(true);
- }
-
- // protected BugzillaReportSubmitForm makeExistingBugPost(RepositoryTaskData
- // taskData)
- // throws UnsupportedEncodingException {
- // return BugzillaReportSubmitForm.makeExistingBugPost(taskData,
- // repository.getUrl(), repository.getUserName(),
- // repository.getPassword(), repository.getCharacterEncoding());
- // }
-
- protected void synchAndAssertState(Set<AbstractTask> tasks, RepositoryTaskSyncState state) {
- for (AbstractTask task : tasks) {
- TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
- assertEquals(task.getSynchronizationState(), state);
- }
- }
-
- // class MockBugzillaReportSubmitForm extends BugzillaReportSubmitForm {
- //
- // public MockBugzillaReportSubmitForm() {
- // super();
- // }
- //
- // @Override
- // public String submitReportToRepository(BugzillaClient client) throws
- // BugzillaException, LoginException,
- // PossibleBugzillaFailureException {
- // return "test-submit";
- // }
- //
- // }
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java
deleted file mode 100644
index 5822290e0..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 Mylyn project committers 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
- *******************************************************************************/
-package org.eclipse.mylyn.bugzilla.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.mylyn.bugzilla.tests.headless.BugzillaQueryTest;
-import org.eclipse.mylyn.bugzilla.tests.headless.BugzillaTaskHistoryTest;
-
-/**
- * @author Mik Kersten
- */
-public class AllBugzillaTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Test for org.eclipse.mylyn.bugzilla.tests");
- // $JUnit-BEGIN$
- suite.addTestSuite(RepositoryTaskHandleTest.class);
- suite.addTestSuite(TaskListNotificationManagerTest.class);
- suite.addTestSuite(BugzillaTaskTest.class);
- suite.addTestSuite(TaskReportGeneratorTest.class);
- suite.addTestSuite(TaskListStandaloneTest.class);
- suite.addTestSuite(BugzillaTaskListManagerTest.class);
- suite.addTestSuite(TaskEditorTest.class);
- suite.addTestSuite(BugzillaQueryTest.class);
- suite.addTestSuite(RepositoryEditorWizardTest.class);
- suite.addTestSuite(RepositoryReportFactoryTest.class);
- suite.addTestSuite(BugzillaConfigurationTest.class);
-// suite.addTestSuite(BugzillaTaskHyperlinkDetectorTest.class);
- suite.addTestSuite(BugzillaSearchEngineTest.class);
- // suite.addTestSuite(Bugzilla220ParserTest.class);
- suite.addTestSuite(BugzillaRepositoryConnectorTest.class);
- suite.addTestSuite(EncodingTest.class);
- // suite.addTestSuite(NewBugWizardTest.class);
- // suite.addTestSuite(RegularExpressionMatchTest.class);
- // suite.addTestSuite(BugzillaNewBugParserTestCDT.class);
- // suite.addTestSuite(BugzillaNewBugParserTestEquinox.class);
- // suite.addTestSuite(BugzillaNewBugParserTestGMT.class);
- // suite.addTestSuite(BugzillaNewBugParserTestPlatform.class);
- // suite.addTestSuite(BugzillaNewBugParserTestVE.class);
- // suite.addTestSuite(BugzillaParserTestNoBug.class);
- suite.addTestSuite(BugzillaProductParserTest.class);
- // TODO: enable
- // suite.addTest(new TestSuite(BugzillaParserTest.class));
- suite.addTestSuite(BugzillaSearchDialogTest.class);
- suite.addTestSuite(DuplicateDetetionTest.class);
- suite.addTestSuite(BugzillaTaskHistoryTest.class);
- // $JUnit-END$
- return suite;
- }
-}
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
deleted file mode 100644
index 944396d14..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.net.URL;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
-import org.eclipse.mylyn.internal.bugzilla.core.SaxConfigurationContentHandler;
-import org.eclipse.mylyn.internal.bugzilla.core.XmlCleaner;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-public class BugzillaConfigurationTest extends TestCase {
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void test222RDFProductConfig() throws Exception {
- BugzillaClient client = new BugzillaClient(new URL(IBugzillaConstants.TEST_BUGZILLA_222_URL), "", "", "", "",
- "UTF-8");
- RepositoryConfiguration config = client.getRepositoryConfiguration();
- assertNotNull(config);
- assertEquals("2.22.1", config.getInstallVersion());
- assertEquals(7, config.getStatusValues().size());
- assertEquals(8, config.getResolutions().size());
- assertEquals(4, config.getPlatforms().size());
- assertEquals(5, config.getOSs().size());
- assertEquals(5, config.getPriorities().size());
- assertEquals(7, config.getSeverities().size());
- assertEquals(3, config.getProducts().size());
- assertEquals(4, config.getOpenStatusValues().size());
- assertEquals(1, config.getComponents("TestProduct").size());
- assertEquals(1, config.getVersions("TestProduct").size());
- assertEquals(0, config.getTargetMilestones("TestProduct").size());
- }
-
- public void test2201RDFProductConfig() throws Exception {
- BugzillaClient client = new BugzillaClient(new URL(IBugzillaConstants.TEST_BUGZILLA_2201_URL), "", "", "", "",
- "UTF-8");
- RepositoryConfiguration config = client.getRepositoryConfiguration();
- assertNotNull(config);
- assertEquals("2.20.1", config.getInstallVersion());
- assertEquals(7, config.getStatusValues().size());
- assertEquals(8, config.getResolutions().size());
- assertEquals(4, config.getPlatforms().size());
- assertEquals(5, config.getOSs().size());
- assertEquals(5, config.getPriorities().size());
- assertEquals(7, config.getSeverities().size());
- assertEquals(1, config.getProducts().size());
- assertEquals(4, config.getOpenStatusValues().size());
- assertEquals(2, config.getComponents("TestProduct").size());
- assertEquals(1, config.getVersions("TestProduct").size());
- // assertEquals(1, config.getTargetMilestones("TestProduct").size());
- }
-
- public void test220RDFProductConfig() throws Exception {
- BugzillaClient client = new BugzillaClient(new URL(IBugzillaConstants.TEST_BUGZILLA_220_URL), "", "", "", "",
- "UTF-8");
- RepositoryConfiguration config = client.getRepositoryConfiguration();
- assertNotNull(config);
- assertEquals("2.20.3", config.getInstallVersion());
- assertEquals(7, config.getStatusValues().size());
- assertEquals(8, config.getResolutions().size());
- assertEquals(4, config.getPlatforms().size());
- assertEquals(5, config.getOSs().size());
- assertEquals(5, config.getPriorities().size());
- assertEquals(7, config.getSeverities().size());
- assertEquals(2, config.getProducts().size());
- assertEquals(4, config.getOpenStatusValues().size());
- assertEquals(2, config.getComponents("TestProduct").size());
- assertEquals(1, config.getVersions("TestProduct").size());
- // assertEquals(1, config.getTargetMilestones("TestProduct").size());
- }
-
- public void test218RDFProductConfig() throws Exception {
- BugzillaClient client = new BugzillaClient(new URL(IBugzillaConstants.TEST_BUGZILLA_218_URL), "", "", "", "",
- "UTF-8");
- RepositoryConfiguration config = client.getRepositoryConfiguration();
- assertNotNull(config);
- assertEquals("2.18.6", config.getInstallVersion());
- assertEquals(7, config.getStatusValues().size());
- assertEquals(8, config.getResolutions().size());
- assertEquals(8, config.getPlatforms().size());
- assertEquals(36, config.getOSs().size());
- assertEquals(5, config.getPriorities().size());
- assertEquals(7, config.getSeverities().size());
- assertEquals(1, config.getProducts().size());
- assertEquals(4, config.getOpenStatusValues().size());
- assertEquals(1, config.getComponents("TestProduct").size());
- assertEquals(1, config.getVersions("TestProduct").size());
- // assertEquals(1, config.getTargetMilestones("TestProduct").size());
- }
-
- public void testEclipseRDFProductConfig() throws Exception {
- BugzillaClient client = new BugzillaClient(new URL(IBugzillaConstants.ECLIPSE_BUGZILLA_URL), "", "", "", "",
- "UTF-8");
- RepositoryConfiguration config = client.getRepositoryConfiguration();
- assertNotNull(config);
- assertEquals("2.22.1", config.getInstallVersion());
- assertEquals(7, config.getStatusValues().size());
- assertEquals(8, config.getResolutions().size());
- assertEquals(6, config.getPlatforms().size());
- assertEquals(29, config.getOSs().size());
- assertEquals(5, config.getPriorities().size());
- assertEquals(7, config.getSeverities().size());
- assertTrue(config.getProducts().size() > 50);
- assertEquals(4, config.getOpenStatusValues().size());
- assertEquals(13, config.getComponents("Mylyn").size());
- assertEquals(24, config.getKeywords().size());
- // assertEquals(10, config.getComponents("Hyades").size());
- // assertEquals(1, config.getTargetMilestones("TestProduct").size());
- }
-
- public void testRepositoryConfigurationCachePersistance() throws Exception {
- RepositoryConfiguration configuration1 = new RepositoryConfiguration();
- configuration1.setRepositoryUrl("url1");
- configuration1.addProduct("Test Product 1");
- assertEquals(1, configuration1.getProducts().size());
-
- RepositoryConfiguration configuration2 = new RepositoryConfiguration();
- configuration1.setRepositoryUrl("url2");
- configuration2.addProduct("Test Product 2");
- assertEquals(1, configuration2.getProducts().size());
-
- BugzillaCorePlugin.addRepositoryConfiguration(configuration1);
- BugzillaCorePlugin.addRepositoryConfiguration(configuration2);
- BugzillaCorePlugin.writeRepositoryConfigFile();
- BugzillaCorePlugin.removeConfiguration(configuration1);
- BugzillaCorePlugin.removeConfiguration(configuration2);
- assertNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
- assertNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration2.getRepositoryUrl()));
- BugzillaCorePlugin.readRepositoryConfigurationFile();
- assertNotNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
- assertNotNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration2.getRepositoryUrl()));
- RepositoryConfiguration testLoadedConfig = BugzillaCorePlugin.getRepositoryConfiguration(configuration1.getRepositoryUrl());
- assertEquals(1, testLoadedConfig.getProducts().size());
- assertEquals(configuration1.getProducts().get(0), testLoadedConfig.getProducts().get(0));
- }
-
-// @SuppressWarnings("deprecation")
-// public void testHtmlCleaner() throws IOException, BugzillaException, GeneralSecurityException {
-// StringBuffer incoming = new StringBuffer();
-// incoming.append("<RDF xmlns=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#");
-// incoming.append("xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#");
-// incoming.append("xmlns:bz=\"http://www.bugzilla.org/rdf#\">");
-// incoming.append("<li>");
-// incoming.append("<bz:product
-// incoming.append("</bz:product>");
-// incoming.append("</li>");
-// incoming.append("</RDF>");
-//
-// StringBuffer result = XmlCleaner.clean(new StringReader(incoming.toString()));
-// System.err.println(result);
-// }
-
- /**
- * Can use this to test config data submitted by users. Be sure not to commit user's config file though. The file
- * included (rdfconfig218.txt) is from mylar.eclipse.org/bugs218
- */
- public void testRepositoryConfigurationFromFile() throws Exception {
-
- URL entryURL = BugzillaTestPlugin.getDefault().getBundle().getEntry("testdata/configuration/rdfconfig218.txt");
- assertNotNull(entryURL);
- URL fileURL = FileLocator.toFileURL(entryURL);
- assertNotNull(fileURL);
-
- BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileURL.getFile())));
-
- if (true) {
- StringBuffer result = XmlCleaner.clean(in);
- StringReader strReader = new StringReader(result.toString());
- in = new BufferedReader(strReader);
- }
-
- SaxConfigurationContentHandler contentHandler = new SaxConfigurationContentHandler();
- final XMLReader reader = XMLReaderFactory.createXMLReader();
- reader.setContentHandler(contentHandler);
- reader.setErrorHandler(new ErrorHandler() {
-
- public void error(SAXParseException exception) throws SAXException {
- throw exception;
- }
-
- public void fatalError(SAXParseException exception) throws SAXException {
- throw exception;
- }
-
- public void warning(SAXParseException exception) throws SAXException {
- throw exception;
- }
- });
- reader.parse(new InputSource(in));
-
- RepositoryConfiguration config = contentHandler.getConfiguration();
- assertNotNull(config);
-
- assertTrue(config.getProducts().contains(
- "Test-Long-Named-Product-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
-
- // Add your additional checking for valid data here if necessary
-
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java
deleted file mode 100644
index 291523b72..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 Mylyn project committers 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
- *******************************************************************************/
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.context.tests.support.TestUtil;
-import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-
-/**
- * Tests for parsing Product Page for new Bugzilla reports
- *
- * @author Mik Kersten
- * @author Rob Elves
- */
-public class BugzillaProductParserTest extends TestCase {
-
- private TaskRepository repository;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND,
- // new URL(IBugzillaConstants.ECLIPSE_BUGZILLA_URL));
- // MylarTaskListPlugin.getRepositoryManager().addRepository(repository);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- // MylarTaskListPlugin.getRepositoryManager().removeRepository(repository);
- }
-
- public BugzillaProductParserTest(String arg0) {
- super(arg0);
- }
-
- private TaskRepository setRepository(String url) {
- repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, url);
- Credentials credentials = TestUtil.readCredentials();
- repository.setAuthenticationCredentials(credentials.username, credentials.password);
- return repository;
- }
-
- public void test222Products() throws Exception {
- setRepository(IBugzillaConstants.TEST_BUGZILLA_222_URL);
- List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getProducts();
- Iterator<String> itr = productList.iterator();
- assertTrue(itr.hasNext());
- assertEquals("Read Only Test Cases", itr.next());
- }
-
- public void test2201Products() throws Exception {
- setRepository(IBugzillaConstants.TEST_BUGZILLA_2201_URL);
- List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getProducts();
- Iterator<String> itr = productList.iterator();
- assertTrue(itr.hasNext());
- assertEquals("TestProduct", "TestProduct", itr.next());
-
- }
-
- public void test220Products() throws Exception {
- setRepository(IBugzillaConstants.TEST_BUGZILLA_220_URL);
- List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getProducts();
- assertEquals(2, productList.size());
- assertTrue(productList.contains("TestProduct"));
- assertTrue(productList.contains("Widget"));
-
- }
-
- public void test218Products() throws Exception {
- setRepository(IBugzillaConstants.TEST_BUGZILLA_218_URL);
- List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getProducts();
- assertEquals(1, productList.size());
- assertTrue(productList.contains("TestProduct"));
- }
-
-// No longer supporting 216
-// public void test216Products() throws Exception {
-//
-// repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_216_URL,
-// IBugzillaConstants.BugzillaServerVersion.SERVER_216.toString());
-//
-// List<String> productList = BugzillaRepositoryUtil.getProductList(repository);
-// Iterator<String> itr = productList.iterator();
-// assertTrue(itr.hasNext());
-// assertEquals("TestProduct", "TestProduct", itr.next());
-// }
-
-}
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
deleted file mode 100644
index 5a4d7f2fb..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
+++ /dev/null
@@ -1,659 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaReportElement;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryQuery;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
-import org.eclipse.mylyn.internal.tasks.core.LocalAttachment;
-import org.eclipse.mylyn.tasks.core.AbstractTask;
-import org.eclipse.mylyn.tasks.core.RepositoryAttachment;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
-import org.eclipse.mylyn.tasks.core.AbstractTask.RepositoryTaskSyncState;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.ui.search.RepositorySearchResult;
-import org.eclipse.mylyn.tasks.ui.search.SearchHitCollector;
-
-/**
- * @author Mik Kersten
- * @author Rob Elves
- * @author Nathan Hapke
- */
-public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
-
- public void testFocedQuerySynchronization() throws CoreException {
- init222();
- TasksUiPlugin.getSynchronizationManager().setForceSyncExec(true);
- TasksUiPlugin.getTaskDataManager().clear();
- assertEquals(0, taskList.getAllTasks().size());
- BugzillaRepositoryQuery bugQuery = new BugzillaRepositoryQuery(
- IBugzillaConstants.TEST_BUGZILLA_222_URL,
- "http://mylyn.eclipse.org/bugs222/buglist.cgi?short_desc_type=allwordssubstr&short_desc=&product=Read+Only+Test+Cases&long_desc_type=allwordssubstr&long_desc=&bug_status=NEW&order=Importance",
- "testFocedQuerySynchronization");
-
- taskList.addQuery(bugQuery);
-
- TasksUiPlugin.getSynchronizationManager().synchronize(connector, bugQuery, null, false);
-
- assertEquals(1, bugQuery.getChildren().size());
- AbstractTask hit = (AbstractTask) bugQuery.getChildren().toArray()[0];
- assertTrue(TasksUiPlugin.getTaskDataManager().getNewTaskData(hit.getRepositoryUrl(), hit.getTaskId()) != null);
- TasksUiPlugin.getTaskDataManager().remove(hit.getRepositoryUrl(), hit.getTaskId());
-
- TasksUiPlugin.getSynchronizationManager().synchronize(connector, bugQuery, null, true);
- assertEquals(1, bugQuery.getChildren().size());
- hit = (AbstractTask) bugQuery.getChildren().toArray()[0];
- assertTrue(TasksUiPlugin.getTaskDataManager().getNewTaskData(hit.getRepositoryUrl(), hit.getTaskId()) != null);
-
- }
-
- public void testCreateTaskFromExistingId() throws Exception {
- init222();
- try {
- connector.createTaskFromExistingId(repository, "9999", new NullProgressMonitor());
- fail();
- } catch (CoreException ce) {
-
- }
-
- BugzillaTask task = generateLocalTaskAndDownload("1");
- assertNotNull(task);
- assertNotNull(TasksUiPlugin.getTaskDataManager().getNewTaskData(task.getRepositoryUrl(), task.getTaskId()));
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSynchronizationState());
-
- BugzillaTask retrievedTask = (BugzillaTask) taskList.getTask(task.getHandleIdentifier());
- assertNotNull(retrievedTask);
- assertEquals(task.getHandleIdentifier(), retrievedTask.getHandleIdentifier());
- }
-
- public void testAnonymousRepositoryAccess() throws Exception {
- init218();
- assertNotNull(repository);
- repository.setAuthenticationCredentials("", "");
- // test anonymous task retrieval
- BugzillaTask task = this.generateLocalTaskAndDownload("2");
- assertNotNull(task);
-
- // // test anonymous query (note that this demonstrates query via
- // eclipse search (ui)
- // SearchHitCollector collector = new SearchHitCollector(taskList);
- // collector.setProgressMonitor(new NullProgressMonitor());
- // BugzillaSearchOperation operation = new BugzillaSearchOperation(
- // repository,
- // "http://mylyn.eclipse.org/bugs218/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=",
- // null, collector, "-1");
- //
- String queryUrl = "http://mylyn.eclipse.org/bugs218/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=";
- BugzillaRepositoryQuery bugzillaQuery = new BugzillaRepositoryQuery(repository.getUrl(), queryUrl, "search");
-
- SearchHitCollector collector = new SearchHitCollector(taskList, repository, bugzillaQuery, taskFactory);
- RepositorySearchResult result = (RepositorySearchResult) collector.getSearchResult();
-
- // operation.run(new NullProgressMonitor());
- // BugzillaSearchQuery searchQuery = new BugzillaSearchQuery(collector);
- collector.run(new NullProgressMonitor());
- assertEquals(2, result.getElements().length);
-
- for (AbstractTask hit : collector.getTasks()) {
- assertTrue(hit.getSummary().contains("search-match-test"));
- }
-
- // test anonymous update of configuration
- RepositoryConfiguration config = BugzillaCorePlugin.getRepositoryConfiguration(repository, false);
- assertNotNull(config);
- assertTrue(config.getComponents().size() > 0);
- }
-
- public void testUpdate() throws Exception {
- init222();
- String taskNumber = "3";
- TasksUiPlugin.getTaskDataManager().clear();
- assertEquals(0, TasksUiPlugin.getTaskListManager().getTaskList().getAllTasks().size());
- BugzillaTask task = this.generateLocalTaskAndDownload(taskNumber);
- assertEquals("search-match-test 2", task.getSummary());
- assertEquals("TestProduct", task.getProduct());
- assertEquals("P1", task.getPriority());
- assertEquals("blocker", task.getSeverity());
- assertEquals("nhapke@cs.ubc.ca", task.getOwner());
- // assertEquals("2007-04-18 14:21:40",
- // task.getCompletionDate().toString());
- assertFalse(task.isCompleted());
- assertEquals("http://mylyn.eclipse.org/bugs222/show_bug.cgi?id=3", task.getUrl());
- }
-
- public void testUpdateWithSubTasks() throws Exception {
- init222();
- String taskNumber = "23";
- TasksUiPlugin.getTaskDataManager().clear();
- assertEquals(0, TasksUiPlugin.getTaskListManager().getTaskList().getAllTasks().size());
- BugzillaTask task = this.generateLocalTaskAndDownload(taskNumber);
- assertNotNull(task.getChildren());
- assertEquals(2, task.getChildren().size());
- }
-
- public void testContextAttachFailure() throws Exception {
- init218();
- BugzillaTask task = this.generateLocalTaskAndDownload("3");
- assertNotNull(task);
- assertNotNull(TasksUiPlugin.getTaskDataManager().getNewTaskData(task.getRepositoryUrl(), task.getTaskId()));
- TasksUiPlugin.getTaskListManager().activateTask(task);
- File sourceContextFile = ContextCorePlugin.getContextManager().getFileForContext(task.getHandleIdentifier());
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSynchronizationState());
- sourceContextFile.createNewFile();
- sourceContextFile.deleteOnExit();
- repository.setAuthenticationCredentials("wrong", "wrong");
- try {
- connector.getAttachmentHandler().attachContext(repository, task, "", new NullProgressMonitor());
- } catch (CoreException e) {
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSynchronizationState());
- return;
- }
- fail("Should have failed due to invalid userid and password.");
- }
-
- public void testSynchronize() throws CoreException {
- init222();
-
- TasksUiPlugin.getTaskDataManager().clear();
-
- // Get the task
- BugzillaTask task = generateLocalTaskAndDownload("3");
-
- RepositoryTaskData taskData = TasksUiPlugin.getTaskDataManager().getEditableCopy(task.getRepositoryUrl(),
- task.getTaskId());
- assertNotNull(taskData);
-
- TasksUiPlugin.getTaskListManager().getTaskList().moveToContainer(task,
- TasksUiPlugin.getTaskListManager().getTaskList().getDefaultCategory());
- int numComments = taskData.getComments().size();
-
- // Modify it
- String newCommentText = "BugzillaRepositoryClientTest.testSynchronize(): " + (new Date()).toString();
- taskData.setNewComment(newCommentText);
- Set<RepositoryTaskAttribute> changed = new HashSet<RepositoryTaskAttribute>();
- changed.add(taskData.getAttribute(RepositoryTaskAttribute.COMMENT_NEW));
- TasksUiPlugin.getTaskDataManager().saveEdits(task.getRepositoryUrl(), task.getTaskId(), changed);
-
- // Submit changes
- submit(task, taskData);
-
- TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
- // After submit task should be in SYNCHRONIZED state
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSynchronizationState());
- RepositoryTaskData taskData2 = TasksUiPlugin.getTaskDataManager().getNewTaskData(task.getRepositoryUrl(),
- task.getTaskId());
- assertFalse(taskData2.getLastModified().equals(taskData.getLastModified()));
- // Still not read
- assertFalse(taskData2.getLastModified().equals(task.getLastReadTimeStamp()));
- TasksUiPlugin.getSynchronizationManager().setTaskRead(task, true);
- assertEquals(taskData2.getLastModified(), task.getLastReadTimeStamp());
- assertTrue(taskData2.getComments().size() > numComments);
-
- // 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);
- TasksUiPlugin.getTaskDataManager().remove(task.getRepositoryUrl(), task.getTaskId());
- TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, false, null);
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSynchronizationState());
- RepositoryTaskData bugReport2 = null;
- bugReport2 = TasksUiPlugin.getTaskDataManager().getNewTaskData(task.getRepositoryUrl(), task.getTaskId());
- assertNotNull(bugReport2);
- assertEquals(task.getTaskId(), bugReport2.getId());
-
- assertEquals(newCommentText, bugReport2.getComments().get(numComments).getText());
- // TODO: Test that comment was appended
- // ArrayList<Comment> comments = task.getTaskData().getComments();
- // assertNotNull(comments);
- // assertTrue(comments.size() > 0);
- // Comment lastComment = comments.get(comments.size() - 1);
- // assertEquals(newCommentText, lastComment.getText());
-
- }
-
- public void testUniqueQueryHitObjects() {
- init222();
- BugzillaRepositoryQuery query1 = new BugzillaRepositoryQuery(IBugzillaConstants.TEST_BUGZILLA_222_URL,
- "queryurl", "description1");
- BugzillaTask query1Hit = new BugzillaTask(IBugzillaConstants.TEST_BUGZILLA_222_URL, "1", "description1");
- taskList.addQuery(query1);
- taskList.addTask(query1Hit, query1);
-
- BugzillaRepositoryQuery query2 = new BugzillaRepositoryQuery(IBugzillaConstants.TEST_BUGZILLA_222_URL,
- "queryurl2", "description2");
- BugzillaTask query2Hit = new BugzillaTask(IBugzillaConstants.TEST_BUGZILLA_222_URL, "1", "description2");
- taskList.addQuery(query2);
- taskList.addTask(query2Hit, query1);
-
- assertEquals(2, taskList.getQueries().size());
- assertEquals(1, taskList.getAllTasks().size());
- for (AbstractTask hit : query1.getChildren()) {
- for (AbstractTask hit2 : query2.getChildren()) {
- assertTrue(hit.getClass().equals(hit2.getClass()));
- }
- }
-
- taskList.deleteQuery(query1);
- taskList.deleteQuery(query2);
- assertEquals(1, taskList.getAllTasks().size());
- }
-
- public void testAttachToExistingReport() throws Exception {
- init222();
- String taskNumber = "33";
- BugzillaTask task = generateLocalTaskAndDownload(taskNumber);
- RepositoryTaskData taskData = TasksUiPlugin.getTaskDataManager().getNewTaskData(task.getRepositoryUrl(),
- task.getTaskId());
-
- assertNotNull(task);
- assertNotNull(taskData);
- TasksUiPlugin.getSynchronizationManager().setTaskRead(task, true);
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSynchronizationState());
- assertEquals(taskNumber, taskData.getId());
- int numAttached = taskData.getAttachments().size();
- String fileName = "test-attach-" + System.currentTimeMillis() + ".txt";
-
- assertNotNull(repository.getUserName());
- assertNotNull(repository.getPassword());
-
- /* Initialize a local attachment */
- LocalAttachment attachment = new LocalAttachment();
- attachment.setDescription("Test attachment " + new Date());
- attachment.setContentType("text/plain");
- attachment.setPatch(false);
- attachment.setReport(taskData);
- attachment.setComment("Automated JUnit attachment test"); // optional
-
- /* Test attempt to upload a non-existent file */
- attachment.setFilePath("/this/is/not/a/real-file");
- attachment.setFile(new File(attachment.getFilePath()));
- attachment.setFilename("real-file");
- // IAttachmentHandler attachmentHandler =
- // connector.getAttachmentHandler();
- BugzillaClient client = connector.getClientManager().getClient(repository);
- try {
- client.postAttachment(attachment.getReport().getId(), attachment.getComment(), attachment);
- fail();
- } catch (Exception e) {
- }
- // attachmentHandler.uploadAttachment(repository, task, comment,
- // summary, file, contentType, isPatch, proxySettings)
- // assertFalse(attachmentHandler.uploadAttachment(attachment,
- // repository.getUserName(), repository.getPassword(),
- // Proxy.NO_PROXY));
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSynchronizationState());
- task = (BugzillaTask) connector.createTaskFromExistingId(repository, taskNumber, new NullProgressMonitor());
- TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
-
- assertEquals(numAttached, taskData.getAttachments().size());
-
- /* Test attempt to upload an empty file */
- File attachFile = new File(fileName);
- attachment.setFilePath(attachFile.getAbsolutePath());
- BufferedWriter write = new BufferedWriter(new FileWriter(attachFile));
- attachFile = new File(attachment.getFilePath());
- attachment.setFile(attachFile);
- attachment.setFilename(attachFile.getName());
- // assertFalse(attachmentHandler.uploadAttachment(attachment,
- // repository.getUserName(), repository.getPassword(),
- // Proxy.NO_PROXY));
- try {
- client.postAttachment(attachment.getReport().getId(), attachment.getComment(), attachment);
- fail();
- } catch (Exception e) {
- }
- task = (BugzillaTask) connector.createTaskFromExistingId(repository, taskNumber, new NullProgressMonitor());
- TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
- taskData = TasksUiPlugin.getTaskDataManager().getNewTaskData(task.getRepositoryUrl(), task.getTaskId());
- assertEquals(numAttached, taskData.getAttachments().size());
-
- /* Test uploading a proper file */
- write.write("test file");
- write.close();
- attachment.setFilePath(attachFile.getAbsolutePath());
- // assertTrue(attachmentHandler.uploadAttachment(attachment,
- // repository.getUserName(), repository.getPassword(),
- // Proxy.NO_PROXY));
- File fileToAttach = new File(attachment.getFilePath());
- assertTrue(fileToAttach.exists());
- attachment.setFile(fileToAttach);
- attachment.setFilename(fileToAttach.getName());
- client.postAttachment(attachment.getReport().getId(), attachment.getComment(), attachment);
-
- task = (BugzillaTask) connector.createTaskFromExistingId(repository, taskNumber, new NullProgressMonitor());
- TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
- taskData = TasksUiPlugin.getTaskDataManager().getNewTaskData(task.getRepositoryUrl(), task.getTaskId());
- assertEquals(numAttached + 1, taskData.getAttachments().size());
-
- // use assertion to track clean-up
- assertTrue(attachFile.delete());
- }
-
- public void testSynchChangedReports() throws Exception {
-
- init222();
- String taskID = "4";
- BugzillaTask task4 = generateLocalTaskAndDownload(taskID);
- RepositoryTaskData taskData4 = TasksUiPlugin.getTaskDataManager().getEditableCopy(task4.getRepositoryUrl(),
- task4.getTaskId());
- assertNotNull(task4);
- assertNotNull(taskData4);
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task4.getSynchronizationState());
- assertEquals(taskID, taskData4.getId());
-
- BugzillaTask task5 = generateLocalTaskAndDownload("5");
- RepositoryTaskData taskData5 = TasksUiPlugin.getTaskDataManager().getEditableCopy(task5.getRepositoryUrl(),
- task5.getTaskId());
- assertNotNull(task5);
- assertNotNull(taskData5);
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task5.getSynchronizationState());
- assertEquals("5", taskData5.getId());
-
- Set<AbstractTask> tasks = new HashSet<AbstractTask>();
- tasks.add(task4);
- tasks.add(task5);
-
- // Precondition for test passing is that task5's modification data is
- // AFTER
- // task4's
-
- TasksUiPlugin.getRepositoryManager().setSynchronizationTime(repository, task5.getLastReadTimeStamp(),
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
-
- boolean changed = connector.markStaleTasks(repository, tasks, new NullProgressMonitor());
- assertTrue(changed);
- // Always last known changed returned
- assertFalse(task4.isStale());
- assertTrue(task5.isStale());
-
- String priority4 = null;
- if (task4.getPriority().equals("P1")) {
- priority4 = "P2";
- taskData4.setAttributeValue(BugzillaReportElement.PRIORITY.getKeyString(), priority4);
- } else {
- priority4 = "P1";
- taskData4.setAttributeValue(BugzillaReportElement.PRIORITY.getKeyString(), priority4);
- }
-
- String priority5 = null;
- if (task5.getPriority().equals("P1")) {
- priority5 = "P2";
- taskData5.setAttributeValue(BugzillaReportElement.PRIORITY.getKeyString(), priority5);
- } else {
- priority5 = "P1";
- taskData5.setAttributeValue(BugzillaReportElement.PRIORITY.getKeyString(), priority5);
- }
-
- assertNotNull(repository.getUserName());
- assertNotNull(repository.getPassword());
-
- submit(task4, taskData4);
- submit(task5, taskData5);
-
- changed = connector.markStaleTasks(repository, tasks, new NullProgressMonitor());
-
- assertTrue(task4.isStale());
- assertTrue(task5.isStale());
-
- TasksUiPlugin.getSynchronizationManager().synchronize(connector, tasks, true, null);
-
- for (AbstractTask task : tasks) {
- if (task.getTaskId() == "4") {
- assertEquals(priority4, task4.getPriority());
- }
- if (task.getTaskId() == "5") {
- assertEquals(priority5, task5.getPriority());
- }
- }
- }
-
- public void testIncomingWhenOfflineDeleted() throws Exception {
-
- init222();
- BugzillaTask task7 = generateLocalTaskAndDownload("7");
- RepositoryTaskData recentTaskData = TasksUiPlugin.getTaskDataManager().getNewTaskData(task7.getRepositoryUrl(),
- task7.getTaskId());
- assertNotNull(recentTaskData);
- TasksUiPlugin.getSynchronizationManager().setTaskRead(task7, true);
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task7.getSynchronizationState());
- assertEquals("7", recentTaskData.getId());
-
- Set<AbstractTask> tasks = new HashSet<AbstractTask>();
- tasks.add(task7);
-
- TasksUiPlugin.getRepositoryManager().setSynchronizationTime(repository, task7.getLastReadTimeStamp(),
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
-
- assertNotNull(TasksUiPlugin.getTaskDataManager().getNewTaskData(IBugzillaConstants.TEST_BUGZILLA_222_URL, "7"));
- TasksUiPlugin.getTaskDataManager().remove(task7.getRepositoryUrl(), task7.getTaskId());
-
- assertNull(TasksUiPlugin.getTaskDataManager().getNewTaskData(IBugzillaConstants.TEST_BUGZILLA_222_URL, "7"));
-
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task7.getSynchronizationState());
- assertNotNull(task7.getLastReadTimeStamp());
- // Task no longer stored offline
- // make an external change
- assertNotNull(repository.getUserName());
- assertNotNull(repository.getPassword());
-
- String priority = null;
- if (task7.getPriority().equals("P1")) {
- priority = "P2";
- recentTaskData.setAttributeValue(BugzillaReportElement.PRIORITY.getKeyString(), priority);
- } else {
- priority = "P1";
- recentTaskData.setAttributeValue(BugzillaReportElement.PRIORITY.getKeyString(), priority);
- }
- // REMOVE ALL TASK DATA
- TasksUiPlugin.getTaskDataManager().clear();
- connector.getTaskDataHandler().postTaskData(repository, recentTaskData, new NullProgressMonitor());
- TasksUiPlugin.getSynchronizationManager().synchronizeChanged(connector, repository);
- assertEquals(RepositoryTaskSyncState.INCOMING, task7.getSynchronizationState());
- }
-
- public void testTimeTracker222() throws Exception {
- init222();
- timeTracker(15, true);
- }
-
- // We'll skip these two for now and just test 222 and 218 since
- // they are the most common. If problems arise we can re-enable.
- // public void testTimeTracker2201() throws Exception {
- // init2201();
- // timeTracker(22, true);
- // }
- //
- // public void testTimeTracker220() throws Exception {
- // init220();
- // timeTracker(8, true);
- // }
-
- public void testTimeTracker218() throws Exception {
- init218();
- timeTracker(20, false);
- }
-
- /**
- * @param enableDeadline
- * bugzilla 218 doesn't support deadlines
- */
- protected void timeTracker(int taskid, boolean enableDeadline) throws Exception {
- BugzillaTask bugtask = generateLocalTaskAndDownload("" + taskid);
- RepositoryTaskData bugtaskdata = TasksUiPlugin.getTaskDataManager().getNewTaskData(bugtask.getRepositoryUrl(),
- bugtask.getTaskId());
- assertNotNull(bugtaskdata);
- assertEquals(taskid + "", bugtaskdata.getId());
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, bugtask.getSynchronizationState());
-
- Set<AbstractTask> tasks = new HashSet<AbstractTask>();
- tasks.add(bugtask);
-
- // synchAndAssertState(tasks, RepositoryTaskSyncState.SYNCHRONIZED);
-
- TasksUiPlugin.getRepositoryManager().setSynchronizationTime(repository, bugtask.getLastReadTimeStamp(),
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- // connector.synchronizeChanged(repository);
-
- // Set<AbstractTask> changedTasks =
- // connector.getOfflineTaskHandler().getChangedSinceLastSync(repository,
- // tasks);
- // assertEquals(1, changedTasks.size());
-
- assertNotNull(repository.getUserName());
- assertNotNull(repository.getPassword());
-
- float estimatedTime, remainingTime, actualTime, addTime;
- String deadline = null;
-
- estimatedTime = Float.parseFloat(bugtaskdata.getAttributeValue(BugzillaReportElement.ESTIMATED_TIME.getKeyString()));
- remainingTime = Float.parseFloat(bugtaskdata.getAttributeValue(BugzillaReportElement.REMAINING_TIME.getKeyString()));
- actualTime = Float.parseFloat(bugtaskdata.getAttributeValue(BugzillaReportElement.ACTUAL_TIME.getKeyString()));
- if (enableDeadline)
- deadline = bugtaskdata.getAttributeValue(BugzillaReportElement.DEADLINE.getKeyString());
-
- estimatedTime += 2;
- remainingTime += 1.5;
- addTime = 0.75f;
- if (enableDeadline)
- deadline = generateNewDay();
-
- bugtaskdata.setAttributeValue(BugzillaReportElement.ESTIMATED_TIME.getKeyString(), "" + estimatedTime);
- bugtaskdata.setAttributeValue(BugzillaReportElement.REMAINING_TIME.getKeyString(), "" + remainingTime);
- bugtaskdata.setAttributeValue(BugzillaReportElement.WORK_TIME.getKeyString(), "" + addTime);
- if (enableDeadline)
- bugtaskdata.setAttributeValue(BugzillaReportElement.DEADLINE.getKeyString(), deadline);
-
-// for (AbstractTask task : tasks) {
-// RepositoryTaskData taskData = TasksUiPlugin.getTaskDataManager().getNewTaskData(
-// task.getHandleIdentifier());
- bugtaskdata.setAttributeValue(BugzillaReportElement.ADD_COMMENT.getKeyString(), "New Estimate: "
- + estimatedTime + "\nNew Remaining: " + remainingTime + "\nAdd: " + addTime);
- submit(bugtask, bugtaskdata);
-// }
-
- synchAndAssertState(tasks, RepositoryTaskSyncState.SYNCHRONIZED);
-
- bugtaskdata = TasksUiPlugin.getTaskDataManager()
- .getNewTaskData(bugtask.getRepositoryUrl(), bugtask.getTaskId());
-
- assertEquals(estimatedTime,
- Float.parseFloat(bugtaskdata.getAttributeValue(BugzillaReportElement.ESTIMATED_TIME.getKeyString())));
- assertEquals(remainingTime,
- Float.parseFloat(bugtaskdata.getAttributeValue(BugzillaReportElement.REMAINING_TIME.getKeyString())));
- assertEquals(actualTime + addTime,
- Float.parseFloat(bugtaskdata.getAttributeValue(BugzillaReportElement.ACTUAL_TIME.getKeyString())));
- if (enableDeadline)
- assertEquals(deadline, bugtaskdata.getAttributeValue(BugzillaReportElement.DEADLINE.getKeyString()));
-
- }
-
- private String generateNewDay() {
- int year = 2006;
- int month = (int) (Math.random() * 12 + 1);
- int day = (int) (Math.random() * 28 + 1);
- return "" + year + "-" + ((month <= 9) ? "0" : "") + month + "-" + ((day <= 9) ? "0" : "") + day;
- }
-
- /**
- * Ensure obsoletes and patches are marked as such by the parser.
- */
- public void testAttachmentAttributes() throws Exception {
- init222();
- int bugId = 19;
- String taskNumber = "" + bugId;
- BugzillaTask task = generateLocalTaskAndDownload(taskNumber);
-
- // TasksUiPlugin.getSynchronizationManager().synchronize(connector,
- // task, true, null);
-
- assertNotNull(task);
-
- boolean isPatch[] = { false, true, false, false, false, false, false, true, false, false };
- boolean isObsolete[] = { false, true, false, true, false, false, false, false, false, false };
-
- RepositoryTaskData taskData = TasksUiPlugin.getTaskDataManager().getNewTaskData(task.getRepositoryUrl(),
- task.getTaskId());
-
- Iterator<RepositoryAttachment> iter = taskData.getAttachments().iterator();
-
- int index = 0;
- while (iter.hasNext()) {
- assertTrue(validateAttachmentAttributes(iter.next(), isPatch[index], isObsolete[index]));
- index++;
- }
- }
-
- private boolean validateAttachmentAttributes(RepositoryAttachment att, boolean isPatch, boolean isObsolete) {
- return (att.isPatch() == isPatch) && (att.isObsolete() == isObsolete);
- }
-
-// public void testSimpleLoad() throws Exception {
-// repository = new TaskRepository(DEFAULT_KIND,
-// IBugzillaConstants.ECLIPSE_BUGZILLA_URL);
-// //Credentials credentials = MylarTestUtils.readCredentials();
-// //repository.setAuthenticationCredentials(credentials.username,
-// credentials.password);
-//
-// //repository.setTimeZoneId("Canada/Eastern");
-// assertNotNull(manager);
-// manager.addRepository(repository,
-// TasksUiPlugin.getDefault().getRepositoriesFilePath());
-//
-// taskList = TasksUiPlugin.getTaskListManager().getTaskList();
-//
-// AbstractRepositoryConnector abstractRepositoryConnector =
-// manager.getRepositoryConnector(DEFAULT_KIND);
-//
-// assertEquals(abstractRepositoryConnector.getRepositoryType(), DEFAULT_KIND);
-//
-// connector = (BugzillaRepositoryConnector) abstractRepositoryConnector;
-//
-// long start = System.currentTimeMillis();
-// BugzillaTask task = null;
-// for(int x = 1; x < 5; x++) {
-// if(task != null)
-// taskList.deleteTask(task);
-//
-// task = this.generateLocalTaskAndDownload("154100");
-// assertNotNull(task);
-// }
-// System.err.println("Total: "+((System.currentTimeMillis() - start)/1000));
-// }
-
- // class MockBugzillaReportSubmitForm extends BugzillaReportSubmitForm {
- //
- // public MockBugzillaReportSubmitForm(String encoding_utf_8) {
- // super(encoding_utf_8);
- // }
- //
- // @Override
- // public String submitReportToRepository() throws BugzillaException,
- // LoginException,
- // PossibleBugzillaFailureException {
- // return "test-submit";
- // }
- //
- // }
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchDialogTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchDialogTest.java
deleted file mode 100644
index b7c742a27..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchDialogTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.internal.bugzilla.ui.search.BugzillaSearchPage;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.TaskRepositoryManager;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Test the bugzilla search dialog.
- *
- * @author Jeff Pound
- */
-public class BugzillaSearchDialogTest extends TestCase {
-
- private TaskRepositoryManager manager;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- manager = TasksUiPlugin.getRepositoryManager();
- assertNotNull(manager);
- manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- if (manager != null) {
- manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
- }
- }
-
- /**
- * Test that the search dialog is initialized properly with the given repository.
- *
- * @throws Exception
- */
- public void testSearchDialogInit() throws Exception {
- TaskRepository repo = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_222_URL,
- IBugzillaConstants.BugzillaServerVersion.SERVER_222.toString());
- manager.addRepository(repo, TasksUiPlugin.getDefault().getRepositoriesFilePath());
- BugzillaSearchPage page = new BugzillaSearchPage(repo);
- Shell shell = BugzillaTestPlugin.getDefault().getWorkbench().getDisplay().getShells()[0];
- page.createControl(shell);
- page.setVisible(true);
-
- /*
- * This assertion will fail with a 0 product count if the options are
- * not retrieved properly, throw an exception if the page is not
- * initialized properly, or pass otherwise.
- */
- assertFalse(page.getProductCount() == 0);
- }
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchEngineTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchEngineTest.java
deleted file mode 100644
index 3b384757f..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchEngineTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryQuery;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
-import org.eclipse.mylyn.tasks.core.AbstractTask;
-import org.eclipse.mylyn.tasks.core.QueryHitCollector;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.TaskFactory;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-
-/**
- * @author Rob Elves
- */
-public class BugzillaSearchEngineTest extends TestCase {
-
- private static final String QUERY_NAME = "Query Page Name";
-
- private static final String BUG_DESC_SUBSTRING_SEARCH = "/buglist.cgi?short_desc_type=allwordssubstr&short_desc=";// search-match-test&amp";
-
- private static final String SEARCH_DESCRIPTION = "search-match-test";
-
- private static final int NUM_EXPECTED_HITS = 2;
-
- private static final int NUM_REPOSITORIES = 0;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- TasksUiPlugin.getRepositoryManager().clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
- assertEquals(NUM_REPOSITORIES, TasksUiPlugin.getRepositoryManager().getRepositories(
- BugzillaCorePlugin.REPOSITORY_KIND).size());
- }
-
- @Override
- protected void tearDown() throws Exception {
- TasksUiPlugin.getRepositoryManager().clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
- super.tearDown();
- }
-
-// public void testSearching216() throws Exception {
-// TaskRepository repository = new
-// TaskRepository(BugzillaPlugin.REPOSITORY_KIND,
-// IBugzillaConstants.TEST_BUGZILLA_216_URL,
-// IBugzillaConstants.BugzillaServerVersion.SERVER_216.toString());
-// MylarTaskListPlugin.getRepositoryManager().addRepository(repository);
-// List<AbstractQueryHit> hits =
-// runQuery(IBugzillaConstants.TEST_BUGZILLA_216_URL, SEARCH_DESCRIPTION);
-// assertEquals(NUM_EXPECTED_HITS, hits.size());
-// }
-
- public void testSearching218() throws Exception {
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_218_URL,
- IBugzillaConstants.BugzillaServerVersion.SERVER_218.toString());
- TasksUiPlugin.getRepositoryManager().addRepository(repository,
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- assertEquals(NUM_EXPECTED_HITS, runQuery(IBugzillaConstants.TEST_BUGZILLA_218_URL, SEARCH_DESCRIPTION).size());
- }
-
- public void testSearching220() throws Exception {
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_220_URL,
- IBugzillaConstants.BugzillaServerVersion.SERVER_220.toString());
- TasksUiPlugin.getRepositoryManager().addRepository(repository,
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- assertEquals(NUM_EXPECTED_HITS, runQuery(IBugzillaConstants.TEST_BUGZILLA_220_URL, SEARCH_DESCRIPTION).size());
- }
-
- public void testSearching2201() throws Exception {
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_2201_URL,
- IBugzillaConstants.BugzillaServerVersion.SERVER_220.toString());
- TasksUiPlugin.getRepositoryManager().addRepository(repository,
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- assertEquals(NUM_EXPECTED_HITS, runQuery(IBugzillaConstants.TEST_BUGZILLA_2201_URL, SEARCH_DESCRIPTION).size());
- }
-
- public void testSearching222() throws Exception {
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_222_URL,
- IBugzillaConstants.BugzillaServerVersion.SERVER_222.toString());
- TasksUiPlugin.getRepositoryManager().addRepository(repository,
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- Set<AbstractTask> hits = runQuery(IBugzillaConstants.TEST_BUGZILLA_222_URL, SEARCH_DESCRIPTION);
- assertEquals(NUM_EXPECTED_HITS, hits.size());
- }
-
- @SuppressWarnings("deprecation")
- private Set<AbstractTask> runQuery(String repositoryURL, String SearchString) throws Exception {
- TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
- BugzillaCorePlugin.REPOSITORY_KIND, repositoryURL);
- assertNotNull(repository);
-
- final BugzillaRepositoryQuery repositoryQuery = new BugzillaRepositoryQuery(repository.getUrl(),
- repository.getUrl() + BUG_DESC_SUBSTRING_SEARCH + SearchString, QUERY_NAME);
-
- AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
- BugzillaCorePlugin.REPOSITORY_KIND);
-// TaskList taskList = TasksUiPlugin.getTaskListManager().getTaskList();
- QueryHitCollector collector = new QueryHitCollector(new TaskFactory(repository));
-
- connector.performQuery(repositoryQuery, repository, new NullProgressMonitor(), collector);
-
- // results.addAll(connector.performQuery(repositoryQuery, new
- // NullProgressMonitor(), new MultiStatus(TasksUiPlugin.PLUGIN_ID,
- // IStatus.OK, "Query result", null)));
- return collector.getTasks();
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskListManagerTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskListManagerTest.java
deleted file mode 100644
index 98716236f..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskListManagerTest.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryQuery;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
-import org.eclipse.mylyn.tasks.core.AbstractTask;
-import org.eclipse.mylyn.tasks.core.AbstractTaskCategory;
-import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.TaskList;
-import org.eclipse.mylyn.tasks.ui.TaskListManager;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-
-/**
- * @author Mik Kersten
- */
-public class BugzillaTaskListManagerTest extends TestCase {
-
- private TaskListManager manager;
-
- private TaskRepository repository;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- manager = TasksUiPlugin.getTaskListManager();
- manager.readExistingOrCreateNewList();
- manager.resetTaskList();
- manager.saveTaskList();
- repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.ECLIPSE_BUGZILLA_URL);
- TasksUiPlugin.getRepositoryManager().addRepository(repository,
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- manager.resetTaskList();
- TasksUiPlugin.getTaskListManager().saveTaskList();
-// TasksUiPlugin.getDefault().getTaskListSaveManager().saveTaskList(true);
- TasksUiPlugin.getRepositoryManager().removeRepository(repository,
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- }
-
- // TODO: move
- public void testRemindedPersistance() {
-
- String repositoryUrl = "https://bugs.eclipse.org/bugs";
-
- String bugNumber = "106939";
-
- BugzillaTask task1 = new BugzillaTask(repositoryUrl, bugNumber, "label");
- manager.getTaskList().addTask(task1);
-
- task1.setReminded(true);
-
- TasksUiPlugin.getTaskListManager().saveTaskList();
- TasksUiPlugin.getTaskListManager().resetTaskList();
- TasksUiPlugin.getTaskListManager().readExistingOrCreateNewList();
-
- TaskList taskList = manager.getTaskList();
- assertEquals(1, taskList.getAllTasks().size());
- Set<AbstractTask> tasksReturned = taskList.getRepositoryTasks(repositoryUrl);
- assertNotNull(tasksReturned);
- assertEquals(1, tasksReturned.size());
- for (AbstractTask task : tasksReturned) {
- assertTrue(task.isReminded());
- }
- }
-
- public void testRepositoryTaskExternalization() {
- BugzillaTask repositoryTask = new BugzillaTask("repo", "1", "label");
- repositoryTask.setTaskKind("kind");
- manager.getTaskList().moveToContainer(repositoryTask,
- TasksUiPlugin.getTaskListManager().getTaskList().getDefaultCategory());
- manager.saveTaskList();
-
- manager.resetTaskList();
- // manager.getTaskList().clear();
- // TaskList list = new TaskList();
- // manager.setTaskList(list);
- manager.readExistingOrCreateNewList();
- assertEquals(1, manager.getTaskList().getDefaultCategory().getChildren().size());
- AbstractTask readTask = manager.getTaskList().getDefaultCategory().getChildren().iterator().next();
-
- assertEquals(repositoryTask.getHandleIdentifier(), readTask.getHandleIdentifier());
- assertEquals(repositoryTask.getSummary(), readTask.getSummary());
- assertEquals(repositoryTask.getTaskKind(), readTask.getTaskKind());
- }
-
- public void testQueryExternalization() {
- AbstractRepositoryQuery query = new BugzillaRepositoryQuery("repositoryUrl", "queryUrl", "label");
- // long time = 1234;
- // Date oldDate = new Date(time);
- // query.setLastRefresh(oldDate);
- assertEquals("repositoryUrl", query.getRepositoryUrl());
- assertEquals("queryUrl", query.getUrl());
- assertEquals("<never>", query.getLastSynchronizedTimeStamp());
- query.setLastSynchronizedStamp("today");
- // assertEquals(time, query.getLastSynchronized().getTime());
- manager.getTaskList().addQuery(query);
- manager.saveTaskList();
- assertNotNull(manager.getTaskList());
-
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
- assertEquals(1, manager.getTaskList().getQueries().size());
- AbstractRepositoryQuery readQuery = manager.getTaskList().getQueries().iterator().next();
- assertEquals(query.getUrl(), readQuery.getUrl());
- assertEquals(query.getRepositoryUrl(), readQuery.getRepositoryUrl());
- assertEquals("today", query.getLastSynchronizedTimeStamp());
- assertEquals("repositoryUrl", readQuery.getRepositoryUrl());
- // assertEquals(time, readQuery.getLastSynchronized().getTime());
- }
-
- public void testBugzillaCustomQueryExternalization() {
- BugzillaRepositoryQuery query = new BugzillaRepositoryQuery("repositoryUrl", "queryUrl", "label");
- query.setCustomQuery(true);
- manager.getTaskList().addQuery(query);
- manager.saveTaskList();
-
- manager.resetTaskList();
- // manager.getTaskList().clear();
- // TaskList list = new TaskList();
- // manager.setTaskList(list);
- manager.readExistingOrCreateNewList();
- assertEquals(1, manager.getTaskList().getQueries().size());
- BugzillaRepositoryQuery readQuery = (BugzillaRepositoryQuery) manager.getTaskList()
- .getQueries()
- .iterator()
- .next();
- assertTrue(readQuery.isCustomQuery());
- }
-
- public void testLegacyTaskListReading() throws IOException {
- File originalFile = manager.getTaskListFile();
- File legacyListFile = new File("temptasklist.xml");
- legacyListFile.deleteOnExit();
- BugzillaTestUtil.copy(BugzillaTestUtil.getLocalFile("testdata/legacy/tasklist_0_4_8.xml"), legacyListFile);
-
- assertEquals(362451, legacyListFile.length());
- assertTrue(legacyListFile.exists());
-
- manager.setTaskListFile(legacyListFile);
- manager.readExistingOrCreateNewList();
- manager.setTaskListFile(originalFile);
-
- Collection<AbstractTask> allTasks = manager.getTaskList().getAllTasks();
- Set<AbstractTask> allRootTasks = manager.getTaskList().getDefaultCategory().getChildren();
- Set<AbstractTaskCategory> allCategories = manager.getTaskList().getCategories();
- Set<AbstractTaskContainer> allRoots = manager.getTaskList().getRootElements();
- assertEquals(0, allRootTasks.size());
-
- manager.saveTaskList();
- // manager.getTaskList().clear();
- manager.resetTaskList();
- // TaskList list = new TaskList();
- // manager.setTaskList(list);
- manager.readExistingOrCreateNewList();
-
- assertEquals(allRootTasks.size(), manager.getTaskList().getDefaultCategory().getChildren().size());
- assertEquals(allCategories, manager.getTaskList().getCategories());
- assertEquals(allRoots.size(), manager.getTaskList().getRootElements().size());
- assertEquals(allTasks.size(), manager.getTaskList().getAllTasks().size());
-
- // rewrite and test again
- manager.saveTaskList();
- // manager.getTaskList().clear();
- manager.resetTaskList();
- // list = new TaskList();
- // manager.setTaskList(list);
- manager.readExistingOrCreateNewList();
-
- assertEquals(allRootTasks.size(), manager.getTaskList().getDefaultCategory().getChildren().size());
- assertEquals(allCategories, manager.getTaskList().getCategories());
- assertEquals(allRoots.size(), manager.getTaskList().getRootElements().size());
- assertEquals(allTasks.size(), manager.getTaskList().getAllTasks().size());
-
- manager.deactivateTask(manager.getTaskList().getActiveTask());
- }
-
- public void testDeleteQuery() {
- AbstractRepositoryQuery query = new BugzillaRepositoryQuery("repositoryUrl", "queryUrl", "label");
- manager.getTaskList().addQuery(query);
-
- AbstractRepositoryQuery readQuery = manager.getTaskList().getQueries().iterator().next();
- assertEquals(query, readQuery);
-
- manager.getTaskList().deleteQuery(query);
- assertEquals(0, manager.getTaskList().getQueries().size());
- }
-
- public void testDeleteQueryAfterRename() {
- AbstractRepositoryQuery query = new BugzillaRepositoryQuery("repositoryUrl", "queryUrl", "label");
- manager.getTaskList().addQuery(query);
-
- AbstractRepositoryQuery readQuery = manager.getTaskList().getQueries().iterator().next();
- assertEquals(query, readQuery);
- manager.getTaskList().renameContainer(query, "newName");
- manager.getTaskList().deleteQuery(query);
- assertEquals(0, manager.getTaskList().getQueries().size());
- }
-
- public void testCreateQueryWithSameName() {
- AbstractRepositoryQuery query = new BugzillaRepositoryQuery("repositoryUrl", "queryUrl", "label");
- manager.getTaskList().addQuery(query);
- assertEquals(1, manager.getTaskList().getQueries().size());
- AbstractRepositoryQuery readQuery = manager.getTaskList().getQueries().iterator().next();
- assertEquals(query, readQuery);
-
- manager.getTaskList().addQuery(new BugzillaRepositoryQuery("repositoryUrl", "queryUrl", "label"));
- assertEquals(1, manager.getTaskList().getQueries().size());
- }
-}
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
deleted file mode 100644
index 27916eebd..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttributeFactory;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaReportElement;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
-import org.eclipse.mylyn.tasks.core.TaskComment;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-
-/**
- * @author Mik Kersten
- */
-public class BugzillaTaskTest extends TestCase {
-
- private BugzillaAttributeFactory attributeFactory = new BugzillaAttributeFactory();
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- new BugzillaTaskDataHandler((BugzillaRepositoryConnector) TasksUiPlugin.getRepositoryManager()
- .getRepositoryConnector(BugzillaCorePlugin.REPOSITORY_KIND));
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testCompletionDate() throws Exception {
- BugzillaTask task = new BugzillaTask("repo", "1", "summary");
- RepositoryTaskData taskData = new RepositoryTaskData(new BugzillaAttributeFactory(),
- BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.ECLIPSE_BUGZILLA_URL, "1");
-
- //XXX rewrite test
-
- assertNull(task.getCompletionDate());
-
- Date now = new Date();
- String nowTimeStamp = new SimpleDateFormat(BugzillaAttributeFactory.comment_creation_ts_format).format(now);
-
- TaskComment taskComment = new TaskComment(new BugzillaAttributeFactory(), 1);
- RepositoryTaskAttribute attribute = attributeFactory.createAttribute(BugzillaReportElement.BUG_WHEN.getKeyString());
- attribute.setValue(nowTimeStamp);
- taskComment.addAttribute(BugzillaReportElement.BUG_WHEN.getKeyString(), attribute);
- taskData.addComment(taskComment);
- assertNull(task.getCompletionDate());
-
- RepositoryTaskAttribute resolvedAttribute = attributeFactory.createAttribute(BugzillaReportElement.BUG_STATUS.getKeyString());
- resolvedAttribute.setValue(IBugzillaConstants.VALUE_STATUS_RESOLVED);
- taskData.addAttribute(BugzillaReportElement.BUG_STATUS.getKeyString(), resolvedAttribute);
- AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
- BugzillaCorePlugin.REPOSITORY_KIND);
- connector.updateTaskFromTaskData(new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, "http://eclipse.org"),
- task, taskData);
- assertNotNull(task.getCompletionDate());
- assertEquals(taskData.getAttributeFactory().getDateForAttributeType(
- BugzillaReportElement.BUG_WHEN.getKeyString(), nowTimeStamp), task.getCompletionDate());
-
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestPlugin.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestPlugin.java
deleted file mode 100644
index 0b9aa30cd..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestPlugin.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class BugzillaTestPlugin extends AbstractUIPlugin {
- // The shared instance.
- private static BugzillaTestPlugin plugin;
-
- // Resource bundle.
- private ResourceBundle resourceBundle;
-
- /**
- * The constructor.
- */
- public BugzillaTestPlugin() {
- super();
- plugin = this;
- }
-
- /**
- * This method is called upon plug-in activation
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- plugin = null;
- resourceBundle = null;
- }
-
- /**
- * Returns the shared instance.
- */
- public static BugzillaTestPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns the string from the plugin's resource bundle, or 'key' if not found.
- */
- public static String getResourceString(String key) {
- ResourceBundle bundle = BugzillaTestPlugin.getDefault().getResourceBundle();
- try {
- return (bundle != null) ? bundle.getString(key) : key;
- } catch (MissingResourceException e) {
- return key;
- }
- }
-
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- try {
- if (resourceBundle == null)
- resourceBundle = ResourceBundle.getBundle("org.eclipse.mylyn.bugzilla.tests.TestsPluginResources");
- } catch (MissingResourceException x) {
- resourceBundle = null;
- }
- return resourceBundle;
- }
-
- /**
- * Returns an image descriptor for the image file at the given plug-in relative path.
- *
- * @param path
- * the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String path) {
- return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.mylyn.bugzilla.tests", path);
- }
-}
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
deleted file mode 100644
index 10ddf2f31..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestUtil.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.mylyn.tasks.tests.TasksTestsPlugin;
-
-/**
- * @author Mik Kersten
- */
-public class BugzillaTestUtil {
-
- public static File getLocalFile(String path) {
- try {
- URL installURL = TasksTestsPlugin.getDefault().getBundle().getEntry(path);
- URL localURL = FileLocator.toFileURL(installURL);
- return new File(localURL.getFile());
- } catch (IOException e) {
- return null;
- }
- }
-
- /**
- * Adapted from Java Developers' almanac
- */
- public static void copy(File source, File dest) throws IOException {
- InputStream in = new FileInputStream(source);
- OutputStream out = new FileOutputStream(dest);
- byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- in.close();
- out.close();
- }
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/DuplicateDetetionTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/DuplicateDetetionTest.java
deleted file mode 100644
index 161147940..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/DuplicateDetetionTest.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttributeFactory;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.internal.bugzilla.ui.editor.NewBugzillaTaskEditor;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
-import org.eclipse.mylyn.tasks.ui.editors.AbstractNewRepositoryTaskEditor;
-import org.eclipse.mylyn.tasks.ui.editors.NewTaskEditorInput;
-import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Jeff Pound
- */
-public class DuplicateDetetionTest extends TestCase {
-
- private TaskRepository repository;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
-
- }
-
- public void testDuplicateDetection() throws Exception {
-
- String stackTrace = "java.lang.NullPointerException\nat jeff.testing.stack.trace.functionality(jeff.java:481)";
-
- RepositoryTaskData model = new RepositoryTaskData(new BugzillaAttributeFactory(),
- BugzillaCorePlugin.REPOSITORY_KIND, repository.getUrl(), TasksUiPlugin.getTaskDataManager()
- .getNewRepositoryTaskId());
- model.setDescription(stackTrace);
- model.setNew(true);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- NewTaskEditorInput input = new NewTaskEditorInput(repository, model);
- TasksUiUtil.openEditor(input, TaskEditor.ID_EDITOR, page);
-
- TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
- NewBugzillaTaskEditor editor = (NewBugzillaTaskEditor) taskEditor.getActivePageInstance();
- assertTrue(editor.searchForDuplicates());
-
- editor.markDirty(false);
- editor.close();
- }
-
- public void testNoStackTrace() throws Exception {
- String fakeStackTrace = "this is not really a stacktrace";
- RepositoryTaskData model = new RepositoryTaskData(new BugzillaAttributeFactory(),
- BugzillaCorePlugin.REPOSITORY_KIND, repository.getUrl(), TasksUiPlugin.getTaskDataManager()
- .getNewRepositoryTaskId());
- model.setDescription(fakeStackTrace);
- model.setNew(true);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- NewTaskEditorInput input = new NewTaskEditorInput(repository, model);
- TasksUiUtil.openEditor(input, TaskEditor.ID_EDITOR, page);
-
- TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
- NewBugzillaTaskEditor editor = (NewBugzillaTaskEditor) taskEditor.getActivePageInstance();
- assertNull(AbstractNewRepositoryTaskEditor.getStackTraceFromDescription(model.getDescription()));
-
- editor.markDirty(false);
- editor.close();
- }
-
- public void testStackTraceWithAppendedText() throws Exception {
-
- String stackTrace = "java.lang.NullPointerException\nat jeff.testing.stack.trace.functionality(jeff.java:481)";
- String extraText = "\nExtra text that isnt' part of the stack trace java:";
-
- RepositoryTaskData model = new RepositoryTaskData(new BugzillaAttributeFactory(),
- BugzillaCorePlugin.REPOSITORY_KIND, repository.getUrl(), TasksUiPlugin.getTaskDataManager()
- .getNewRepositoryTaskId());
-
- model.setDescription(extraText + "\n" + stackTrace + "\n");
- model.setNew(true);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- NewTaskEditorInput input = new NewTaskEditorInput(repository, model);
- TasksUiUtil.openEditor(input, TaskEditor.ID_EDITOR, page);
-
- TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
- NewBugzillaTaskEditor editor = (NewBugzillaTaskEditor) taskEditor.getActivePageInstance();
- assertEquals(stackTrace, AbstractNewRepositoryTaskEditor.getStackTraceFromDescription(model.getDescription())
- .trim());
-
- editor.markDirty(false);
- editor.close();
- }
-
- public void testStackTraceMisaligned() throws Exception {
-
- String stackTrace = "java.lang.IllegalStateException: zip file closed\n"
- + " at java.util.zip.ZipFile.ensureOpen (ZipFile.java:518)\n"
- + "at java.util.zip.ZipFile.getEntry (ZipFile.java:251)\n"
- + " at java.util.jar.JarFile.getEntry(JarFile.java:200)\n"
- + "at sun.net.www.protocol.jar.URLJarFile.getEntry\n" + " (URLJarFile.java:90)\n"
- + "at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:112)\n"
- + "at sun.net.www.protocol.jar.JarURLConnection.getInputStream\n" + "(JarURLConnection.java:124)\n"
- + "at org.eclipse.jdt.internal.core.JavaElement\n.getURLContents(JavaElement.java:734)";
-
- RepositoryTaskData model = new RepositoryTaskData(new BugzillaAttributeFactory(),
- BugzillaCorePlugin.REPOSITORY_KIND, repository.getUrl(), TasksUiPlugin.getTaskDataManager()
- .getNewRepositoryTaskId());
-
- model.setDescription(stackTrace);
- model.setNew(true);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- NewTaskEditorInput input = new NewTaskEditorInput(repository, model);
- TasksUiUtil.openEditor(input, TaskEditor.ID_EDITOR, page);
-
- TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
- NewBugzillaTaskEditor editor = (NewBugzillaTaskEditor) taskEditor.getActivePageInstance();
- assertEquals(stackTrace, AbstractNewRepositoryTaskEditor.getStackTraceFromDescription(model.getDescription())
- .trim());
-
- editor.markDirty(false);
- editor.close();
- }
-
- public void testStackTraceSUN() throws Exception {
-
- // SUN, IBM (no space before brackets, one set of brackets)
- String stackTrace = "java.lang.IllegalStateException: zip file closed\n"
- + " at java.util.zip.ZipFile.ensureOpen(ZipFile.java:518)\n"
- + " at java.util.zip.ZipFile.getEntry(ZipFile.java:251)\n"
- + " at java.util.jar.JarFile.getEntry(JarFile.java:200)\n"
- + " at sun.net.www.protocol.jar.URLJarFile.getEntry(URLJarFile.java:90)\n"
- + " at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:112)\n"
- + " at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:124)\n"
- + " at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:734)";
-
- RepositoryTaskData model = new RepositoryTaskData(new BugzillaAttributeFactory(),
- BugzillaCorePlugin.REPOSITORY_KIND, repository.getUrl(), TasksUiPlugin.getTaskDataManager()
- .getNewRepositoryTaskId());
-
- model.setDescription(stackTrace);
- model.setNew(true);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- NewTaskEditorInput input = new NewTaskEditorInput(repository, model);
- TasksUiUtil.openEditor(input, TaskEditor.ID_EDITOR, page);
-
- TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
- NewBugzillaTaskEditor editor = (NewBugzillaTaskEditor) taskEditor.getActivePageInstance();
- assertEquals(stackTrace, AbstractNewRepositoryTaskEditor.getStackTraceFromDescription(model.getDescription())
- .trim());
-
- editor.markDirty(false);
- editor.close();
- }
-
- public void testStackTraceGCJ() throws Exception {
-
- // gcj/gij (path and lib names in additional brackets)
- String stackTrace = "java.lang.Error: Something bad happened\n"
- + " at testcase.main(java.lang.String[]) (Unknown Source)\n"
- + " at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)\n"
- + " at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)";
-
- RepositoryTaskData model = new RepositoryTaskData(new BugzillaAttributeFactory(),
- BugzillaCorePlugin.REPOSITORY_KIND, repository.getUrl(), TasksUiPlugin.getTaskDataManager()
- .getNewRepositoryTaskId());
-
- model.setDescription(stackTrace);
- model.setNew(true);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- NewTaskEditorInput input = new NewTaskEditorInput(repository, model);
- TasksUiUtil.openEditor(input, TaskEditor.ID_EDITOR, page);
-
- TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
- NewBugzillaTaskEditor editor = (NewBugzillaTaskEditor) taskEditor.getActivePageInstance();
- assertEquals(stackTrace, AbstractNewRepositoryTaskEditor.getStackTraceFromDescription(model.getDescription())
- .trim());
-
- editor.markDirty(false);
- editor.close();
- }
-
- public void testStackTraceNoLineNums() throws Exception {
-
- // ikvm (no line numbers)
- String stackTrace = "java.lang.Error: Something bad happened\n" + " at testcase.main (testcase.java)\n"
- + " at java.lang.reflect.Method.Invoke (Method.java)";
-
- RepositoryTaskData model = new RepositoryTaskData(new BugzillaAttributeFactory(),
- BugzillaCorePlugin.REPOSITORY_KIND, repository.getUrl(), TasksUiPlugin.getTaskDataManager()
- .getNewRepositoryTaskId());
-
- model.setDescription(stackTrace);
- model.setNew(true);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- NewTaskEditorInput input = new NewTaskEditorInput(repository, model);
- TasksUiUtil.openEditor(input, TaskEditor.ID_EDITOR, page);
-
- TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
- NewBugzillaTaskEditor editor = (NewBugzillaTaskEditor) taskEditor.getActivePageInstance();
- assertEquals(stackTrace, AbstractNewRepositoryTaskEditor.getStackTraceFromDescription(model.getDescription())
- .trim());
-
- editor.markDirty(false);
- editor.close();
- }
-
- public void testStackTraceJRockit() throws Exception {
-
- // jrockit (slash delimiters)
- String stackTrace = "java.lang.Error: Something bad happened\n"
- + " at java/io/BufferedReader.readLine(BufferedReader.java:331)\n"
- + " at java/io/BufferedReader.readLine(BufferedReader.java:362)\n"
- + " at java/util/Properties.load(Properties.java:192)\n"
- + " at java/util/logging/LogManager.readConfiguration(L:555)";
-
- RepositoryTaskData model = new RepositoryTaskData(new BugzillaAttributeFactory(),
- BugzillaCorePlugin.REPOSITORY_KIND, repository.getUrl(), TasksUiPlugin.getTaskDataManager()
- .getNewRepositoryTaskId());
-
- model.setDescription(stackTrace);
- model.setNew(true);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- NewTaskEditorInput input = new NewTaskEditorInput(repository, model);
- TasksUiUtil.openEditor(input, TaskEditor.ID_EDITOR, page);
-
- TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
- NewBugzillaTaskEditor editor = (NewBugzillaTaskEditor) taskEditor.getActivePageInstance();
- assertEquals(stackTrace, AbstractNewRepositoryTaskEditor.getStackTraceFromDescription(model.getDescription())
- .trim());
-
- editor.markDirty(false);
- editor.close();
- }
-
- public void testStackTraceOther() throws Exception {
-
- // jamvm, sablevm, kaffe, cacao (space before brackets, one set of brackets)
- String stackTrace = "java.lang.Error: Something bad happened\n" + " at testcase.main (testcase.java:3)\n"
- + " at java.lang.VirtualMachine.invokeMain (VirtualMachine.java)\n"
- + " at java.lang.VirtualMachine.main (VirtualMachine.java:108)";
-
- RepositoryTaskData model = new RepositoryTaskData(new BugzillaAttributeFactory(),
- BugzillaCorePlugin.REPOSITORY_KIND, repository.getUrl(), TasksUiPlugin.getTaskDataManager()
- .getNewRepositoryTaskId());
-
- model.setDescription(stackTrace);
- model.setNew(true);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- NewTaskEditorInput input = new NewTaskEditorInput(repository, model);
- TasksUiUtil.openEditor(input, TaskEditor.ID_EDITOR, page);
-
- TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
- NewBugzillaTaskEditor editor = (NewBugzillaTaskEditor) taskEditor.getActivePageInstance();
- assertEquals(stackTrace, AbstractNewRepositoryTaskEditor.getStackTraceFromDescription(model.getDescription())
- .trim());
-
- editor.markDirty(false);
- editor.close();
- }
-}
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
deleted file mode 100644
index b3e8c7e7f..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/EncodingTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaReportElement;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-
-/**
- * @author Mik Kersten
- */
-public class EncodingTest extends AbstractBugzillaTest {
-
- public void testEncodingSetting() {
-
- String charset = BugzillaClient.getCharsetFromString("text/html; charset=UTF-8");
- assertEquals("UTF-8", charset);
-
- charset = BugzillaClient.getCharsetFromString("text/html");
- assertEquals(null, charset);
-
- charset = BugzillaClient.getCharsetFromString("<<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-2\">>");
- assertEquals("iso-8859-2", charset);
-
- charset = BugzillaClient.getCharsetFromString("<<meta http-equiv=\"Content-Type\" content=\"text/html\">>");
- assertEquals(null, charset);
- }
-
- /**
- * This test just shows that when the encoding is changed on the repository synchronization does in fact return in a
- * different encoding (though it may not be legible)
- */
- public void testDifferentReportEncoding() throws CoreException {
- init222();
- repository.setCharacterEncoding("UTF-8");
- BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingId(repository, "57",
- new NullProgressMonitor());
- assertNotNull(task);
- //TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
- assertTrue(task.getSummary().equals("\u00E6"));//"\u05D0"));
- taskList.deleteTask(task);
- connector.getClientManager().repositoryRemoved(repository);
- repository.setCharacterEncoding("ISO-8859-1");
- task = (BugzillaTask) connector.createTaskFromExistingId(repository, "57", new NullProgressMonitor());
- assertNotNull(task);
- //TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
- // iso-8859-1 'incorrect' interpretation
- assertFalse(task.getSummary().equals("\u00E6"));//"\u05D0"));
- }
-
- public void testProperEncodingUponPost() throws CoreException {
- init222();
- repository.setCharacterEncoding("UTF-8");
- BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingId(repository, "57",
- new NullProgressMonitor());
- RepositoryTaskData taskData = TasksUiPlugin.getTaskDataManager().getNewTaskData(task.getRepositoryUrl(),
- task.getTaskId());
- assertNotNull(task);
- assertTrue(task.getSummary().equals("\u00E6"));//"\u05D0"));
- String priority = null;
- if (task.getPriority().equals("P1")) {
- priority = "P2";
- taskData.setAttributeValue(BugzillaReportElement.PRIORITY.getKeyString(), priority);
- } else {
- priority = "P1";
- taskData.setAttributeValue(BugzillaReportElement.PRIORITY.getKeyString(), priority);
- }
-
- submit(task, taskData);
- taskList.deleteTask(task);
- task = (BugzillaTask) connector.createTaskFromExistingId(repository, "57", new NullProgressMonitor());
- assertNotNull(task);
- assertTrue(task.getSummary().equals("\u00E6"));//"\u05D0"));
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java
deleted file mode 100644
index 12bea4912..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttributeFactory;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaReportElement;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-
-/**
- * @author Mik Kersten
- * @author Ian Bull
- */
-public class NewBugWizardTest extends TestCase {
-
- public void testPlatformOptions() throws Exception {
-
- RepositoryTaskData newReport = new RepositoryTaskData(new BugzillaAttributeFactory(),
- BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_220_URL, "1");
-
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_220_URL);
- BugzillaRepositoryConnector.setupNewBugAttributes(repository, newReport);
- BugzillaCorePlugin.getDefault().setPlatformOptions(newReport);
-
- String os = Platform.getOS();
- if (os.equals("win32"))
- assertEquals("Windows", newReport.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- else if (os.equals("solaris"))
- assertEquals("Solaris", newReport.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- else if (os.equals("qnx"))
- assertEquals("QNX-Photon", newReport.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- else if (os.equals("macosx"))
- assertEquals("Mac OS", newReport.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- else if (os.equals("linux"))
- assertEquals("Linux", newReport.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- else if (os.equals("hpux"))
- assertEquals("HP-UX", newReport.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- else if (os.equals("aix"))
- assertEquals("AIX", newReport.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
-
- String platform = Platform.getOSArch();
- if (platform.equals("x86")) {
- if (os.equals("macosx"))
- assertEquals("Macintosh", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString())
- .getValue());
- else
- assertEquals("PC", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
- } else if (platform.equals("x86_64"))
- assertEquals("PC", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
- else if (platform.equals("ia64"))
- assertEquals("PC", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
- else if (platform.equals("ia64_32"))
- assertEquals("PC", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
- else if (platform.equals("sparc"))
- assertEquals("Sun", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
- else if (platform.equals("ppc")) {
- if (os.equals("macosx"))
- assertEquals("Macintosh", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString())
- .getValue());
- else
- assertEquals("Power", newReport.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString())
- .getValue());
- }
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java
deleted file mode 100644
index 0a3b33989..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.net.UnknownHostException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.mylyn.context.tests.support.TestUtil;
-import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientFactory;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.internal.bugzilla.ui.tasklist.BugzillaRepositorySettingsPage;
-import org.eclipse.mylyn.internal.tasks.ui.wizards.EditRepositoryWizard;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.TaskRepositoryManager;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.web.core.WebClientUtil;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Rob Elves
- */
-public class RepositoryEditorWizardTest extends TestCase {
-
- private TaskRepositoryManager manager;
-
- private TaskRepository repository;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- manager = TasksUiPlugin.getRepositoryManager();
- manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
- repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
- Credentials credentials = TestUtil.readCredentials();
- repository.setAuthenticationCredentials(credentials.username, credentials.password);
- repository.setAnonymous(false);
- TasksUiPlugin.getRepositoryManager().addRepository(repository,
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- }
-
- public void testValidationInvalidPassword() throws Exception {
-
- EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
- WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
- dialog.create();
- BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- // BugzillaClient client =
- // BugzillaClientFactory.createClient(page.getServerUrl(),
- // page.getUserName(), page.getPassword(), page.getHttpAuthUserId(),
- // page.getHttpAuthPassword(), page.getCharacterEncoding());
- page.setPassword("bogus");
- try {
- BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(),
- page.getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(),
- WebClientUtil.getPlatformProxy(), page.getCharacterEncoding());
- client.validate();
- } catch (CoreException e) {
- return;
- }
- fail("LoginException didn't occur!");
- }
-
- public void testValidationInvalidUserid() throws Exception {
- EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
- WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
- dialog.create();
- BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- page.setUserId("bogus");
- try {
- BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(),
- page.getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(),
- WebClientUtil.getPlatformProxy(), page.getCharacterEncoding());
- client.validate();
- } catch (CoreException e) {
- return;
- }
- fail("LoginException didn't occur!");
- }
-
- public void testValidationInvalidUrl() throws Exception {
- EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
- WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
- dialog.create();
- BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- page.setUrl("http://invalid");
- try {
- BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(),
- page.getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(),
- WebClientUtil.getPlatformProxy(), page.getCharacterEncoding());
- client.validate();
- } catch (CoreException e) {
- assertTrue(e.getStatus().getException() instanceof UnknownHostException);
- return;
- }
- fail("UnknownHostException didn't occur!");
- }
-
- // TODO: Test locking up?
- // public void testAutoVersion() throws Exception {
- // repository.setVersion(BugzillaRepositorySettingsPage.LABEL_AUTOMATIC_VERSION);
- // EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
- // WizardDialog dialog = new
- // WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- // wizard);
- // dialog.create();
- // BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage)
- // wizard.getSettingsPage();
- // page.setTesting(true);
- // assertEquals(BugzillaRepositorySettingsPage.LABEL_AUTOMATIC_VERSION,
- // page.getVersion());
- // page.validateSettings();
- // assertEquals("2.22", page.getVersion());
- // }
-
- public void testPersistChangeOfUrl() throws Exception {
- assertEquals(1, manager.getAllRepositories().size());
- String tempUid = repository.getUserName();
- String tempPass = repository.getPassword();
- EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
- WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
- dialog.create();
- BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(),
- page.getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(),
- WebClientUtil.getPlatformProxy(), page.getCharacterEncoding());
- client.validate();
- page.setUrl(IBugzillaConstants.TEST_BUGZILLA_218_URL);
- wizard.performFinish();
- assertEquals(1, manager.getAllRepositories().size());
- TaskRepository repositoryTest = manager.getRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_218_URL);
- assertNotNull(repositoryTest);
- assertEquals(tempUid, repositoryTest.getUserName());
- assertEquals(tempPass, repositoryTest.getPassword());
- }
-
- public void testPersistChangeUserId() throws Exception {
- assertEquals(1, manager.getAllRepositories().size());
- EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
- WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
- dialog.create();
- BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(),
- page.getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(),
- WebClientUtil.getPlatformProxy(), page.getCharacterEncoding());
- client.validate();
- page.setUserId("bogus");
- wizard.performFinish();
- assertEquals(1, manager.getAllRepositories().size());
- TaskRepository repositoryTest = manager.getRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_222_URL);
- assertNotNull(repositoryTest);
- wizard = new EditRepositoryWizard(repositoryTest);
- dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
- dialog.create();
- page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- try {
- client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(), page.getPassword(),
- page.getHttpAuthUserId(), page.getHttpAuthPassword(), WebClientUtil.getPlatformProxy(),
- page.getCharacterEncoding());
- client.validate();
- } catch (CoreException e) {
- return;
- }
- fail("LoginException didn't occur!");
- }
-
-}
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
deleted file mode 100644
index 84587230f..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java
+++ /dev/null
@@ -1,452 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.context.tests.support.TestUtil;
-import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttributeFactory;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaReportElement;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.tasks.core.AbstractTaskDataHandler;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-
-/**
- * @author Rob Elves
- * @author Mik Kersten
- */
-public class RepositoryReportFactoryTest extends TestCase {
-
- BugzillaAttributeFactory attributeFactory = new BugzillaAttributeFactory();
-
- TaskRepository repository;
-
- BugzillaRepositoryConnector connector;
-
- private RepositoryTaskData init(String taskId) throws CoreException {
- AbstractTaskDataHandler handler = connector.getTaskDataHandler();
- RepositoryTaskData taskData = handler.getTaskData(repository, taskId, new NullProgressMonitor());
- return taskData;
- }
-
- private TaskRepository setRepository(String kind, String url) {
- connector = (BugzillaRepositoryConnector) TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
- BugzillaCorePlugin.REPOSITORY_KIND);
- repository = new TaskRepository(kind, url);
- Credentials credentials = TestUtil.readCredentials();
- repository.setAuthenticationCredentials(credentials.username, credentials.password);
- return repository;
- }
-
- public void testInvalidCredentials222() throws Exception {
- String bugid = "1";
- String errorMessage = "";
- try {
- setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
- repository.setAuthenticationCredentials("invalid", "invalid");
- init(bugid);
- } catch (CoreException e) {
- errorMessage = e.getStatus().getMessage();
- }
- assertTrue(errorMessage.startsWith("Unable to login"));
- repository.flushAuthenticationCredentials();
- }
-
- public void testBugNotFound222() {
-
- String bugid = "-1";
- String errorMessage = "";
- try {
- setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
- // If this isn't called the BugzillaClient will be reused (with old
- // credentials) so
- // force drop of old client connection.
- // Note that this is usually called by notification
- connector.getClientManager().repositoryAdded(repository);
- init(bugid);
- } catch (CoreException e) {
- errorMessage = e.getStatus().getMessage();
- }
- assertTrue(errorMessage.startsWith("Repository error from"));
- }
-
- // public void testReadingReport() throws Exception {
- // String bugid = "2";
- // setRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- // IBugzillaConstants.TEST_BUGZILLA_222_URL);
- // RepositoryTaskData report = init(bugid);
- //
- // assertNotNull(report);
- // assertEquals("search-match-test 1",
- // report.getAttribute(BugzillaReportElement.SHORT_DESC.getKeyString())
- // .getValue());
- // assertEquals("TestProduct",
- // report.getAttribute(BugzillaReportElement.PRODUCT.getKeyString()).getValue());
- // assertEquals("PC",
- // report.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
- // assertEquals("Windows",
- // report.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- // // first comment (#0) is the summary so this value is always 1
- // // greater
- // // than what is shown on the report ui
- // assertEquals(3, report.getComments().size());
- // assertEquals("search-match-test 1",
- // report.getComments().get(0).getAttribute(
- // BugzillaReportElement.THETEXT.getKeyString()).getValue());
- // // assertEquals(15, report.getAttachments().size());
- // // assertEquals("1",
- // //
- // report.getAttachments().get(0).getAttribute(BugzillaReportElement.ATTACHID).getValue());
- // // assertEquals("2006-03-10 14:11",
- // //
- // report.getAttachments().get(0).getAttribute(BugzillaReportElement.DATE)
- // // .getValue());
- // // assertEquals("Testing upload",
- // //
- // report.getAttachments().get(0).getAttribute(BugzillaReportElement.DESC)
- // // .getValue());
- // // assertEquals("patch130217.txt",
- // //
- // report.getAttachments().get(0).getAttribute(BugzillaReportElement.FILENAME)
- // // .getValue());
- // // assertEquals("text/plain",
- // //
- // report.getAttachments().get(0).getAttribute(BugzillaReportElement.TYPE).getValue());
- // }
-
- public void testReadingReport222() throws Exception {
- String bugid = "2";
- setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
- RepositoryTaskData report = init(bugid);
-
- assertNotNull(report);
- assertEquals("search-match-test 1", report.getAttribute(BugzillaReportElement.SHORT_DESC.getKeyString())
- .getValue());
- assertEquals("search-match-test 1", report.getSummary());
- assertEquals("search-match-test 1", report.getDescription());
- assertEquals("TestProduct", report.getAttribute(BugzillaReportElement.PRODUCT.getKeyString()).getValue());
- assertEquals("TestProduct", report.getProduct());
- assertEquals("TestComponent", report.getAttribute(BugzillaReportElement.COMPONENT.getKeyString()).getValue());
- assertEquals("PC", report.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
- assertEquals("Windows", report.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- assertEquals("other", report.getAttribute(BugzillaReportElement.VERSION.getKeyString()).getValue());
- assertEquals("P1", report.getAttribute(BugzillaReportElement.PRIORITY.getKeyString()).getValue());
- assertEquals("normal", report.getAttribute(BugzillaReportElement.BUG_SEVERITY.getKeyString()).getValue());
- assertEquals("" + bugid, report.getAttribute(BugzillaReportElement.BUG_ID.getKeyString()).getValue());
- assertEquals("NEW", report.getAttribute(BugzillaReportElement.BUG_STATUS.getKeyString()).getValue());
- assertEquals("2006-05-23 17:46", report.getAttribute(BugzillaReportElement.CREATION_TS.getKeyString())
- .getValue());
- assertEquals("2007-05-08 12:44:41", report.getAttribute(BugzillaReportElement.DELTA_TS.getKeyString())
- .getValue());
- assertEquals("---", report.getAttribute(BugzillaReportElement.TARGET_MILESTONE.getKeyString()).getValue());
- assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.REPORTER.getKeyString()).getValue());
- assertEquals("nhapke@cs.ubc.ca", report.getAttribute(BugzillaReportElement.ASSIGNED_TO.getKeyString())
- .getValue());
- assertEquals(2, report.getComments().size());
- // assertEquals("relves@cs.ubc.ca",
- // report.getComments().get(0).getAttribute(
- // BugzillaReportElement.WHO.getKeyString()).getValue());
- // assertEquals("2006-05-23 17:46:24",
- // report.getComments().get(0).getAttribute(
- // BugzillaReportElement.BUG_WHEN.getKeyString()).getValue());
- // assertEquals("search-match-test 1",
- // report.getComments().get(0).getAttribute(
- // BugzillaReportElement.THETEXT.getKeyString()).getValue());
- // assertEquals(0, report.getAttachments().size());
- }
-
- public void testReadingReport2201() throws Exception {
- String bugid = "1";
- setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_2201_URL);
- RepositoryTaskData report = init(bugid);
-
- assertNotNull(report);
- assertEquals("1", report.getAttribute(BugzillaReportElement.BUG_ID.getKeyString()).getValue());
- assertEquals("search-match-test 1", report.getAttribute(BugzillaReportElement.SHORT_DESC.getKeyString())
- .getValue());
- assertEquals("TestProduct", report.getAttribute(BugzillaReportElement.PRODUCT.getKeyString()).getValue());
- assertEquals("TestComponent", report.getAttribute(BugzillaReportElement.COMPONENT.getKeyString()).getValue());
- assertEquals("PC", report.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
- assertEquals("Windows", report.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- assertEquals("other", report.getAttribute(BugzillaReportElement.VERSION.getKeyString()).getValue());
- assertEquals("P2", report.getAttribute(BugzillaReportElement.PRIORITY.getKeyString()).getValue());
- assertEquals("normal", report.getAttribute(BugzillaReportElement.BUG_SEVERITY.getKeyString()).getValue());
- assertEquals("NEW", report.getAttribute(BugzillaReportElement.BUG_STATUS.getKeyString()).getValue());
- assertEquals("2006-03-02 18:13", report.getAttribute(BugzillaReportElement.CREATION_TS.getKeyString())
- .getValue());
- assertEquals("2006-05-03 13:06:11", report.getAttribute(BugzillaReportElement.DELTA_TS.getKeyString())
- .getValue());
- assertEquals("---", report.getAttribute(BugzillaReportElement.TARGET_MILESTONE.getKeyString()).getValue());
- RepositoryTaskAttribute attribute = report.getAttribute(BugzillaReportElement.BLOCKED.getKeyString());
- assertEquals("2, 9", attribute.getValue());
- attribute = report.getAttribute(BugzillaReportElement.CC.getKeyString());
- assertEquals(2, attribute.getValues().size());
- assertEquals("relves@cs.ubc.ca", attribute.getValues().get(0));
- assertEquals("relves@gmail.com", attribute.getValues().get(1));
- assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.REPORTER.getKeyString()).getValue());
- assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.ASSIGNED_TO.getKeyString())
- .getValue());
- }
-
- // public void testReadingReport2201Eclipse() throws Exception {
- // String bugid = "24448";
- // TaskRepository repository = new
- // TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- // IBugzillaConstants.ECLIPSE_BUGZILLA_URL);
- //
- // RepositoryTaskData report = new RepositoryTaskData(attributeFactory,
- // BugzillaCorePlugin.REPOSITORY_KIND, repository
- // .getUrl(), bugid);
- // BugzillaServerFacade.setupExistingBugAttributes(repository.getUrl(),
- // report);
- // factory.populateReport(report, repository.getUrl(), null,
- // repository.getUserName(), repository.getPassword(),
- // null);
- //
- // assertNotNull(report);
- // assertEquals("24448",
- // report.getAttribute(BugzillaReportElement.BUG_ID.getKeyString()).getValue());
- // assertEquals("Ant causing Out of Memory",
- // report.getAttribute(BugzillaReportElement.SHORT_DESC.getKeyString())
- // .getValue());
- // assertEquals("Platform",
- // report.getAttribute(BugzillaReportElement.PRODUCT.getKeyString()).getValue());
- // assertEquals("Ant",
- // report.getAttribute(BugzillaReportElement.COMPONENT.getKeyString()).getValue());
- // assertEquals("PC",
- // report.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
- // assertEquals("other",
- // report.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- // assertEquals("2.0",
- // report.getAttribute(BugzillaReportElement.VERSION.getKeyString()).getValue());
- // assertEquals("P2",
- // report.getAttribute(BugzillaReportElement.PRIORITY.getKeyString()).getValue());
- // assertEquals("normal",
- // report.getAttribute(BugzillaReportElement.BUG_SEVERITY.getKeyString()).getValue());
- // assertEquals("RESOLVED",
- // report.getAttribute(BugzillaReportElement.BUG_STATUS.getKeyString()).getValue());
- // assertEquals("WONTFIX",
- // report.getAttribute(BugzillaReportElement.RESOLUTION.getKeyString()).getValue());
- // assertEquals("2002-10-07 09:32",
- // report.getAttribute(BugzillaReportElement.CREATION_TS.getKeyString())
- // .getValue());
- // assertEquals("2006-02-03 12:03:57",
- // report.getAttribute(BugzillaReportElement.DELTA_TS.getKeyString())
- // .getValue());
- // assertEquals("core, performance, ui",
- // report.getAttribute(BugzillaReportElement.KEYWORDS.getKeyString())
- // .getValue());
- // // RepositoryTaskAttribute attribute =
- // // report.getAttribute(BugzillaReportElement.CC);
- // // assertEquals(30, attribute.getValues().size());
- // // assertEquals("relves@cs.ubc.ca", attribute.getValues().get(0));
- // // assertEquals("relves@gmail.com", attribute.getValues().get(1));
- // // assertEquals("relves@cs.ubc.ca",
- // // report.getAttribute(BugzillaReportElement.REPORTER).getValue());
- // // assertEquals("relves@cs.ubc.ca",
- // // report.getAttribute(BugzillaReportElement.ASSIGNED_TO).getValue());
- // // assertEquals(1, report.getComments().size());
- // // assertEquals("relves@cs.ubc.ca",
- // //
- // report.getComments().get(0).getAttribute(BugzillaReportElement.WHO).getValue());
- // // assertEquals("2006-03-02 18:13",
- // //
- // report.getComments().get(0).getAttribute(BugzillaReportElement.BUG_WHEN)
- // // .getValue());
- // // assertEquals("search-match-test 1",
- // //
- // report.getComments().get(0).getAttribute(BugzillaReportElement.THETEXT)
- // // .getValue());
- // // assertEquals(0, report.getAttachments().size());
- // }
-
- // public void testReadingReport220() throws Exception {
- // String bugid = "1";
- // TaskRepository repository = new
- // TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- // IBugzillaConstants.TEST_BUGZILLA_220_URL);
- //
- // RepositoryTaskData report = new RepositoryTaskData(attributeFactory,
- // BugzillaCorePlugin.REPOSITORY_KIND,
- // repository.getUrl(), bugid);
- // BugzillaServerFacade.setupExistingBugAttributes(repository.getUrl(),
- // report);
- // factory.populateReport(report, repository.getUrl(), null,
- // repository.getUserName(), repository.getPassword(),
- // null);
- //
- // assertNotNull(report);
- // assertEquals("1",
- // report.getAttribute(BugzillaReportElement.BUG_ID.getKeyString()).getValue());
- // assertEquals("search-match-test",
- // report.getAttribute(BugzillaReportElement.SHORT_DESC.getKeyString())
- // .getValue());
- // assertEquals("TestProduct",
- // report.getAttribute(BugzillaReportElement.PRODUCT.getKeyString()).getValue());
- // assertEquals("TestComponent",
- // report.getAttribute(BugzillaReportElement.COMPONENT.getKeyString()).getValue());
- // assertEquals("PC",
- // report.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
- // assertEquals("Windows",
- // report.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- // assertEquals("other",
- // report.getAttribute(BugzillaReportElement.VERSION.getKeyString()).getValue());
- // assertEquals("P2",
- // report.getAttribute(BugzillaReportElement.PRIORITY.getKeyString()).getValue());
- // assertEquals("normal",
- // report.getAttribute(BugzillaReportElement.BUG_SEVERITY.getKeyString()).getValue());
- // assertEquals("NEW",
- // report.getAttribute(BugzillaReportElement.BUG_STATUS.getKeyString()).getValue());
- // assertEquals("2006-03-02 17:30",
- // report.getAttribute(BugzillaReportElement.CREATION_TS.getKeyString())
- // .getValue());
- // assertEquals("2006-04-20 15:13:43",
- // report.getAttribute(BugzillaReportElement.DELTA_TS.getKeyString())
- // .getValue());
- // assertEquals("---",
- // report.getAttribute(BugzillaReportElement.TARGET_MILESTONE.getKeyString()).getValue());
- // assertEquals("relves@cs.ubc.ca",
- // report.getAttribute(BugzillaReportElement.REPORTER.getKeyString()).getValue());
- // assertEquals("relves@cs.ubc.ca",
- // report.getAttribute(BugzillaReportElement.ASSIGNED_TO.getKeyString())
- // .getValue());
- // assertEquals("relves@cs.ubc.ca",
- // report.getAttribute(BugzillaReportElement.CC.getKeyString()).getValue());
- // assertEquals(3, report.getComments().size());
- // assertEquals("relves@cs.ubc.ca",
- // report.getComments().get(0).getAttribute(
- // BugzillaReportElement.WHO.getKeyString()).getValue());
- // assertEquals("2006-03-02 17:30",
- // report.getComments().get(0).getAttribute(
- // BugzillaReportElement.BUG_WHEN.getKeyString()).getValue());
- // assertEquals("search-match-test",
- // report.getComments().get(0).getAttribute(
- // BugzillaReportElement.THETEXT.getKeyString()).getValue());
- // assertEquals(0, report.getAttachments().size());
- // }
-
- public void testReadingReport218() throws Exception {
- String bugid = "1";
- setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_218_URL);
- RepositoryTaskData report = init(bugid);
- assertNotNull(report);
- assertEquals("1", report.getAttribute(BugzillaReportElement.BUG_ID.getKeyString()).getValue());
- assertEquals("search-match-test 1", report.getAttribute(BugzillaReportElement.SHORT_DESC.getKeyString())
- .getValue());
- assertEquals("TestProduct", report.getAttribute(BugzillaReportElement.PRODUCT.getKeyString()).getValue());
- assertEquals("TestComponent", report.getAttribute(BugzillaReportElement.COMPONENT.getKeyString()).getValue());
- assertEquals("PC", report.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
- assertEquals("Windows XP", report.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- assertEquals("other", report.getAttribute(BugzillaReportElement.VERSION.getKeyString()).getValue());
- assertEquals("P2", report.getAttribute(BugzillaReportElement.PRIORITY.getKeyString()).getValue());
- assertEquals("normal", report.getAttribute(BugzillaReportElement.BUG_SEVERITY.getKeyString()).getValue());
- assertEquals("NEW", report.getAttribute(BugzillaReportElement.BUG_STATUS.getKeyString()).getValue());
- assertEquals("2006-03-02 18:09", report.getAttribute(BugzillaReportElement.CREATION_TS.getKeyString())
- .getValue());
- assertEquals("2006-05-05 17:45:24", report.getAttribute(BugzillaReportElement.DELTA_TS.getKeyString())
- .getValue());
- assertEquals("---", report.getAttribute(BugzillaReportElement.TARGET_MILESTONE.getKeyString()).getValue());
- assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.REPORTER.getKeyString()).getValue());
- assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.ASSIGNED_TO.getKeyString())
- .getValue());
- assertEquals(0, report.getAttachments().size());
- }
-
- public void testTimeTracking222() throws Exception {
- setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
- RepositoryTaskData report = init("11");
- assertEquals("7.50", report.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()).getValue());
- assertEquals("4.00", report.getAttribute(BugzillaReportElement.ACTUAL_TIME.getKeyString()).getValue());
- assertEquals("3.00", report.getAttribute(BugzillaReportElement.REMAINING_TIME.getKeyString()).getValue());
- assertEquals("2005-03-04", report.getAttribute(BugzillaReportElement.DEADLINE.getKeyString()).getValue());
- }
-
- // public void testTimeTracking2201() throws Exception {
- // RepositoryTaskData report =
- // init(IBugzillaConstants.TEST_BUGZILLA_2201_URL, 23);
- //
- // assertEquals("7.50",
- // report.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()).getValue());
- // assertEquals("1.00",
- // report.getAttribute(BugzillaReportElement.ACTUAL_TIME.getKeyString()).getValue());
- // assertEquals("3.00",
- // report.getAttribute(BugzillaReportElement.REMAINING_TIME.getKeyString()).getValue());
- // assertEquals("2005-03-04",
- // report.getAttribute(BugzillaReportElement.DEADLINE.getKeyString()).getValue());
- // }
- //
- // public void testTimeTracking220() throws Exception {
- // RepositoryTaskData report =
- // init(IBugzillaConstants.TEST_BUGZILLA_220_URL, 9);
- //
- // assertEquals("7.50",
- // report.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()).getValue());
- // assertEquals("1.00",
- // report.getAttribute(BugzillaReportElement.ACTUAL_TIME.getKeyString()).getValue());
- // assertEquals("3.00",
- // report.getAttribute(BugzillaReportElement.REMAINING_TIME.getKeyString()).getValue());
- // assertEquals("2005-03-04",
- // report.getAttribute(BugzillaReportElement.DEADLINE.getKeyString()).getValue());
- // }
-
- public void testTimeTracking218() throws Exception {
- setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_218_URL);
- RepositoryTaskData report = init("19");
- assertEquals("7.50", report.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()).getValue());
- assertEquals("1.00", report.getAttribute(BugzillaReportElement.ACTUAL_TIME.getKeyString()).getValue());
- assertEquals("3.00", report.getAttribute(BugzillaReportElement.REMAINING_TIME.getKeyString()).getValue());
- }
-
- public void testMultipleDepensOn() throws Exception {
- String bugid = "5";
- setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_218_URL);
- RepositoryTaskData report = init(bugid);
- assertNotNull(report);
- assertEquals("5", report.getAttribute(BugzillaReportElement.BUG_ID.getKeyString()).getValue());
- assertEquals("6, 7", report.getAttribute(BugzillaReportElement.DEPENDSON.getKeyString()).getValue());
- assertEquals("13, 14", report.getAttribute(BugzillaReportElement.BLOCKED.getKeyString()).getValue());
- }
-
- public void testBugReportAPI() throws Exception {
- String bugid = "3";
- setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
- RepositoryTaskData report = init(bugid);
- assertNotNull(report);
- assertTrue(report != null);
- RepositoryTaskData bugReport = report;
- assertEquals("search-match-test 2", bugReport.getSummary());
- assertEquals("search-match-test 2", bugReport.getDescription());
- assertEquals("TestProduct", bugReport.getProduct());
- assertEquals("nhapke@cs.ubc.ca", bugReport.getAssignedTo());
- }
-
- public void testDeltaTsTruncation() {
- String ts1 = "2006-07-06 03:22:08 0900";
- String ts1_truncated = "2006-07-06 03:22:08";
- 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, BugzillaClient.stripTimeZone(ts2));
-
- String ts3 = "2006-07-06 03:22:08 PST";
- String ts3_truncated = "2006-07-06 03:22:08";
- assertEquals(ts3_truncated, BugzillaClient.stripTimeZone(ts3));
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryTaskHandleTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryTaskHandleTest.java
deleted file mode 100644
index bf78c462a..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryTaskHandleTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 - 2006 Mylar committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.tasks.ui.TaskListManager;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-
-/**
- * @author Mik Kersten
- */
-public class RepositoryTaskHandleTest extends TestCase {
-
- private TaskListManager manager = TasksUiPlugin.getTaskListManager();
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- manager = TasksUiPlugin.getTaskListManager();
- manager.resetTaskList();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- manager.resetTaskList();
- }
-
- // Dash now allowed in task id
- // public void testInvalidHandle() {
- // // MockRepositoryTask task = new MockRepositoryTask()
- // String url = "http://foo";
- // assertEquals(url + "-" + "abc", RepositoryTaskHandleUtil.getHandle(url,
- // "abc"));
- // Exception caught = null;
- // try {
- // RepositoryTaskHandleUtil.getHandle(url, "a-23");
- // } catch (Exception e) {
- // caught = e;
- // }
- // assertNotNull(caught);
- // }
-
- public void testRepositoryUrlHandles() {
-
- String repository = IBugzillaConstants.ECLIPSE_BUGZILLA_URL;
- String id = "123";
- BugzillaTask bugTask = new BugzillaTask(repository, id, "label 124");
- assertEquals(repository, bugTask.getRepositoryUrl());
-
- manager.getTaskList().moveToContainer(bugTask,
- TasksUiPlugin.getTaskListManager().getTaskList().getDefaultCategory());
- manager.saveTaskList();
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
-
- BugzillaTask readReport = (BugzillaTask) manager.getTaskList()
- .getDefaultCategory()
- .getChildren()
- .iterator()
- .next();
- assertEquals(readReport.getSummary(), readReport.getSummary());
- assertEquals(readReport.getRepositoryUrl(), readReport.getRepositoryUrl());
- }
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskEditorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskEditorTest.java
deleted file mode 100644
index 4d88eaa4e..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskEditorTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 - 2006 Mylar committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttributeFactory;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
-import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor;
-import org.eclipse.mylyn.tasks.ui.editors.NewTaskEditorInput;
-import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Jeff Pound
- */
-public class TaskEditorTest extends TestCase {
-
- private static final String DESCRIPTION = "summary";
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
- TasksUiPlugin.getRepositoryManager().clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
- TasksUiPlugin.getTaskListManager().resetTaskList();
- TasksUiPlugin.getTaskListManager().saveTaskList();
- // TasksUiPlugin.getDefault().getTaskListSaveManager().saveTaskList(true);
- super.tearDown();
- }
-
- /**
- * Automated task creation needs to access newly created task editors. This test tests that the access is available.
- *
- * @throws Exception
- */
- public void testAccessNewEditor() throws Exception {
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_222_URL);
-
- RepositoryTaskData model = new RepositoryTaskData(new BugzillaAttributeFactory(),
- BugzillaCorePlugin.REPOSITORY_KIND, repository.getUrl(), TasksUiPlugin.getTaskDataManager()
- .getNewRepositoryTaskId());
- model.setNew(true);
- BugzillaRepositoryConnector.setupNewBugAttributes(repository, model);
- NewTaskEditorInput editorInput = new NewTaskEditorInput(repository, model);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- TasksUiUtil.openEditor(editorInput, TaskEditor.ID_EDITOR, page);
- assertTrue(page.getActiveEditor() instanceof TaskEditor);
- TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
- assertTrue(taskEditor.getActivePageInstance() instanceof AbstractRepositoryTaskEditor);
- AbstractRepositoryTaskEditor editor = (AbstractRepositoryTaskEditor) taskEditor.getActivePageInstance();
-
- String desc = DESCRIPTION;
- String summary = "summary";
- // ensure we have access without exceptions
- editor.setDescriptionText(desc);
- editor.setSummaryText(summary);
- // editor.doSave(new NullProgressMonitor());
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListNotificationManagerTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListNotificationManagerTest.java
deleted file mode 100644
index 4278863b9..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListNotificationManagerTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryQuery;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask;
-import org.eclipse.mylyn.internal.tasks.core.LocalTask;
-import org.eclipse.mylyn.internal.tasks.ui.ITaskListNotification;
-import org.eclipse.mylyn.internal.tasks.ui.TaskListNotificationIncoming;
-import org.eclipse.mylyn.internal.tasks.ui.TaskListNotificationManager;
-import org.eclipse.mylyn.tasks.core.AbstractTask;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.AbstractTask.RepositoryTaskSyncState;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-
-/**
- * @author Rob Elves
- */
-public class TaskListNotificationManagerTest extends TestCase {
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testTaskListNotificationReminder() throws InterruptedException {
-
- Date now = new Date();
-
- AbstractTask task0 = new LocalTask("0", "t0 - test 0");
- AbstractTask task1 = new LocalTask("1", "t1 - test 1");
- AbstractTask task2 = new LocalTask("2", "t2 - test 2");
-
- task0.setScheduledForDate(new Date(now.getTime() - 2000));
- task1.setScheduledForDate(new Date(now.getTime() - 2000));
- task2.setScheduledForDate(new Date(now.getTime() - 2000));
-
- TasksUiPlugin.getTaskListManager().getTaskList().addTask(task0);
- TasksUiPlugin.getTaskListManager().getTaskList().addTask(task1);
- TasksUiPlugin.getTaskListManager().getTaskList().addTask(task2);
-
- TaskListNotificationManager notificationManager = TasksUiPlugin.getTaskListNotificationManager();
- notificationManager.collectNotifications();
-
- task0 = TasksUiPlugin.getTaskListManager().getTaskList().getTask("local-0");
- assertNotNull(task0);
- assertTrue(task0.isReminded());
- task1 = TasksUiPlugin.getTaskListManager().getTaskList().getTask("local-1");
- assertNotNull(task1);
- assertTrue(task1.isReminded());
- task2 = TasksUiPlugin.getTaskListManager().getTaskList().getTask("local-2");
- assertNotNull(task2);
- assertTrue(task2.isReminded());
-
- }
-
- public void testTaskListNotificationIncoming() {
-
- TaskRepository repository = new TaskRepository("bugzilla", "https://bugs.eclipse.org/bugs");
- TasksUiPlugin.getRepositoryManager().addRepository(repository,
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- AbstractTask task = new BugzillaTask("https://bugs.eclipse.org/bugs", "142891", "label");
- assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSynchronizationState());
- assertFalse(task.isNotified());
- TasksUiPlugin.getTaskListManager().getTaskList().addTask(task);
- TaskListNotificationManager notificationManager = TasksUiPlugin.getTaskListNotificationManager();
- notificationManager.collectNotifications();
- assertTrue(notificationManager.getNotifications().contains(new TaskListNotificationIncoming(task)));
- task = TasksUiPlugin.getTaskListManager().getTaskList().getTask("https://bugs.eclipse.org/bugs-142891");
- assertNotNull(task);
- assertTrue(task.isNotified());
- }
-
- public void testTaskListNotificationQueryIncoming() {
- BugzillaTask hit = new BugzillaTask("https://bugs.eclipse.org/bugs", "1", "summary");
- assertFalse(hit.isNotified());
- BugzillaRepositoryQuery query = new BugzillaRepositoryQuery("https://bugs.eclipse.org/bugs", "queryUrl",
- "summary");
- TasksUiPlugin.getTaskListManager().getTaskList().addQuery(query);
- TasksUiPlugin.getTaskListManager().getTaskList().addTask(hit, query);
-
- TaskListNotificationManager notificationManager = TasksUiPlugin.getTaskListNotificationManager();
- assertFalse(hit.isNotified());
- notificationManager.collectNotifications();
- for (ITaskListNotification notification : notificationManager.getNotifications()) {
- notification.getLabel().equals(hit.getSummary());
- }
- //assertTrue(notificationManager.getNotifications().contains(new TaskListNotificationQueryIncoming(hit)));
- assertTrue(hit.isNotified());
- }
-
- public void testTaskListNotificationQueryIncomingRepeats() {
- TasksUiPlugin.getTaskListManager().resetTaskList();
- BugzillaTask hit = new BugzillaTask("https://bugs.eclipse.org/bugs", "1", "summary");
- String hitHandle = hit.getHandleIdentifier();
- assertFalse(hit.isNotified());
- BugzillaRepositoryQuery query = new BugzillaRepositoryQuery("https://bugs.eclipse.org/bugs", "queryUrl",
- "summary");
- TasksUiPlugin.getTaskListManager().getTaskList().addQuery(query);
- TasksUiPlugin.getTaskListManager().getTaskList().addTask(hit, query);
- TaskListNotificationManager notificationManager = TasksUiPlugin.getTaskListNotificationManager();
- notificationManager.collectNotifications();
- for (ITaskListNotification notification : notificationManager.getNotifications()) {
- notification.getLabel().equals(hit.getSummary());
- }
- //assertTrue(notificationManager.getNotifications().iterator().next().equals(new TaskListNotificationQueryIncoming(hit)));
- assertTrue(hit.isNotified());
-
- TasksUiPlugin.getTaskListManager().saveTaskList();
- TasksUiPlugin.getTaskListManager().resetTaskList();
- assertEquals(0, TasksUiPlugin.getTaskListManager().getTaskList().getQueries().size());
- assertTrue(TasksUiPlugin.getTaskListManager().readExistingOrCreateNewList());
- assertEquals(1, TasksUiPlugin.getTaskListManager().getTaskList().getQueries().size());
- BugzillaTask hitLoaded = (BugzillaTask) TasksUiPlugin.getTaskListManager().getTaskList().getTask(hitHandle);
- assertNotNull(hitLoaded);
- assertTrue(hitLoaded.isNotified());
- }
-
-}
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
deleted file mode 100644
index e43e3d3d4..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListStandaloneTest.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryQuery;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.internal.bugzilla.ui.tasklist.BugzillaTaskListFactory;
-import org.eclipse.mylyn.internal.tasks.core.LocalTask;
-import org.eclipse.mylyn.tasks.core.AbstractTask;
-import org.eclipse.mylyn.tasks.core.AbstractTaskListFactory;
-import org.eclipse.mylyn.tasks.ui.TaskListManager;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-
-/**
- * @author Mik Kersten
- * @author Rob Elves
- */
-public class TaskListStandaloneTest extends TestCase {
-
- private TaskListManager manager;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- TasksUiPlugin.getRepositoryManager().clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
- manager = TasksUiPlugin.getTaskListManager();
-
- manager.resetTaskList();
- assertEquals("should be empty: " + manager.getTaskList().getDefaultCategory().getChildren(), 0,
- manager.getTaskList().getDefaultCategory().getChildren().size());
- }
-
- @Override
- protected void tearDown() throws Exception {
- manager.resetTaskList();
- manager.saveTaskList();
- super.tearDown();
- }
-
- public void testDueDateExternalization() {
- AbstractTask task = new LocalTask("1", "task 1");
- Date dueDate = new Date();
- task.setDueDate(dueDate);
- manager.getTaskList().moveToContainer(task, manager.getTaskList().getDefaultCategory());
- assertEquals(1, manager.getTaskList().getAllTasks().size());
-
- manager.saveTaskList();
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
- assertEquals(1, manager.getTaskList().getAllTasks().size());
- Set<AbstractTask> readList = manager.getTaskList().getDefaultCategory().getChildren();
- AbstractTask readTask = readList.iterator().next();
- assertTrue(readTask.getSummary().equals("task 1"));
- assertTrue(readTask.getDueDate().compareTo(dueDate) == 0);
- }
-
- public void testPastReminder() {
- AbstractTask task = new LocalTask("1", "1");
- long now = new Date().getTime();
- task.setScheduledForDate(new Date(now - 1000));
- assertTrue(task.isPastReminder());
-
- task.setScheduledForDate(new Date(now + 1000));
- assertFalse(task.isPastReminder());
-
- task.setScheduledForDate(new Date(now - 1000));
- task.setCompleted(true);
- assertTrue(task.isPastReminder());
- }
-
- public void testDates() {
- Date start = Calendar.getInstance().getTime();
- Date creation = new Date();
- AbstractTask task = new LocalTask("1", "task 1");
-
- manager.getTaskList().moveToContainer(task, manager.getTaskList().getDefaultCategory());
- assertDatesCloseEnough(task.getCreationDate(), start);
-
- task.setCompleted(true);
- assertDatesCloseEnough(task.getCompletionDate(), start);
-
- task.setScheduledForDate(start);
- assertDatesCloseEnough(task.getScheduledForDate(), start);
-
- assertEquals(2, manager.getTaskList().getRootElements().size());
- manager.saveTaskList();
-
- assertNotNull(manager.getTaskList());
- // TaskList list = new TaskList();
- // manager.setTaskList(list);
- // assertEquals(0, manager.getTaskList().getRootTasks().size());
- // manager.readOrCreateTaskList();
- // assertNotNull(manager.getTaskList());
- assertEquals(1, manager.getTaskList().getDefaultCategory().getChildren().size());
-
- Set<AbstractTask> readList = manager.getTaskList().getDefaultCategory().getChildren();
- AbstractTask readTask = readList.iterator().next();
- assertTrue(readTask.getSummary().equals("task 1"));
-
- assertEquals("should be: " + creation, task.getCreationDate(), readTask.getCreationDate());
- assertEquals(task.getCompletionDate(), readTask.getCompletionDate());
- assertEquals(task.getScheduledForDate(), readTask.getScheduledForDate());
- }
-
- // Task retention when connector missing upon startup
- public void testOrphanedTasks() {
- List<AbstractTaskListFactory> originalExternalizers = manager.getTaskListWriter().getExternalizers();
- List<AbstractTaskListFactory> externalizers;
- externalizers = new ArrayList<AbstractTaskListFactory>();
- externalizers.add(new BugzillaTaskListFactory());
- // make some tasks
- // save them
- BugzillaTask task = new BugzillaTask("http://bugs", "1", "1");
- manager.getTaskList().addTask(task);
- manager.saveTaskList();
-
- // reload tasklist and check that they persist
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
- assertEquals(1, manager.getTaskList().getAllTasks().size());
-
- // removed/disable externalizers
- externalizers.clear();
- manager.getTaskListWriter().setDelegateExternalizers(externalizers);
-
- // reload tasklist ensure task didn't load
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- // Save the task list (tasks with missing connectors should get
- // persisted)
- manager.saveTaskList();
-
- // re-enable connector
- externalizers.add(new BugzillaTaskListFactory());
- manager.getTaskListWriter().setDelegateExternalizers(externalizers);
-
- // re-load tasklist
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
-
- // ensure that task now gets loaded
- assertEquals(1, manager.getTaskList().getAllTasks().size());
- manager.getTaskListWriter().setDelegateExternalizers(originalExternalizers);
- }
-
- // Query retention when connector missing/fails to load
- public void testOrphanedQueries() {
- List<AbstractTaskListFactory> originalExternalizers = manager.getTaskListWriter().getExternalizers();
- List<AbstractTaskListFactory> externalizers;
- externalizers = new ArrayList<AbstractTaskListFactory>();
- externalizers.add(new BugzillaTaskListFactory());
- // make a query
- BugzillaRepositoryQuery query = new BugzillaRepositoryQuery(IBugzillaConstants.TEST_BUGZILLA_222_URL,
- "http://queryurl", "summary");
-
- manager.getTaskList().addQuery(query);
- manager.saveTaskList();
-
- // reload tasklist and check that they persist
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
- assertEquals(1, manager.getTaskList().getQueries().size());
-
- // removed/disable externalizers
- externalizers.clear();
- manager.getTaskListWriter().setDelegateExternalizers(externalizers);
-
- // reload tasklist ensure query didn't load
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
- assertEquals(0, manager.getTaskList().getQueries().size());
- // Save the task list (queries with missing connectors should get
- // persisted)
- manager.saveTaskList();
-
- // re-enable connector
- externalizers.add(new BugzillaTaskListFactory());
- manager.getTaskListWriter().setDelegateExternalizers(externalizers);
-
- // re-load tasklist
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
-
- // ensure that task now gets loaded
- assertEquals(1, manager.getTaskList().getQueries().size());
- manager.getTaskListWriter().setDelegateExternalizers(originalExternalizers);
- }
-
- public void assertDatesCloseEnough(Date first, Date second) {
- assertTrue(second.getTime() - first.getTime() < 100);
- }
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskReportGeneratorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskReportGeneratorTest.java
deleted file mode 100644
index 62021b7ac..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskReportGeneratorTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryQuery;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask;
-import org.eclipse.mylyn.internal.tasks.core.TaskCategory;
-import org.eclipse.mylyn.internal.tasks.ui.planner.CompletedTaskCollector;
-import org.eclipse.mylyn.internal.tasks.ui.planner.TaskReportGenerator;
-import org.eclipse.mylyn.tasks.core.AbstractTask;
-import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
-import org.eclipse.mylyn.tasks.ui.TaskListManager;
-import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-
-/**
- * @author Mik Kersten
- * @author Rob Elves
- */
-public class TaskReportGeneratorTest extends TestCase {
-
- private TaskListManager manager;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- manager = TasksUiPlugin.getTaskListManager();
- manager.resetTaskList();
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- manager.resetTaskList();
- TasksUiPlugin.getTaskListManager().saveTaskList();
-// TasksUiPlugin.getDefault().getTaskListSaveManager().saveTaskList(true);
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- }
-
- public void testCompletedTasksRetrieved() throws InvocationTargetException, InterruptedException {
- AbstractTask task1 = manager.createNewLocalTask("task 1");
- manager.getTaskList().moveToContainer(task1, manager.getTaskList().getDefaultCategory());
-
- CompletedTaskCollector collector = new CompletedTaskCollector(new Date(0));
- TaskReportGenerator generator = new TaskReportGenerator(manager.getTaskList());
- generator.addCollector(collector);
- generator.run(new NullProgressMonitor());
- assertEquals(0, generator.getAllCollectedTasks().size());
-
- task1.setCompleted(true);
- generator.run(new NullProgressMonitor());
- assertEquals(1, generator.getAllCollectedTasks().size());
- assertEquals(task1, generator.getAllCollectedTasks().get(0));
- }
-
- public void testCompletedTasksDateBoundsRetrieved() throws InvocationTargetException, InterruptedException {
- AbstractTask task1 = manager.createNewLocalTask("task 1");
- manager.getTaskList().moveToContainer(task1, manager.getTaskList().getDefaultCategory());
- task1.setCompleted(true);
- Thread.sleep(1000);
- long now = new Date().getTime();
-
- CompletedTaskCollector collector = new CompletedTaskCollector(new Date(now));
- TaskReportGenerator generator = new TaskReportGenerator(manager.getTaskList());
- generator.addCollector(collector);
- generator.run(new NullProgressMonitor());
- assertEquals(0, generator.getAllCollectedTasks().size());
-
- generator = new TaskReportGenerator(manager.getTaskList());
- collector = new CompletedTaskCollector(new Date(now - 8000));
- generator.addCollector(collector);
- generator.run(new NullProgressMonitor());
- assertEquals(1, generator.getAllCollectedTasks().size());
- assertEquals(task1, generator.getAllCollectedTasks().get(0));
- }
-
- public void testCompletedBugzillaTasksRetrieved() throws InvocationTargetException, InterruptedException {
- BugzillaTask task1 = new BugzillaTask("repo", "1", "bugzillatask 1");
- manager.getTaskList().moveToContainer(task1, manager.getTaskList().getDefaultCategory());
-
- CompletedTaskCollector collector = new CompletedTaskCollector(new Date(0));
- TaskReportGenerator generator = new TaskReportGenerator(manager.getTaskList());
- generator.addCollector(collector);
- generator.run(new NullProgressMonitor());
- assertEquals(0, generator.getAllCollectedTasks().size());
-
- task1.setCompleted(true);
- generator.run(new NullProgressMonitor());
- assertEquals(1, generator.getAllCollectedTasks().size());
- assertEquals(task1, generator.getAllCollectedTasks().get(0));
- }
-
- public void testCompletedTasksInCategoryRetrieved() throws InvocationTargetException, InterruptedException {
- AbstractTask task1 = manager.createNewLocalTask("task 1");
- manager.getTaskList().moveToContainer(task1, manager.getTaskList().getDefaultCategory());
- task1.setCompleted(true);
- TaskCategory cat1 = new TaskCategory("TaskReportGeneratorTest Category");
- manager.getTaskList().addCategory(cat1);
-
- Set<AbstractTaskContainer> catagories = new HashSet<AbstractTaskContainer>();
- catagories.add(cat1);
-
- CompletedTaskCollector collector = new CompletedTaskCollector(new Date(0));
- TaskReportGenerator generator = new TaskReportGenerator(manager.getTaskList(), catagories);
- generator.addCollector(collector);
- generator.run(new NullProgressMonitor());
- assertEquals(0, generator.getAllCollectedTasks().size());
-
- manager.getTaskList().moveToContainer(task1, cat1);
-
- generator.run(new NullProgressMonitor());
- assertEquals(1, generator.getAllCollectedTasks().size());
- assertEquals(task1, generator.getAllCollectedTasks().get(0));
- }
-
- public void testCompletedBugzillaTasksInCategoryRetrieved() throws InvocationTargetException, InterruptedException {
- BugzillaTask task1 = new BugzillaTask("repo", "1", "task 1");
- manager.getTaskList().moveToContainer(task1,
- TasksUiPlugin.getTaskListManager().getTaskList().getDefaultCategory());
- task1.setCompleted(true);
- TaskCategory cat1 = new TaskCategory("TaskReportGeneratorTest Category");
- manager.getTaskList().addCategory(cat1);
-
- Set<AbstractTaskContainer> catagories = new HashSet<AbstractTaskContainer>();
- catagories.add(cat1);
-
- CompletedTaskCollector collector = new CompletedTaskCollector(new Date(0));
- TaskReportGenerator generator = new TaskReportGenerator(manager.getTaskList(), catagories);
- generator.addCollector(collector);
- generator.run(new NullProgressMonitor());
- assertEquals(0, generator.getAllCollectedTasks().size());
-
- manager.getTaskList().moveToContainer(task1, cat1);
-
- generator.run(new NullProgressMonitor());
- assertEquals(1, generator.getAllCollectedTasks().size());
- assertEquals(task1, generator.getAllCollectedTasks().get(0));
- }
-
- public void testCompletedBugzillaTasksInQueryRetrieved() throws InvocationTargetException, InterruptedException {
- BugzillaTask task1 = new BugzillaTask("repo", "1", "task 1");
- manager.getTaskList().moveToContainer(task1,
- TasksUiPlugin.getTaskListManager().getTaskList().getDefaultCategory());
- task1.setCompleted(false);
-
- BugzillaRepositoryQuery bugQuery = new BugzillaRepositoryQuery("repositoryUrl", "queryUrl",
- "TaskReportGeneratorBugzillaQueryCategory");
-
- manager.getTaskList().addQuery(bugQuery);
-
- Set<AbstractTaskContainer> catagories = new HashSet<AbstractTaskContainer>();
- catagories.add(bugQuery);
-
- CompletedTaskCollector collector = new CompletedTaskCollector(new Date(0));
- TaskReportGenerator generator = new TaskReportGenerator(manager.getTaskList(), catagories);
- generator.addCollector(collector);
- generator.run(new NullProgressMonitor());
- assertEquals(0, generator.getAllCollectedTasks().size());
-
- manager.getTaskList().addTask(task1, bugQuery);
-
- generator.run(new NullProgressMonitor());
- assertEquals(0, generator.getAllCollectedTasks().size());
-
- task1.setCompleted(true);
-
- generator.run(new NullProgressMonitor());
- assertEquals(1, generator.getAllCollectedTasks().size());
- assertEquals(task1, generator.getAllCollectedTasks().get(0));
- }
-
-}
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
deleted file mode 100644
index b26e79e87..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests.headless;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.context.tests.support.TestUtil;
-import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaReportElement;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryQuery;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.tasks.core.AbstractTask;
-import org.eclipse.mylyn.tasks.core.AbstractTaskDataHandler;
-import org.eclipse.mylyn.tasks.core.QueryHitCollector;
-import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
-import org.eclipse.mylyn.tasks.core.TaskList;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.TaskFactory;
-
-// import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
-
-/**
- * Example use of headless API (no ui dependencies)
- *
- * @author Rob Elves
- * @author Nathan Hapke
- */
-public class BugzillaQueryTest extends TestCase {
-
- private TaskRepository repository;
-
- private BugzillaRepositoryConnector connector;
-
- private AbstractTaskDataHandler handler;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- //
- // 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 = TestUtil.readCredentials();
- repository.setAuthenticationCredentials(credentials.username, credentials.password);
- }
-
- /**
- * This is the first test so that the repository credentials are correctly set for the other tests
- */
- public void testAddCredentials() {
- if (!repository.hasCredentials()) {
- Credentials credentials = TestUtil.readCredentials();
- repository.setAuthenticationCredentials(credentials.username, credentials.password);
-
- assertTrue(repository.hasCredentials());
- }
- }
-
- public void testGetBug() throws Exception {
- RepositoryTaskData taskData = handler.getTaskData(repository, "1", new NullProgressMonitor());
- 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
- // part of the bug
- assertEquals("P1", taskData.getAttributeValue(BugzillaReportElement.PRIORITY.getKeyString()));
- }
-
- // TODO: Uncomment when bug#176513 completed
-// public void testGetBugs() throws Exception {
-// HashSet<String> taskIds = new HashSet<String>();
-// taskIds.add("1");
-// taskIds.add("2");
-// taskIds.add("4");
-// Map<String, RepositoryTaskData> taskDataMap = handler.getTaskData(repository, taskIds);
-// assertNotNull(taskDataMap);
-// RepositoryTaskData taskData = taskDataMap.get("1");
-// assertEquals("user@mylar.eclipse.org", taskData.getAssignedTo());
-// assertEquals("foo", taskData.getDescription());
-// // You can use the getAttributeValue to pull up the information on any
-// // part of the bug
-// assertEquals("P1", taskData.getAttributeValue(BugzillaReportElement.PRIORITY.getKeyString()));
-//
-// taskData = taskDataMap.get("2");
-// assertEquals("nhapke@cs.ubc.ca", taskData.getAssignedTo());
-// assertEquals("search-match-test 1", taskData.getDescription());
-//
-// taskData = taskDataMap.get("4");
-// assertEquals("relves@cs.ubc.ca", taskData.getReporter());
-// assertEquals("Test", taskData.getDescription());
-// }
-
- // 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()));
- // }
-
- @SuppressWarnings("deprecation")
- 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=";
-
- // holds onto actual hit objects
- TaskList taskList = new TaskList();
- QueryHitCollector collector = new QueryHitCollector(new TaskFactory(repository));
- BugzillaRepositoryConnector connector = new BugzillaRepositoryConnector();
- connector.init(taskList);
- BugzillaRepositoryQuery query = new BugzillaRepositoryQuery(repository.getUrl(), queryUrlString, "summary");
- connector.performQuery(query, repository, new NullProgressMonitor(), collector);
- assertEquals(2, collector.getTasks().size());
- for (AbstractTask hit : collector.getTasks()) {
- assertTrue(hit.getSummary().contains("search-match-test"));
- }
- }
-}
-
-// 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"));
-// }
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaTaskHistoryTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaTaskHistoryTest.java
deleted file mode 100644
index b4b810753..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaTaskHistoryTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 Mylyn project committers 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
- *******************************************************************************/
-package org.eclipse.mylyn.bugzilla.tests.headless;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import org.eclipse.mylyn.bugzilla.tests.AbstractBugzillaTest;
-import org.eclipse.mylyn.context.tests.support.TestUtil;
-import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.internal.bugzilla.core.history.AssignmentEvent;
-import org.eclipse.mylyn.internal.bugzilla.core.history.ResolutionEvent;
-import org.eclipse.mylyn.internal.bugzilla.core.history.StatusEvent;
-import org.eclipse.mylyn.internal.bugzilla.core.history.TaskHistory;
-import org.eclipse.mylyn.tasks.core.TaskList;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-
-public class BugzillaTaskHistoryTest extends AbstractBugzillaTest {
-
- private TaskRepository repository;
-
- private BugzillaRepositoryConnector connector;
-
- private static final String HISTORY_FILE_NAME = "storedHistory.history";
-
- private static final String REPORT_ID = "1";
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- connector = new BugzillaRepositoryConnector();
- connector.init(new TaskList());
- repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
-
- Credentials credentials = TestUtil.readCredentials();
- repository.setAuthenticationCredentials(credentials.username, credentials.password);
- }
-
- public void testGetBugHistory() throws Exception {
-
- BugzillaClient client = connector.getClientManager().getClient(repository);
- assertNotNull(client);
- TaskHistory history = client.getHistory("1");
- assertNotNull(history);
-
- assertEquals(1, history.getAssignmentEvents().size());
- assertEquals(2, history.getStatusEvents().size());
- assertEquals(1, history.getResolutionEvents().size());
- assertEquals(12, history.getOtherEvents().size());
- }
-
- public void testAssignmentEvent() throws Exception {
- BugzillaClient client = connector.getClientManager().getClient(repository);
- assertNotNull(client);
- TaskHistory history = client.getHistory("1");
- assertNotNull(history);
-
- AssignmentEvent assignment = history.getAssignmentEvents().get(0);
- assertEquals("nhapke@cs.ubc.ca", assignment.getName());
- assertEquals("user@mylar.eclipse.org", assignment.getAssigned());
- assertEquals("2006-08-25 17:48:02", assignment.getDate());
- assertEquals("nhapke@cs.ubc.ca", assignment.getRemoved());
- assertEquals("user@mylar.eclipse.org", assignment.getAdded());
- assertEquals("AssignedTo", assignment.getWhat());
- }
-
- public void testStatusEvent() throws Exception {
-
- BugzillaClient client = connector.getClientManager().getClient(repository);
- assertNotNull(client);
- TaskHistory history = client.getHistory("1");
- assertNotNull(history);
-
- StatusEvent statusChange = history.getStatusEvents().get(0);
- assertEquals("nhapke@cs.ubc.ca", statusChange.getName());
- assertEquals("2006-08-25 19:18:05", statusChange.getDate());
- assertEquals("NEW", statusChange.getRemoved());
- assertEquals("ASSIGNED", statusChange.getAdded());
- assertEquals("Status", statusChange.getWhat());
- }
-
- public void testResolutionEvent() throws Exception {
- BugzillaClient client = connector.getClientManager().getClient(repository);
- assertNotNull(client);
- TaskHistory history = client.getHistory(REPORT_ID);
- assertNotNull(history);
-
- ResolutionEvent resolutionChange = history.getResolutionEvents().get(0);
- assertEquals("janvik@cs.ubc.ca", resolutionChange.getName());
- assertEquals("2007-02-15 14:52:51", resolutionChange.getDate());
- assertEquals("", resolutionChange.getRemoved());
- assertEquals("FIXED", resolutionChange.getAdded());
- assertEquals("Resolution", resolutionChange.getWhat());
- }
-
- public void testStoredHistory() throws Exception {
- BugzillaClient client = connector.getClientManager().getClient(repository);
- assertNotNull(client);
- TaskHistory history = client.getHistory(REPORT_ID);
- assertNotNull(history);
- storeHistory(history);
-
- history = getStoredHistory();
-
- assertEquals(1, history.getAssignmentEvents().size());
- assertEquals(2, history.getStatusEvents().size());
- assertEquals(1, history.getResolutionEvents().size());
- assertEquals(12, history.getOtherEvents().size());
-
- // Remove file
- File storedHistoryFile = new File(HISTORY_FILE_NAME);
- assertTrue(storedHistoryFile.delete());
- }
-
- private void storeHistory(TaskHistory history) {
- File saveFile = new File(HISTORY_FILE_NAME);
- saveFile.deleteOnExit();
- try {
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(saveFile));
- out.writeObject(history);
- out.close();
- } catch (FileNotFoundException e) {
- System.err.println("Can't write to: " + saveFile);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- private TaskHistory getStoredHistory() {
- File file = new File(HISTORY_FILE_NAME);
- try {
- ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
- TaskHistory history = (TaskHistory) in.readObject();
- in.close();
- return history;
- } catch (FileNotFoundException e) {
- System.err.println("Can't find: " + file);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
-
- // Should never happen
- return null;
- }
-}

Back to the top