Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2009-09-01 04:13:59 +0000
committerspingel2009-09-01 04:13:59 +0000
commit9ae926ed07a9312950c3a4d39f77fcf56c224ec2 (patch)
treeaa41c700cc2cff128b7d84d2eddd63262bfdbd10 /org.eclipse.mylyn.bugzilla.tests
parente8569061b339be8d15c57c51eed8b163acd0c339 (diff)
downloadorg.eclipse.mylyn.tasks-9ae926ed07a9312950c3a4d39f77fcf56c224ec2.tar.gz
org.eclipse.mylyn.tasks-9ae926ed07a9312950c3a4d39f77fcf56c224ec2.tar.xz
org.eclipse.mylyn.tasks-9ae926ed07a9312950c3a4d39f77fcf56c224ec2.zip
NEW - bug 287225: implement test suite driver for multiple repositories
https://bugs.eclipse.org/bugs/show_bug.cgi?id=287225
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests')
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/META-INF/MANIFEST.MF7
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java24
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java43
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java21
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java260
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java88
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java10
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java8
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchDialogTest.java71
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchTest.java16
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskCompletionTest.java13
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java45
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskListTest.java172
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestConstants.java46
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestPlugin.java100
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestUtil.java54
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/IBugzillaTestConstants.java39
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java18
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryTaskHandleTest.java59
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskEditorTest.java119
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListStandaloneTest.java190
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/client/BugzillaClientTest.java93
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/client/BugzillaTaskHistoryTest.java (renamed from org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaTaskHistoryTest.java)80
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java136
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java (renamed from org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java)100
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaVersionTest.java (renamed from org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaVersionTest.java)6
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java129
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/TestFixture.java129
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaRepositorySettingsPageTest.java (renamed from org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java)13
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaSearchPageTest.java52
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java (renamed from org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskHyperlinkDetectorTest.java)2
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/TaskEditorTest.java76
32 files changed, 860 insertions, 1359 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.bugzilla.tests/META-INF/MANIFEST.MF
index 5b4f990dd..0c9677c59 100644
--- a/org.eclipse.mylyn.bugzilla.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.bugzilla.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2
Bundle-Name: Mylyn Bugzilla Connector Tests
Bundle-SymbolicName: org.eclipse.mylyn.bugzilla.tests
Bundle-Version: 0.0.0
-Bundle-Activator: org.eclipse.mylyn.bugzilla.tests.BugzillaTestPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.junit,
@@ -27,9 +26,11 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.mylyn.commons.ui,
org.eclipse.compare,
org.eclipse.mylyn.commons.core
-Bundle-ActivationPolicy: lazy
Bundle-Vendor: Eclipse Mylyn
Bundle-ClassPath: bugzilla-test.jar
Export-Package: org.eclipse.mylyn.bugzilla.tests;x-internal:=true,
- org.eclipse.mylyn.bugzilla.tests.headless;x-internal:=true
+ org.eclipse.mylyn.bugzilla.tests.client;x-internal:=true,
+ org.eclipse.mylyn.bugzilla.tests.core;x-internal:=true,
+ org.eclipse.mylyn.bugzilla.tests.support;x-internal:=true,
+ org.eclipse.mylyn.bugzilla.tests.ui;x-internal:=true
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
index 94a74a082..b5f032e67 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
@@ -79,40 +79,40 @@ public abstract class AbstractBugzillaTest extends TestCase {
manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
}
+ protected void init34() {
+ init(BugzillaTestConstants.TEST_BUGZILLA_34_URL);
+ }
+
protected void init323() {
- init(IBugzillaTestConstants.TEST_BUGZILLA_323_URL);
+ init(BugzillaTestConstants.TEST_BUGZILLA_323_URL);
}
protected void init322() {
- init(IBugzillaTestConstants.TEST_BUGZILLA_322_URL);
+ init(BugzillaTestConstants.TEST_BUGZILLA_322_URL);
}
protected void init32() {
- init(IBugzillaTestConstants.TEST_BUGZILLA_32_URL);
- }
-
- protected void init31() {
- init(IBugzillaTestConstants.TEST_BUGZILLA_31_URL);
+ init(BugzillaTestConstants.TEST_BUGZILLA_32_URL);
}
protected void init30() {
- init(IBugzillaTestConstants.TEST_BUGZILLA_30_URL);
+ init(BugzillaTestConstants.TEST_BUGZILLA_30_URL);
}
protected void init222() {
- init(IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
+ init(BugzillaTestConstants.TEST_BUGZILLA_222_URL);
}
protected void init2201() {
- init(IBugzillaTestConstants.TEST_BUGZILLA_2201_URL);
+ init(BugzillaTestConstants.TEST_BUGZILLA_2201_URL);
}
protected void init220() {
- init(IBugzillaTestConstants.TEST_BUGZILLA_220_URL);
+ init(BugzillaTestConstants.TEST_BUGZILLA_220_URL);
}
protected void init218() {
- init(IBugzillaTestConstants.TEST_BUGZILLA_218_URL);
+ init(BugzillaTestConstants.TEST_BUGZILLA_218_URL);
}
@SuppressWarnings("deprecation")
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java
new file mode 100644
index 000000000..03d8088be
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.bugzilla.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.mylyn.bugzilla.tests.client.BugzillaClientTest;
+import org.eclipse.mylyn.bugzilla.tests.client.BugzillaTaskHistoryTest;
+import org.eclipse.mylyn.bugzilla.tests.core.BugzillaConfigurationTest;
+import org.eclipse.mylyn.bugzilla.tests.core.BugzillaRepositoryConnectorStandaloneTest;
+import org.eclipse.mylyn.bugzilla.tests.core.BugzillaVersionTest;
+import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
+
+/**
+ * @author Steffen Pingel
+ */
+public class AllBugzillaHeadlessStandaloneTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Headless Standalone Tests for org.eclipse.mylyn.bugzilla.tests");
+ suite.addTestSuite(BugzillaConfigurationTest.class);
+ suite.addTestSuite(BugzillaVersionTest.class);
+ for (BugzillaFixture fixture : BugzillaFixture.ALL) {
+ TestSuite fixtureSuite = fixture.createSuite();
+ fixture.add(fixtureSuite, BugzillaClientTest.class);
+ fixture.add(fixtureSuite, BugzillaTaskHistoryTest.class);
+ fixture.add(fixtureSuite, BugzillaRepositoryConnectorStandaloneTest.class);
+ suite.addTest(fixtureSuite);
+ }
+ return suite;
+ }
+
+}
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
index 7ad9e9fb4..00004b8f0 100644
--- 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
@@ -14,8 +14,11 @@ 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;
+import org.eclipse.mylyn.bugzilla.tests.core.BugzillaRepositoryConnectorStandaloneTest;
+import org.eclipse.mylyn.bugzilla.tests.ui.BugzillaRepositorySettingsPageTest;
+import org.eclipse.mylyn.bugzilla.tests.ui.BugzillaSearchPageTest;
+import org.eclipse.mylyn.bugzilla.tests.ui.BugzillaTaskHyperlinkDetectorTest;
+import org.eclipse.mylyn.bugzilla.tests.ui.TaskEditorTest;
/**
* @author Mik Kersten
@@ -24,25 +27,19 @@ public class AllBugzillaTests {
public static Test suite() {
TestSuite suite = new TestSuite("Tests for org.eclipse.mylyn.bugzilla.tests");
- suite.addTestSuite(RepositoryTaskHandleTest.class);
+ suite.addTest(AllBugzillaHeadlessStandaloneTests.suite());
suite.addTestSuite(BugzillaTaskCompletionTest.class);
suite.addTestSuite(BugzillaTaskDataHandlerTest.class);
- suite.addTestSuite(TaskListStandaloneTest.class);
- suite.addTestSuite(BugzillaTaskListTest.class);
suite.addTestSuite(TaskEditorTest.class);
- suite.addTestSuite(BugzillaQueryTest.class);
- suite.addTestSuite(RepositoryEditorWizardTest.class);
+ suite.addTestSuite(BugzillaRepositoryConnectorStandaloneTest.class);
+ suite.addTestSuite(BugzillaRepositorySettingsPageTest.class);
suite.addTestSuite(RepositoryReportFactoryTest.class);
- suite.addTestSuite(BugzillaConfigurationTest.class);
suite.addTestSuite(BugzillaTaskHyperlinkDetectorTest.class);
suite.addTestSuite(BugzillaSearchTest.class);
suite.addTestSuite(BugzillaRepositoryConnectorTest.class);
suite.addTestSuite(EncodingTest.class);
- suite.addTestSuite(BugzillaProductParserTest.class);
- suite.addTestSuite(BugzillaSearchDialogTest.class);
- suite.addTestSuite(BugzillaTaskHistoryTest.class);
+ suite.addTestSuite(BugzillaSearchPageTest.class);
suite.addTestSuite(BugzillaRepository32Test.class);
- suite.addTestSuite(BugzillaVersionTest.class);
suite.addTestSuite(BugzillaDateTimeTests.class);
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 48f9e3b82..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URL;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
-import org.eclipse.mylyn.commons.net.AuthenticationType;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientManager;
-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.eclipse.mylyn.tasks.core.TaskRepository;
-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 {
-
- BugzillaClientManager bugzillaClientManager = new BugzillaClientManager();
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- private BugzillaClient createClient(String hostUrl, String username, String password, String htAuthUser,
- String htAuthPass, String encoding) throws CoreException, IOException {
- TaskRepository taskRepository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, hostUrl);
-
- AuthenticationCredentials credentials = new AuthenticationCredentials(username, password);
- taskRepository.setCredentials(AuthenticationType.REPOSITORY, credentials, false);
-
- AuthenticationCredentials webCredentials = new AuthenticationCredentials(htAuthUser, htAuthPass);
- taskRepository.setCredentials(AuthenticationType.HTTP, webCredentials, false);
- taskRepository.setCharacterEncoding(encoding);
- BugzillaClient client = bugzillaClientManager.getClient(taskRepository, null);
- client.getRepositoryConfiguration(new NullProgressMonitor());
- return client;
- }
-
- public void test222RDFProductConfig() throws Exception {
-
- BugzillaClient client = createClient(IBugzillaTestConstants.TEST_BUGZILLA_222_URL, "", "", "", "", "UTF-8");
- RepositoryConfiguration config = client.getRepositoryConfiguration();
- assertNotNull(config);
- assertEquals("2.22.1", config.getInstallVersion().toString());
- assertEquals(7, config.getStatusValues().size());
- assertEquals(8, config.getResolutions().size());
- assertEquals(4, config.getPlatforms().size());
- assertEquals(6, 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 = createClient(IBugzillaTestConstants.TEST_BUGZILLA_2201_URL, "", "", "", "", "UTF-8");
- RepositoryConfiguration config = client.getRepositoryConfiguration();
- assertNotNull(config);
- assertEquals("2.20.1", config.getInstallVersion().toString().toString());
- 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 = createClient(IBugzillaTestConstants.TEST_BUGZILLA_220_URL, "", "", "", "", "UTF-8");
- RepositoryConfiguration config = client.getRepositoryConfiguration();
- assertNotNull(config);
- assertEquals("2.20.3", config.getInstallVersion().toString());
- 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 = createClient(IBugzillaTestConstants.TEST_BUGZILLA_218_URL, "", "", "", "", "UTF-8");
- RepositoryConfiguration config = client.getRepositoryConfiguration();
- assertNotNull(config);
- assertEquals("2.18.6", config.getInstallVersion().toString());
- 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 = createClient(IBugzillaConstants.ECLIPSE_BUGZILLA_URL, "", "", "", "", "UTF-8");
- RepositoryConfiguration config = client.getRepositoryConfiguration();
- assertNotNull(config);
- assertEquals("3.0.4", config.getInstallVersion().toString());
- assertEquals(7, config.getStatusValues().size());
- assertEquals(9, config.getResolutions().size());
- assertEquals(6, config.getPlatforms().size());
- assertEquals(32, config.getOSs().size());
- assertEquals(5, config.getPriorities().size());
- assertEquals(7, config.getSeverities().size());
- assertTrue(config.getProducts().size() > 50);
- assertEquals(4, config.getOpenStatusValues().size());
- assertEquals(14, config.getComponents("Mylyn").size());
- assertEquals(27, 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();
- assertNotNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
- assertNotNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration2.getRepositoryUrl()));
- BugzillaCorePlugin.removeConfiguration(configuration1);
- BugzillaCorePlugin.removeConfiguration(configuration2);
- assertNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
- assertNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration2.getRepositoryUrl()));
- BugzillaCorePlugin.setCacheFileRead(false);
- 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()));
-// }
-
- /**
- * 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 mylyn.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) {
- File tempFile = File.createTempFile("XmlCleaner-", "tmp");
- tempFile.deleteOnExit();
- in = XmlCleaner.clean(in, tempFile);
- if (tempFile != null) {
- tempFile.delete();
- }
-
- }
-
- 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 45a8865e8..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-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.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();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public BugzillaProductParserTest(String arg0) {
- super(arg0);
- }
-
- private TaskRepository setRepository(String url) {
- repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, url);
- Credentials credentials = TestUtil.readCredentials();
- repository.setAuthenticationCredentials(credentials.username, credentials.password);
- return repository;
- }
-
- public void test222Products() throws Exception {
- setRepository(IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
- List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, null).getProducts();
- Iterator<String> itr = productList.iterator();
- assertTrue(itr.hasNext());
- assertEquals("Read Only Test Cases", itr.next());
- }
-
- public void test2201Products() throws Exception {
- setRepository(IBugzillaTestConstants.TEST_BUGZILLA_2201_URL);
- List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, null).getProducts();
- Iterator<String> itr = productList.iterator();
- assertTrue(itr.hasNext());
- assertEquals("TestProduct", "TestProduct", itr.next());
-
- }
-
- public void test220Products() throws Exception {
- setRepository(IBugzillaTestConstants.TEST_BUGZILLA_220_URL);
- List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, null).getProducts();
- assertEquals(2, productList.size());
- assertTrue(productList.contains("TestProduct"));
- assertTrue(productList.contains("Widget"));
-
- }
-
- public void test218Products() throws Exception {
- setRepository(IBugzillaTestConstants.TEST_BUGZILLA_218_URL);
- List<String> productList = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, null).getProducts();
- assertEquals(1, productList.size());
- assertTrue(productList.contains("TestProduct"));
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java
index ea584d37b..b22b57781 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java
@@ -89,12 +89,12 @@ public class BugzillaRepository32Test extends AbstractBugzillaTest {
String taskNumber = "1";
assertTrue(CoreUtil.TEST_MODE);
RepositoryQuery query = new RepositoryQuery("bugzilla", "blah");
- query.setRepositoryUrl(IBugzillaTestConstants.TEST_BUGZILLA_322_URL);
+ query.setRepositoryUrl(BugzillaTestConstants.TEST_BUGZILLA_322_URL);
query.setUrl("?short_desc_type=allwordssubstr&short_desc=&product=TestProduct&long_desc_type=allwordssubstr&long_desc=&order=Importance&ctype=rdf");
TasksUiInternal.getTaskList().addQuery(query);
TasksUiInternal.synchronizeQuery(connector, query, null, true);
- ITask task = TasksUiInternal.getTask(IBugzillaTestConstants.TEST_BUGZILLA_322_URL, taskNumber, "");
+ ITask task = TasksUiInternal.getTask(BugzillaTestConstants.TEST_BUGZILLA_322_URL, taskNumber, "");
assertNotNull(task);
ITaskDataWorkingCopy taskDataState = TasksUi.getTaskDataManager().getWorkingCopy(task);//TasksUiPlugin.getTaskDataManager().getTaskData(task);
assertNotNull(taskDataState);
@@ -119,7 +119,7 @@ public class BugzillaRepository32Test extends AbstractBugzillaTest {
TasksUiInternal.synchronizeRepository(repository, false);
- task = TasksUiPlugin.getTaskList().getTask(IBugzillaTestConstants.TEST_BUGZILLA_322_URL, taskNumber);
+ task = TasksUiPlugin.getTaskList().getTask(BugzillaTestConstants.TEST_BUGZILLA_322_URL, taskNumber);
assertNotNull(task);
assertEquals(!p1, task.getPriority().equals("P1"));
@@ -149,7 +149,7 @@ public class BugzillaRepository32Test extends AbstractBugzillaTest {
TasksUiInternal.synchronizeRepository(repository, false);
- task = TasksUiPlugin.getTaskList().getTask(IBugzillaTestConstants.TEST_BUGZILLA_322_URL, taskNumber);
+ task = TasksUiPlugin.getTaskList().getTask(BugzillaTestConstants.TEST_BUGZILLA_322_URL, taskNumber);
assertNotNull(task);
assertEquals(!p1, task.getPriority().equals("P1"));
@@ -507,7 +507,7 @@ public class BugzillaRepository32Test extends AbstractBugzillaTest {
};
TaskRepository taskRepository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND,
- IBugzillaTestConstants.TEST_BUGZILLA_32_URL);
+ BugzillaTestConstants.TEST_BUGZILLA_32_URL);
TasksUiPlugin.getRepositoryManager().addRepository(taskRepository);
AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
index b3ed0b868..2ef47aa6f 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
@@ -265,8 +265,8 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
doReassignOld(taskNumber, "tests@mylyn.eclipse.org");
}
- public void testReassign31() throws CoreException {
- init31();
+ public void testReassign32() throws CoreException {
+ init32();
String taskNumber = "1";
// Get the task
@@ -770,7 +770,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
assertEquals(format1.parse("2007-03-20 16:37"), mapper.getCreationDate());
assertEquals(format2.parse("2008-09-24 13:33:02"), mapper.getModificationDate());
- assertEquals(IBugzillaTestConstants.TEST_BUGZILLA_30_URL, mapper.getTaskUrl());
+ assertEquals(BugzillaTestConstants.TEST_BUGZILLA_30_URL, mapper.getTaskUrl());
assertEquals(BugzillaCorePlugin.CONNECTOR_KIND, mapper.getTaskKind());
assertEquals("2", mapper.getTaskKey());
@@ -945,7 +945,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
}
public void testCustomFields() throws Exception {
- init(IBugzillaTestConstants.TEST_BUGZILLA_303_URL);
+ init(BugzillaTestConstants.TEST_BUGZILLA_303_URL);
String taskNumber = "1";
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 d48f1e3aa..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchDialogTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Jeff Pound and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jeff Pound - initial API and implementation
- *******************************************************************************/
-
-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.internal.tasks.core.TaskRepositoryManager;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-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.CONNECTOR_KIND,
- IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
- repo.setVersion(IBugzillaConstants.BugzillaServerVersion.SERVER_222.toString());
- manager.addRepository(repo);
- 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/BugzillaSearchTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchTest.java
index 598a0a9d8..8033c7fdb 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchTest.java
@@ -58,37 +58,37 @@ public class BugzillaSearchTest extends TestCase {
public void testSearching218() throws Exception {
TaskRepository repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND,
- IBugzillaTestConstants.TEST_BUGZILLA_218_URL);
+ BugzillaTestConstants.TEST_BUGZILLA_218_URL);
repository.setVersion(IBugzillaConstants.BugzillaServerVersion.SERVER_218.toString());
TasksUiPlugin.getRepositoryManager().addRepository(repository);
assertEquals(NUM_EXPECTED_HITS,
- runQuery(IBugzillaTestConstants.TEST_BUGZILLA_218_URL, SEARCH_DESCRIPTION).size());
+ runQuery(BugzillaTestConstants.TEST_BUGZILLA_218_URL, SEARCH_DESCRIPTION).size());
}
public void testSearching220() throws Exception {
TaskRepository repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND,
- IBugzillaTestConstants.TEST_BUGZILLA_220_URL);
+ BugzillaTestConstants.TEST_BUGZILLA_220_URL);
repository.setVersion(IBugzillaConstants.BugzillaServerVersion.SERVER_220.toString());
TasksUiPlugin.getRepositoryManager().addRepository(repository);
assertEquals(NUM_EXPECTED_HITS,
- runQuery(IBugzillaTestConstants.TEST_BUGZILLA_220_URL, SEARCH_DESCRIPTION).size());
+ runQuery(BugzillaTestConstants.TEST_BUGZILLA_220_URL, SEARCH_DESCRIPTION).size());
}
public void testSearching2201() throws Exception {
TaskRepository repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND,
- IBugzillaTestConstants.TEST_BUGZILLA_2201_URL);
+ BugzillaTestConstants.TEST_BUGZILLA_2201_URL);
repository.setVersion(IBugzillaConstants.BugzillaServerVersion.SERVER_220.toString());
TasksUiPlugin.getRepositoryManager().addRepository(repository);
assertEquals(NUM_EXPECTED_HITS,
- runQuery(IBugzillaTestConstants.TEST_BUGZILLA_2201_URL, SEARCH_DESCRIPTION).size());
+ runQuery(BugzillaTestConstants.TEST_BUGZILLA_2201_URL, SEARCH_DESCRIPTION).size());
}
public void testSearching222() throws Exception {
TaskRepository repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND,
- IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
+ BugzillaTestConstants.TEST_BUGZILLA_222_URL);
repository.setVersion(IBugzillaConstants.BugzillaServerVersion.SERVER_222.toString());
TasksUiPlugin.getRepositoryManager().addRepository(repository);
- Set<TaskData> hits = runQuery(IBugzillaTestConstants.TEST_BUGZILLA_222_URL, SEARCH_DESCRIPTION);
+ Set<TaskData> hits = runQuery(BugzillaTestConstants.TEST_BUGZILLA_222_URL, SEARCH_DESCRIPTION);
assertEquals(NUM_EXPECTED_HITS, hits.size());
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskCompletionTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskCompletionTest.java
index 8f2b70d29..2a303a2d3 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskCompletionTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskCompletionTest.java
@@ -41,7 +41,8 @@ public class BugzillaTaskCompletionTest extends TestCase {
super.setUp();
this.connector = (BugzillaRepositoryConnector) TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
BugzillaCorePlugin.CONNECTOR_KIND);
- this.repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaConstants.ECLIPSE_BUGZILLA_URL);
+ this.repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND,
+ BugzillaTestConstants.TEST_BUGZILLA_LATEST_URL);
}
@Override
@@ -50,10 +51,11 @@ public class BugzillaTaskCompletionTest extends TestCase {
}
public void testCompletionDate() throws Exception {
- TaskTask task = new TaskTask(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaConstants.ECLIPSE_BUGZILLA_URL, "1");
+ TaskTask task = new TaskTask(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_LATEST_URL,
+ "1");
TaskAttributeMapper mapper = connector.getTaskDataHandler().getAttributeMapper(repository);
TaskData taskData = new TaskData(mapper, BugzillaCorePlugin.CONNECTOR_KIND,
- IBugzillaConstants.ECLIPSE_BUGZILLA_URL, "1");
+ BugzillaTestConstants.TEST_BUGZILLA_LATEST_URL, "1");
taskData.getRoot().createAttribute(BugzillaAttribute.BUG_STATUS.getKey()).setValue(
IBugzillaConstants.VALUE_STATUS_RESOLVED);
TaskAttribute attrComment = taskData.getRoot().createAttribute("commentId");
@@ -70,10 +72,11 @@ public class BugzillaTaskCompletionTest extends TestCase {
}
public void testCompletionDateForStates() throws Exception {
- TaskTask task = new TaskTask(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaConstants.ECLIPSE_BUGZILLA_URL, "1");
+ TaskTask task = new TaskTask(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_LATEST_URL,
+ "1");
TaskAttributeMapper mapper = connector.getTaskDataHandler().getAttributeMapper(repository);
TaskData taskData = new TaskData(mapper, BugzillaCorePlugin.CONNECTOR_KIND,
- IBugzillaConstants.ECLIPSE_BUGZILLA_URL, "1");
+ BugzillaTestConstants.TEST_BUGZILLA_LATEST_URL, "1");
TaskAttribute status = taskData.getRoot().createAttribute(BugzillaAttribute.BUG_STATUS.getKey());
status.setValue("REOPENED");
TaskAttribute attrComment = taskData.getRoot().createAttribute("commentId");
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java
index 6723f71c6..eb4e2d8e0 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java
@@ -23,8 +23,13 @@ import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.TaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
/**
* @author Frank Becker
@@ -125,7 +130,7 @@ public class BugzillaTaskDataHandlerTest extends TestCase {
public void testCloneTaskData() throws Exception {
String bugid = "9";
- setRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_30_URL);
+ setRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_30_URL);
TaskData report1 = init(bugid);
assertNotNull(report1);
@@ -133,7 +138,7 @@ public class BugzillaTaskDataHandlerTest extends TestCase {
testAttributesFromCloneBug(report1, true);
bugid = "10";
- setRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_30_URL);
+ setRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_30_URL);
TaskData report2 = init(bugid);
assertNotNull(report2);
@@ -172,11 +177,45 @@ public class BugzillaTaskDataHandlerTest extends TestCase {
public void testCharacterEscaping() throws CoreException {
String bugid = "17";
- setRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_30_URL);
+ setRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_30_URL);
TaskData report1 = init(bugid);
assertEquals("Testing! \"&@ $\" &amp;", report1.getRoot()
.getAttribute(BugzillaAttribute.SHORT_DESC.getKey())
.getValue());
}
+ public void testinitializeTaskData() throws Exception {
+ final TaskMapping taskMappingInit = new TaskMapping() {
+ @Override
+ public String getSummary() {
+ return "The Summary";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description";
+ }
+ };
+ final TaskMapping taskMappingSelect = new TaskMapping() {
+ @Override
+ public String getProduct() {
+ return "TestProduct";
+ }
+ };
+
+ TaskRepository taskRepository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND,
+ BugzillaTestConstants.TEST_BUGZILLA_222_URL);
+ TasksUiPlugin.getRepositoryManager().addRepository(taskRepository);
+
+ AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
+ taskRepository.getConnectorKind());
+ AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
+ TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(taskRepository);
+ TaskData taskData = new TaskData(mapper, taskRepository.getConnectorKind(), taskRepository.getRepositoryUrl(),
+ "");
+ assertTrue(taskDataHandler.initializeTaskData(taskRepository, taskData, null, null));
+ assertTrue(taskDataHandler.initializeTaskData(taskRepository, taskData, taskMappingInit, null));
+ assertTrue(taskDataHandler.initializeTaskData(taskRepository, taskData, taskMappingSelect, null));
+ }
+
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskListTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskListTest.java
deleted file mode 100644
index 82d30bef1..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskListTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.util.Set;
-
-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.tasks.core.AbstractTask;
-import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
-import org.eclipse.mylyn.internal.tasks.core.TaskList;
-import org.eclipse.mylyn.internal.tasks.core.TaskTask;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.tests.TaskTestUtil;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-
-/**
- * @author Mik Kersten
- */
-public class BugzillaTaskListTest extends TestCase {
-
- private TaskRepository repository;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- TasksUiPlugin.getTaskList().reset();
- TasksUiPlugin.getExternalizationManager().save(true);
- repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaConstants.ECLIPSE_BUGZILLA_URL);
- TasksUiPlugin.getRepositoryManager().addRepository(repository);
- assertEquals(0, TasksUiPlugin.getTaskList().getAllTasks().size());
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- TasksUiPlugin.getTaskList().reset();
- TasksUiPlugin.getExternalizationManager().save(true);
- TasksUiPlugin.getRepositoryManager().removeRepository(repository,
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- }
-
- @SuppressWarnings("null")
- public void testRemindedPersistance() throws Exception {
-
- String repositoryUrl = "https://bugs.eclipse.org/bugs";
-
- String bugNumber = "106939";
-
- ITask task = TasksUi.getRepositoryModel().createTask(repository, bugNumber);
- TaskTask task1 = null;
- if (task instanceof TaskTask) {
- task1 = (TaskTask) task;
- }
- assertNotNull(task1);
-
- TasksUiPlugin.getTaskList().addTask(task1);
-
- task1.setReminded(true);
- TaskTestUtil.saveAndReadTasklist();
-
- TaskList taskList = TasksUiPlugin.getTaskList();
- assertEquals(1, taskList.getAllTasks().size());
- Set<ITask> tasksReturned = taskList.getTasks(repositoryUrl);
- assertNotNull(tasksReturned);
- assertEquals(1, tasksReturned.size());
- for (ITask taskRet : tasksReturned) {
- assertTrue(((AbstractTask) taskRet).isReminded());
- }
- }
-
- @SuppressWarnings("null")
- public void testRepositoryTaskExternalization() throws Exception {
- ITask task = TasksUi.getRepositoryModel().createTask(repository, "1");
- TaskTask repositoryTask = null;
- if (task instanceof TaskTask) {
- repositoryTask = (TaskTask) task;
- }
- assertNotNull(repositoryTask);
- repositoryTask.setTaskKind("kind");
- TasksUiPlugin.getTaskList().addTask(repositoryTask);
- TaskTestUtil.saveAndReadTasklist();
- assertEquals(1, TasksUiPlugin.getTaskList()
- .getUnmatchedContainer(IBugzillaConstants.ECLIPSE_BUGZILLA_URL)
- .getChildren()
- .size());
- ITask readTask = TasksUiPlugin.getTaskList()
- .getUnmatchedContainer(IBugzillaConstants.ECLIPSE_BUGZILLA_URL)
- .getChildren()
- .iterator()
- .next();
-
- assertEquals(repositoryTask.getHandleIdentifier(), readTask.getHandleIdentifier());
- assertEquals(repositoryTask.getSummary(), readTask.getSummary());
- assertEquals(repositoryTask.getTaskKind(), readTask.getTaskKind());
- }
-
- public void testQueryExternalization() throws Exception {
- RepositoryQuery query = (RepositoryQuery) TasksUi.getRepositoryModel().createRepositoryQuery(repository);
- assertEquals("https://bugs.eclipse.org/bugs", query.getRepositoryUrl());
- assertEquals("<never>", query.getLastSynchronizedTimeStamp());
- query.setLastSynchronizedStamp("today");
- TasksUiPlugin.getTaskList().addQuery(query);
-
- TaskTestUtil.saveAndReadTasklist();
- assertEquals(1, TasksUiPlugin.getTaskList().getQueries().size());
- IRepositoryQuery readQuery = TasksUiPlugin.getTaskList().getQueries().iterator().next();
- assertEquals(query.getRepositoryUrl(), readQuery.getRepositoryUrl());
- assertEquals("today", query.getLastSynchronizedTimeStamp());
- assertEquals("https://bugs.eclipse.org/bugs", readQuery.getRepositoryUrl());
- }
-
- public void testDeleteQuery() {
- RepositoryQuery query = new RepositoryQuery(BugzillaCorePlugin.CONNECTOR_KIND, "queryUrl");
- query.setRepositoryUrl("repositoryUrl");
- TasksUiPlugin.getTaskList().addQuery(query);
-
- IRepositoryQuery readQuery = TasksUiPlugin.getTaskList().getQueries().iterator().next();
- assertEquals(query, readQuery);
-
- TasksUiPlugin.getTaskList().deleteQuery(query);
- assertEquals(0, TasksUiPlugin.getTaskList().getQueries().size());
- }
-
- public void testDeleteQueryAfterRename() {
- RepositoryQuery query = new RepositoryQuery(BugzillaCorePlugin.CONNECTOR_KIND, "queryUrl");
- query.setRepositoryUrl("repositoryUrl");
- TasksUiPlugin.getTaskList().addQuery(query);
-
- IRepositoryQuery readQuery = TasksUiPlugin.getTaskList().getQueries().iterator().next();
- assertEquals(query, readQuery);
- query.setSummary("newName");
- TasksUiPlugin.getTaskList().deleteQuery(query);
- assertEquals(0, TasksUiPlugin.getTaskList().getQueries().size());
- }
-
- public void testCreateQueryWithSameName() {
- RepositoryQuery query = new RepositoryQuery(BugzillaCorePlugin.CONNECTOR_KIND, "queryUrl");
- query.setRepositoryUrl("repositoryUrl");
- TasksUiPlugin.getTaskList().addQuery(query);
- assertEquals(1, TasksUiPlugin.getTaskList().getQueries().size());
- IRepositoryQuery readQuery = TasksUiPlugin.getTaskList().getQueries().iterator().next();
- assertEquals(query, readQuery);
-
- try {
- query = new RepositoryQuery(BugzillaCorePlugin.CONNECTOR_KIND, "queryUrl");
- query.setRepositoryUrl("repositoryUrl");
- TasksUiPlugin.getTaskList().addQuery(query);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- if (!e.getMessage().equals("Handle queryUrl already exists in task list")) {
- throw e;
- }
- }
- assertEquals(1, TasksUiPlugin.getTaskList().getQueries().size());
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestConstants.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestConstants.java
new file mode 100644
index 000000000..78720c348
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestConstants.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.bugzilla.tests;
+
+/**
+ * @author Frank Becker
+ */
+public class BugzillaTestConstants {
+
+ /* For now test on 3.0 as earliest bugzilla. Also bugs30 should always be the latest 3.0.x release */
+ public static final String TEST_BUGZILLA_30_URL = getServerUrl("bugs30"); //$NON-NLS-1$
+
+ public static final String TEST_BUGZILLA_218_URL = getServerUrl("bugs218");
+
+ public static final String TEST_BUGZILLA_220_URL = getServerUrl("bugs220");
+
+ public static final String TEST_BUGZILLA_2201_URL = getServerUrl("bugs220");
+
+ public static final String TEST_BUGZILLA_222_URL = getServerUrl("bugs222");
+
+ public static final String TEST_BUGZILLA_303_URL = getServerUrl("bugs30");
+
+ public static final String TEST_BUGZILLA_32_URL = getServerUrl("bugs32");
+
+ public static final String TEST_BUGZILLA_322_URL = getServerUrl("bugs322");
+
+ public static final String TEST_BUGZILLA_323_URL = getServerUrl("bugs323");
+
+ public static final String TEST_BUGZILLA_34_URL = getServerUrl("bugs34"); //$NON-NLS-1$
+
+ public static final String TEST_BUGZILLA_LATEST_URL = TEST_BUGZILLA_34_URL;
+
+ private static final String getServerUrl(String version) {
+ String url = System.getProperty("bugzilla.server.url" + version, null); //$NON-NLS-1$
+ return (url != null) ? url : System.getProperty("bugzilla.server.url", "http://mylyn.eclipse.org/" + version); //$NON-NLS-1$
+ }
+}
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 f1aabebd2..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestPlugin.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-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 641a77fbf..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTestUtil.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-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/IBugzillaTestConstants.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/IBugzillaTestConstants.java
deleted file mode 100644
index aeacc06d6..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/IBugzillaTestConstants.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-/**
- * @author Frank Becker
- */
-public interface IBugzillaTestConstants {
-
- static final String TEST_BUGZILLA_218_URL = "http://mylyn.eclipse.org/bugs218"; //$NON-NLS-1$
-
- static final String TEST_BUGZILLA_220_URL = "http://mylyn.eclipse.org/bugs220"; //$NON-NLS-1$
-
- static final String TEST_BUGZILLA_2201_URL = "http://mylyn.eclipse.org/bugs2201"; //$NON-NLS-1$
-
- static final String TEST_BUGZILLA_222_URL = "http://mylyn.eclipse.org/bugs222"; //$NON-NLS-1$
-
- static final String TEST_BUGZILLA_30_URL = "http://mylyn.eclipse.org/bugs30"; //$NON-NLS-1$
-
- static final String TEST_BUGZILLA_303_URL = "http://mylyn.eclipse.org/bugs303"; //$NON-NLS-1$
-
- static final String TEST_BUGZILLA_31_URL = "http://mylyn.eclipse.org/bugs31"; //$NON-NLS-1$
-
- static final String TEST_BUGZILLA_32_URL = "http://mylyn.eclipse.org/bugs32"; //$NON-NLS-1$
-
- static final String TEST_BUGZILLA_322_URL = "http://mylyn.eclipse.org/bugs322"; //$NON-NLS-1$
-
- static final String TEST_BUGZILLA_323_URL = "http://mylyn.eclipse.org/bugs323"; //$NON-NLS-1$
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java
index 53a4a5da3..8da4bc2cf 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java
@@ -60,7 +60,7 @@ public class RepositoryReportFactoryTest extends TestCase {
String bugid = "1";
String errorMessage = "";
try {
- setRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
+ setRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_222_URL);
repository.setAuthenticationCredentials("invalid", "invalid");
init(bugid);
} catch (CoreException e) {
@@ -75,7 +75,7 @@ public class RepositoryReportFactoryTest extends TestCase {
String bugid = "-1";
String errorMessage = "";
try {
- setRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
+ setRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_222_URL);
// If this isn't called the BugzillaClient will be reused (with old
// credentials) so
// force drop of old client connection.
@@ -134,7 +134,7 @@ public class RepositoryReportFactoryTest extends TestCase {
public void testReadingReport222() throws Exception {
String bugid = "2";
- setRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
+ setRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_222_URL);
TaskData report = init(bugid);
assertNotNull(report);
assertEquals("search-match-test 1", report.getRoot()
@@ -175,7 +175,7 @@ public class RepositoryReportFactoryTest extends TestCase {
public void testReadingReport2201() throws Exception {
String bugid = "1";
- setRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_2201_URL);
+ setRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_2201_URL);
TaskData report = init(bugid);
assertNotNull(report);
@@ -348,7 +348,7 @@ public class RepositoryReportFactoryTest extends TestCase {
public void testReadingReport218() throws Exception {
String bugid = "1";
- setRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_218_URL);
+ setRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_218_URL);
TaskData report = init(bugid);
assertNotNull(report);
assertEquals("1", report.getRoot().getAttribute(BugzillaAttribute.BUG_ID.getKey()).getValue());
@@ -377,7 +377,7 @@ public class RepositoryReportFactoryTest extends TestCase {
}
public void testTimeTracking222() throws Exception {
- setRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
+ setRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_222_URL);
TaskData report = init("11");
assertEquals("7.50", report.getRoot().getAttribute(BugzillaAttribute.ESTIMATED_TIME.getKey()).getValue());
assertEquals("4.00", report.getRoot().getAttribute(BugzillaAttribute.ACTUAL_TIME.getKey()).getValue());
@@ -414,7 +414,7 @@ public class RepositoryReportFactoryTest extends TestCase {
// }
public void testTimeTracking218() throws Exception {
- setRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_218_URL);
+ setRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_218_URL);
TaskData report = init("19");
TaskAttribute root = report.getRoot();
assertEquals("7.50", root.getAttribute(BugzillaAttribute.ESTIMATED_TIME.getKey()).getValue());
@@ -424,7 +424,7 @@ public class RepositoryReportFactoryTest extends TestCase {
public void testMultipleDepensOn() throws Exception {
String bugid = "5";
- setRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_218_URL);
+ setRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_218_URL);
TaskData report = init(bugid);
assertNotNull(report);
TaskAttribute root = report.getRoot();
@@ -435,7 +435,7 @@ public class RepositoryReportFactoryTest extends TestCase {
public void testBugReportAPI() throws Exception {
String bugid = "3";
- setRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
+ setRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_222_URL);
TaskData report = init(bugid);
assertNotNull(report);
assertTrue(report != null);
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 325b4ca7f..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryTaskHandleTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-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.tasks.core.TaskTask;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.tests.TaskTestUtil;
-import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
-
-/**
- * @author Mik Kersten
- */
-public class RepositoryTaskHandleTest extends TestCase {
-
- @Override
- protected void setUp() throws Exception {
- TaskTestUtil.resetTaskList();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TaskTestUtil.resetTaskList();
- }
-
- public void testRepositoryUrlHandles() throws Exception {
- String taskId = "123";
- String repositoryUrl = IBugzillaConstants.ECLIPSE_BUGZILLA_URL;
- TaskRepository repository = new TaskRepository(MockRepositoryConnector.REPOSITORY_KIND, repositoryUrl);
- TasksUiPlugin.getRepositoryManager().addRepository(repository);
-
- ITask bugTask = new TaskTask(BugzillaCorePlugin.CONNECTOR_KIND, repositoryUrl, taskId);
- bugTask.setSummary("Summary");
- assertEquals(repositoryUrl, bugTask.getRepositoryUrl());
-
- TasksUiPlugin.getTaskList().addTask(bugTask);
- TaskTestUtil.saveAndReadTasklist();
-
- ITask readReport = TasksUiPlugin.getTaskList().getTask(repositoryUrl, taskId);
- assertEquals("Summary", readReport.getSummary());
- assertEquals(repositoryUrl, readReport.getRepositoryUrl());
- TasksUiPlugin.getRepositoryManager().removeRepository(repository,
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- }
-}
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 ebed448b2..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskEditorTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Jeff Pound and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jeff Pound - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
-import org.eclipse.mylyn.tasks.core.TaskMapping;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
-import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
-import org.eclipse.mylyn.tasks.core.data.TaskData;
-import org.eclipse.mylyn.tasks.tests.TaskTestUtil;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-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 {
-
- @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());
- TaskTestUtil.resetTaskList();
- TasksUiPlugin.getExternalizationManager().requestSave();
- 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 {
- final TaskMapping taskMappingInit = new TaskMapping() {
- @Override
- public String getSummary() {
- return "The Summary";
- }
-
- @Override
- public String getDescription() {
- return "The Description";
- }
- };
- final TaskMapping taskMappingSelect = new TaskMapping() {
- @Override
- public String getProduct() {
- return "TestProduct";
- }
- };
-
- TaskRepository taskRepository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND,
- IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
- TasksUiPlugin.getRepositoryManager().addRepository(taskRepository);
- final TaskData[] taskData = new TaskData[1];
-
- taskData[0] = TasksUiInternal.createTaskData(taskRepository, taskMappingInit, taskMappingSelect, null);
- TasksUiInternal.createAndOpenNewTask(taskData[0]);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
- assertEquals("New Task", taskEditor.getTitle());
- }
-
- public void testinitializeTaskData() throws Exception {
- final TaskMapping taskMappingInit = new TaskMapping() {
- @Override
- public String getSummary() {
- return "The Summary";
- }
-
- @Override
- public String getDescription() {
- return "The Description";
- }
- };
- final TaskMapping taskMappingSelect = new TaskMapping() {
- @Override
- public String getProduct() {
- return "TestProduct";
- }
- };
-
- TaskRepository taskRepository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND,
- IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
- TasksUiPlugin.getRepositoryManager().addRepository(taskRepository);
-
- AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
- taskRepository.getConnectorKind());
- AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
- TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(taskRepository);
- TaskData taskData = new TaskData(mapper, taskRepository.getConnectorKind(), taskRepository.getRepositoryUrl(),
- "");
- assertTrue(taskDataHandler.initializeTaskData(taskRepository, taskData, null, null));
- assertTrue(taskDataHandler.initializeTaskData(taskRepository, taskData, taskMappingInit, null));
- assertTrue(taskDataHandler.initializeTaskData(taskRepository, taskData, taskMappingSelect, null));
- }
-}
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 b2560f4b9..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/TaskListStandaloneTest.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests;
-
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
-import org.eclipse.mylyn.internal.tasks.core.DateRange;
-import org.eclipse.mylyn.internal.tasks.core.LocalTask;
-import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
-import org.eclipse.mylyn.internal.tasks.core.TaskTask;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.tests.TaskTestUtil;
-
-/**
- * @author Mik Kersten
- * @author Rob Elves
- */
-public class TaskListStandaloneTest extends TestCase {
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- TasksUiPlugin.getTaskList().reset();
- TasksUiPlugin.getExternalizationManager().save(true);
- TasksUiPlugin.getRepositoryManager().clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
- assertEquals("should be empty: " + TasksUiPlugin.getTaskList().getDefaultCategory().getChildren(), 0,
- TasksUiPlugin.getTaskList().getDefaultCategory().getChildren().size());
- }
-
- @Override
- protected void tearDown() throws Exception {
- TasksUiPlugin.getTaskList().reset();
- TasksUiPlugin.getExternalizationManager().save(true);
- super.tearDown();
- }
-
- public void testDueDateExternalization() throws Exception {
- AbstractTask task = new LocalTask("1", "task 1");
- Date dueDate = new Date();
- task.setDueDate(dueDate);
- TasksUiPlugin.getTaskList().addTask(task);
- assertEquals(1, TasksUiPlugin.getTaskList().getAllTasks().size());
-
- TaskTestUtil.saveAndReadTasklist();
-
- assertEquals(1, TasksUiPlugin.getTaskList().getAllTasks().size());
- Collection<ITask> readList = TasksUiPlugin.getTaskList().getDefaultCategory().getChildren();
- ITask readTask = readList.iterator().next();
- assertTrue(readTask.getSummary().equals("task 1"));
- assertTrue(readTask.getDueDate().compareTo(dueDate) == 0);
- }
-
- public void testPastReminder() throws InterruptedException {
- AbstractTask task = new LocalTask("1", "1");
-
- task.setScheduledForDate(new DateRange(Calendar.getInstance()));
- Thread.sleep(2000);
- assertFalse(TasksUiPlugin.getTaskActivityManager().isPastReminder(task));
-
- Calendar cal = Calendar.getInstance();
- cal.add(Calendar.MINUTE, 2);
- task.setScheduledForDate(new DateRange(cal));
- assertFalse(TasksUiPlugin.getTaskActivityManager().isPastReminder(task));
-
- Calendar cal1 = Calendar.getInstance();
- cal1.add(Calendar.MINUTE, -2);
- task.setScheduledForDate(new DateRange(cal1, cal));
- assertFalse(TasksUiPlugin.getTaskActivityManager().isPastReminder(task));
-
- Calendar cal2 = Calendar.getInstance();
- cal2.add(Calendar.MINUTE, -2);
- task.setScheduledForDate(new DateRange(cal2));
- task.setCompletionDate(new Date());
- assertFalse(TasksUiPlugin.getTaskActivityManager().isPastReminder(task));
- }
-
- public void testDates() {
- Date start = Calendar.getInstance().getTime();
- Date creation = new Date();
- AbstractTask task = new LocalTask("1", "task 1");
-
- TasksUiPlugin.getTaskList().addTask(task);
- assertNull(task.getCreationDate());
- task.setCreationDate(start);
- assertEquals(start, task.getCreationDate());
-
- assertNull(task.getCompletionDate());
- task.setCompletionDate(creation);
- assertEquals(creation, task.getCompletionDate());
-
- assertEquals(1, TasksUiPlugin.getTaskList().getRootElements().size());
- TasksUiPlugin.getExternalizationManager().requestSave();
-
- assertNotNull(TasksUiPlugin.getTaskList());
- assertEquals(1, TasksUiPlugin.getTaskList().getDefaultCategory().getChildren().size());
-
- Collection<ITask> readList = TasksUiPlugin.getTaskList().getDefaultCategory().getChildren();
- AbstractTask readTask = (AbstractTask) 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() throws Exception {
- // make some tasks
- // save them
- assertEquals(0, TasksUiPlugin.getTaskList().getAllTasks().size());
- ITask task = new TaskTask(BugzillaCorePlugin.CONNECTOR_KIND, "http://bugs", "1");
- TasksUiPlugin.getTaskList().addTask(task);
-
- // reload tasklist and check that they persist
- TaskTestUtil.saveAndReadTasklist();
- assertEquals(1, TasksUiPlugin.getTaskList().getAllTasks().size());
-
- // removed/disable externalizers
- AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().removeRepositoryConnector(
- BugzillaCorePlugin.CONNECTOR_KIND);
-
- // reload tasklist ensure task didn't load
- TaskTestUtil.saveAndReadTasklist();
- assertEquals(0, TasksUiPlugin.getTaskList().getAllTasks().size());
- // Save the task list (tasks with missing connectors should get
- // persisted)
- TasksUiPlugin.getExternalizationManager().save(true);
-
- // re-enable connector
- TasksUiPlugin.getRepositoryManager().addRepositoryConnector(connector);
-
- // re-load tasklist
- TaskTestUtil.saveAndReadTasklist();
-
- // ensure that task now gets loaded
- assertEquals(1, TasksUiPlugin.getTaskList().getAllTasks().size());
- assertNotNull("1", TasksUiPlugin.getTaskList().getTask("http://bugs", "1"));
- }
-
- // Query retention when connector missing/fails to load
- public void testOrphanedQueries() throws Exception {
- // make a query
- assertEquals(0, TasksUiPlugin.getTaskList().getQueries().size());
- RepositoryQuery query = new RepositoryQuery(BugzillaCorePlugin.CONNECTOR_KIND, "bugzillaQuery");
- TasksUiPlugin.getTaskList().addQuery(query);
- TasksUiPlugin.getExternalizationManager().save(true);
-
- // reload tasklist and check that they persist
- TaskTestUtil.saveAndReadTasklist();
- assertEquals(1, TasksUiPlugin.getTaskList().getQueries().size());
-
- // removed/disable externalizers
- AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().removeRepositoryConnector(
- BugzillaCorePlugin.CONNECTOR_KIND);
-
- // reload tasklist ensure query didn't load
- TaskTestUtil.saveAndReadTasklist();
- assertEquals(0, TasksUiPlugin.getTaskList().getQueries().size());
- // Save the task list (queries with missing connectors should get
- // persisted)
- TasksUiPlugin.getExternalizationManager().requestSave();
-
- // re-enable connector
- TasksUiPlugin.getRepositoryManager().addRepositoryConnector(connector);
-
- // re-load tasklist
- TaskTestUtil.saveAndReadTasklist();
-
- // ensure that query now gets loaded
- assertEquals(1, TasksUiPlugin.getTaskList().getQueries().size());
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/client/BugzillaClientTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/client/BugzillaClientTest.java
new file mode 100644
index 000000000..4e6681b32
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/client/BugzillaClientTest.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.bugzilla.tests.client;
+
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
+import org.eclipse.mylyn.commons.net.AbstractWebLocation;
+import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientFactory;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
+import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
+import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+
+/**
+ * @author Robert Elves
+ */
+public class BugzillaClientTest extends TestCase {
+
+ private BugzillaClient client;
+
+ @Override
+ protected void setUp() throws Exception {
+ client = BugzillaFixture.current().client();
+ }
+
+ public void testRDFProductConfig() throws Exception {
+ RepositoryConfiguration config = client.getRepositoryConfiguration();
+ assertNotNull(config);
+ assertEquals(BugzillaFixture.current().getVersion(), config.getInstallVersion().toString());
+ assertEquals(7, config.getStatusValues().size());
+ assertEquals(9, config.getResolutions().size());
+ assertEquals(6, config.getPlatforms().size());
+ assertEquals(32, config.getOSs().size());
+ assertEquals(5, config.getPriorities().size());
+ assertEquals(7, config.getSeverities().size());
+ assertTrue(config.getProducts().size() > 50);
+ assertEquals(4, config.getOpenStatusValues().size());
+ assertEquals(14, config.getComponents("Mylyn").size());
+ assertEquals(27, config.getKeywords().size());
+ assertEquals(1, config.getComponents("TestProduct").size());
+ assertEquals(1, config.getVersions("TestProduct").size());
+ assertEquals(0, config.getTargetMilestones("TestProduct").size());
+ // assertEquals(10, config.getComponents("Hyades").size());
+ // assertEquals(1, config.getTargetMilestones("TestProduct").size());
+ }
+
+ public void testValidate() throws Exception {
+ TaskRepository repository = BugzillaFixture.current().repository();
+ AbstractWebLocation location = BugzillaFixture.current().location();
+ client = new BugzillaClient(location, repository.getCharacterEncoding(), repository.getProperties(),
+ BugzillaRepositoryConnector.getLanguageSetting(IBugzillaConstants.DEFAULT_LANG));
+ client.validate(new NullProgressMonitor());
+ }
+
+ public void testValidateInvalidProxy() throws Exception {
+ TaskRepository repository = BugzillaFixture.current().repository();
+ AbstractWebLocation location = BugzillaFixture.current().location(PrivilegeLevel.USER,
+ new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 12356)));
+
+ client = BugzillaClientFactory.createClient(repository);
+ client = new BugzillaClient(location, repository.getCharacterEncoding(), repository.getProperties(),
+ BugzillaRepositoryConnector.getLanguageSetting(IBugzillaConstants.DEFAULT_LANG));
+ client.validate(new NullProgressMonitor());
+ }
+
+// public void testCredentialsEncoding() throws IOException, BugzillaException, KeyManagementException,
+// GeneralSecurityException {
+// String poundSignUTF8 = BugzillaClient.addCredentials(IBugzillaTestConstants.TEST_BUGZILLA_222_URL, "UTF-8",
+// "testUser", "\u00A3");
+// assertTrue(poundSignUTF8.endsWith("password=%C2%A3"));
+// String poundSignISO = BugzillaClient.addCredentials(IBugzillaTestConstants.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/client/BugzillaTaskHistoryTest.java
index 623ad9d0a..b57b37ba9 100644
--- 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/client/BugzillaTaskHistoryTest.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2009 Nathan Hapke and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Tasktop Technologies - initial API and implementation
+ * Nathan Hapke - initial API and implementation
+ * Tasktop Technologies - improvements
*******************************************************************************/
-package org.eclipse.mylyn.bugzilla.tests.headless;
+package org.eclipse.mylyn.bugzilla.tests.client;
import java.io.File;
import java.io.FileInputStream;
@@ -19,43 +20,31 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import org.eclipse.mylyn.bugzilla.tests.AbstractBugzillaTest;
-import org.eclipse.mylyn.bugzilla.tests.IBugzillaTestConstants;
-import org.eclipse.mylyn.context.tests.support.TestUtil;
-import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
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.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.TaskRepository;
-
-public class BugzillaTaskHistoryTest extends AbstractBugzillaTest {
- private TaskRepository repository;
-
- private BugzillaRepositoryConnector connector;
+/**
+ * @author Nathan Hapke
+ * @author Steffen Pingel
+ */
+public class BugzillaTaskHistoryTest extends TestCase {
private static final String HISTORY_FILE_NAME = "storedHistory.history";
- private static final String REPORT_ID = "1";
+ private BugzillaClient client;
@Override
public void setUp() throws Exception {
- super.setUp();
- connector = new BugzillaRepositoryConnector();
- repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
-
- Credentials credentials = TestUtil.readCredentials();
- repository.setAuthenticationCredentials(credentials.username, credentials.password);
+ client = BugzillaFixture.current().client();
}
public void testGetBugHistory() throws Exception {
-
- BugzillaClient client = connector.getClientManager().getClient(repository, null);
- assertNotNull(client);
TaskHistory history = client.getHistory("1", null);
assertNotNull(history);
@@ -66,8 +55,6 @@ public class BugzillaTaskHistoryTest extends AbstractBugzillaTest {
}
public void testAssignmentEvent() throws Exception {
- BugzillaClient client = connector.getClientManager().getClient(repository, null);
- assertNotNull(client);
TaskHistory history = client.getHistory("1", null);
assertNotNull(history);
@@ -81,9 +68,6 @@ public class BugzillaTaskHistoryTest extends AbstractBugzillaTest {
}
public void testStatusEvent() throws Exception {
-
- BugzillaClient client = connector.getClientManager().getClient(repository, null);
- assertNotNull(client);
TaskHistory history = client.getHistory("1", null);
assertNotNull(history);
@@ -96,9 +80,7 @@ public class BugzillaTaskHistoryTest extends AbstractBugzillaTest {
}
public void testResolutionEvent() throws Exception {
- BugzillaClient client = connector.getClientManager().getClient(repository, null);
- assertNotNull(client);
- TaskHistory history = client.getHistory(REPORT_ID, null);
+ TaskHistory history = client.getHistory("1", null);
assertNotNull(history);
ResolutionEvent resolutionChange = history.getResolutionEvents().get(0);
@@ -109,23 +91,22 @@ public class BugzillaTaskHistoryTest extends AbstractBugzillaTest {
assertEquals("Resolution", resolutionChange.getWhat());
}
- public void testStoredHistory() throws Exception {
- BugzillaClient client = connector.getClientManager().getClient(repository, null);
- assertNotNull(client);
- TaskHistory history = client.getHistory(REPORT_ID, null);
+ public void testPersistHistory() throws Exception {
+ TaskHistory history = client.getHistory("1", null);
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());
+ try {
+ storeHistory(history);
+
+ history = getStoredHistory();
+
+ assertEquals(1, history.getAssignmentEvents().size());
+ assertEquals(2, history.getStatusEvents().size());
+ assertEquals(1, history.getResolutionEvents().size());
+ assertEquals(12, history.getOtherEvents().size());
+ } finally {
+ // clean up
+ new File(HISTORY_FILE_NAME).delete();
+ }
}
private void storeHistory(TaskHistory history) throws FileNotFoundException, IOException {
@@ -143,4 +124,5 @@ public class BugzillaTaskHistoryTest extends AbstractBugzillaTest {
in.close();
return history;
}
+
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java
new file mode 100644
index 000000000..bcc9018ec
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.bugzilla.tests.core;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
+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;
+
+/**
+ * @author Robert Elves
+ */
+public class BugzillaConfigurationTest extends TestCase {
+
+ public void testRepositoryConfigurationCachePersistance() throws Exception {
+ if (BugzillaCorePlugin.getConfigurationCacheFile() == null) {
+ File file = File.createTempFile("bugzilla", null);
+ file.deleteOnExit();
+ BugzillaCorePlugin.setConfigurationCacheFile(file);
+ }
+
+ 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();
+ assertNotNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
+ assertNotNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration2.getRepositoryUrl()));
+ BugzillaCorePlugin.removeConfiguration(configuration1);
+ BugzillaCorePlugin.removeConfiguration(configuration2);
+ assertNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration1.getRepositoryUrl()));
+ assertNull(BugzillaCorePlugin.getRepositoryConfiguration(configuration2.getRepositoryUrl()));
+ BugzillaCorePlugin.setCacheFileRead(false);
+ 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));
+ }
+
+ // FIXME re-enable?
+// @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()));
+// }
+
+ /**
+ * 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 mylyn.eclipse.org/bugs218
+ */
+ public void testRepositoryConfigurationFromFile() throws Exception {
+ File file = BugzillaFixture.getFile("testdata/configuration/rdfconfig218.txt");
+ BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+
+ if (true) {
+ File tempFile = File.createTempFile("XmlCleaner-", "tmp");
+ tempFile.deleteOnExit();
+ in = XmlCleaner.clean(in, tempFile);
+ if (tempFile != null) {
+ tempFile.delete();
+ }
+
+ }
+
+ 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/headless/BugzillaQueryTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java
index 6997dcafc..fee175807 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2009 Nathan Hapke and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Tasktop Technologies - initial API and implementation
+ * Nathan Hapke - initial API and implementation
+ * Tasktop Technologies - improvements
*******************************************************************************/
-package org.eclipse.mylyn.bugzilla.tests.headless;
+package org.eclipse.mylyn.bugzilla.tests.core;
import java.util.HashSet;
import java.util.Set;
@@ -17,37 +18,25 @@ import java.util.Set;
import junit.framework.TestCase;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.bugzilla.tests.IBugzillaTestConstants;
+import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
-import org.eclipse.mylyn.context.tests.support.TestUtil;
-import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaLanguageSettings;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
/**
- * Example use of headless API (no ui dependencies)
- *
- * @author Rob Elves
* @author Nathan Hapke
+ * @author Rob Elves
*/
-public class BugzillaQueryTest extends TestCase {
+public class BugzillaRepositoryConnectorStandaloneTest extends TestCase {
private TaskRepository repository;
- @SuppressWarnings("unused")
- private AbstractRepositoryConnector connectorOriginal;
-
private BugzillaRepositoryConnector connector;
@SuppressWarnings("unused")
@@ -55,26 +44,12 @@ public class BugzillaQueryTest extends TestCase {
@Override
protected void setUp() throws Exception {
- super.setUp();
-
- connectorOriginal = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
- BugzillaCorePlugin.CONNECTOR_KIND);
-
- BugzillaLanguageSettings language = BugzillaCorePlugin.getDefault().getLanguageSetting(
- IBugzillaConstants.DEFAULT_LANG);
-
+ repository = BugzillaFixture.current().repository();
connector = new BugzillaRepositoryConnector();
- BugzillaRepositoryConnector.addLanguageSetting(language);
+// BugzillaLanguageSettings language = BugzillaCorePlugin.getDefault().getLanguageSetting(
+// IBugzillaConstants.DEFAULT_LANG);
+// BugzillaRepositoryConnector.addLanguageSetting(language);
handler = connector.getTaskDataHandler();
- repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
- Credentials credentials = TestUtil.readCredentials();
- repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials(credentials.username,
- credentials.password), false);
- }
-
- @Override
- protected void tearDown() throws Exception {
-
}
/**
@@ -158,23 +133,6 @@ public class BugzillaQueryTest extends TestCase {
}
}
- // README
- // public void testPostBug() throws Exception {
- // RepositoryTaskData taskData = handler.getTaskData(repository, "1");
- // assertNotNull(taskData);
- // assertEquals("user@mylar.eclipse.org", taskData.getAssignedTo());
- // assertEquals("foo", taskData.getDescription());
- // taskData.setSummary("New Summary");
- // // post this modification back to the repository
- // handler.postTaskData(repository, taskData);
- //
- // // You can use the getAttributeValue to pull up the information on any
- // // part of the bug
- // // assertEquals("P1",
- // //
- // taskData.getAttributeValue(BugzillaReportElement.PRIORITY.getKeyString()));
- // }
-
public void testQueryViaConnector() throws Exception {
String queryUrlString = repository.getRepositoryUrl()
+ "/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=";
@@ -200,37 +158,5 @@ public class BugzillaQueryTest extends TestCase {
"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(IBugzillaTestConstants.TEST_BUGZILLA_222_URL,
-// "UTF-8",
-// "testUser", "\u00A3");
-// assertTrue(poundSignUTF8.endsWith("password=%C2%A3"));
-// String poundSignISO =
-// BugzillaClient.addCredentials(IBugzillaTestConstants.TEST_BUGZILLA_222_URL,
-// "ISO-8859-1", "testUser", "\u00A3");
-// assertFalse(poundSignISO.contains("%C2%A3"));
-// assertTrue(poundSignISO.endsWith("password=%A3"));
-// }
+
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaVersionTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaVersionTest.java
index 50c7ddcef..ee98c3628 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaVersionTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaVersionTest.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies and others.
+ * Copyright (c) 2009 Frank Becker and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Tasktop Technologies - initial API and implementation
+ * Frank Becker - initial API and implementation
*******************************************************************************/
-package org.eclipse.mylyn.bugzilla.tests;
+package org.eclipse.mylyn.bugzilla.tests.core;
import junit.framework.TestCase;
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
new file mode 100644
index 000000000..a7439c03f
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.bugzilla.tests.support;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.mylyn.bugzilla.tests.BugzillaTestConstants;
+import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientManager;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Steffen Pingel
+ */
+public class BugzillaFixture extends TestFixture {
+
+ private static BugzillaFixture current;
+
+ public static BugzillaFixture BUGS_2_18 = new BugzillaFixture(BugzillaTestConstants.TEST_BUGZILLA_218_URL,//
+ "2.18.6", "");
+
+ public static BugzillaFixture BUGS_2_20 = new BugzillaFixture(BugzillaTestConstants.TEST_BUGZILLA_220_URL, //
+ "2.20.7", "");
+
+ public static BugzillaFixture BUGS_2_22 = new BugzillaFixture(BugzillaTestConstants.TEST_BUGZILLA_222_URL, //
+ "2.22.7", "");
+
+ public static BugzillaFixture BUGS_3_0 = new BugzillaFixture(BugzillaTestConstants.TEST_BUGZILLA_30_URL, //
+ "3.0.8", "");
+
+ public static BugzillaFixture BUGS_3_2 = new BugzillaFixture(BugzillaTestConstants.TEST_BUGZILLA_32_URL, //
+ "3.2.4", "");
+
+ public static BugzillaFixture BUGS_3_2_3 = new BugzillaFixture(BugzillaTestConstants.TEST_BUGZILLA_323_URL, //
+ "3.2.3", "");
+
+ public static BugzillaFixture BUGS_3_4 = new BugzillaFixture(BugzillaTestConstants.TEST_BUGZILLA_34_URL, //
+ "3.4.1", "");
+
+ public static BugzillaFixture DEFAULT = BUGS_3_4;
+
+ public static final BugzillaFixture[] ALL = new BugzillaFixture[] { BUGS_2_18, BUGS_2_20, BUGS_2_22, BUGS_3_2,
+ BUGS_3_2_3, BUGS_3_4 };
+
+ private final String version;
+
+ public static void cleanup010() throws Exception {
+ }
+
+ public static BugzillaFixture current(BugzillaFixture fixture) {
+ if (current == null) {
+ current = fixture;
+ }
+ return current;
+ }
+
+ public static BugzillaFixture current() {
+ return current(DEFAULT);
+ }
+
+ public BugzillaFixture(String url, String version, String info) {
+ super(BugzillaCorePlugin.CONNECTOR_KIND, url);
+ this.version = version;
+ setInfo("Bugzilla " + version + ((info.length() > 0) ? "/" + info : ""));
+ }
+
+ @Override
+ public BugzillaFixture activate() {
+ current = this;
+ return this;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public BugzillaClient client() throws CoreException, IOException {
+ return client(getRepositoryUrl(), "", "", "", "", "UTF-8");
+ }
+
+ public BugzillaClient client(String hostUrl, String username, String password, String htAuthUser,
+ String htAuthPass, String encoding) throws CoreException, IOException {
+ TaskRepository taskRepository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, hostUrl);
+
+ AuthenticationCredentials credentials = new AuthenticationCredentials(username, password);
+ taskRepository.setCredentials(AuthenticationType.REPOSITORY, credentials, false);
+
+ AuthenticationCredentials webCredentials = new AuthenticationCredentials(htAuthUser, htAuthPass);
+ taskRepository.setCredentials(AuthenticationType.HTTP, webCredentials, false);
+ taskRepository.setCharacterEncoding(encoding);
+
+ BugzillaClientManager bugzillaClientManager = new BugzillaClientManager();
+ BugzillaClient client = bugzillaClientManager.getClient(taskRepository, null);
+ client.getRepositoryConfiguration(new NullProgressMonitor());
+ return client;
+ }
+
+ public static File getFile(String filename) throws IOException {
+ Bundle bundle = Platform.getBundle("org.eclipse.mylyn.bugzilla.tests");
+ if (bundle != null) {
+ URL localURL = FileLocator.toFileURL(bundle.getEntry(filename));
+ filename = localURL.getFile();
+ } else {
+ URL localURL = BugzillaFixture.class.getResource("");
+ filename = localURL.getFile() + "../../../../../../../" + filename;
+ }
+ return new File(filename);
+ }
+
+}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/TestFixture.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/TestFixture.java
new file mode 100644
index 000000000..adee4db42
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/TestFixture.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.bugzilla.tests.support;
+
+import java.net.Proxy;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.mylyn.commons.net.AbstractWebLocation;
+import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
+import org.eclipse.mylyn.commons.net.IProxyProvider;
+import org.eclipse.mylyn.commons.net.WebLocation;
+import org.eclipse.mylyn.context.tests.support.TestUtil;
+import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
+import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
+import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+
+/**
+ * @author Steffen Pingel
+ */
+public abstract class TestFixture {
+
+ private final String connectorKind;
+
+ private String info;
+
+ protected final String repositoryUrl;
+
+ public TestFixture(String connectorKind, String repositoryUrl) {
+ this.connectorKind = connectorKind;
+ this.repositoryUrl = repositoryUrl;
+ }
+
+ protected abstract TestFixture activate();
+
+ public void add(TestSuite suite, Class<? extends TestCase> clazz) {
+ if (Boolean.parseBoolean(System.getProperty("mylyn.tests.annotate")) && getInfo() != null) {
+ suite.addTest(new TestSuite(clazz, clazz.getName() + " [" + getInfo() + "]"));
+ } else {
+ suite.addTestSuite(clazz);
+ }
+ }
+
+ public TestSuite createSuite() {
+ TestSuite suite = new TestSuite("Testing on " + getInfo());
+ suite.addTest(new TestCase("activiating " + getRepositoryUrl()) {
+ @Override
+ protected void runTest() throws Throwable {
+ activate();
+ }
+ });
+ return suite;
+ }
+
+ public String getConnectorKind() {
+ return connectorKind;
+ }
+
+ public String getInfo() {
+ return info;
+ }
+
+ public String getRepositoryUrl() {
+ return repositoryUrl;
+ }
+
+ public AbstractWebLocation location() throws Exception {
+ return location(PrivilegeLevel.USER);
+ }
+
+ public AbstractWebLocation location(PrivilegeLevel level) throws Exception {
+ return location(level, Proxy.NO_PROXY);
+ }
+
+ public AbstractWebLocation location(PrivilegeLevel level, Proxy proxy) throws Exception {
+ Credentials credentials = TestUtil.readCredentials(level);
+ return location(credentials.username, credentials.password, proxy);
+ }
+
+ public AbstractWebLocation location(String username, String password) throws Exception {
+ return location(username, password, Proxy.NO_PROXY);
+ }
+
+ public AbstractWebLocation location(String username, String password, final Proxy proxy) throws Exception {
+ return new WebLocation(repositoryUrl, username, password, new IProxyProvider() {
+ public Proxy getProxyForHost(String host, String proxyType) {
+ return proxy;
+ }
+ });
+ }
+
+ public TaskRepository repository() {
+ TaskRepository repository = new TaskRepository(connectorKind, repositoryUrl);
+ Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
+ repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials(credentials.username,
+ credentials.password), false);
+ return repository;
+ }
+
+ protected void setInfo(String info) {
+ this.info = info;
+ }
+
+ public TaskRepository singleRepository() {
+ TaskRepositoryManager manager = TasksUiPlugin.getRepositoryManager();
+ manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
+
+ TaskRepository repository = new TaskRepository(connectorKind, repositoryUrl);
+ Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
+ repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials(credentials.username,
+ credentials.password), false);
+ manager.addRepository(repository);
+ return repository;
+ }
+
+}
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/ui/BugzillaRepositorySettingsPageTest.java
index 21e7ab670..1a6ce0e6e 100644
--- 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/ui/BugzillaRepositorySettingsPageTest.java
@@ -9,7 +9,7 @@
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
-package org.eclipse.mylyn.bugzilla.tests;
+package org.eclipse.mylyn.bugzilla.tests.ui;
import java.net.MalformedURLException;
@@ -17,6 +17,7 @@ import junit.framework.TestCase;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.mylyn.bugzilla.tests.BugzillaTestConstants;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.context.tests.support.TestUtil;
@@ -34,7 +35,7 @@ import org.eclipse.ui.PlatformUI;
/**
* @author Rob Elves
*/
-public class RepositoryEditorWizardTest extends TestCase {
+public class BugzillaRepositorySettingsPageTest extends TestCase {
private TaskRepositoryManager manager;
@@ -45,7 +46,7 @@ public class RepositoryEditorWizardTest extends TestCase {
super.setUp();
manager = TasksUiPlugin.getRepositoryManager();
manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
- repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
+ repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaTestConstants.TEST_BUGZILLA_222_URL);
Credentials credentials = TestUtil.readCredentials();
repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials(credentials.username,
credentials.password), false);
@@ -147,11 +148,11 @@ public class RepositoryEditorWizardTest extends TestCase {
BugzillaClient client = createClient(page.getRepositoryUrl(), page.getUserName(), page.getPassword(),
page.getHttpAuthUserId(), page.getHttpAuthPassword(), page.getCharacterEncoding());
client.validate(null);
- page.setUrl(IBugzillaTestConstants.TEST_BUGZILLA_218_URL);
+ page.setUrl(BugzillaTestConstants.TEST_BUGZILLA_218_URL);
wizard.performFinish();
assertEquals(1, manager.getAllRepositories().size());
TaskRepository repositoryTest = manager.getRepository(BugzillaCorePlugin.CONNECTOR_KIND,
- IBugzillaTestConstants.TEST_BUGZILLA_218_URL);
+ BugzillaTestConstants.TEST_BUGZILLA_218_URL);
assertNotNull(repositoryTest);
assertEquals(tempUid, repositoryTest.getUserName());
assertEquals(tempPass, repositoryTest.getPassword());
@@ -170,7 +171,7 @@ public class RepositoryEditorWizardTest extends TestCase {
wizard.performFinish();
assertEquals(1, manager.getAllRepositories().size());
TaskRepository repositoryTest = manager.getRepository(BugzillaCorePlugin.CONNECTOR_KIND,
- IBugzillaTestConstants.TEST_BUGZILLA_222_URL);
+ BugzillaTestConstants.TEST_BUGZILLA_222_URL);
assertNotNull(repositoryTest);
wizard = new EditRepositoryWizard(repositoryTest);
dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaSearchPageTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaSearchPageTest.java
new file mode 100644
index 000000000..eb8d2ea66
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaSearchPageTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 Jeff Pound and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jeff Pound - initial API and implementation
+ * Tasktop Technologies - improvements
+ *******************************************************************************/
+
+package org.eclipse.mylyn.bugzilla.tests.ui;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
+import org.eclipse.mylyn.internal.bugzilla.ui.search.BugzillaSearchPage;
+import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+
+/**
+ * Test the bugzilla search dialog.
+ *
+ * @author Jeff Pound
+ * @author Steffen Pingel
+ */
+public class BugzillaSearchPageTest extends TestCase {
+
+ private TaskRepository repository;
+
+ @Override
+ public void setUp() throws Exception {
+ repository = BugzillaFixture.DEFAULT.singleRepository();
+ }
+
+ /**
+ * Test that the search dialog is initialized properly with the given repository.
+ */
+ public void testInit() throws Exception {
+ BugzillaSearchPage page = new BugzillaSearchPage(repository);
+ page.createControl(WorkbenchUtil.getShell());
+ 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/BugzillaTaskHyperlinkDetectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java
index c8d628c4f..923d65c7d 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskHyperlinkDetectorTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaTaskHyperlinkDetectorTest.java
@@ -9,7 +9,7 @@
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
-package org.eclipse.mylyn.bugzilla.tests;
+package org.eclipse.mylyn.bugzilla.tests.ui;
import junit.framework.TestCase;
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/TaskEditorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/TaskEditorTest.java
new file mode 100644
index 000000000..945d3dd02
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/TaskEditorTest.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 Jeff Pound and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jeff Pound - initial API and implementation
+ * Tasktop Technologies - improvements
+ *******************************************************************************/
+
+package org.eclipse.mylyn.bugzilla.tests.ui;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.tasks.core.TaskMapping;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Jeff Pound
+ * @author Steffen Pingel
+ */
+public class TaskEditorTest extends TestCase {
+
+ private TaskRepository repository;
+
+ @Override
+ protected void setUp() throws Exception {
+ BugzillaFixture.current();
+ repository = BugzillaFixture.DEFAULT.singleRepository();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
+ }
+
+ /**
+ * Tests that a task editor opens when creating new Bugzilla tasks.
+ */
+ public void testOpenNewEditor() throws Exception {
+ final TaskMapping taskMappingInit = new TaskMapping() {
+ @Override
+ public String getSummary() {
+ return "The Summary";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description";
+ }
+ };
+ final TaskMapping taskMappingSelect = new TaskMapping() {
+ @Override
+ public String getProduct() {
+ return "TestProduct";
+ }
+ };
+
+ final TaskData[] taskData = new TaskData[1];
+
+ taskData[0] = TasksUiInternal.createTaskData(repository, taskMappingInit, taskMappingSelect, null);
+ TasksUiInternal.createAndOpenNewTask(taskData[0]);
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
+ assertEquals("New Task", taskEditor.getTitle());
+ }
+
+}

Back to the top