Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-05-20 02:19:51 +0000
committerspingel2010-05-20 02:19:51 +0000
commitb516888496479301ea39e9e70ba8a114579dd06a (patch)
treea8fb33ee23ec8df011ef7668bccbe02f99f91204 /org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac
parent1e5289a909edf91a92646efad3abf242f80a293e (diff)
downloadorg.eclipse.mylyn.tasks-b516888496479301ea39e9e70ba8a114579dd06a.tar.gz
org.eclipse.mylyn.tasks-b516888496479301ea39e9e70ba8a114579dd06a.tar.xz
org.eclipse.mylyn.tasks-b516888496479301ea39e9e70ba8a114579dd06a.zip
NEW - bug 309255: unable to open the trac ticket
https://bugs.eclipse.org/bugs/show_bug.cgi?id=309255
Diffstat (limited to 'org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac')
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java3
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java86
2 files changed, 82 insertions, 7 deletions
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java
index c08638324..0d66a308a 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java
@@ -38,6 +38,9 @@ public class TracFixture extends TestFixture {
public static XmlRpcServer.TestData data010;
+ public static TracFixture TRAC_INVALID = new TracFixture(Version.TRAC_0_9, TracTestConstants.TEST_TRAC_INVALID_URL,
+ "0.11", "Invalid URL");
+
public static TracFixture TRAC_0_9_WEB = new TracFixture(Version.TRAC_0_9, TracTestConstants.TEST_TRAC_096_URL,
"0.9", "Web");
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java
index c07f01851..e85bfe019 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java
@@ -13,25 +13,48 @@ package org.eclipse.mylyn.trac.tests.ui;
import junit.framework.TestCase;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.ui.wizard.TracRepositorySettingsPage;
import org.eclipse.mylyn.internal.trac.ui.wizard.TracRepositorySettingsPage.TracValidator;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.trac.tests.support.TracFixture;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
/**
* @author Steffen Pingel
*/
public class TracRepositorySettingsPageTest extends TestCase {
- private TracRepositorySettingsPage page;
+ // make protected methods visible
+ private static class MyTracRepositorySettingsPage extends TracRepositorySettingsPage {
+
+ public MyTracRepositorySettingsPage(TaskRepository taskRepository) {
+ super(taskRepository);
+ }
+
+ @Override
+ protected void applyValidatorResult(Validator validator) {
+ // see AbstractRespositorySettingsPage.validate()
+ if (validator.getStatus() == null) {
+ validator.setStatus(Status.OK_STATUS);
+ }
+ super.applyValidatorResult(validator);
+ }
+
+ }
+
+ private MyTracRepositorySettingsPage page;
private TracValidator validator;
+ private WizardDialog dialog;
+
public TracRepositorySettingsPageTest() {
}
@@ -39,11 +62,27 @@ public class TracRepositorySettingsPageTest extends TestCase {
protected void setUp() throws Exception {
super.setUp();
- page = new TracRepositorySettingsPage(null);
+ page = new MyTracRepositorySettingsPage(null);
+
+ // stub wizard and dialog
+ Wizard wizard = new Wizard() {
+ @Override
+ public boolean performFinish() {
+ return true;
+ }
+ };
+ wizard.addPage(page);
+ dialog = new WizardDialog(null, wizard);
+ dialog.create();
+// page.createControl(dialog.getShell());
+// page.setVisible(true);
+ }
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- page.createControl(shell);
- page.setVisible(true);
+ @Override
+ protected void tearDown() throws Exception {
+ if (dialog != null) {
+ dialog.close();
+ }
}
protected void initialize(TracFixture fixture) throws Exception {
@@ -64,6 +103,10 @@ public class TracRepositorySettingsPageTest extends TestCase {
validator.run(new NullProgressMonitor());
assertNull(validator.getResult());
assertNull(validator.getStatus());
+
+ page.applyValidatorResult(validator);
+ assertEquals(Version.XML_RPC, page.getTracVersion());
+ assertEquals("Repository is valid.", page.getMessage());
}
public void testValidateWeb() throws Exception {
@@ -72,6 +115,10 @@ public class TracRepositorySettingsPageTest extends TestCase {
validator.run(new NullProgressMonitor());
assertNull(validator.getResult());
assertNull(validator.getStatus());
+
+ page.applyValidatorResult(validator);
+ assertEquals(Version.TRAC_0_9, page.getTracVersion());
+ assertEquals("Repository is valid.", page.getMessage());
}
public void testValidateAutomaticUser() throws Exception {
@@ -83,6 +130,10 @@ public class TracRepositorySettingsPageTest extends TestCase {
validator.run(new NullProgressMonitor());
assertEquals(Version.XML_RPC, validator.getResult());
assertNull(validator.getStatus());
+
+ page.applyValidatorResult(validator);
+ assertEquals(Version.XML_RPC, page.getTracVersion());
+ assertEquals("Repository is valid.", page.getMessage());
}
public void testValidateAutomaticAnonymous() throws Exception {
@@ -96,6 +147,27 @@ public class TracRepositorySettingsPageTest extends TestCase {
validator.run(new NullProgressMonitor());
assertEquals(Version.TRAC_0_9, validator.getResult());
assertNotNull(validator.getStatus());
+
+ page.applyValidatorResult(validator);
+ assertEquals(Version.TRAC_0_9, page.getTracVersion());
+ assertEquals("Repository is valid.", page.getMessage());
}
+ public void testValidateInvalid() throws Exception {
+ initialize(TracFixture.TRAC_INVALID);
+
+ page.setTracVersion(null);
+ validator = page.new TracValidator(page.createTaskRepository(), null);
+
+ try {
+ validator.run(new NullProgressMonitor());
+ fail("Expected CoreException");
+ } catch (CoreException e) {
+ validator.setStatus(e.getStatus());
+ }
+
+ page.applyValidatorResult(validator);
+ assertNull(page.getTracVersion());
+ assertEquals(IMessageProvider.ERROR, page.getMessageType());
+ }
}

Back to the top