Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2006-10-31 20:33:04 -0500
committerrelves2006-10-31 20:33:04 -0500
commitdc841c630afff6eea9fa48a58143d396d272fead (patch)
tree08ea931884873a5c3cab941da3342efdd2e6e0d7 /org.eclipse.mylyn.bugzilla.tests
parent73c53ca524c7b66c4a719271f75428656ad910d6 (diff)
downloadorg.eclipse.mylyn.tasks-dc841c630afff6eea9fa48a58143d396d272fead.tar.gz
org.eclipse.mylyn.tasks-dc841c630afff6eea9fa48a58143d396d272fead.tar.xz
org.eclipse.mylyn.tasks-dc841c630afff6eea9fa48a58143d396d272fead.zip
NEW - bug 161443: Improve support for sites protected by http authentication
https://bugs.eclipse.org/bugs/show_bug.cgi?id=161443
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests')
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java7
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java38
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java40
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java51
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaSearchDialogTest.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskTest.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/EncodingTest.java11
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java68
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java234
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java108
11 files changed, 252 insertions, 315 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
index 4897c1451..bbd2c2ffc 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
@@ -21,6 +21,7 @@ import junit.framework.TestCase;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.mylar.context.tests.support.MylarTestUtils;
import org.eclipse.mylar.context.tests.support.MylarTestUtils.Credentials;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaException;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportSubmitForm;
@@ -133,12 +134,12 @@ public abstract class AbstractBugzillaTest extends TestCase {
class MockBugzillaReportSubmitForm extends BugzillaReportSubmitForm {
- public MockBugzillaReportSubmitForm(String encoding_utf_8) {
- super(encoding_utf_8);
+ public MockBugzillaReportSubmitForm() {
+ super();
}
@Override
- public String submitReportToRepository() throws BugzillaException, LoginException,
+ public String submitReportToRepository(BugzillaClient client) throws BugzillaException, LoginException,
PossibleBugzillaFailureException {
return "test-submit";
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
index 34a91aeaf..8d92eb681 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java
@@ -20,13 +20,12 @@ import java.net.URL;
import junit.framework.TestCase;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.internal.bugzilla.core.RepositoryConfiguration;
-import org.eclipse.mylar.internal.bugzilla.core.RepositoryConfigurationFactory;
import org.eclipse.mylar.internal.bugzilla.core.SaxConfigurationContentHandler;
import org.eclipse.mylar.internal.bugzilla.core.XmlCleaner;
-import org.eclipse.mylar.tasks.core.TaskRepository;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -45,11 +44,8 @@ public class BugzillaConfigurationTest extends TestCase {
}
public void test222RDFProductConfig() throws Exception {
- RepositoryConfigurationFactory factory = new RepositoryConfigurationFactory();
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_222_URL);
- RepositoryConfiguration config = factory.getConfiguration(repository.getUrl(), null, repository.getUserName(),
- repository.getPassword(), null);
+ BugzillaClient client = new BugzillaClient(new URL(IBugzillaConstants.TEST_BUGZILLA_222_URL), "","","","", "UTF-8");
+ RepositoryConfiguration config = client.getRepositoryConfiguration();
assertNotNull(config);
assertEquals("2.22.1", config.getInstallVersion());
assertEquals(7, config.getStatusValues().size());
@@ -66,11 +62,8 @@ public class BugzillaConfigurationTest extends TestCase {
}
public void test2201RDFProductConfig() throws Exception {
- RepositoryConfigurationFactory factory = new RepositoryConfigurationFactory();
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_2201_URL);
- RepositoryConfiguration config = factory.getConfiguration(repository.getUrl(), null, repository.getUserName(),
- repository.getPassword(), null);
+ BugzillaClient client = new BugzillaClient(new URL(IBugzillaConstants.TEST_BUGZILLA_2201_URL), "","","","", "UTF-8");
+ RepositoryConfiguration config = client.getRepositoryConfiguration();
assertNotNull(config);
assertEquals("2.20.1", config.getInstallVersion());
assertEquals(7, config.getStatusValues().size());
@@ -87,11 +80,8 @@ public class BugzillaConfigurationTest extends TestCase {
}
public void test220RDFProductConfig() throws Exception {
- RepositoryConfigurationFactory factory = new RepositoryConfigurationFactory();
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_220_URL);
- RepositoryConfiguration config = factory.getConfiguration(repository.getUrl(), null, repository.getUserName(),
- repository.getPassword(), null);
+ BugzillaClient client = new BugzillaClient(new URL(IBugzillaConstants.TEST_BUGZILLA_220_URL), "","","","", "UTF-8");
+ RepositoryConfiguration config = client.getRepositoryConfiguration();
assertNotNull(config);
assertEquals("2.20.3", config.getInstallVersion());
assertEquals(7, config.getStatusValues().size());
@@ -108,11 +98,8 @@ public class BugzillaConfigurationTest extends TestCase {
}
public void test218RDFProductConfig() throws Exception {
- RepositoryConfigurationFactory factory = new RepositoryConfigurationFactory();
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_218_URL);
- RepositoryConfiguration config = factory.getConfiguration(repository.getUrl(), null, repository.getUserName(),
- repository.getPassword(), null);
+ BugzillaClient client = new BugzillaClient(new URL(IBugzillaConstants.TEST_BUGZILLA_218_URL), "","","","", "UTF-8");
+ RepositoryConfiguration config = client.getRepositoryConfiguration();
assertNotNull(config);
assertEquals("2.18.6", config.getInstallVersion());
assertEquals(7, config.getStatusValues().size());
@@ -129,11 +116,8 @@ public class BugzillaConfigurationTest extends TestCase {
}
public void testEclipseRDFProductConfig() throws Exception {
- RepositoryConfigurationFactory factory = new RepositoryConfigurationFactory();
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.ECLIPSE_BUGZILLA_URL);
- RepositoryConfiguration config = factory.getConfiguration(repository.getUrl(), null, repository.getUserName(),
- repository.getPassword(), null);
+ BugzillaClient client = new BugzillaClient(new URL(IBugzillaConstants.ECLIPSE_BUGZILLA_URL), "","","","", "UTF-8");
+ RepositoryConfiguration config = client.getRepositoryConfiguration();
assertNotNull(config);
assertEquals("2.20.1", config.getInstallVersion());
assertEquals(7, config.getStatusValues().size());
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
index 00adc24d0..1a136d6b5 100644
--- 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
@@ -15,8 +15,9 @@ import java.util.List;
import junit.framework.TestCase;
+import org.eclipse.mylar.context.tests.support.MylarTestUtils;
+import org.eclipse.mylar.context.tests.support.MylarTestUtils.Credentials;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaServerFacade;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.tasks.core.TaskRepository;
@@ -48,24 +49,24 @@ public class BugzillaProductParserTest extends TestCase {
super(arg0);
}
+ private TaskRepository setRepository(String url) {
+ repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, url);
+ Credentials credentials = MylarTestUtils.readCredentials();
+ repository.setAuthenticationCredentials(credentials.username, credentials.password);
+ return repository;
+ }
+
public void test222Products() throws Exception {
-
- repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL,
- IBugzillaConstants.BugzillaServerVersion.SERVER_220.toString());
-
- List<String> productList = BugzillaServerFacade.getProductList(repository.getUrl(), null, repository.getUserName(), repository.getPassword(), IBugzillaConstants.ENCODING_UTF_8);
+ setRepository(IBugzillaConstants.TEST_BUGZILLA_222_URL);
+ List<String> productList = BugzillaCorePlugin.getDefault().getRepositoryConfiguration(repository, false).getProducts();
Iterator<String> itr = productList.iterator();
assertTrue(itr.hasNext());
assertEquals("Read Only Test Cases", itr.next());
-
}
public void test2201Products() throws Exception {
-
- repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_2201_URL,
- IBugzillaConstants.BugzillaServerVersion.SERVER_220.toString());
-
- List<String> productList = BugzillaServerFacade.getProductList(repository.getUrl(), null, repository.getUserName(), repository.getPassword(), IBugzillaConstants.ENCODING_UTF_8);
+ setRepository(IBugzillaConstants.TEST_BUGZILLA_2201_URL);
+ List<String> productList = BugzillaCorePlugin.getDefault().getRepositoryConfiguration(repository, false).getProducts();
Iterator<String> itr = productList.iterator();
assertTrue(itr.hasNext());
assertEquals("TestProduct", "TestProduct", itr.next());
@@ -73,11 +74,8 @@ public class BugzillaProductParserTest extends TestCase {
}
public void test220Products() throws Exception {
-
- repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_220_URL,
- IBugzillaConstants.BugzillaServerVersion.SERVER_220.toString());
-
- List<String> productList = BugzillaServerFacade.getProductList(repository.getUrl(), null, repository.getUserName(), repository.getPassword(), IBugzillaConstants.ENCODING_UTF_8);
+ setRepository(IBugzillaConstants.TEST_BUGZILLA_220_URL);
+ List<String> productList = BugzillaCorePlugin.getDefault().getRepositoryConfiguration(repository, false).getProducts();
assertEquals(2, productList.size());
assertTrue(productList.contains("TestProduct"));
assertTrue(productList.contains("Widget"));
@@ -85,14 +83,10 @@ public class BugzillaProductParserTest extends TestCase {
}
public void test218Products() throws Exception {
-
- repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_218_URL,
- IBugzillaConstants.BugzillaServerVersion.SERVER_218.toString());
-
- List<String> productList = BugzillaServerFacade.getProductList(repository.getUrl(), null, repository.getUserName(), repository.getPassword(), IBugzillaConstants.ENCODING_UTF_8);
+ setRepository(IBugzillaConstants.TEST_BUGZILLA_218_URL);
+ List<String> productList = BugzillaCorePlugin.getDefault().getRepositoryConfiguration(repository, false).getProducts();
assertEquals(1, productList.size());
assertTrue(productList.contains("TestProduct"));
-
}
// No longer supporting 216
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 6a94ddbbc..24567b208 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
@@ -15,7 +15,6 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.net.InetAddress;
-import java.net.Proxy;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Date;
@@ -29,7 +28,7 @@ import org.apache.commons.httpclient.params.HttpConnectionParams;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylar.context.core.ContextCorePlugin;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaAttachmentHandler;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaException;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaQueryHit;
@@ -59,7 +58,7 @@ import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
*/
public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
- private BugzillaAttachmentHandler attachmentHandler = new BugzillaAttachmentHandler();
+// private BugzillaAttachmentHandler attachmentHandler = new BugzillaAttachmentHandler();
public void testCreateTaskFromExistingId() throws Exception {
init222();
@@ -115,9 +114,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
}
// test anonymous update of configuration
- RepositoryConfiguration config = BugzillaCorePlugin.getRepositoryConfiguration(true, repository.getUrl(),
- TasksUiPlugin.getDefault().getProxySettings(), repository.getUserName(), repository.getPassword(),
- repository.getCharacterEncoding());
+ RepositoryConfiguration config = BugzillaCorePlugin.getDefault().getRepositoryConfiguration(repository, false);
assertNotNull(config);
assertTrue(config.getComponents().size() > 0);
}
@@ -168,7 +165,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
assertEquals(RepositoryTaskSyncState.OUTGOING, task.getSyncState());
// Submit changes
- MockBugzillaReportSubmitForm form = new MockBugzillaReportSubmitForm(IBugzillaConstants.ENCODING_UTF_8);
+ MockBugzillaReportSubmitForm form = new MockBugzillaReportSubmitForm();
form.setTaskData(task.getTaskData());
new BugSubmissionHandler(connector).submitBugReport(form, null, true, true);
// submit casuses a synch which should result in
@@ -302,10 +299,20 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
attachment.setReport(task.getTaskData());
attachment.setComment("Automated JUnit attachment test"); // optional
+
+
/* Test attempt to upload a non-existent file */
attachment.setFilePath("/this/is/not/a/real-file");
- assertFalse(attachmentHandler.uploadAttachment(attachment, repository.getUserName(), repository.getPassword(),
- Proxy.NO_PROXY));
+ //IAttachmentHandler attachmentHandler = connector.getAttachmentHandler();
+ BugzillaClient client = connector.getClientManager().getClient(repository);
+ try {
+ client.uploadAttachment(attachment.getReport().getId(), attachment.getComment(), attachment.getDescription(), new File(attachment.getFilePath()), attachment.getContentType(), attachment.isPatch());
+ fail();
+ } catch (Exception e) {
+ }
+// attachmentHandler.uploadAttachment(repository, task, comment, description, file, contentType, isPatch, proxySettings)
+// assertFalse(attachmentHandler.uploadAttachment(attachment, repository.getUserName(), repository.getPassword(),
+// Proxy.NO_PROXY));
assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSyncState());
task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber, null);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
@@ -316,8 +323,13 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
File attachFile = new File(fileName);
attachment.setFilePath(attachFile.getAbsolutePath());
BufferedWriter write = new BufferedWriter(new FileWriter(attachFile));
- assertFalse(attachmentHandler.uploadAttachment(attachment, repository.getUserName(), repository.getPassword(),
- Proxy.NO_PROXY));
+// assertFalse(attachmentHandler.uploadAttachment(attachment, repository.getUserName(), repository.getPassword(),
+// Proxy.NO_PROXY));
+ try {
+ client.uploadAttachment(attachment.getReport().getId(), attachment.getComment(), attachment.getDescription(), new File(attachment.getFilePath()), attachment.getContentType(), attachment.isPatch());
+ fail();
+ } catch (Exception e) {
+ }
task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber, null);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
@@ -327,8 +339,13 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
write.write("test file");
write.close();
attachment.setFilePath(attachFile.getAbsolutePath());
- assertTrue(attachmentHandler.uploadAttachment(attachment, repository.getUserName(), repository.getPassword(),
- Proxy.NO_PROXY));
+// assertTrue(attachmentHandler.uploadAttachment(attachment, repository.getUserName(), repository.getPassword(),
+// Proxy.NO_PROXY));
+ try {
+ client.uploadAttachment(attachment.getReport().getId(), attachment.getComment(), attachment.getDescription(), new File(attachment.getFilePath()), attachment.getContentType(), attachment.isPatch());
+ } catch (Exception e) {
+ fail();
+ }
task = (BugzillaTask) connector.createTaskFromExistingKey(repository, taskNumber, null);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertEquals(numAttached + 1, task.getTaskData().getAttachments().size());
@@ -384,9 +401,9 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
BugzillaReportSubmitForm bugzillaReportSubmitForm;
bugzillaReportSubmitForm = makeExistingBugPost(task4.getTaskData());
- bugzillaReportSubmitForm.submitReportToRepository();
+ bugzillaReportSubmitForm.submitReportToRepository(connector.getClientManager().getClient(repository));
bugzillaReportSubmitForm = makeExistingBugPost(task5.getTaskData());
- bugzillaReportSubmitForm.submitReportToRepository();
+ bugzillaReportSubmitForm.submitReportToRepository(connector.getClientManager().getClient(repository));
changedTasks = connector.getOfflineTaskHandler().getChangedSinceLastSync(repository, tasks, null);
assertEquals("Changed reports expected ", 2, changedTasks.size());
@@ -445,7 +462,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
BugzillaReportSubmitForm bugzillaReportSubmitForm;
bugzillaReportSubmitForm = makeExistingBugPost(recentTaskData);
- bugzillaReportSubmitForm.submitReportToRepository();
+ bugzillaReportSubmitForm.submitReportToRepository(connector.getClientManager().getClient(repository));
TasksUiPlugin.getSynchronizationManager().synchronizeChanged(connector, repository);
assertEquals(RepositoryTaskSyncState.INCOMING, task7.getSyncState());
}
@@ -528,7 +545,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
task.getTaskData().setAttributeValue(BugzillaReportElement.ADD_COMMENT.getKeyString(),
"New Estimate: " + estimatedTime + "\nNew Remaining: " + remainingTime + "\nAdd: " + addTime);
bugzillaReportSubmitForm = makeExistingBugPost(task.getTaskData());
- bugzillaReportSubmitForm.submitReportToRepository();
+ bugzillaReportSubmitForm.submitReportToRepository(connector.getClientManager().getClient(repository));
}
// assertEquals("Changed reports expected ", 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
index d6e7825ef..1589263fe 100644
--- 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
@@ -67,6 +67,6 @@ public class BugzillaSearchDialogTest extends TestCase {
* not retrieved properly, throw an exception if the page is not
* initialized properly, or pass otherwise.
*/
- assertFalse(page.getProductCount() == 0);
+ assertFalse(page.getProductCount() == 0);
}
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskTest.java
index a7b95ea9c..45e8f104f 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskTest.java
@@ -19,12 +19,14 @@ import org.eclipse.mylar.internal.bugzilla.core.BugzillaAttributeFactory;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaOfflineTaskHandler;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportElement;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaTask;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute;
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
import org.eclipse.mylar.tasks.core.TaskComment;
import org.eclipse.mylar.tasks.core.TaskList;
+import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
/**
* @author Mik Kersten
@@ -38,7 +40,7 @@ public class BugzillaTaskTest extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- offlineHandler = new BugzillaOfflineTaskHandler(new TaskList());
+ offlineHandler = new BugzillaOfflineTaskHandler((BugzillaRepositoryConnector)TasksUiPlugin.getRepositoryManager().getRepositoryConnector(BugzillaCorePlugin.REPOSITORY_KIND), new TaskList());
}
@Override
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/EncodingTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/EncodingTest.java
index 4101fc7af..4f673422e 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/EncodingTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/EncodingTest.java
@@ -17,7 +17,7 @@ import java.text.ParseException;
import javax.security.auth.login.LoginException;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaServerFacade;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaTask;
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
@@ -28,17 +28,17 @@ public class EncodingTest extends AbstractBugzillaTest {
public void testEncodingSetting() throws LoginException, IOException, ParseException {
- String charset = BugzillaServerFacade.getCharsetFromString("text/html; charset=UTF-8");
+ String charset = BugzillaClient.getCharsetFromString("text/html; charset=UTF-8");
assertEquals("UTF-8", charset);
- charset = BugzillaServerFacade.getCharsetFromString("text/html");
+ charset = BugzillaClient.getCharsetFromString("text/html");
assertEquals(null, charset);
- charset = BugzillaServerFacade
+ charset = BugzillaClient
.getCharsetFromString("<<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-2\">>");
assertEquals("iso-8859-2", charset);
- charset = BugzillaServerFacade
+ charset = BugzillaClient
.getCharsetFromString("<<meta http-equiv=\"Content-Type\" content=\"text/html\">>");
assertEquals(null, charset);
}
@@ -56,6 +56,7 @@ public class EncodingTest extends AbstractBugzillaTest {
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertTrue(task.getDescription().equals("\u05D0"));
taskList.deleteTask(task);
+ connector.getClientManager().repositoryRemoved(repository);
repository.setCharacterEncoding("ISO-8859-1");
task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "57", null);
assertNotNull(task);
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java
index 3495b7b79..45a137c46 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java
@@ -16,7 +16,7 @@ import junit.framework.TestCase;
import org.eclipse.core.runtime.Platform;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportElement;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaServerFacade;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport;
import org.eclipse.mylar.internal.bugzilla.ui.wizard.BugzillaProductPage;
@@ -34,7 +34,7 @@ public class NewBugWizardTest extends TestCase {
NewBugzillaReport newReport = new NewBugzillaReport(IBugzillaConstants.TEST_BUGZILLA_220_URL, "1");
TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
IBugzillaConstants.TEST_BUGZILLA_220_URL);
- BugzillaServerFacade.setupNewBugAttributes(repository.getUrl(), null, repository.getUserName(), repository.getPassword(), newReport, null);
+ BugzillaRepositoryConnector.setupNewBugAttributes(repository, newReport);
BugzillaProductPage page = new BugzillaProductPage(PlatformUI.getWorkbench(), null, repository);
page.setPlatformOptions(newReport);
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java
index 929f94594..56b18dc9f 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/RepositoryEditorWizardTest.java
@@ -20,8 +20,9 @@ import junit.framework.TestCase;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.mylar.context.tests.support.MylarTestUtils;
import org.eclipse.mylar.context.tests.support.MylarTestUtils.Credentials;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaClientFactory;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaServerFacade;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.internal.bugzilla.ui.tasklist.BugzillaRepositorySettingsPage;
import org.eclipse.mylar.internal.tasks.ui.wizards.EditRepositoryWizard;
@@ -58,12 +59,15 @@ public class RepositoryEditorWizardTest extends TestCase {
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
dialog.create();
BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- BugzillaServerFacade.validateCredentials(null, page.getServerUrl(), page.getCharacterEncoding(), page
- .getUserName(), page.getPassword());
+ // BugzillaClient client =
+ // BugzillaClientFactory.createClient(page.getServerUrl(),
+ // page.getUserName(), page.getPassword(), page.getHttpAuthUserId(),
+ // page.getHttpAuthPassword(), page.getCharacterEncoding());
page.setPassword("bogus");
try {
- BugzillaServerFacade.validateCredentials(null, page.getServerUrl(), page.getCharacterEncoding(), page
- .getUserName(), page.getPassword());
+ BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(), page
+ .getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(), page.getCharacterEncoding());
+ client.validate();
} catch (LoginException e) {
return;
}
@@ -75,12 +79,11 @@ public class RepositoryEditorWizardTest extends TestCase {
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
dialog.create();
BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- BugzillaServerFacade.validateCredentials(null, page.getServerUrl(), page.getCharacterEncoding(), page
- .getUserName(), page.getPassword());
page.setUserId("bogus");
try {
- BugzillaServerFacade.validateCredentials(null, page.getServerUrl(), page.getCharacterEncoding(), page
- .getUserName(), page.getPassword());
+ BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(), page
+ .getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(), page.getCharacterEncoding());
+ client.validate();
} catch (LoginException e) {
return;
}
@@ -92,18 +95,30 @@ public class RepositoryEditorWizardTest extends TestCase {
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
dialog.create();
BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- BugzillaServerFacade.validateCredentials(null, page.getServerUrl(), page.getCharacterEncoding(), page
- .getUserName(), page.getPassword());
page.setUrl("http://invalid");
try {
- BugzillaServerFacade.validateCredentials(null, page.getServerUrl(), page.getCharacterEncoding(), page
- .getUserName(), page.getPassword());
+ BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(), page
+ .getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(), page.getCharacterEncoding());
+ client.validate();
} catch (UnknownHostException e) {
return;
}
fail("UnknownHostException didn't occur!");
}
+ // TODO: Test locking up?
+// public void testAutoVersion() throws Exception {
+// repository.setVersion(BugzillaRepositorySettingsPage.LABEL_AUTOMATIC_VERSION);
+// EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
+// WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
+// dialog.create();
+// BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
+// page.setTesting(true);
+// assertEquals(BugzillaRepositorySettingsPage.LABEL_AUTOMATIC_VERSION, page.getVersion());
+// page.validateSettings();
+// assertEquals("2.22", page.getVersion());
+// }
+
public void testPersistChangeOfUrl() throws Exception {
assertEquals(1, manager.getAllRepositories().size());
String tempUid = repository.getUserName();
@@ -112,8 +127,9 @@ public class RepositoryEditorWizardTest extends TestCase {
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
dialog.create();
BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- BugzillaServerFacade.validateCredentials(null, page.getServerUrl(), page.getCharacterEncoding(), page
- .getUserName(), page.getPassword());
+ BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(), page
+ .getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(), page.getCharacterEncoding());
+ client.validate();
page.setUrl(IBugzillaConstants.TEST_BUGZILLA_218_URL);
wizard.performFinish();
assertEquals(1, manager.getAllRepositories().size());
@@ -130,8 +146,9 @@ public class RepositoryEditorWizardTest extends TestCase {
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
dialog.create();
BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- BugzillaServerFacade.validateCredentials(null, page.getServerUrl(), page.getCharacterEncoding(), page
- .getUserName(), page.getPassword());
+ BugzillaClient client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(), page
+ .getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(), page.getCharacterEncoding());
+ client.validate();
page.setUserId("bogus");
wizard.performFinish();
assertEquals(1, manager.getAllRepositories().size());
@@ -143,24 +160,13 @@ public class RepositoryEditorWizardTest extends TestCase {
dialog.create();
page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
try {
- BugzillaServerFacade.validateCredentials(null, page.getServerUrl(), page.getCharacterEncoding(), page
- .getUserName(), page.getPassword());
+ client = BugzillaClientFactory.createClient(page.getServerUrl(), page.getUserName(), page.getPassword(),
+ page.getHttpAuthUserId(), page.getHttpAuthPassword(), page.getCharacterEncoding());
+ client.validate();
} catch (LoginException e) {
return;
}
fail("LoginException didn't occur!");
}
- public void testAutoVersion() throws Exception {
- repository.setVersion(BugzillaRepositorySettingsPage.LABEL_AUTOMATIC_VERSION);
- EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
- WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
- dialog.create();
- BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage();
- page.setTesting(true);
- assertEquals(BugzillaRepositorySettingsPage.LABEL_AUTOMATIC_VERSION, page.getVersion());
- page.validateSettings();
- assertEquals("2.22", page.getVersion());
- }
-
}
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 94b89888c..8ef30d981 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
@@ -11,25 +11,24 @@
package org.eclipse.mylar.bugzilla.tests;
-import java.io.IOException;
-
-import javax.security.auth.login.LoginException;
+import java.net.Proxy;
import junit.framework.TestCase;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.mylar.context.tests.support.MylarTestUtils;
import org.eclipse.mylar.context.tests.support.MylarTestUtils.Credentials;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaAttributeFactory;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaException;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportElement;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportSubmitForm;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaServerFacade;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylar.internal.bugzilla.core.RepositoryReportFactory;
+import org.eclipse.mylar.tasks.core.IOfflineTaskHandler;
import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute;
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
import org.eclipse.mylar.tasks.core.TaskRepository;
+import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
/**
* @author Rob Elves
@@ -37,119 +36,107 @@ import org.eclipse.mylar.tasks.core.TaskRepository;
*/
public class RepositoryReportFactoryTest extends TestCase {
- RepositoryReportFactory factory = new RepositoryReportFactory();
-
BugzillaAttributeFactory attributeFactory = new BugzillaAttributeFactory();
- private RepositoryTaskData init(String URL, int bugid) throws Exception {
- TaskRepository repository = getRepository(BugzillaCorePlugin.REPOSITORY_KIND, URL);
+ TaskRepository repository;
- RepositoryTaskData report = new RepositoryTaskData(attributeFactory, BugzillaCorePlugin.REPOSITORY_KIND,
- repository.getUrl(), "" + bugid);
- BugzillaServerFacade.setupExistingBugAttributes(repository.getUrl(), report);
- factory.populateReport(report, repository.getUrl(), null, repository.getUserName(), repository.getPassword(),
- IBugzillaConstants.ENCODING_UTF_8);
+ BugzillaRepositoryConnector connector;
- return report;
+ private RepositoryTaskData init(String taskId) throws CoreException {
+ IOfflineTaskHandler handler = connector.getOfflineTaskHandler();
+ RepositoryTaskData taskData = handler.downloadTaskData(repository, taskId, Proxy.NO_PROXY);
+ return taskData;
}
- private TaskRepository getRepository(String kind, String url) {
- TaskRepository repository = new TaskRepository(kind, url);
+ private TaskRepository setRepository(String kind, String url) {
+ connector = (BugzillaRepositoryConnector) TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
+ BugzillaCorePlugin.REPOSITORY_KIND);
+ repository = new TaskRepository(kind, url);
Credentials credentials = MylarTestUtils.readCredentials();
repository.setAuthenticationCredentials(credentials.username, credentials.password);
return repository;
}
- public void testBugNotFound222() throws Exception {
- String bugid = "-1";
- String errorMessage = "";
- TaskRepository repository = getRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_222_URL);
- try {
- RepositoryTaskData report = new RepositoryTaskData(attributeFactory, repository.getKind(), repository
- .getUrl(), bugid);
- factory.populateReport(report, repository.getUrl(), null, repository.getUserName(), repository
- .getPassword(), null);
- } catch (LoginException e) {
- //
- } catch (BugzillaException e) {
- errorMessage = e.getMessage();
- }
- assertEquals(IBugzillaConstants.ERROR_MSG_INVALID_BUG_ID, errorMessage);
- }
-
public void testInvalidCredentials222() throws Exception {
String bugid = "1";
String errorMessage = "";
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_222_URL);
- repository.setAuthenticationCredentials("invalid", "invalid");
try {
- RepositoryTaskData report = new RepositoryTaskData(attributeFactory, BugzillaCorePlugin.REPOSITORY_KIND,
- repository.getUrl(), bugid);
- factory.populateReport(report, repository.getUrl(), null, repository.getUserName(), repository
- .getPassword(), null);
- } catch (LoginException e) {
- errorMessage = e.getMessage();
- } catch (IOException e) {
- errorMessage = e.getMessage();
+ setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
+ repository.setAuthenticationCredentials("invalid", "invalid");
+ init(bugid);
+ } catch (CoreException e) {
+ errorMessage = e.getStatus().getException().getMessage();
}
- assertEquals(IBugzillaConstants.ERROR_INVALID_USERNAME_OR_PASSWORD, errorMessage);
+ assertEquals("Invalid credentials.", errorMessage);
repository.flushAuthenticationCredentials();
}
- public void testReadingReport() throws Exception {
- String bugid = "2";
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_222_URL);
-
- RepositoryTaskData report = new RepositoryTaskData(attributeFactory, BugzillaCorePlugin.REPOSITORY_KIND,
- repository.getUrl(), bugid);
- BugzillaServerFacade.setupExistingBugAttributes(repository.getUrl(), report);
- factory.populateReport(report, repository.getUrl(), null, repository.getUserName(), repository.getPassword(),
- null);
+ public void testBugNotFound222() {
- assertNotNull(report);
- assertEquals("search-match-test 1", report.getAttribute(BugzillaReportElement.SHORT_DESC.getKeyString())
- .getValue());
- assertEquals("TestProduct", report.getAttribute(BugzillaReportElement.PRODUCT.getKeyString()).getValue());
- assertEquals("PC", report.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
- assertEquals("Windows", report.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
- // first comment (#0) is the description so this value is always 1
- // greater
- // than what is shown on the report ui
- assertEquals(3, report.getComments().size());
- assertEquals("search-match-test 1", report.getComments().get(0).getAttribute(
- BugzillaReportElement.THETEXT.getKeyString()).getValue());
- // assertEquals(15, report.getAttachments().size());
- // assertEquals("1",
- // report.getAttachments().get(0).getAttribute(BugzillaReportElement.ATTACHID).getValue());
- // assertEquals("2006-03-10 14:11",
- // report.getAttachments().get(0).getAttribute(BugzillaReportElement.DATE)
- // .getValue());
- // assertEquals("Testing upload",
- // report.getAttachments().get(0).getAttribute(BugzillaReportElement.DESC)
- // .getValue());
- // assertEquals("patch130217.txt",
- // report.getAttachments().get(0).getAttribute(BugzillaReportElement.FILENAME)
- // .getValue());
- // assertEquals("text/plain",
- // report.getAttachments().get(0).getAttribute(BugzillaReportElement.TYPE).getValue());
+ String bugid = "-1";
+ String errorMessage = "";
+ try {
+ setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
+ // If this isn't called the BugzillaClient will be reused (with old
+ // credentials) so
+ // force drop of old client connection.
+ // Note that this is usually called by notification
+ connector.getClientManager().repositoryAdded(repository);
+ init(bugid);
+ } catch (CoreException e) {
+ errorMessage = e.getStatus().getException().getMessage();
+ }
+ assertEquals(IBugzillaConstants.ERROR_MSG_INVALID_BUG_ID, errorMessage);
}
+ // public void testReadingReport() throws Exception {
+ // String bugid = "2";
+ // setRepository(BugzillaCorePlugin.REPOSITORY_KIND,
+ // IBugzillaConstants.TEST_BUGZILLA_222_URL);
+ // RepositoryTaskData report = init(bugid);
+ //
+ // assertNotNull(report);
+ // assertEquals("search-match-test 1",
+ // report.getAttribute(BugzillaReportElement.SHORT_DESC.getKeyString())
+ // .getValue());
+ // assertEquals("TestProduct",
+ // report.getAttribute(BugzillaReportElement.PRODUCT.getKeyString()).getValue());
+ // assertEquals("PC",
+ // report.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
+ // assertEquals("Windows",
+ // report.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
+ // // first comment (#0) is the description so this value is always 1
+ // // greater
+ // // than what is shown on the report ui
+ // assertEquals(3, report.getComments().size());
+ // assertEquals("search-match-test 1",
+ // report.getComments().get(0).getAttribute(
+ // BugzillaReportElement.THETEXT.getKeyString()).getValue());
+ // // assertEquals(15, report.getAttachments().size());
+ // // assertEquals("1",
+ // //
+ // report.getAttachments().get(0).getAttribute(BugzillaReportElement.ATTACHID).getValue());
+ // // assertEquals("2006-03-10 14:11",
+ // //
+ // report.getAttachments().get(0).getAttribute(BugzillaReportElement.DATE)
+ // // .getValue());
+ // // assertEquals("Testing upload",
+ // //
+ // report.getAttachments().get(0).getAttribute(BugzillaReportElement.DESC)
+ // // .getValue());
+ // // assertEquals("patch130217.txt",
+ // //
+ // report.getAttachments().get(0).getAttribute(BugzillaReportElement.FILENAME)
+ // // .getValue());
+ // // assertEquals("text/plain",
+ // //
+ // report.getAttachments().get(0).getAttribute(BugzillaReportElement.TYPE).getValue());
+ // }
+
public void testReadingReport222() throws Exception {
- int bugid = 2;
- // TaskRepository repository = new
- // TaskRepository(BugzillaPlugin.REPOSITORY_KIND,
- // IBugzillaConstants.TEST_BUGZILLA_222_URL);
- //
- // RepositoryTaskData report = new RepositoryTaskData(attributeFactory,
- // BugzillaPlugin.REPOSITORY_KIND, repository.getUrl(), bugid);
- // BugzillaRepositoryUtil.setupExistingBugAttributes(repository.getUrl(),
- // report);
- // factory.populateReport(report, repository.getUrl(), null,
- // repository.getUserName(), repository.getPassword(), null);
- RepositoryTaskData report = init(IBugzillaConstants.TEST_BUGZILLA_222_URL, bugid);
+ String bugid = "2";
+ setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
+ RepositoryTaskData report = init(bugid);
assertNotNull(report);
assertEquals("search-match-test 1", report.getAttribute(BugzillaReportElement.SHORT_DESC.getKeyString())
@@ -158,7 +145,7 @@ public class RepositoryReportFactoryTest extends TestCase {
assertEquals("search-match-test 1", report.getDescription());
assertEquals("TestProduct", report.getAttribute(BugzillaReportElement.PRODUCT.getKeyString()).getValue());
assertEquals("TestProduct", report.getProduct());
- assertEquals("TestComponent", report.getAttribute(BugzillaReportElement.COMPONENT.getKeyString()).getValue());
+ assertEquals("TestComponent", report.getAttribute(BugzillaReportElement.COMPONENT.getKeyString()).getValue());
assertEquals("PC", report.getAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString()).getValue());
assertEquals("Windows", report.getAttribute(BugzillaReportElement.OP_SYS.getKeyString()).getValue());
assertEquals("other", report.getAttribute(BugzillaReportElement.VERSION.getKeyString()).getValue());
@@ -173,7 +160,7 @@ public class RepositoryReportFactoryTest extends TestCase {
assertEquals("---", report.getAttribute(BugzillaReportElement.TARGET_MILESTONE.getKeyString()).getValue());
assertEquals("relves@cs.ubc.ca", report.getAttribute(BugzillaReportElement.REPORTER.getKeyString()).getValue());
assertEquals("nhapke@cs.ubc.ca", report.getAttribute(BugzillaReportElement.ASSIGNED_TO.getKeyString())
- .getValue());
+ .getValue());
assertEquals(3, report.getComments().size());
assertEquals("relves@cs.ubc.ca", report.getComments().get(0).getAttribute(
BugzillaReportElement.WHO.getKeyString()).getValue());
@@ -186,14 +173,8 @@ public class RepositoryReportFactoryTest extends TestCase {
public void testReadingReport2201() throws Exception {
String bugid = "1";
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_2201_URL);
-
- RepositoryTaskData report = new RepositoryTaskData(attributeFactory, BugzillaCorePlugin.REPOSITORY_KIND,
- repository.getUrl(), bugid);
- BugzillaServerFacade.setupExistingBugAttributes(repository.getUrl(), report);
- factory.populateReport(report, repository.getUrl(), null, repository.getUserName(), repository.getPassword(),
- null);
+ setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_2201_URL);
+ RepositoryTaskData report = init(bugid);
assertNotNull(report);
assertEquals("1", report.getAttribute(BugzillaReportElement.BUG_ID.getKeyString()).getValue());
@@ -370,15 +351,8 @@ public class RepositoryReportFactoryTest extends TestCase {
public void testReadingReport218() throws Exception {
String bugid = "1";
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_218_URL);
-
- RepositoryTaskData report = new RepositoryTaskData(attributeFactory, BugzillaCorePlugin.REPOSITORY_KIND,
- repository.getUrl(), bugid);
- BugzillaServerFacade.setupExistingBugAttributes(repository.getUrl(), report);
- factory.populateReport(report, repository.getUrl(), null, repository.getUserName(), repository.getPassword(),
- null);
-
+ setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_218_URL);
+ RepositoryTaskData report = init(bugid);
assertNotNull(report);
assertEquals("1", report.getAttribute(BugzillaReportElement.BUG_ID.getKeyString()).getValue());
assertEquals("search-match-test 1", report.getAttribute(BugzillaReportElement.SHORT_DESC.getKeyString())
@@ -410,8 +384,8 @@ public class RepositoryReportFactoryTest extends TestCase {
}
public void testTimeTracking222() throws Exception {
- RepositoryTaskData report = init(IBugzillaConstants.TEST_BUGZILLA_222_URL, 11);
-
+ setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
+ RepositoryTaskData report = init("11");
assertEquals("7.50", report.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()).getValue());
assertEquals("4.00", report.getAttribute(BugzillaReportElement.ACTUAL_TIME.getKeyString()).getValue());
assertEquals("3.00", report.getAttribute(BugzillaReportElement.REMAINING_TIME.getKeyString()).getValue());
@@ -447,8 +421,8 @@ public class RepositoryReportFactoryTest extends TestCase {
// }
public void testTimeTracking218() throws Exception {
- RepositoryTaskData report = init(IBugzillaConstants.TEST_BUGZILLA_218_URL, 19);
-
+ setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_218_URL);
+ RepositoryTaskData report = init("19");
assertEquals("7.50", report.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()).getValue());
assertEquals("1.00", report.getAttribute(BugzillaReportElement.ACTUAL_TIME.getKeyString()).getValue());
assertEquals("3.00", report.getAttribute(BugzillaReportElement.REMAINING_TIME.getKeyString()).getValue());
@@ -456,15 +430,8 @@ public class RepositoryReportFactoryTest extends TestCase {
public void testMultipleDepensOn() throws Exception {
String bugid = "5";
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_218_URL);
-
- RepositoryTaskData report = new RepositoryTaskData(attributeFactory, BugzillaCorePlugin.REPOSITORY_KIND,
- repository.getUrl(), bugid);
- BugzillaServerFacade.setupExistingBugAttributes(repository.getUrl(), report);
- factory.populateReport(report, repository.getUrl(), null, repository.getUserName(), repository.getPassword(),
- null);
-
+ setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_218_URL);
+ RepositoryTaskData report = init(bugid);
assertNotNull(report);
assertEquals("5", report.getAttribute(BugzillaReportElement.BUG_ID.getKeyString()).getValue());
assertEquals("6, 7", report.getAttribute(BugzillaReportElement.DEPENDSON.getKeyString()).getValue());
@@ -473,15 +440,8 @@ public class RepositoryReportFactoryTest extends TestCase {
public void testBugReportAPI() throws Exception {
String bugid = "3";
- TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
- IBugzillaConstants.TEST_BUGZILLA_222_URL);
-
- RepositoryTaskData report = new RepositoryTaskData(attributeFactory, BugzillaCorePlugin.REPOSITORY_KIND,
- repository.getUrl(), bugid);
- BugzillaServerFacade.setupExistingBugAttributes(repository.getUrl(), report);
- factory.populateReport(report, repository.getUrl(), null, repository.getUserName(), repository.getPassword(),
- null);
-
+ setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
+ RepositoryTaskData report = init(bugid);
assertNotNull(report);
assertTrue(report instanceof RepositoryTaskData);
RepositoryTaskData bugReport = (RepositoryTaskData) report;
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java
index db3e41c3f..889510c33 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java
@@ -11,12 +11,7 @@
package org.eclipse.mylar.bugzilla.tests.headless;
-import java.io.IOException;
-import java.net.InetSocketAddress;
import java.net.Proxy;
-import java.security.GeneralSecurityException;
-import java.security.KeyManagementException;
-import java.util.List;
import junit.framework.TestCase;
@@ -24,17 +19,17 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylar.context.tests.support.MylarTestUtils;
import org.eclipse.mylar.context.tests.support.MylarTestUtils.Credentials;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaException;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportElement;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryQuery;
-import org.eclipse.mylar.internal.bugzilla.core.BugzillaServerFacade;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.tasks.core.AbstractQueryHit;
+import org.eclipse.mylar.tasks.core.IOfflineTaskHandler;
import org.eclipse.mylar.tasks.core.QueryHitCollector;
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
import org.eclipse.mylar.tasks.core.TaskList;
import org.eclipse.mylar.tasks.core.TaskRepository;
+import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
/**
*
@@ -47,13 +42,23 @@ import org.eclipse.mylar.tasks.core.TaskRepository;
public class BugzillaQueryTest extends TestCase {
private TaskRepository repository;
-
+ private BugzillaRepositoryConnector connector;
+ private IOfflineTaskHandler handler;
+ private Proxy proxy = Proxy.NO_PROXY;
+
@Override
protected void setUp() throws Exception {
super.setUp();
+
+ connector = (BugzillaRepositoryConnector) TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
+ BugzillaCorePlugin.REPOSITORY_KIND);
+ handler = connector.getOfflineTaskHandler();
repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
+ Credentials credentials = MylarTestUtils.readCredentials();
+ repository.setAuthenticationCredentials(credentials.username, credentials.password);
}
-
+
+
/**
* This is the first test so that the repository credentials are correctly
* set for the other tests
@@ -67,33 +72,32 @@ public class BugzillaQueryTest extends TestCase {
}
}
- public void testValidateCredentials() throws IOException, BugzillaException, KeyManagementException,
- GeneralSecurityException {
- BugzillaServerFacade.validateCredentials(null, repository.getUrl(), repository.getCharacterEncoding(),
- repository.getUserName(), repository.getPassword());
- }
-
- public void testValidateCredentialsInvalidProxy() throws IOException, BugzillaException, KeyManagementException,
- GeneralSecurityException {
- BugzillaServerFacade.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 = BugzillaServerFacade.addCredentials(IBugzillaConstants.TEST_BUGZILLA_222_URL, "UTF-8",
- "testUser", "\u00A3");
- assertTrue(poundSignUTF8.endsWith("password=%C2%A3"));
- String poundSignISO = BugzillaServerFacade.addCredentials(IBugzillaConstants.TEST_BUGZILLA_222_URL,
- "ISO-8859-1", "testUser", "\u00A3");
- assertFalse(poundSignISO.contains("%C2%A3"));
- assertTrue(poundSignISO.endsWith("password=%A3"));
- }
+// public void testValidateCredentials() throws IOException, BugzillaException, KeyManagementException,
+// GeneralSecurityException {
+// BugzillaClient.validateCredentials(null, repository.getUrl(), repository.getCharacterEncoding(),
+// repository.getUserName(), repository.getPassword());
+// }
+//
+// public void testValidateCredentialsInvalidProxy() throws IOException, BugzillaException, KeyManagementException,
+// GeneralSecurityException {
+// BugzillaClient.validateCredentials(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 12356)),
+// repository.getUrl(), repository.getCharacterEncoding(), repository.getUserName(), repository
+// .getPassword());
+// }
+
+// public void testCredentialsEncoding() throws IOException, BugzillaException, KeyManagementException,
+// GeneralSecurityException {
+// String poundSignUTF8 = BugzillaClient.addCredentials(IBugzillaConstants.TEST_BUGZILLA_222_URL, "UTF-8",
+// "testUser", "\u00A3");
+// assertTrue(poundSignUTF8.endsWith("password=%C2%A3"));
+// String poundSignISO = BugzillaClient.addCredentials(IBugzillaConstants.TEST_BUGZILLA_222_URL,
+// "ISO-8859-1", "testUser", "\u00A3");
+// assertFalse(poundSignISO.contains("%C2%A3"));
+// assertTrue(poundSignISO.endsWith("password=%A3"));
+// }
public void testGetBug() throws Exception {
- RepositoryTaskData taskData = BugzillaServerFacade.getBug(repository.getUrl(), repository.getUserName(),
- repository.getPassword(), null, repository.getCharacterEncoding(), 1);
+ RepositoryTaskData taskData = handler.downloadTaskData(repository, "1", proxy);
assertNotNull(taskData);
assertEquals("user@mylar.eclipse.org", taskData.getAssignedTo());
@@ -106,19 +110,9 @@ public class BugzillaQueryTest extends TestCase {
assertEquals("P1", taskData.getAttributeValue(BugzillaReportElement.PRIORITY.getKeyString()));
}
- public void testGetProductList() throws Exception {
- List<String> products = BugzillaServerFacade.getProductList(repository.getUrl(), null,
- repository.getUserName(), repository.getPassword(), repository.getCharacterEncoding());
-
- assertEquals(3, products.size());
- assertTrue(products.contains("Read Only Test Cases"));
- assertTrue(products.contains("Read Write Test Cases"));
- assertTrue(products.contains("TestProduct"));
- }
-
public void testQueryViaConnector() throws Exception {
String queryUrlString = repository.getUrl()
- + "/buglist.cgi?ctype=rdf&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=";
+ + "/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=search-match-test&product=TestProduct&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&deadlinefrom=&deadlineto=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=";
// holds onto actual hit objects
TaskList taskList = new TaskList();
@@ -133,26 +127,4 @@ public class BugzillaQueryTest extends TestCase {
assertTrue(hit.getDescription().contains("search-match-test"));
}
}
-}
-
-// public void testQueryBugs() throws Exception {
-//
-// QueryHitCollector collector = new QueryHitCollector(new TaskList());
-//
-// // Note need for ctype=rdf in query url
-// String urlString =
-// "http://mylar.eclipse.org/bugs222/buglist.cgi?ctype=rdf&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=";
-// RepositoryQueryResultsFactory queryFactory = new
-// RepositoryQueryResultsFactory();
-//
-// // Tasklist can be null but calls to hit.getOrCreateCorrespondingTask() will
-// return null.
-// queryFactory.performQuery(null, repository.getUrl(), collector, urlString,
-// null, -1, repository
-// .getCharacterEncoding());
-//
-// assertEquals(2, collector.getHits().size());
-// for (AbstractQueryHit hit : collector.getHits()) {
-// assertTrue(hit.getDescription().contains("search-match-test"));
-// }
-// }
+} \ No newline at end of file

Back to the top