Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 47034 Details for
Bug 150456
Trac connector: refactor test cases to use repositories at mylar.eclipse.org
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Moves test utils to context.tests
mylar-trac-test-case-refactoring-patch-3.txt (text/plain), 56.06 KB, created by
Steffen Pingel
on 2006-07-30 18:10:19 EDT
(
hide
)
Description:
Moves test utils to context.tests
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2006-07-30 18:10:19 EDT
Size:
56.06 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.trac.tests >Index: src/org/eclipse/mylar/trac/tests/TracXmlRpcClientTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/TracXmlRpcClientTest.java,v >retrieving revision 1.3 >diff -u -r1.3 TracXmlRpcClientTest.java >--- src/org/eclipse/mylar/trac/tests/TracXmlRpcClientTest.java 27 Jul 2006 23:15:06 -0000 1.3 >+++ src/org/eclipse/mylar/trac/tests/TracXmlRpcClientTest.java 30 Jul 2006 22:10:32 -0000 >@@ -32,7 +32,7 @@ > } > > 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 @@ > 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()); > } > > } >Index: src/org/eclipse/mylar/trac/tests/AbstractTracClientRepositoryTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/AbstractTracClientRepositoryTest.java,v >retrieving revision 1.1 >diff -u -r1.1 AbstractTracClientRepositoryTest.java >--- src/org/eclipse/mylar/trac/tests/AbstractTracClientRepositoryTest.java 27 Jul 2006 23:15:06 -0000 1.1 >+++ src/org/eclipse/mylar/trac/tests/AbstractTracClientRepositoryTest.java 30 Jul 2006 22:10:31 -0000 >@@ -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 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"); >Index: src/org/eclipse/mylar/trac/tests/Trac09ClientTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/Trac09ClientTest.java,v >retrieving revision 1.3 >diff -u -r1.3 Trac09ClientTest.java >--- src/org/eclipse/mylar/trac/tests/Trac09ClientTest.java 27 Jul 2006 23:15:06 -0000 1.3 >+++ src/org/eclipse/mylar/trac/tests/Trac09ClientTest.java 30 Jul 2006 22:10:31 -0000 >@@ -28,12 +28,14 @@ > } > > 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 @@ > 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()); > } > > } >Index: src/org/eclipse/mylar/trac/tests/Constants.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/Constants.java,v >retrieving revision 1.3 >diff -u -r1.3 Constants.java >--- src/org/eclipse/mylar/trac/tests/Constants.java 27 Jul 2006 23:15:06 -0000 1.3 >+++ src/org/eclipse/mylar/trac/tests/Constants.java 30 Jul 2006 22:10:31 -0000 >@@ -16,22 +16,13 @@ > */ > 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"; >+ > > } >Index: src/org/eclipse/mylar/trac/tests/AbstractTracClientTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/AbstractTracClientTest.java,v >retrieving revision 1.2 >diff -u -r1.2 AbstractTracClientTest.java >--- src/org/eclipse/mylar/trac/tests/AbstractTracClientTest.java 27 Jul 2006 23:15:06 -0000 1.2 >+++ src/org/eclipse/mylar/trac/tests/AbstractTracClientTest.java 30 Jul 2006 22:10:31 -0000 >@@ -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 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 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 @@ > 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; > } > >Index: src/org/eclipse/mylar/trac/tests/TracXmlRpcClientSearchTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/TracXmlRpcClientSearchTest.java,v >retrieving revision 1.3 >diff -u -r1.3 TracXmlRpcClientSearchTest.java >--- src/org/eclipse/mylar/trac/tests/TracXmlRpcClientSearchTest.java 27 Jul 2006 23:15:06 -0000 1.3 >+++ src/org/eclipse/mylar/trac/tests/TracXmlRpcClientSearchTest.java 30 Jul 2006 22:10:32 -0000 >@@ -37,8 +37,8 @@ > 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)); > } >Index: src/org/eclipse/mylar/trac/tests/TracXmlRpcTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/TracXmlRpcTest.java,v >retrieving revision 1.8 >diff -u -r1.8 TracXmlRpcTest.java >--- src/org/eclipse/mylar/trac/tests/TracXmlRpcTest.java 27 Jul 2006 18:51:55 -0000 1.8 >+++ src/org/eclipse/mylar/trac/tests/TracXmlRpcTest.java 30 Jul 2006 22:10:32 -0000 >@@ -25,14 +25,19 @@ > 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 @@ > > 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 @@ > 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 @@ > // 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 @@ > } > > 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 @@ > > 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 @@ > 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 @@ > 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 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 @@ > 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 @@ > > 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 @@ > 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 @@ > 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 @@ > 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 @@ > > 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 { >Index: src/org/eclipse/mylar/trac/tests/AbstractTracClientSearchTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/AbstractTracClientSearchTest.java,v >retrieving revision 1.5 >diff -u -r1.5 AbstractTracClientSearchTest.java >--- src/org/eclipse/mylar/trac/tests/AbstractTracClientSearchTest.java 28 Jul 2006 00:59:37 -0000 1.5 >+++ src/org/eclipse/mylar/trac/tests/AbstractTracClientSearchTest.java 30 Jul 2006 22:10:31 -0000 >@@ -100,7 +100,7 @@ > > 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 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 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)); > } > >Index: src/org/eclipse/mylar/trac/tests/TracRepositoryConnectorTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/TracRepositoryConnectorTest.java,v >retrieving revision 1.9 >diff -u -r1.9 TracRepositoryConnectorTest.java >--- src/org/eclipse/mylar/trac/tests/TracRepositoryConnectorTest.java 27 Jul 2006 23:15:06 -0000 1.9 >+++ src/org/eclipse/mylar/trac/tests/TracRepositoryConnectorTest.java 30 Jul 2006 22:10:32 -0000 >@@ -20,11 +20,14 @@ > 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 @@ > // 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 @@ > 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 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 @@ > 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 @@ > 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 @@ > 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()); >Index: src/org/eclipse/mylar/trac/tests/TracClientFactoryTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/TracClientFactoryTest.java,v >retrieving revision 1.2 >diff -u -r1.2 TracClientFactoryTest.java >--- src/org/eclipse/mylar/trac/tests/TracClientFactoryTest.java 27 Jul 2006 18:51:55 -0000 1.2 >+++ src/org/eclipse/mylar/trac/tests/TracClientFactoryTest.java 30 Jul 2006 22:10:31 -0000 >@@ -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 @@ > */ > 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) { > } >Index: .refactorings/2006/7/30/refactorings.history >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/.refactorings/2006/7/30/refactorings.history,v >retrieving revision 1.1 >diff -u -r1.1 refactorings.history >--- .refactorings/2006/7/30/refactorings.history 27 Jul 2006 23:15:06 -0000 1.1 >+++ .refactorings/2006/7/30/refactorings.history 30 Jul 2006 22:10:30 -0000 >@@ -3,4 +3,6 @@ > <refactoring comment="Rename method 'org.eclipse.mylar.trac.tests.support.TracTestRepositoryFactory.connectRepository1()' to 'connect010' - Original element: 'org.eclipse.mylar.trac.tests.support.TracTestRepositoryFactory.connectRepository1()' - Renamed element: 'org.eclipse.mylar.trac.tests.support.TracTestRepositoryFactory.connect010()' - Update references to refactored element" delegate="false" deprecate="true" description="Rename method 'connectRepository1'" flags="589830" id="org.eclipse.jdt.ui.rename.method" input="/src<org.eclipse.mylar.trac.tests.support{TracTestRepositoryFactory.java[TracTestRepositoryFactory~connectRepository1" name="connect010" references="true" stamp="1154029296744" version="1.0"/> > <refactoring comment="Rename method 'org.eclipse.mylar.trac.tests.support.TestFixture.initializeRepository1()' to 'init010' - Original element: 'org.eclipse.mylar.trac.tests.support.TestFixture.initializeRepository1()' - Renamed element: 'org.eclipse.mylar.trac.tests.support.TestFixture.init010()' - Update references to refactored element" delegate="false" deprecate="true" description="Rename method 'initializeRepository1'" flags="589830" id="org.eclipse.jdt.ui.rename.method" input="/src<org.eclipse.mylar.trac.tests.support{TestFixture.java[TestFixture~initializeRepository1" name="init010" references="true" stamp="1154029842945" version="1.0"/> > <refactoring comment="Rename method 'org.eclipse.mylar.trac.tests.support.TestFixture.cleanupRepository1()' to 'cleanup010' - Original element: 'org.eclipse.mylar.trac.tests.support.TestFixture.cleanupRepository1()' - Renamed element: 'org.eclipse.mylar.trac.tests.support.TestFixture.cleanup010()' - Update references to refactored element" delegate="false" deprecate="true" description="Rename method 'cleanupRepository1'" flags="589830" id="org.eclipse.jdt.ui.rename.method" input="/src<org.eclipse.mylar.trac.tests.support{TestFixture.java[TestFixture~cleanupRepository1" name="cleanup010" references="true" stamp="1154029855355" version="1.0"/> >+<refactoring comment="Rename field 'TEST_REPOSITORY1_URL' in 'org.eclipse.mylar.trac.tests.Constants' to 'TEST_TRAC_010_URL' - Original element: 'org.eclipse.mylar.trac.tests.Constants.TEST_REPOSITORY1_URL' - Renamed element: 'org.eclipse.mylar.trac.tests.Constants.TEST_TRAC_010_URL' - Update references to refactored element - Update textual occurrences in comments and strings" delegate="false" deprecate="true" description="Rename field 'TEST_REPOSITORY1_URL'" flags="589830" getter="false" id="org.eclipse.jdt.ui.rename.field" input="/src<org.eclipse.mylar.trac.tests{Constants.java[Constants^TEST_REPOSITORY1_URL" name="TEST_TRAC_010_URL" references="true" setter="false" stamp="1154273808025" textual="false" version="1.0"/> >+<refactoring comment="Rename type 'org.eclipse.mylar.trac.tests.support.TracTestUtils' to 'MylarTestUtils' - Original element: 'org.eclipse.mylar.trac.tests.support.TracTestUtils' - Renamed element: 'org.eclipse.mylar.trac.tests.support.MylarTestUtils' - Update references to refactored element - Update textual occurrences in comments and strings" description="Rename type 'TracTestUtils'" flags="589830" id="org.eclipse.jdt.ui.rename.type" input="/src<org.eclipse.mylar.trac.tests.support{TracTestUtils.java[TracTestUtils" matchStrategy="1" name="MylarTestUtils" qualified="false" references="true" similarDeclarations="false" stamp="1154294077466" textual="false" version="1.0"/> > </session> >Index: .refactorings/2006/7/30/refactorings.index >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/.refactorings/2006/7/30/refactorings.index,v >retrieving revision 1.1 >diff -u -r1.1 refactorings.index >--- .refactorings/2006/7/30/refactorings.index 27 Jul 2006 23:15:06 -0000 1.1 >+++ .refactorings/2006/7/30/refactorings.index 30 Jul 2006 22:10:31 -0000 >@@ -1,3 +1,5 @@ > 1154029296744 Rename method 'connectRepository1' >+1154294077466 Rename type 'TracTestUtils' >+1154273808025 Rename field 'TEST_REPOSITORY1_URL' > 1154029855355 Rename method 'cleanupRepository1' > 1154029842945 Rename method 'initializeRepository1' >Index: src/org/eclipse/mylar/trac/tests/support/XmlRpcServer.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/support/XmlRpcServer.java,v >retrieving revision 1.4 >diff -u -r1.4 XmlRpcServer.java >--- src/org/eclipse/mylar/trac/tests/support/XmlRpcServer.java 27 Jul 2006 18:51:55 -0000 1.4 >+++ src/org/eclipse/mylar/trac/tests/support/XmlRpcServer.java 30 Jul 2006 22:10:33 -0000 >@@ -35,11 +35,11 @@ > > public abstract void delete() throws Exception; > >- protected void itemCreated() { >+ void itemCreated() { > data.items.add(this); > } > >- protected void itemDeleted() { >+ void itemDeleted() { > data.items.remove(this); > } > >Index: src/org/eclipse/mylar/trac/tests/support/TestFixture.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/support/TestFixture.java,v >retrieving revision 1.3 >diff -u -r1.3 TestFixture.java >--- src/org/eclipse/mylar/trac/tests/support/TestFixture.java 27 Jul 2006 23:15:06 -0000 1.3 >+++ src/org/eclipse/mylar/trac/tests/support/TestFixture.java 30 Jul 2006 22:10:33 -0000 >@@ -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 @@ > */ > 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"); >- >- server.ticket().deleteAll(); >- >- server.ticketMilestone("m1").deleteAndCreate(); >- Ticket ticket = server.ticket().create("summary1", "description1"); >- ticket.update("comment", "milestone", "m1"); >+ /** >+ * 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.ticketVersion("1.0").itemCreated(); >+ server.ticketVersion("2.0").itemCreated(); >+ >+ 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; > } > } > >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/META-INF/MANIFEST.MF,v >retrieving revision 1.10 >diff -u -r1.10 MANIFEST.MF >--- META-INF/MANIFEST.MF 27 Jul 2006 23:15:06 -0000 1.10 >+++ META-INF/MANIFEST.MF 30 Jul 2006 22:10:31 -0000 >@@ -10,7 +10,8 @@ > 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 >#P org.eclipse.mylar.bugzilla.tests >Index: src/org/eclipse/mylar/bugzilla/tests/RepositoryReportFactoryTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.tests/src/org/eclipse/mylar/bugzilla/tests/RepositoryReportFactoryTest.java,v >retrieving revision 1.20 >diff -u -r1.20 RepositoryReportFactoryTest.java >--- src/org/eclipse/mylar/bugzilla/tests/RepositoryReportFactoryTest.java 21 Jul 2006 19:25:52 -0000 1.20 >+++ src/org/eclipse/mylar/bugzilla/tests/RepositoryReportFactoryTest.java 30 Jul 2006 22:10:37 -0000 >@@ -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 @@ > > 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; > } > >Index: src/org/eclipse/mylar/bugzilla/tests/BugzillaRepositoryConnectorTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.tests/src/org/eclipse/mylar/bugzilla/tests/BugzillaRepositoryConnectorTest.java,v >retrieving revision 1.42 >diff -u -r1.42 BugzillaRepositoryConnectorTest.java >--- src/org/eclipse/mylar/bugzilla/tests/BugzillaRepositoryConnectorTest.java 28 Jul 2006 00:23:04 -0000 1.42 >+++ src/org/eclipse/mylar/bugzilla/tests/BugzillaRepositoryConnectorTest.java 30 Jul 2006 22:10:35 -0000 >@@ -13,19 +13,16 @@ > > 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 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 @@ > > 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); >Index: src/org/eclipse/mylar/bugzilla/tests/RepositoryEditorWizardTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.tests/src/org/eclipse/mylar/bugzilla/tests/RepositoryEditorWizardTest.java,v >retrieving revision 1.5 >diff -u -r1.5 RepositoryEditorWizardTest.java >--- src/org/eclipse/mylar/bugzilla/tests/RepositoryEditorWizardTest.java 14 Jul 2006 15:40:09 -0000 1.5 >+++ src/org/eclipse/mylar/bugzilla/tests/RepositoryEditorWizardTest.java 30 Jul 2006 22:10:36 -0000 >@@ -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 @@ > 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); > } >#P org.eclipse.mylar.context.tests >Index: .cvsignore >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.context.tests/.cvsignore,v >retrieving revision 1.1 >diff -u -r1.1 .cvsignore >--- .cvsignore 17 Jun 2005 20:51:19 -0000 1.1 >+++ .cvsignore 30 Jul 2006 22:10:38 -0000 >@@ -1 +1,2 @@ > bin >+credentials.properties >Index: src/org/eclipse/mylar/core/core/tests/support/MylarTestUtils.java >=================================================================== >RCS file: src/org/eclipse/mylar/core/core/tests/support/MylarTestUtils.java >diff -N src/org/eclipse/mylar/core/core/tests/support/MylarTestUtils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/core/core/tests/support/MylarTestUtils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,86 @@ >+/******************************************************************************* >+ * 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.core.core.tests.support; >+ >+import java.io.File; >+import java.io.FileInputStream; >+import java.net.URL; >+import java.util.Properties; >+ >+import junit.framework.AssertionFailedError; >+ >+import org.eclipse.core.runtime.FileLocator; >+import org.eclipse.mylar.core.core.tests.MylarCoreTestsPlugin; >+ >+/** >+ * @author Steffen Pingel >+ */ >+public class MylarTestUtils { >+ >+ public enum PrivilegeLevel { >+ ANONYMOUS, USER, ADMIN >+ }; >+ >+ public static class Credentials { >+ >+ public final String username; >+ >+ public final String password; >+ >+ public Credentials(String username, String password) { >+ this.username = username; >+ this.password = password; >+ } >+ >+ public Credentials(Properties properties, String prefix) { >+ this.username = properties.getProperty(prefix + "username"); >+ this.password = properties.getProperty(prefix + "password"); >+ >+ if (username == null || password == null) { >+ throw new AssertionFailedError( >+ "username or password not found in <plug-in dir>/credentials.properties, make sure file is valid"); >+ } >+ } >+ >+ } >+ >+ public static Credentials readCredentials() { >+ return readCredentials(PrivilegeLevel.USER, null); >+ } >+ >+ public static Credentials readCredentials(PrivilegeLevel level) { >+ return readCredentials(level, null); >+ } >+ >+ public static Credentials readCredentials(PrivilegeLevel level, String realm) { >+ if (level == PrivilegeLevel.ANONYMOUS) { >+ return new Credentials("", ""); >+ } >+ >+ Properties properties = new Properties(); >+ try { >+ URL localURL = FileLocator.toFileURL(MylarCoreTestsPlugin.getDefault().getBundle().getEntry( >+ "credentials.properties")); >+ properties.load(new FileInputStream(new File(localURL.getFile()))); >+ } catch (Exception e) { >+ throw new AssertionFailedError("must define credentials in <plug-in dir>/credentials.properties"); >+ } >+ >+ realm = (realm != null) ? realm + "." : ""; >+ if (level == PrivilegeLevel.ADMIN) { >+ return new Credentials(properties, realm + "admin."); >+ } else { >+ return new Credentials(properties, ""); >+ } >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 150456
:
47026
|
47027
|
47032
| 47034 |
47035