Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java19
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java20
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java21
-rw-r--r--org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientRepositoryTest.java28
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientSearchTest.java10
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AbstractTracClientTest.java27
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Constants.java15
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Trac09ClientTest.java12
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracClientFactoryTest.java55
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryConnectorTest.java63
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcClientSearchTest.java4
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcClientTest.java14
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcTest.java153
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TestFixture.java76
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/XmlRpcServer.java4
16 files changed, 255 insertions, 269 deletions
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 65bf2b118..6e4e0a781 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
@@ -13,19 +13,16 @@ package org.eclipse.mylar.bugzilla.tests;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.Socket;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.Properties;
import java.util.Set;
import javax.security.auth.login.LoginException;
@@ -33,7 +30,8 @@ import javax.security.auth.login.LoginException;
import junit.framework.TestCase;
import org.apache.commons.httpclient.params.HttpConnectionParams;
-import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.Credentials;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaAttachmentHandler;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaException;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin;
@@ -102,17 +100,8 @@ public class BugzillaRepositoryConnectorTest extends TestCase {
protected void init(String url) {
repository = new TaskRepository(DEFAULT_KIND, url);
- // Valid user name and password must be set for tests to pass
- try {
- Properties properties = new Properties();
- URL localURL = FileLocator.toFileURL(BugzillaTestPlugin.getDefault().getBundle().getEntry(
- "credentials.properties"));
- properties.load(new FileInputStream(new File(localURL.getFile())));
- repository.setAuthenticationCredentials(properties.getProperty("username"), properties
- .getProperty("password"));
- } catch (Throwable t) {
- fail("must define credentials in <plug-in dir>/credentials.properties");
- }
+ Credentials credentials = MylarTestUtils.readCredentials();
+ repository.setAuthenticationCredentials(credentials.username, credentials.password);
repository.setTimeZoneId("Canada/Eastern");
manager.addRepository(repository);
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java
index a20bb12e0..086e9d61f 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
@@ -11,18 +11,15 @@
package org.eclipse.mylar.bugzilla.tests;
-import java.io.File;
-import java.io.FileInputStream;
-import java.net.URL;
import java.net.UnknownHostException;
-import java.util.Properties;
import javax.security.auth.login.LoginException;
import junit.framework.TestCase;
-import org.eclipse.core.runtime.FileLocator;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.Credentials;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaServerFacade;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
@@ -48,17 +45,8 @@ public class RepositoryEditorWizardTest extends TestCase {
manager = TasksUiPlugin.getRepositoryManager();
manager.clearRepositories();
repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
- // Valid user name and password must be set for tests to pass
- try {
- Properties properties = new Properties();
- URL localURL = FileLocator.toFileURL(BugzillaTestPlugin.getDefault().getBundle().getEntry(
- "credentials.properties"));
- properties.load(new FileInputStream(new File(localURL.getFile())));
- repository.setAuthenticationCredentials(properties.getProperty("username"), properties
- .getProperty("password"));
- } catch (Throwable t) {
- fail("Must define credentials in <plug-in dir>/credentials.properties");
- }
+ Credentials credentials = MylarTestUtils.readCredentials();
+ repository.setAuthenticationCredentials(credentials.username, credentials.password);
TasksUiPlugin.getRepositoryManager().addRepository(repository);
}
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 5250e9105..1935b6eec 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,17 +11,14 @@
package org.eclipse.mylar.bugzilla.tests;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.net.URL;
-import java.util.Properties;
import javax.security.auth.login.LoginException;
import junit.framework.TestCase;
-import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.Credentials;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaAttributeFactory;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportElement;
@@ -57,18 +54,8 @@ public class RepositoryReportFactoryTest extends TestCase {
private TaskRepository getRepository(String kind, String url) {
TaskRepository repository = new TaskRepository(kind, url);
-
- // Valid user name and password must be set for tests to pass
- try {
- Properties properties = new Properties();
- URL localURL = FileLocator.toFileURL(BugzillaTestPlugin.getDefault().getBundle().getEntry(
- "credentials.properties"));
- properties.load(new FileInputStream(new File(localURL.getFile())));
- repository.setAuthenticationCredentials(properties.getProperty("username"), properties
- .getProperty("password"));
- } catch (Throwable t) {
- fail("must define credentials in <plug-in dir>/credentials.properties");
- }
+ Credentials credentials = MylarTestUtils.readCredentials();
+ repository.setAuthenticationCredentials(credentials.username, credentials.password);
return repository;
}
diff --git a/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
index a3827b263..e39fa9bce 100644
--- a/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
@@ -10,7 +10,8 @@ Require-Bundle: org.junit,
org.eclipse.mylar.context.core,
org.eclipse.mylar.tasks.ui,
org.eclipse.mylar.trac.ui,
- org.eclipse.mylar.tasks.core
+ org.eclipse.mylar.tasks.core,
+ org.eclipse.mylar.core.tests
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
index fb3d4c5a7..fad915ff6 100644
--- 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
@@ -11,6 +11,9 @@
package org.eclipse.mylar.trac.tests;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.Credentials;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.PrivilegeLevel;
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;
@@ -27,39 +30,38 @@ public class AbstractTracClientRepositoryTest extends AbstractTracClientTest {
}
public void testValidate010() throws Exception {
- connect010();
- validate();
+ validate(Constants.TEST_TRAC_010_URL);
}
public void testValidate010DigestAuth() throws Exception {
- connect010DigestAuth();
- validate();
+ validate(Constants.TEST_TRAC_010_DIGEST_AUTH_URL);
}
- protected void validate() throws TracException {
+ protected void validate(String url) throws Exception {
+ Credentials credentials = MylarTestUtils.readCredentials(PrivilegeLevel.USER);
+
+ // standard connect
+ connect(url);
repository.validate();
- }
- public void testValidateFailWrongUrl() throws Exception {
+ // invalid url
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");
+ // invalid password
+ connect(url, credentials.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);
+ // invalid username
+ connect(url, "wrongusername", credentials.password);
try {
repository.validate();
fail("Expected TracLoginException");
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 6ccfb423a..1eb091386 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
@@ -100,7 +100,7 @@ public abstract class AbstractTracClientSearchTest extends AbstractTracClientTes
public void testSearchMilestone1() throws Exception {
TracSearch search = new TracSearch();
- search.addFilter("milestone", "m1");
+ search.addFilter("milestone", "milestone1");
List<TracTicket> result = new ArrayList<TracTicket>();
repository.search(search, result);
assertEquals(1, result.size());
@@ -109,8 +109,8 @@ public abstract class AbstractTracClientSearchTest extends AbstractTracClientTes
public void testSearchMilestone2() throws Exception {
TracSearch search = new TracSearch();
- search.addFilter("milestone", "m1");
- search.addFilter("milestone", "m2");
+ search.addFilter("milestone", "milestone1");
+ search.addFilter("milestone", "milestone2");
search.setOrderBy("id");
List<TracTicket> result = new ArrayList<TracTicket>();
repository.search(search, result);
@@ -122,13 +122,13 @@ public abstract class AbstractTracClientSearchTest extends AbstractTracClientTes
public void testSearchExactMatch() throws Exception {
TracSearch search = new TracSearch();
- search.addFilter("milestone", "m1");
+ search.addFilter("milestone", "milestone1");
search.addFilter("summary", "summary1");
List<TracTicket> result = new ArrayList<TracTicket>();
repository.search(search, result);
assertEquals(1, result.size());
assertTicketEquals(tickets.get(0), result.get(0));
- assertEquals("m1", result.get(0).getValue(Key.MILESTONE));
+ assertEquals("milestone1", result.get(0).getValue(Key.MILESTONE));
assertEquals("summary1", result.get(0).getValue(Key.SUMMARY));
}
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 f6e937fe5..e4c747556 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,14 +11,11 @@
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.core.runtime.FileLocator;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.Credentials;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.PrivilegeLevel;
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;
@@ -49,8 +46,7 @@ public abstract class AbstractTracClientTest extends TestCase {
}
public ITracClient connect010() throws Exception {
- return connect(Constants.TEST_REPOSITORY1_URL, Constants.TEST_REPOSITORY1_ADMIN_USERNAME,
- Constants.TEST_REPOSITORY1_ADMIN_PASSWORD);
+ return connect(Constants.TEST_TRAC_010_URL);
}
public ITracClient connect010DigestAuth() throws Exception {
@@ -58,16 +54,8 @@ public abstract class AbstractTracClientTest extends TestCase {
}
public ITracClient connect(String url) throws Exception {
- try {
- 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
+ Credentials credentials = MylarTestUtils.readCredentials(PrivilegeLevel.USER);
+ return connect(url, credentials.username, credentials.password);
}
public ITracClient connect(String url, String username, String password) throws Exception {
@@ -76,9 +64,6 @@ public abstract class AbstractTracClientTest extends TestCase {
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/Constants.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Constants.java
index fff8739d0..012e540da 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
@@ -16,22 +16,13 @@ package org.eclipse.mylar.trac.tests;
*/
public class Constants {
- public static final String TEST_REPOSITORY1_URL = "http://trac.steffenpingel.de/mylar-test";
-
- public static final String TEST_REPOSITORY1_SSL_URL = "https://trac.steffenpingel.de/mylar-test";
-
- public static final String TEST_REPOSITORY1_ADMIN_USERNAME = "trac-ticket-admin";
-
- public static final String TEST_REPOSITORY1_ADMIN_PASSWORD = "trac-ticket-admin";
-
- public static final String TEST_REPOSITORY1_USERNAME = "trac-test";
-
- 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_SSL_URL = "https://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/Trac09ClientTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Trac09ClientTest.java
index c9d00532a..4fca80725 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
@@ -28,12 +28,14 @@ public class Trac09ClientTest extends AbstractTracClientRepositoryTest {
}
public void testValidate096() throws Exception {
- connect096();
- validate();
+ validate(Constants.TEST_TRAC_096_URL);
}
public void testValidateAnonymousLogin() throws Exception {
- connect(Constants.TEST_REPOSITORY1_URL, "", "");
+ connect(Constants.TEST_TRAC_010_URL, "", "");
+ repository.validate();
+
+ connect(Constants.TEST_TRAC_096_URL, "", "");
repository.validate();
}
@@ -48,8 +50,8 @@ public class Trac09ClientTest extends AbstractTracClientRepositoryTest {
return o1.getName().compareTo(o2.getName());
}
});
- assertEquals("v1", versions[0].getName());
- assertEquals("v2", versions[1].getName());
+ assertEquals("1.0", versions[0].getName());
+ assertEquals("2.0", versions[1].getName());
}
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracClientFactoryTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracClientFactoryTest.java
index 6d6863742..7a5e568df 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracClientFactoryTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracClientFactoryTest.java
@@ -11,10 +11,11 @@
package org.eclipse.mylar.trac.tests;
-import java.net.Authenticator;
-
import junit.framework.TestCase;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.Credentials;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.PrivilegeLevel;
import org.eclipse.mylar.internal.trac.core.ITracClient;
import org.eclipse.mylar.internal.trac.core.Trac09Client;
import org.eclipse.mylar.internal.trac.core.TracClientFactory;
@@ -28,53 +29,59 @@ import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
*/
public class TracClientFactoryTest extends TestCase {
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- // make sure no dialog pops up to prompt for a password
- Authenticator.setDefault(null);
- }
-
public void testCreateClient() throws Exception {
- ITracClient client = TracClientFactory.createClient(Constants.TEST_REPOSITORY1_URL, Version.TRAC_0_9, "user",
+ ITracClient client = TracClientFactory.createClient(Constants.TEST_TRAC_010_URL, Version.TRAC_0_9, "user",
"password");
assertTrue(client instanceof Trac09Client);
- client = TracClientFactory.createClient(Constants.TEST_REPOSITORY1_SSL_URL, Version.TRAC_0_9, "user",
- "password");
+ client = TracClientFactory.createClient(Constants.TEST_TRAC_010_SSL_URL, Version.TRAC_0_9, "user", "password");
assertTrue(client instanceof Trac09Client);
- client = TracClientFactory.createClient(Constants.TEST_REPOSITORY1_URL, Version.XML_RPC, "user", "password");
+ client = TracClientFactory.createClient(Constants.TEST_TRAC_010_URL, Version.XML_RPC, "user", "password");
assertTrue(client instanceof TracXmlRpcClient);
- client = TracClientFactory
- .createClient(Constants.TEST_REPOSITORY1_SSL_URL, Version.XML_RPC, "user", "password");
+ client = TracClientFactory.createClient(Constants.TEST_TRAC_010_SSL_URL, Version.XML_RPC, "user", "password");
assertTrue(client instanceof TracXmlRpcClient);
}
public void testCreateClientNull() throws Exception {
try {
- TracClientFactory.createClient(Constants.TEST_REPOSITORY1_SSL_URL, null, "user", "password");
+ TracClientFactory.createClient(Constants.TEST_TRAC_010_URL, null, "user", "password");
fail("Expected Exception");
} catch (Exception e) {
}
}
- public void testProbeClient() throws Exception {
- Version version = TracClientFactory.probeClient(Constants.TEST_REPOSITORY1_URL,
- Constants.TEST_REPOSITORY1_USERNAME, Constants.TEST_REPOSITORY1_PASSWORD);
- assertEquals(Version.XML_RPC, version);
+ public void testProbeClient096() throws Exception {
+ probeClient(Constants.TEST_TRAC_096_URL, false);
+ }
+
+ public void testProbeClient010() throws Exception {
+ probeClient(Constants.TEST_TRAC_010_URL, true);
+ }
+
+ public void testProbeClient010DigestAuth() throws Exception {
+ probeClient(Constants.TEST_TRAC_010_DIGEST_AUTH_URL, true);
+ }
+
+ protected void probeClient(String url, boolean xmlrpcInstalled) throws Exception {
+ Credentials credentials = MylarTestUtils.readCredentials(PrivilegeLevel.USER);
+ Version version = TracClientFactory.probeClient(url, credentials.username, credentials.password);
+ if (xmlrpcInstalled) {
+ assertEquals(Version.XML_RPC, version);
+ } else {
+ assertEquals(Version.TRAC_0_9, version);
+ }
- version = TracClientFactory.probeClient(Constants.TEST_REPOSITORY1_URL, "", "");
+ version = TracClientFactory.probeClient(url, "", "");
assertEquals(Version.TRAC_0_9, version);
try {
- version = TracClientFactory.probeClient(Constants.TEST_REPOSITORY1_URL, "invaliduser", "password");
+ version = TracClientFactory.probeClient(url, "invaliduser", "password");
fail("Expected TracLoginException, got " + version);
} catch (TracLoginException e) {
}
try {
- version = TracClientFactory.probeClient(Constants.TEST_REPOSITORY1_URL + "/nonexistant", "", "");
+ version = TracClientFactory.probeClient(url + "/nonexistant", "", "");
fail("Expected TracException, got " + version);
} catch (TracException e) {
}
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 88f80c8b3..8d3f8427d 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
@@ -20,11 +20,14 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.Credentials;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.PrivilegeLevel;
import org.eclipse.mylar.internal.tasks.ui.wizards.EditRepositoryWizard;
-import org.eclipse.mylar.internal.trac.TracUiPlugin;
import org.eclipse.mylar.internal.trac.TracRepositoryConnector;
import org.eclipse.mylar.internal.trac.TracRepositoryQuery;
import org.eclipse.mylar.internal.trac.TracTask;
+import org.eclipse.mylar.internal.trac.TracUiPlugin;
import org.eclipse.mylar.internal.trac.core.ITracClient;
import org.eclipse.mylar.internal.trac.core.InvalidTicketException;
import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
@@ -76,12 +79,12 @@ public class TracRepositoryConnectorTest extends TestCase {
// TestFixture.cleanupRepository1();
}
- protected void init(Version version) {
+ protected void init(String url, Version version) {
String kind = TracUiPlugin.REPOSITORY_KIND;
+ Credentials credentials = MylarTestUtils.readCredentials(PrivilegeLevel.USER);
- repository = new TaskRepository(kind, Constants.TEST_REPOSITORY1_URL);
- repository.setAuthenticationCredentials(Constants.TEST_REPOSITORY1_USERNAME,
- Constants.TEST_REPOSITORY1_USERNAME);
+ repository = new TaskRepository(kind, url);
+ repository.setAuthenticationCredentials(credentials.username, credentials.password);
repository.setTimeZoneId(ITracClient.TIME_ZONE);
repository.setCharacterEncoding(ITracClient.CHARSET);
repository.setVersion(version.name());
@@ -103,13 +106,18 @@ public class TracRepositoryConnectorTest extends TestCase {
assertEquals(null, connector.getRepositoryUrlFromTaskUrl("http://host/repo/ticket-2342"));
}
- public void testCreateTaskFromExistingKeyXmlRpc() {
- init(Version.XML_RPC);
+ public void testCreateTaskFromExistingKeyXmlRpc_010() {
+ init(Constants.TEST_TRAC_010_URL, Version.XML_RPC);
+ createTaskFromExistingKey();
+ }
+
+ public void testCreateTaskFromExistingKeyTrac09_010() {
+ init(Constants.TEST_TRAC_010_URL, Version.TRAC_0_9);
createTaskFromExistingKey();
}
- public void testCreateTaskFromExistingKeyTrac09() {
- init(Version.TRAC_0_9);
+ public void testCreateTaskFromExistingKeyTrac09_096() {
+ init(Constants.TEST_TRAC_096_URL, Version.TRAC_0_9);
createTaskFromExistingKey();
}
@@ -129,7 +137,7 @@ public class TracRepositoryConnectorTest extends TestCase {
}
public void testClientManagerChangeTaskRepositorySettings() throws MalformedURLException {
- init(Version.TRAC_0_9);
+ init(Constants.TEST_TRAC_010_URL, Version.TRAC_0_9);
ITracClient client = connector.getClientManager().getRepository(repository);
assertEquals(Version.TRAC_0_9, client.getVersion());
@@ -145,25 +153,28 @@ public class TracRepositoryConnectorTest extends TestCase {
assertEquals(Version.XML_RPC, client.getVersion());
}
- public void testPerformQueryXmlRpc() {
- init(Version.XML_RPC);
- performQuery();
+ public void testPerformQueryXmlRpc_010() {
+ performQuery(Constants.TEST_TRAC_010_URL, Version.XML_RPC);
+ }
+
+ public void testPerformQueryTrac09_010() {
+ performQuery(Constants.TEST_TRAC_010_URL, Version.TRAC_0_9);
}
- public void testPerformQueryTrac09() {
- init(Version.TRAC_0_9);
- performQuery();
+ public void testPerformQueryTrac09_096() {
+ performQuery(Constants.TEST_TRAC_096_URL, Version.TRAC_0_9);
}
- protected void performQuery() {
+ protected void performQuery(String url, Version version) {
+ init(url, version);
+
TracSearch search = new TracSearch();
- search.addFilter("milestone", "m1");
- search.addFilter("milestone", "m2");
+ search.addFilter("milestone", "milestone1");
+ search.addFilter("milestone", "milestone2");
search.setOrderBy("id");
- String queryUrl = Constants.TEST_REPOSITORY1_URL + ITracClient.QUERY_URL + search.toUrl();
- TracRepositoryQuery query = new TracRepositoryQuery(Constants.TEST_REPOSITORY1_URL, queryUrl, "description",
- tasklist);
+ String queryUrl = url + ITracClient.QUERY_URL + search.toUrl();
+ TracRepositoryQuery query = new TracRepositoryQuery(url, queryUrl, "description", tasklist);
MultiStatus queryStatus = new MultiStatus(TracUiPlugin.PLUGIN_ID, IStatus.OK, "Query result", null);
List<AbstractQueryHit> result = connector.performQuery(query, new NullProgressMonitor(), queryStatus);
@@ -183,9 +194,9 @@ public class TracRepositoryConnectorTest extends TestCase {
ticket.putBuiltinValue(Key.TYPE, "mytype");
TracTask task = new TracTask("", "", true);
- TracRepositoryConnector.updateTaskDetails(Constants.TEST_REPOSITORY1_URL, task, ticket, false);
+ TracRepositoryConnector.updateTaskDetails(Constants.TEST_TRAC_010_URL, task, ticket, false);
- assertEquals(Constants.TEST_REPOSITORY1_URL + ITracClient.TICKET_URL + "123", task.getUrl());
+ assertEquals(Constants.TEST_TRAC_010_URL + ITracClient.TICKET_URL + "123", task.getUrl());
assertEquals("123: mysummary", task.getDescription());
assertEquals("P3", task.getPriority());
assertEquals("mytype", task.getTaskType());
@@ -196,9 +207,9 @@ public class TracRepositoryConnectorTest extends TestCase {
ticket.putBuiltinValue(Key.SUMMARY, "mysummary");
TracTask task = new TracTask("", "", true);
- TracRepositoryConnector.updateTaskDetails(Constants.TEST_REPOSITORY1_URL, task, ticket, false);
+ TracRepositoryConnector.updateTaskDetails(Constants.TEST_TRAC_010_URL, task, ticket, false);
- assertEquals(Constants.TEST_REPOSITORY1_URL + ITracClient.TICKET_URL + "456", task.getUrl());
+ assertEquals(Constants.TEST_TRAC_010_URL + ITracClient.TICKET_URL + "456", task.getUrl());
assertEquals("456: mysummary", task.getDescription());
assertEquals("P3", task.getPriority());
assertEquals(null, task.getTaskType());
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 9b870c8e0..900280ee9 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
@@ -37,8 +37,8 @@ public class TracXmlRpcClientSearchTest extends AbstractTracClientSearchTest {
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(username, result.get(0).getValue(Key.REPORTER));
+ assertEquals("milestone1", result.get(0).getValue(Key.MILESTONE));
+ assertEquals("anonymous", 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 5d527d8f3..8edf46eb8 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
@@ -32,7 +32,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
}
public void testValidateFailNoAuth() throws Exception {
- connect(Constants.TEST_REPOSITORY1_URL, "", "");
+ connect(Constants.TEST_TRAC_010_URL, "", "");
try {
repository.validate();
fail("Expected TracLoginException");
@@ -60,12 +60,12 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
return o1.getName().compareTo(o2.getName());
}
});
- assertEquals("v1", versions[0].getName());
- assertEquals("description1", versions[0].getDescription());
- assertEquals(new Date(86400 * 1000), versions[0].getTime());
- assertEquals("v2", versions[1].getName());
- assertEquals("description2", versions[1].getDescription());
- assertEquals(new Date(86400 * 2 * 1000), versions[1].getTime());
+ assertEquals("1.0", versions[0].getName());
+ assertEquals("", versions[0].getDescription());
+ assertEquals(new Date(0), versions[0].getTime());
+ assertEquals("2.0", versions[1].getName());
+ assertEquals("", versions[1].getDescription());
+ assertEquals(new Date(0), versions[1].getTime());
}
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcTest.java
index 3a7e88d9d..7cdd677e0 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcTest.java
@@ -25,14 +25,19 @@ import junit.framework.TestCase;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.Credentials;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.PrivilegeLevel;
import org.eclipse.mylar.internal.trac.core.TracHttpClientTransportFactory;
/**
* Test cases for <a href="http://trac-hacks.org/wiki/XmlRpcPlugin">Trac XML-RPC
- * Plugin</a> API. Revision 848 or higher is required.
+ * Plugin</a> API. Revision 1070 or higher is required.
*
* <p>
- * This class does not depend on any of the Mylar connector classes.
+ * This class does not depend on any Mylar (connector) classes except for
+ * TracHttpClientTransportFactory which is needed for initialization of
+ * HttpClient.
*
* @author Steffen Pingel
*/
@@ -48,13 +53,27 @@ public class TracXmlRpcTest extends TestCase {
private Random random;
+ private ArrayList<Integer> tickets;
+
+ @Override
protected void setUp() throws Exception {
super.setUp();
random = new Random();
- createConnection(new URL(Constants.TEST_REPOSITORY1_URL + XMLRPC_URL),
- Constants.TEST_REPOSITORY1_ADMIN_USERNAME, Constants.TEST_REPOSITORY1_ADMIN_PASSWORD);
+ Credentials credentials = MylarTestUtils.readCredentials(PrivilegeLevel.ADMIN);
+ createConnection(new URL(Constants.TEST_TRAC_010_URL + XMLRPC_URL), credentials.username, credentials.password);
+
+ tickets = new ArrayList<Integer>();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+
+ for (int id : tickets) {
+ call("ticket.delete", id);
+ }
}
private void createConnection(URL url, String username, String password) throws Exception {
@@ -63,10 +82,10 @@ public class TracXmlRpcTest extends TestCase {
config.setBasicUserName(username);
config.setBasicPassword(password);
config.setServerURL(url);
-
+
xmlrpc = new XmlRpcClient();
xmlrpc.setConfig(config);
-
+
TracHttpClientTransportFactory factory = new TracHttpClientTransportFactory(xmlrpc);
xmlrpc.setTransportFactory(factory);
@@ -74,8 +93,10 @@ public class TracXmlRpcTest extends TestCase {
// this.password = password;
}
- protected void tearDown() throws Exception {
- super.tearDown();
+ private int createTicket(String summary, String description, Map attributes) throws XmlRpcException, IOException {
+ int id = (Integer) call("ticket.create", summary, description, attributes);
+ tickets.add(id);
+ return id;
}
private Object call(String method, Object... parameters) throws XmlRpcException, IOException {
@@ -101,14 +122,15 @@ public class TracXmlRpcTest extends TestCase {
}
call(module + ".create", "foo", "bar");
+ try {
+ assertHasValue((Object[]) call(module + ".getAll"), "foo");
+ assertEquals("bar", (String) (call(module + ".get", "foo")));
- assertHasValue((Object[]) call(module + ".getAll"), "foo");
- assertEquals("bar", (String) (call(module + ".get", "foo")));
-
- call(module + ".update", "foo", "baz");
- assertEquals("baz", (String) (call(module + ".get", "foo")));
-
- call(module + ".delete", "foo");
+ call(module + ".update", "foo", "baz");
+ assertEquals("baz", (String) (call(module + ".get", "foo")));
+ } finally {
+ call(module + ".delete", "foo");
+ }
}
private Object createValue(Object fieldName, Object clazz) {
@@ -140,23 +162,25 @@ public class TracXmlRpcTest extends TestCase {
call(module + ".create", "foo", attributes);
- assertHasValue((Object[]) call(module + ".getAll"), "foo");
- Map values = (Map) call(module + ".get", "foo");
- for (String attribute : attributes.keySet()) {
- assertEquals(attributes.get(attribute), values.get(attribute));
- }
+ try {
+ assertHasValue((Object[]) call(module + ".getAll"), "foo");
+ Map values = (Map) call(module + ".get", "foo");
+ for (String attribute : attributes.keySet()) {
+ assertEquals(attributes.get(attribute), values.get(attribute));
+ }
- for (int i = 0; i < fields.length; i += 2) {
- attributes.put((String) fields[i], createValue(fields[i], fields[i + 1]));
- }
+ for (int i = 0; i < fields.length; i += 2) {
+ attributes.put((String) fields[i], createValue(fields[i], fields[i + 1]));
+ }
- call(module + ".update", "foo", attributes);
- values = (Map) call(module + ".get", "foo");
- for (String attribute : attributes.keySet()) {
- assertEquals(attributes.get(attribute), values.get(attribute));
+ call(module + ".update", "foo", attributes);
+ values = (Map) call(module + ".get", "foo");
+ for (String attribute : attributes.keySet()) {
+ assertEquals(attributes.get(attribute), values.get(attribute));
+ }
+ } finally {
+ call(module + ".delete", "foo");
}
-
- call(module + ".delete", "foo");
}
public void testMilestoneDate() throws XmlRpcException, IOException {
@@ -195,8 +219,7 @@ public class TracXmlRpcTest extends TestCase {
assertTicketHasAttributes(attributes, id, ticket, true);
}
- private void assertTicketHasAttributes(Map<String, Object> attributes, int id, Object[] ticket,
- boolean newTicket) {
+ private void assertTicketHasAttributes(Map<String, Object> attributes, int id, Object[] ticket, boolean newTicket) {
assertEquals(id, ticket[0]);
assertTrue(ticket[1] instanceof Integer); // time created
// time changed
@@ -215,15 +238,13 @@ public class TracXmlRpcTest extends TestCase {
Map<String, Object> attributes = new Hashtable<String, Object>();
attributes.put("type", "task");
attributes.put("status", "closed");
- int id = (Integer) call("ticket.create", "summary", "description", attributes);
+ int id = createTicket("summary", "description", attributes);
attributes.put("summary", "summary");
attributes.put("description", "description");
Object[] ticket = (Object[]) call("ticket.get", id);
assertTicketHasAttributes(attributes, id, ticket);
-
- call("ticket.delete", id);
}
public void testGetTicketNonExistant() throws XmlRpcException, IOException {
@@ -243,19 +264,17 @@ public class TracXmlRpcTest extends TestCase {
public void testGetTicketUmlaute() throws XmlRpcException, IOException {
Map<String, Object> attributes = new Hashtable<String, Object>();
- int id = (Integer) call("ticket.create", "summaryńÍ▄", "▀▀▀", attributes);
+ int id = createTicket("summaryńÍ▄", "▀▀▀", attributes);
attributes.put("summary", "summaryńÍ▄");
attributes.put("description", "▀▀▀");
Object[] ticket = (Object[]) call("ticket.get", id);
assertTicketHasAttributes(attributes, id, ticket);
-
- call("ticket.delete", id);
}
public void testUpdateTicket() throws XmlRpcException, IOException {
- int id = (Integer) call("ticket.create", "summary", "description", new Hashtable());
+ int id = createTicket("summary", "description", new Hashtable());
Map<String, Object> attributes = new Hashtable<String, Object>();
attributes.put("summary", "changed");
@@ -268,14 +287,12 @@ public class TracXmlRpcTest extends TestCase {
for (String attribute : attributes.keySet()) {
assertEquals(attributes.get(attribute), values.get(attribute));
}
-
- call("ticket.delete", id);
}
public void testTicketCustomFields() throws XmlRpcException, IOException {
Map<String, Object> attributes = new Hashtable<String, Object>();
attributes.put("custom_text_field", "myvalue");
- int id = (Integer) call("ticket.create", "summary", "description", attributes);
+ int id = createTicket("summary", "description", attributes);
// check for default values
attributes.put("custom_checkbox_field", "1");
@@ -296,12 +313,10 @@ public class TracXmlRpcTest extends TestCase {
ticket = (Object[]) call("ticket.get", id);
assertTicketHasAttributes(attributes, id, ticket, false);
-
- call("ticket.delete", id);
}
public void testGetChangeLog() throws XmlRpcException, IOException {
- int id = (Integer) call("ticket.create", "summary", "description", new Hashtable());
+ int id = createTicket("summary", "description", new Hashtable());
Map<String, Object> attributes = new Hashtable<String, Object>();
attributes.put("summary", "changed");
@@ -314,13 +329,11 @@ public class TracXmlRpcTest extends TestCase {
assertEquals("summary", entry[2]); // field
assertEquals("summary", entry[3]); // old value
assertEquals("changed", entry[4]); // new value
-
- call("ticket.delete", id);
}
public void testMultiGetTicket() throws XmlRpcException, IOException {
- int id1 = (Integer) call("ticket.create", "summary1", "description1", new Hashtable());
- int id2 = (Integer) call("ticket.create", "summary2", "description2", new Hashtable());
+ int id1 = createTicket("summary1", "description1", new Hashtable());
+ int id2 = createTicket("summary2", "description2", new Hashtable());
List<Map> calls = new ArrayList<Map>();
calls.add(createMultiCall("ticket.get", id1));
@@ -338,13 +351,10 @@ public class TracXmlRpcTest extends TestCase {
attributes.put("summary", "summary2");
attributes.put("description", "description2");
assertTicketHasAttributes(attributes, id2, ticket);
-
- call("ticket.delete", id1);
- call("ticket.delete", id2);
}
public void testAttachment() throws XmlRpcException, IOException {
- int id = (Integer) call("ticket.create", "summary", "description", new Hashtable());
+ int id = createTicket("summary", "description", new Hashtable());
String filename = (String) call("ticket.putAttachment", id, "attach.txt", "data".getBytes(), true);
// the returned filename may differ, since another ticket may have an
@@ -371,12 +381,10 @@ public class TracXmlRpcTest extends TestCase {
assertEquals(2, ret.length);
assertHasValue(ret, filename);
assertHasValue(ret, filename3);
-
- call("ticket.delete", id);
}
public void testDeleteAttachment() throws XmlRpcException, IOException {
- int id = (Integer) call("ticket.create", "summary", "description", new Hashtable());
+ int id = createTicket("summary", "description", new Hashtable());
String filename = (String) call("ticket.putAttachment", id, "attach.txt", "data".getBytes(), true);
@@ -388,53 +396,42 @@ public class TracXmlRpcTest extends TestCase {
ret = (Object[]) call("ticket.listAttachments", id);
assertEquals(0, ret.length);
-
- call("ticket.delete", id);
}
public void testQuery() throws XmlRpcException, IOException {
- Object[] ret = (Object[]) call("ticket.query", "summary~=foo|bar|baz|summary|ticket");
+ Object[] ret = (Object[]) call("ticket.query", "summary~=foo|bar|baz");
for (Object id : ret) {
call("ticket.delete", (Integer) id);
}
- int id1 = (Integer) call("ticket.create", "foobarsummary1", "description", new Hashtable());
- int id2 = (Integer) call("ticket.create", "foobaz summary2", "description", new Hashtable());
- int id3 = (Integer) call("ticket.create", "ticket3", "description3", new Hashtable());
+ int id1 = createTicket("foobarsum1", "description", new Hashtable());
+ int id2 = createTicket("foobaz sum2", "description", new Hashtable());
+ int id3 = createTicket("foobarbaz3", "foobarbaz description3", new Hashtable());
- ret = (Object[]) call("ticket.query", "summary=foobarsummary1|foobaz summary2");
+ ret = (Object[]) call("ticket.query", "summary=foobarsum1|foobaz sum2");
assertEquals(2, ret.length);
assertEquals(id1, ret[0]);
assertEquals(id2, ret[1]);
- ret = (Object[]) call("ticket.query", "summary~=fooba&summary~=summary");
- assertEquals(2, ret.length);
- assertEquals(id1, ret[0]);
- assertEquals(id2, ret[1]);
-
- // ret = (Vector) call("ticket.query", "summary~=bar&summary~=baz");
- // assertEquals(0, ret.size());
+ // the first criterium is ignored
+ ret = (Object[]) call("ticket.query", "summary~=foobarsum1&summary~=foobaz sum2");
+ assertEquals(1, ret.length);
+ assertEquals(id2, ret[0]);
ret = (Object[]) call("ticket.query", "summary~=bar|baz");
- assertEquals(2, ret.length);
+ assertEquals(3, ret.length);
- ret = (Object[]) call("ticket.query", "description~=description3");
+ ret = (Object[]) call("ticket.query", "description~=foobarbaz description3");
assertEquals(1, ret.length);
assertEquals(id3, ret[0]);
-
- call("ticket.delete", id1);
- call("ticket.delete", id2);
- call("ticket.delete", id3);
}
public void testQueryAll() throws XmlRpcException, IOException {
- int id = (Integer) call("ticket.create", "foo", "description", new Hashtable());
+ int id = createTicket("foo", "description", new Hashtable());
Object[] ret = (Object[]) call("ticket.query", "order=id");
assertTrue(ret.length > 0);
assertHasValue(ret, id);
-
- call("ticket.delete", id);
}
public void testPriorities() throws XmlRpcException, IOException {
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 ae2115472..eb93310bc 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
@@ -11,8 +11,10 @@
package org.eclipse.mylar.trac.tests.support;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.Credentials;
+import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.PrivilegeLevel;
import org.eclipse.mylar.trac.tests.Constants;
-import org.eclipse.mylar.trac.tests.support.XmlRpcServer.Ticket;
/**
* Initializes Trac repositories to a defined state. This is done once per test
@@ -23,40 +25,64 @@ import org.eclipse.mylar.trac.tests.support.XmlRpcServer.Ticket;
*/
public class TestFixture {
- public static XmlRpcServer.TestData data1;
+ public static XmlRpcServer.TestData data010;
- 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);
-
- server.ticketVersion(null).deleteAll();
- server.ticketVersion("v1").create(86400, "description1");
- server.ticketVersion("v2").create(86400 * 2, "description2");
+ /**
+ * Adds the existing repository content to the test data of
+ * <code>server</code>.
+ */
+ private static void initializeTestData(XmlRpcServer server) throws Exception {
+ server.ticketMilestone("milestone1").itemCreated();
+ server.ticketMilestone("milestone2").itemCreated();
+ server.ticketMilestone("milestone3").itemCreated();
+ server.ticketMilestone("milestone4").itemCreated();
- server.ticket().deleteAll();
+ server.ticketVersion("1.0").itemCreated();
+ server.ticketVersion("2.0").itemCreated();
- server.ticketMilestone("m1").deleteAndCreate();
- Ticket ticket = server.ticket().create("summary1", "description1");
- ticket.update("comment", "milestone", "m1");
+ server.ticket(1).itemCreated();
+ server.ticket(2).itemCreated();
+ server.ticket(3).itemCreated();
+ server.ticket(4).itemCreated();
+ }
- server.ticketMilestone("m2").deleteAndCreate();
- ticket = server.ticket().create("summary2", "description2");
- ticket.update("comment", "milestone", "m2");
- ticket = server.ticket().create("summary3", "description3");
- ticket.update("comment", "milestone", "m2");
+// private static void initializeRepository(XmlRpcServer server) throws Exception {
+// server.ticketVersion(null).deleteAll();
+// server.ticketVersion("1.0").create(0, "");
+// server.ticketVersion("2.0").create(0, "");
+//
+// server.ticketMilestone(null).deleteAll();
+// server.ticketMilestone("milestone1").create();
+// server.ticketMilestone("milestone2").create();
+// server.ticketMilestone("milestone3").create();
+// server.ticketMilestone("milestone4").create();
+//
+// server.ticket().deleteAll();
+// Ticket ticket = server.ticket().create("summary1", "description1");
+// ticket.update("comment", "milestone", "milestone1");
+// ticket = server.ticket().create("summary2", "description2");
+// ticket.update("comment", "milestone", "milestone2");
+// ticket = server.ticket().create("summary3", "description3");
+// ticket.update("comment", "milestone", "milestone2");
+// ticket = server.ticket().create("summary4", "description4");
+// }
- ticket = server.ticket().create("summary4", "description4");
+ public static XmlRpcServer.TestData init010() throws Exception {
+ if (data010 == null) {
+ Credentials credentials = MylarTestUtils.readCredentials(PrivilegeLevel.USER);
+ XmlRpcServer server = new XmlRpcServer(Constants.TEST_TRAC_010_URL, credentials.username,
+ credentials.password);
- data1 = server.getData();
+ initializeTestData(server);
+ data010 = server.getData();
}
- return data1;
+ return data010;
}
public static void cleanup010() throws Exception {
- if (data1 != null) {
- data1.cleanup();
- data1 = null;
+ if (data010 != null) {
+ // data010.cleanup();
+ data010 = null;
}
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/XmlRpcServer.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/XmlRpcServer.java
index 810733564..c6412d8a1 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/XmlRpcServer.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/XmlRpcServer.java
@@ -35,11 +35,11 @@ public class XmlRpcServer {
public abstract void delete() throws Exception;
- protected void itemCreated() {
+ void itemCreated() {
data.items.add(this);
}
- protected void itemDeleted() {
+ void itemDeleted() {
data.items.remove(this);
}

Back to the top