Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2006-07-27 19:15:18 -0400
committermkersten2006-07-27 19:15:18 -0400
commita78c7ecd6a9f8b9e1064b746a9f77349fbdef290 (patch)
tree629085e619a0f15756a948565f508bcb70123824 /org.eclipse.mylyn.trac.tests
parentbe5d594e9c1ce67b5086eef5de3878def1663830 (diff)
downloadorg.eclipse.mylyn.tasks-a78c7ecd6a9f8b9e1064b746a9f77349fbdef290.tar.gz
org.eclipse.mylyn.tasks-a78c7ecd6a9f8b9e1064b746a9f77349fbdef290.tar.xz
org.eclipse.mylyn.tasks-a78c7ecd6a9f8b9e1064b746a9f77349fbdef290.zip
Completed: 151077: Add support for HTTP Digest authentication to Trac connector
https://bugs.eclipse.org/bugs/show_bug.cgi?id=151077
Diffstat (limited to 'org.eclipse.mylyn.trac.tests')
-rw-r--r--org.eclipse.mylyn.trac.tests/.cvsignore2
-rw-r--r--org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientRepositoryTest.java70
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientSearchTest.java41
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientTest.java72
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java2
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Constants.java6
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Trac09ClientSearchTest.java11
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Trac09ClientTest.java30
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryConnectorTest.java2
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracTestPlugin.java52
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcClientSearchTest.java14
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcClientTest.java27
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/AbstractTracRepositoryFactory.java52
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TestFixture.java6
15 files changed, 237 insertions, 152 deletions
diff --git a/org.eclipse.mylyn.trac.tests/.cvsignore b/org.eclipse.mylyn.trac.tests/.cvsignore
index ba077a403..b0b9ecf46 100644
--- a/org.eclipse.mylyn.trac.tests/.cvsignore
+++ b/org.eclipse.mylyn.trac.tests/.cvsignore
@@ -1 +1,3 @@
bin
+credentials.properties
+credentials.properties
diff --git a/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
index c6ff60942..a3827b263 100644
--- a/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
@@ -12,3 +12,5 @@ Require-Bundle: org.junit,
org.eclipse.mylar.trac.ui,
org.eclipse.mylar.tasks.core
Export-Package: org.eclipse.mylar.trac.tests
+Bundle-Activator: org.eclipse.mylar.trac.tests.TracTestPlugin
+Eclipse-LazyStart: true
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientRepositoryTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientRepositoryTest.java
new file mode 100644
index 000000000..fb3d4c5a7
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientRepositoryTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2006 - 2006 Mylar eclipse.org project 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:
+ * Mylar project committers - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylar.trac.tests;
+
+import org.eclipse.mylar.internal.trac.core.TracException;
+import org.eclipse.mylar.internal.trac.core.TracLoginException;
+import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
+
+/**
+ * Test cases for classes that implement {@link ITracClient}.
+ *
+ * @author Steffen Pingel
+ */
+public class AbstractTracClientRepositoryTest extends AbstractTracClientTest {
+
+ public AbstractTracClientRepositoryTest(Version version) {
+ super(version);
+ }
+
+ public void testValidate010() throws Exception {
+ connect010();
+ validate();
+ }
+
+ public void testValidate010DigestAuth() throws Exception {
+ connect010DigestAuth();
+ validate();
+ }
+
+ protected void validate() throws TracException {
+ repository.validate();
+ }
+
+ public void testValidateFailWrongUrl() throws Exception {
+ connect("http://non.existant/repository");
+ try {
+ repository.validate();
+ fail("Expected TracException");
+ } catch (TracException e) {
+ }
+ }
+
+ public void testValidateFailAuthWrongPassword() throws Exception {
+ connect(Constants.TEST_REPOSITORY1_URL, Constants.TEST_REPOSITORY1_ADMIN_USERNAME, "wrongpassword");
+ try {
+ repository.validate();
+ fail("Expected TracLoginException");
+ } catch (TracLoginException e) {
+ }
+ }
+
+ public void testValidateFailAuthWrongUsername() throws Exception {
+ connect(Constants.TEST_REPOSITORY1_URL, "wrongusername", Constants.TEST_REPOSITORY1_ADMIN_PASSWORD);
+ try {
+ repository.validate();
+ fail("Expected TracLoginException");
+ } catch (TracLoginException e) {
+ }
+ }
+
+}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientSearchTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientSearchTest.java
index d87408678..8cfedbf9c 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientSearchTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientSearchTest.java
@@ -15,45 +15,42 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
-
+import org.eclipse.mylar.internal.trac.core.ITracClient;
import org.eclipse.mylar.internal.trac.core.TracException;
+import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
import org.eclipse.mylar.internal.trac.model.TracSearch;
import org.eclipse.mylar.internal.trac.model.TracTicket;
import org.eclipse.mylar.internal.trac.model.TracTicket.Key;
-import org.eclipse.mylar.trac.tests.support.AbstractTracRepositoryFactory;
import org.eclipse.mylar.trac.tests.support.TestFixture;
import org.eclipse.mylar.trac.tests.support.XmlRpcServer.TestData;
import org.eclipse.mylar.trac.tests.support.XmlRpcServer.Ticket;
/**
* Test cases that validate search results for classes that implement
- * {@link ITracRepositor}.
+ * {@link ITracClient}.
*
* @author Steffen Pingel
*/
-public abstract class AbstractTracClientSearchTest extends TestCase {
-
- protected AbstractTracRepositoryFactory factory;
+public abstract class AbstractTracClientSearchTest extends AbstractTracClientTest {
protected List<Ticket> tickets;
- public AbstractTracClientSearchTest(AbstractTracRepositoryFactory factory) {
- this.factory = factory;
+ public AbstractTracClientSearchTest(Version version) {
+ super(version);
}
protected void setUp() throws Exception {
super.setUp();
- TestData data = TestFixture.initializeRepository1();
+ TestData data = TestFixture.init010();
tickets = data.tickets;
- factory.connectRepository1();
+ connect010();
}
protected void tearDown() throws Exception {
super.tearDown();
-
+
// TestFixture.cleanupRepository1();
}
@@ -68,16 +65,16 @@ public abstract class AbstractTracClientSearchTest extends TestCase {
}
public void testGetTicket() throws Exception {
- TracTicket ticket = factory.repository.getTicket(tickets.get(0).getId());
+ TracTicket ticket = repository.getTicket(tickets.get(0).getId());
assertTicketEquals(tickets.get(0), ticket);
- ticket = factory.repository.getTicket(tickets.get(1).getId());
+ ticket = repository.getTicket(tickets.get(1).getId());
assertTicketEquals(tickets.get(1), ticket);
}
public void testGetTicketInvalidId() throws Exception {
try {
- factory.repository.getTicket(Integer.MAX_VALUE);
+ repository.getTicket(Integer.MAX_VALUE);
fail("Expected TracException");
} catch (TracException e) {
}
@@ -85,8 +82,12 @@ public abstract class AbstractTracClientSearchTest extends TestCase {
public void testSearchAll() throws Exception {
TracSearch search = new TracSearch();
+ // TODO figure out why search must be ordered when logged in (otherwise
+ // no results will be returned)
+ search.setOrderBy("id");
List<TracTicket> result = new ArrayList<TracTicket>();
- factory.repository.search(search, result);
+ repository.search(search, result);
+ System.out.println(result.size());
assertEquals(tickets.size(), result.size());
}
@@ -94,7 +95,7 @@ public abstract class AbstractTracClientSearchTest extends TestCase {
TracSearch search = new TracSearch();
search.addFilter("milestone", "does not exist");
List<TracTicket> result = new ArrayList<TracTicket>();
- factory.repository.search(search, result);
+ repository.search(search, result);
assertEquals(0, result.size());
}
@@ -102,7 +103,7 @@ public abstract class AbstractTracClientSearchTest extends TestCase {
TracSearch search = new TracSearch();
search.addFilter("milestone", "m1");
List<TracTicket> result = new ArrayList<TracTicket>();
- factory.repository.search(search, result);
+ repository.search(search, result);
assertEquals(1, result.size());
assertTicketEquals(tickets.get(0), result.get(0));
}
@@ -113,7 +114,7 @@ public abstract class AbstractTracClientSearchTest extends TestCase {
search.addFilter("milestone", "m2");
search.setOrderBy("id");
List<TracTicket> result = new ArrayList<TracTicket>();
- factory.repository.search(search, result);
+ repository.search(search, result);
assertEquals(3, result.size());
assertTicketEquals(tickets.get(0), result.get(0));
assertTicketEquals(tickets.get(1), result.get(1));
@@ -125,7 +126,7 @@ public abstract class AbstractTracClientSearchTest extends TestCase {
search.addFilter("milestone", "m1");
search.addFilter("summary", "summary1");
List<TracTicket> result = new ArrayList<TracTicket>();
- factory.repository.search(search, result);
+ repository.search(search, result);
assertEquals(1, result.size());
assertTicketEquals(tickets.get(0), result.get(0));
assertEquals("m1", result.get(0).getValue(Key.MILESTONE));
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientTest.java
index 04016d479..f6e937fe5 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientTest.java
@@ -11,45 +11,75 @@
package org.eclipse.mylar.trac.tests;
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.URL;
+import java.util.Properties;
+
import junit.framework.TestCase;
-import org.eclipse.mylar.internal.trac.core.TracLoginException;
-import org.eclipse.mylar.trac.tests.support.AbstractTracRepositoryFactory;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.mylar.internal.trac.core.ITracClient;
+import org.eclipse.mylar.internal.trac.core.TracClientFactory;
+import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
/**
- * Test cases for classes that implement {@link ITracRepositor}.
+ * Provides a base implementation for test cases that access trac repositories.
*
* @author Steffen Pingel
*/
public abstract class AbstractTracClientTest extends TestCase {
- protected AbstractTracRepositoryFactory factory;
+ public String repositoryUrl;
+
+ public ITracClient repository;
+
+ public String username;
+
+ public String password;
- public AbstractTracClientTest(AbstractTracRepositoryFactory factory) {
- this.factory = factory;
+ private Version version;
+
+ public AbstractTracClientTest(Version version) {
+ this.version = version;
}
- public void testValidate() throws Exception {
- factory.connectRepository1();
- factory.repository.validate();
+ public ITracClient connect096() throws Exception {
+ return connect(Constants.TEST_TRAC_096_URL);
}
- public void testValidateFailAuthWrongPassword() throws Exception {
- factory.connect(Constants.TEST_REPOSITORY1_URL, Constants.TEST_REPOSITORY1_ADMIN_USERNAME, "wrongpassword");
- try {
- factory.repository.validate();
- fail("Expected TracLoginException");
- } catch (TracLoginException e) {
- }
+ public ITracClient connect010() throws Exception {
+ return connect(Constants.TEST_REPOSITORY1_URL, Constants.TEST_REPOSITORY1_ADMIN_USERNAME,
+ Constants.TEST_REPOSITORY1_ADMIN_PASSWORD);
}
- public void testValidateFailAuthWrongUsername() throws Exception {
- factory.connect(Constants.TEST_REPOSITORY1_URL, "wrongusername", Constants.TEST_REPOSITORY1_ADMIN_PASSWORD);
+ public ITracClient connect010DigestAuth() throws Exception {
+ return connect(Constants.TEST_TRAC_010_DIGEST_AUTH_URL);
+ }
+
+ public ITracClient connect(String url) throws Exception {
try {
- factory.repository.validate();
- fail("Expected TracLoginException");
- } catch (TracLoginException e) {
+ Properties properties = new Properties();
+ URL localURL = FileLocator.toFileURL(TracTestPlugin.getDefault().getBundle().getEntry(
+ "credentials.properties"));
+ properties.load(new FileInputStream(new File(localURL.getFile())));
+ return connect(url, properties.getProperty("username"), properties.getProperty("password"));
+ } catch (Throwable t) {
+ fail("must define credentials in <plug-in dir>/credentials.properties");
}
+ return null; // never reached
+ }
+
+ public ITracClient connect(String url, String username, String password) throws Exception {
+ this.repositoryUrl = url;
+ this.username = username;
+ this.password = password;
+ this.repository = TracClientFactory.createClient(url, version, username, password);
+
+ // make sure no dialog pops up to prompt for a password
+ // Authenticator.setDefault(null);
+
+ return this.repository;
}
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java
index eaed32e34..cf4962872 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java
@@ -21,6 +21,8 @@ import junit.framework.TestSuite;
public class AllTracTests {
public static Test suite() {
+// UrlConnectionUtil.initCommonsLoggingSettings();
+
TestSuite suite = new TestSuite("Test for org.eclipse.mylar.trac.tests");
// $JUnit-BEGIN$
// suite.addTestSuite(TracXmlRpcTest.class);
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Constants.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Constants.java
index e856d96c7..fff8739d0 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Constants.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Constants.java
@@ -28,4 +28,10 @@ public class Constants {
public static final String TEST_REPOSITORY1_PASSWORD = "trac-test";
+ public static final String TEST_TRAC_096_URL = "http://mylar.eclipse.org/trac096";
+
+ public static final String TEST_TRAC_010_URL = "http://mylar.eclipse.org/trac010";
+
+ public static final String TEST_TRAC_010_DIGEST_AUTH_URL = "http://mylar.eclipse.org/trac010digest";
+
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Trac09ClientSearchTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Trac09ClientSearchTest.java
index 20f9bc3bc..27c6b809f 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Trac09ClientSearchTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Trac09ClientSearchTest.java
@@ -11,12 +11,7 @@
package org.eclipse.mylar.trac.tests;
-import java.net.URL;
-
-import org.eclipse.mylar.internal.trac.core.ITracClient;
-import org.eclipse.mylar.internal.trac.core.Trac09Client;
import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
-import org.eclipse.mylar.trac.tests.support.AbstractTracRepositoryFactory;
/**
* @author Steffen Pingel
@@ -24,11 +19,7 @@ import org.eclipse.mylar.trac.tests.support.AbstractTracRepositoryFactory;
public class Trac09ClientSearchTest extends AbstractTracClientSearchTest {
public Trac09ClientSearchTest() {
- super(new AbstractTracRepositoryFactory() {
- protected ITracClient createRepository(String url, String username, String password) throws Exception {
- return new Trac09Client(new URL(url), Version.TRAC_0_9, username, password);
- }
- });
+ super(Version.TRAC_0_9);
}
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Trac09ClientTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Trac09ClientTest.java
index 43a49efa0..c9d00532a 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Trac09ClientTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Trac09ClientTest.java
@@ -11,40 +11,37 @@
package org.eclipse.mylar.trac.tests;
-import java.net.URL;
import java.util.Arrays;
import java.util.Comparator;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylar.internal.trac.core.ITracClient;
-import org.eclipse.mylar.internal.trac.core.Trac09Client;
import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
import org.eclipse.mylar.internal.trac.model.TracVersion;
-import org.eclipse.mylar.trac.tests.support.AbstractTracRepositoryFactory;
/**
* @author Steffen Pingel
*/
-public class Trac09ClientTest extends AbstractTracClientTest {
+public class Trac09ClientTest extends AbstractTracClientRepositoryTest {
public Trac09ClientTest() {
- super(new AbstractTracRepositoryFactory() {
- protected ITracClient createRepository(String url, String username, String password) throws Exception {
- return new Trac09Client(new URL(url), Version.TRAC_0_9, username, password);
- }
- });
+ super(Version.TRAC_0_9);
+ }
+
+ public void testValidate096() throws Exception {
+ connect096();
+ validate();
}
public void testValidateAnonymousLogin() throws Exception {
- factory.connect(Constants.TEST_REPOSITORY1_URL, "", "");
- factory.repository.validate();
+ connect(Constants.TEST_REPOSITORY1_URL, "", "");
+ repository.validate();
}
public void testUpdateAttributes() throws Exception {
- factory.connectRepository1();
- assertNull(factory.repository.getMilestones());
- factory.repository.updateAttributes(new NullProgressMonitor());
- TracVersion[] versions = factory.repository.getVersions();
+ connect010();
+ assertNull(repository.getMilestones());
+ repository.updateAttributes(new NullProgressMonitor());
+ TracVersion[] versions = repository.getVersions();
assertEquals(2, versions.length);
Arrays.sort(versions, new Comparator<TracVersion>() {
public int compare(TracVersion o1, TracVersion o2) {
@@ -55,5 +52,4 @@ public class Trac09ClientTest extends AbstractTracClientTest {
assertEquals("v2", versions[1].getName());
}
-
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryConnectorTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryConnectorTest.java
index 20d719375..88f80c8b3 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryConnectorTest.java
@@ -67,7 +67,7 @@ public class TracRepositoryConnectorTest extends TestCase {
tasklist = TasksUiPlugin.getTaskListManager().getTaskList();
- data = TestFixture.initializeRepository1();
+ data = TestFixture.init010();
}
protected void tearDown() throws Exception {
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracTestPlugin.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracTestPlugin.java
new file mode 100644
index 000000000..35aa3f5f7
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracTestPlugin.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006 - 2006 Mylar eclipse.org project 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:
+ * Mylar project committers - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylar.trac.tests;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ *
+ * @author Steffen Pingel
+ */
+public class TracTestPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.mylar.trac.tests";
+
+ // The shared instance
+ private static TracTestPlugin plugin;
+
+ public TracTestPlugin() {
+ plugin = this;
+ }
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static TracTestPlugin getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcClientSearchTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcClientSearchTest.java
index 11a432200..9b870c8e0 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcClientSearchTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcClientSearchTest.java
@@ -11,17 +11,13 @@
package org.eclipse.mylar.trac.tests;
-import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.mylar.internal.trac.core.ITracClient;
-import org.eclipse.mylar.internal.trac.core.TracXmlRpcClient;
import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
import org.eclipse.mylar.internal.trac.model.TracSearch;
import org.eclipse.mylar.internal.trac.model.TracTicket;
import org.eclipse.mylar.internal.trac.model.TracTicket.Key;
-import org.eclipse.mylar.trac.tests.support.AbstractTracRepositoryFactory;
/**
* @author Steffen Pingel
@@ -29,24 +25,20 @@ import org.eclipse.mylar.trac.tests.support.AbstractTracRepositoryFactory;
public class TracXmlRpcClientSearchTest extends AbstractTracClientSearchTest {
public TracXmlRpcClientSearchTest() {
- super(new AbstractTracRepositoryFactory() {
- protected ITracClient createRepository(String url, String username, String password) throws Exception {
- return new TracXmlRpcClient(new URL(url), Version.XML_RPC, username, password);
- }
- });
+ super(Version.XML_RPC);
}
public void testSearchValidateTicket() throws Exception {
TracSearch search = new TracSearch();
search.addFilter("summary", "summary1");
List<TracTicket> result = new ArrayList<TracTicket>();
- factory.repository.search(search, result);
+ repository.search(search, result);
assertEquals(1, result.size());
assertTicketEquals(tickets.get(0), result.get(0));
assertEquals("component1", result.get(0).getValue(Key.COMPONENT));
assertEquals("description1", result.get(0).getValue(Key.DESCRIPTION));
assertEquals("m1", result.get(0).getValue(Key.MILESTONE));
- assertEquals(factory.username, result.get(0).getValue(Key.REPORTER));
+ assertEquals(username, result.get(0).getValue(Key.REPORTER));
assertEquals("summary1", result.get(0).getValue(Key.SUMMARY));
// assertEquals("", result.get(0).getValue(Key.VERSION));
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcClientTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcClientTest.java
index fdc03af8f..5d527d8f3 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcClientTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcClientTest.java
@@ -11,56 +11,49 @@
package org.eclipse.mylar.trac.tests;
-import java.net.URL;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylar.internal.trac.core.ITracClient;
import org.eclipse.mylar.internal.trac.core.TracLoginException;
import org.eclipse.mylar.internal.trac.core.TracRemoteException;
import org.eclipse.mylar.internal.trac.core.TracXmlRpcClient;
import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
import org.eclipse.mylar.internal.trac.model.TracVersion;
-import org.eclipse.mylar.trac.tests.support.AbstractTracRepositoryFactory;
/**
* @author Steffen Pingel
*/
-public class TracXmlRpcClientTest extends AbstractTracClientTest {
+public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
public TracXmlRpcClientTest() {
- super(new AbstractTracRepositoryFactory() {
- protected ITracClient createRepository(String url, String username, String password) throws Exception {
- return new TracXmlRpcClient(new URL(url), Version.XML_RPC, username, password);
- }
- });
+ super(Version.XML_RPC);
}
public void testValidateFailNoAuth() throws Exception {
- factory.connect(Constants.TEST_REPOSITORY1_URL, "", "");
+ connect(Constants.TEST_REPOSITORY1_URL, "", "");
try {
- factory.repository.validate();
+ repository.validate();
fail("Expected TracLoginException");
} catch (TracLoginException e) {
}
}
public void testMulticallExceptions() throws Exception {
- factory.connectRepository1();
+ connect010();
try {
- ((TracXmlRpcClient) factory.repository).getTickets(new int[] { 1, Integer.MAX_VALUE });
+ ((TracXmlRpcClient) repository).getTickets(new int[] { 1, Integer.MAX_VALUE });
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
}
public void testUpdateAttributes() throws Exception {
- factory.connectRepository1();
- assertNull(factory.repository.getMilestones());
- factory.repository.updateAttributes(new NullProgressMonitor());
- TracVersion[] versions = factory.repository.getVersions();
+ connect010();
+ assertNull(repository.getMilestones());
+ repository.updateAttributes(new NullProgressMonitor());
+ TracVersion[] versions = repository.getVersions();
assertEquals(2, versions.length);
Arrays.sort(versions, new Comparator<TracVersion>() {
public int compare(TracVersion o1, TracVersion o2) {
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/AbstractTracRepositoryFactory.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/AbstractTracRepositoryFactory.java
deleted file mode 100644
index e638fcbaa..000000000
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/AbstractTracRepositoryFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 - 2006 Mylar eclipse.org project 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:
- * Mylar project committers - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylar.trac.tests.support;
-
-import java.net.Authenticator;
-
-import org.eclipse.mylar.internal.trac.core.ITracClient;
-import org.eclipse.mylar.trac.tests.Constants;
-
-/**
- * @author Steffen Pingel
- *
- */
-public abstract class AbstractTracRepositoryFactory {
-
- public String repositoryUrl;
-
- public ITracClient repository;
-
- public String username;
-
- public String password;
-
- public ITracClient connectRepository1() throws Exception {
- return connect(Constants.TEST_REPOSITORY1_URL, Constants.TEST_REPOSITORY1_ADMIN_USERNAME,
- Constants.TEST_REPOSITORY1_ADMIN_PASSWORD);
- }
-
- public ITracClient connect(String url, String username, String password) throws Exception {
- this.repositoryUrl = url;
- this.username = username;
- this.password = password;
- this.repository = createRepository(url, username, password);
-
- // make sure no dialog pops up to prompt for a password
- Authenticator.setDefault(null);
-
- return this.repository;
- }
-
- protected abstract ITracClient createRepository(String url, String username, String password) throws Exception;
-
-}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TestFixture.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TestFixture.java
index 11bdc5d0d..ae2115472 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TestFixture.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TestFixture.java
@@ -25,7 +25,7 @@ public class TestFixture {
public static XmlRpcServer.TestData data1;
- public static XmlRpcServer.TestData initializeRepository1() throws Exception {
+ public static XmlRpcServer.TestData init010() throws Exception {
if (data1 == null) {
XmlRpcServer server = new XmlRpcServer(Constants.TEST_REPOSITORY1_URL,
Constants.TEST_REPOSITORY1_ADMIN_USERNAME, Constants.TEST_REPOSITORY1_ADMIN_PASSWORD);
@@ -33,7 +33,7 @@ public class TestFixture {
server.ticketVersion(null).deleteAll();
server.ticketVersion("v1").create(86400, "description1");
server.ticketVersion("v2").create(86400 * 2, "description2");
-
+
server.ticket().deleteAll();
server.ticketMilestone("m1").deleteAndCreate();
@@ -53,7 +53,7 @@ public class TestFixture {
return data1;
}
- public static void cleanupRepository1() throws Exception {
+ public static void cleanup010() throws Exception {
if (data1 != null) {
data1.cleanup();
data1 = null;

Back to the top