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 46883 Details for
Bug 151896
Trac connector: update dependency to Apache XML-RPC 3.0
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]
Updates Trac connector dependency to Apache XML-RPC 3.0
mylar-trac-xmlrpc-3-patch.txt (text/plain), 53.79 KB, created by
Steffen Pingel
on 2006-07-27 11:18:43 EDT
(
hide
)
Description:
Updates Trac connector dependency to Apache XML-RPC 3.0
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2006-07-27 11:18:43 EDT
Size:
53.79 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.trac >Index: src/org/eclipse/mylar/internal/trac/MylarTracPlugin.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac/src/org/eclipse/mylar/internal/trac/MylarTracPlugin.java,v >retrieving revision 1.6 >diff -u -r1.6 MylarTracPlugin.java >--- src/org/eclipse/mylar/internal/trac/MylarTracPlugin.java 14 Jul 2006 15:37:11 -0000 1.6 >+++ src/org/eclipse/mylar/internal/trac/MylarTracPlugin.java 27 Jul 2006 14:54:01 -0000 >@@ -23,8 +23,10 @@ > import javax.net.ssl.HttpsURLConnection; > import javax.net.ssl.SSLContext; > >+import org.apache.commons.httpclient.protocol.Protocol; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.mylar.context.core.MylarStatusHandler; >+import org.eclipse.mylar.internal.tasks.core.SslProtocolSocketFactory; > import org.eclipse.mylar.internal.tasks.ui.views.TaskRepositoriesView; > import org.eclipse.mylar.internal.trac.core.TracException; > import org.eclipse.mylar.internal.trac.core.TracLoginException; >@@ -54,6 +56,15 @@ > > public void start(BundleContext context) throws Exception { > super.start(context); >+ >+ // TODO the protocol configuration of HttpClient should not be registered globally >+ Protocol acceptAllSsl = new Protocol("https", new SslProtocolSocketFactory(), 443); >+ Protocol.registerProtocol("https", acceptAllSsl); >+ >+ // TODO the logging configuration of HttpClient should be done elsewhere >+ System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); >+ System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header", "off"); >+ System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "off"); > } > > public void stop(BundleContext context) throws Exception { >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac/META-INF/MANIFEST.MF,v >retrieving revision 1.18 >diff -u -r1.18 MANIFEST.MF >--- META-INF/MANIFEST.MF 26 Jul 2006 16:07:25 -0000 1.18 >+++ META-INF/MANIFEST.MF 27 Jul 2006 14:54:01 -0000 >@@ -10,7 +10,6 @@ > org.eclipse.core.runtime, > org.eclipse.mylar.context.core, > org.eclipse.mylar.tasks.ui, >- org.apache.xmlrpc, > org.eclipse.mylar.tasks.core > Eclipse-LazyStart: true > Export-Package: org.eclipse.mylar.internal.trac, >Index: src/org/eclipse/mylar/internal/trac/core/TracXmlRpcClient.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac/src/org/eclipse/mylar/internal/trac/core/TracXmlRpcClient.java,v >retrieving revision 1.2 >diff -u -r1.2 TracXmlRpcClient.java >--- src/org/eclipse/mylar/internal/trac/core/TracXmlRpcClient.java 14 Jul 2006 15:37:11 -0000 1.2 >+++ src/org/eclipse/mylar/internal/trac/core/TracXmlRpcClient.java 27 Jul 2006 14:54:02 -0000 >@@ -1,26 +1,20 @@ > package org.eclipse.mylar.internal.trac.core; > >-import java.io.IOException; >-import java.io.InputStream; >-import java.io.OutputStream; > import java.net.HttpURLConnection; > import java.net.URL; > import java.util.ArrayList; > import java.util.Collections; >-import java.util.Hashtable; >+import java.util.HashMap; > import java.util.List; >-import java.util.Vector; >+import java.util.Map; > >-import org.apache.xmlrpc.XmlRpc; >-import org.apache.xmlrpc.XmlRpcClient; >-import org.apache.xmlrpc.XmlRpcClientException; > import org.apache.xmlrpc.XmlRpcException; >-import org.apache.xmlrpc.XmlRpcTransport; >-import org.apache.xmlrpc.XmlRpcTransportFactory; >+import org.apache.xmlrpc.client.XmlRpcClient; >+import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.OperationCanceledException; > import org.eclipse.mylar.context.core.MylarStatusHandler; >-import org.eclipse.mylar.internal.trac.MylarTracPlugin; >+import org.eclipse.mylar.internal.trac.core.TracHttpClientTransportFactory.TracHttpException; > import org.eclipse.mylar.internal.trac.model.TracComponent; > import org.eclipse.mylar.internal.trac.model.TracMilestone; > import org.eclipse.mylar.internal.trac.model.TracPriority; >@@ -52,9 +46,22 @@ > return xmlrpc; > } > >- // initialize XML-RPC library >- XmlRpc.setDefaultInputEncoding(ITracClient.CHARSET); >+ XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); >+ config.setEncoding(ITracClient.CHARSET); >+ config.setBasicUserName(username); >+ config.setBasicPassword(password); >+ config.setServerURL(getXmlRpcUrl()); >+ >+ xmlrpc = new XmlRpcClient(); >+ xmlrpc.setConfig(config); >+ >+ TracHttpClientTransportFactory factory = new TracHttpClientTransportFactory(xmlrpc); >+ xmlrpc.setTransportFactory(factory); > >+ return xmlrpc; >+ } >+ >+ private URL getXmlRpcUrl() throws TracException { > try { > String location = repositoryUrl.toString(); > if (hasAuthenticationCredentials()) { >@@ -62,29 +69,20 @@ > } > location += XMLRPC_URL; > >- URL url = new URL(location); >- TransportFactory transport = new TransportFactory(url); >- xmlrpc = new XmlRpcClient(url, transport); >+ return new URL(location); > } catch (Exception e) { > throw new TracException(e); > } >- >- return xmlrpc; > } > > private Object call(String method, Object... parameters) throws TracException { > getClient(); > >- Vector<Object> params = new Vector<Object>(); >- for (Object parameter : parameters) { >- params.add(parameter); >- } >- > try { >- return xmlrpc.execute(method, params); >- } catch (HttpException e) { >- if (e.responseCode == HttpURLConnection.HTTP_FORBIDDEN >- || e.responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) { >+ return xmlrpc.execute(method, parameters); >+ } catch (TracHttpException e) { >+ if (e.code == HttpURLConnection.HTTP_FORBIDDEN >+ || e.code == HttpURLConnection.HTTP_UNAUTHORIZED) { > throw new TracLoginException(); > } else { > throw new TracException(e); >@@ -96,8 +94,8 @@ > } > } > >- private Vector multicall(Hashtable<String, Object>... calls) throws TracException { >- Vector result = (Vector) call("system.multicall", new Object[] { calls }); >+ private Object[] multicall(Map<String, Object>... calls) throws TracException { >+ Object[] result = (Object[]) call("system.multicall", new Object[] { calls }); > for (Object item : result) { > try { > checkForException(item); >@@ -111,8 +109,8 @@ > } > > private void checkForException(Object result) throws NumberFormatException, XmlRpcException { >- if (result instanceof Hashtable) { >- Hashtable exceptionData = (Hashtable) result; >+ if (result instanceof Map) { >+ Map exceptionData = (Map) result; > if (exceptionData.containsKey("faultCode") && exceptionData.containsKey("faultString")) { > throw new XmlRpcException(Integer.parseInt(exceptionData.get("faultCode").toString()), > (String) exceptionData.get("faultString")); >@@ -120,19 +118,19 @@ > } > } > >- private Hashtable<String, Object> createMultiCall(String methodName, Object... parameters) throws TracException { >- Hashtable<String, Object> table = new Hashtable<String, Object>(); >+ private Map<String, Object> createMultiCall(String methodName, Object... parameters) throws TracException { >+ Map<String, Object> table = new HashMap<String, Object>(); > table.put("methodName", methodName); > table.put("params", parameters); > return table; > } > > private Object getMultiCallResult(Object item) { >- return ((Vector) item).get(0); >+ return ((Object[]) item)[0]; > } > > public void validate() throws TracException { >- Vector result = (Vector) call("system.listMethods"); >+ Object[] result = (Object[]) call("system.listMethods"); > boolean hasGetTicket = false, hasQuery = false; > for (Object methodName : result) { > if ("ticket.get".equals(methodName)) { >@@ -151,23 +149,23 @@ > } > > public TracTicket getTicket(int id) throws TracException { >- Vector result = (Vector) call("ticket.get", id); >+ Object[] result = (Object[]) call("ticket.get", id); > return parseTicket(result); > } > > @SuppressWarnings("unchecked") > public List<TracTicket> getTickets(int[] ids) throws TracException { >- Hashtable<String, Object>[] calls = new Hashtable[ids.length]; >+ Map<String, Object>[] calls = new Map[ids.length]; > for (int i = 0; i < calls.length; i++) { > calls[i] = createMultiCall("ticket.get", ids[i]); > } > >- Vector result = multicall(calls); >- assert result.size() == ids.length; >+ Object[] result = multicall(calls); >+ assert result.length == ids.length; > >- List<TracTicket> tickets = new ArrayList<TracTicket>(result.size()); >+ List<TracTicket> tickets = new ArrayList<TracTicket>(result.length); > for (Object item : result) { >- Vector ticketResult = (Vector) getMultiCallResult(item); >+ Object[] ticketResult = (Object[]) getMultiCallResult(item); > tickets.add(parseTicket(ticketResult)); > } > >@@ -177,25 +175,25 @@ > @SuppressWarnings("unchecked") > public void search(TracSearch query, List<TracTicket> tickets) throws TracException { > // an empty query string is not valid, therefore prepend order >- Vector result = (Vector) call("ticket.query", "order=id" + query.toQuery()); >+ Object[] result = (Object[]) call("ticket.query", "order=id" + query.toQuery()); > >- Hashtable<String, Object>[] calls = new Hashtable[result.size()]; >+ Map<String, Object>[] calls = new Map[result.length]; > for (int i = 0; i < calls.length; i++) { >- calls[i] = createMultiCall("ticket.get", result.get(i)); >+ calls[i] = createMultiCall("ticket.get", result[i]); > } > result = multicall(calls); > > for (Object item : result) { >- Vector ticketResult = (Vector) getMultiCallResult(item); >+ Object[] ticketResult = (Object[]) getMultiCallResult(item); > tickets.add(parseTicket(ticketResult)); > } > } > >- private TracTicket parseTicket(Vector result) throws InvalidTicketException { >- TracTicket ticket = new TracTicket((Integer) result.get(0)); >- ticket.setCreated((Integer) result.get(1)); >- ticket.setLastChanged((Integer) result.get(2)); >- Hashtable attributes = (Hashtable) result.get(3); >+ private TracTicket parseTicket(Object[] ticketResult) throws InvalidTicketException { >+ TracTicket ticket = new TracTicket((Integer) ticketResult[0]); >+ ticket.setCreated((Integer) ticketResult[1]); >+ ticket.setLastChanged((Integer) ticketResult[2]); >+ Map attributes = (Map) ticketResult[3]; > for (Object key : attributes.keySet()) { > ticket.putTracValue(key.toString(), attributes.get(key).toString()); > } >@@ -205,26 +203,26 @@ > public synchronized void updateAttributes(IProgressMonitor monitor) throws TracException { > monitor.beginTask("Updating attributes", 8); > >- Vector result = getAttributes("ticket.component"); >- components = new ArrayList<TracComponent>(result.size()); >+ Object[] result = getAttributes("ticket.component"); >+ components = new ArrayList<TracComponent>(result.length); > for (Object item : result) { >- components.add(parseComponent((Hashtable) getMultiCallResult(item))); >+ components.add(parseComponent((Map) getMultiCallResult(item))); > } > monitor.worked(1); > if (monitor.isCanceled()) > throw new OperationCanceledException(); > > result = getAttributes("ticket.milestone"); >- milestones = new ArrayList<TracMilestone>(result.size()); >+ milestones = new ArrayList<TracMilestone>(result.length); > for (Object item : result) { >- milestones.add(parseMilestone((Hashtable) getMultiCallResult(item))); >+ milestones.add(parseMilestone((Map) getMultiCallResult(item))); > } > monitor.worked(1); > if (monitor.isCanceled()) > throw new OperationCanceledException(); > > List<TicketAttributeResult> attributes = getTicketAttributes("ticket.priority"); >- priorities = new ArrayList<TracPriority>(result.size()); >+ priorities = new ArrayList<TracPriority>(result.length); > for (TicketAttributeResult attribute : attributes) { > priorities.add(new TracPriority(attribute.name, attribute.value)); > } >@@ -234,7 +232,7 @@ > throw new OperationCanceledException(); > > attributes = getTicketAttributes("ticket.resolution"); >- ticketResolutions = new ArrayList<TracTicketResolution>(result.size()); >+ ticketResolutions = new ArrayList<TracTicketResolution>(result.length); > for (TicketAttributeResult attribute : attributes) { > ticketResolutions.add(new TracTicketResolution(attribute.name, attribute.value)); > } >@@ -244,7 +242,7 @@ > throw new OperationCanceledException(); > > attributes = getTicketAttributes("ticket.severity"); >- severities = new ArrayList<TracSeverity>(result.size()); >+ severities = new ArrayList<TracSeverity>(result.length); > for (TicketAttributeResult attribute : attributes) { > severities.add(new TracSeverity(attribute.name, attribute.value)); > } >@@ -254,7 +252,7 @@ > throw new OperationCanceledException(); > > attributes = getTicketAttributes("ticket.status"); >- ticketStatus = new ArrayList<TracTicketStatus>(result.size()); >+ ticketStatus = new ArrayList<TracTicketStatus>(result.length); > for (TicketAttributeResult attribute : attributes) { > ticketStatus.add(new TracTicketStatus(attribute.name, attribute.value)); > } >@@ -264,7 +262,7 @@ > throw new OperationCanceledException(); > > attributes = getTicketAttributes("ticket.type"); >- ticketTypes = new ArrayList<TracTicketType>(result.size()); >+ ticketTypes = new ArrayList<TracTicketType>(result.length); > for (TicketAttributeResult attribute : attributes) { > ticketTypes.add(new TracTicketType(attribute.name, attribute.value)); > } >@@ -274,23 +272,23 @@ > throw new OperationCanceledException(); > > result = getAttributes("ticket.version"); >- versions = new ArrayList<TracVersion>(result.size()); >+ versions = new ArrayList<TracVersion>(result.length); > for (Object item : result) { >- versions.add(parseVersion((Hashtable) getMultiCallResult(item))); >+ versions.add(parseVersion((Map) getMultiCallResult(item))); > } > monitor.worked(1); > if (monitor.isCanceled()) > throw new OperationCanceledException(); > } > >- private TracComponent parseComponent(Hashtable result) { >+ private TracComponent parseComponent(Map result) { > TracComponent component = new TracComponent((String) result.get("name")); > component.setOwner((String) result.get("owner")); > component.setDescription((String) result.get("description")); > return component; > } > >- private TracMilestone parseMilestone(Hashtable result) { >+ private TracMilestone parseMilestone(Map result) { > TracMilestone milestone = new TracMilestone((String) result.get("name")); > milestone.setCompleted(TracUtils.parseDate((Integer) result.get("completed"))); > milestone.setDue(TracUtils.parseDate((Integer) result.get("due"))); >@@ -298,7 +296,7 @@ > return milestone; > } > >- private TracVersion parseVersion(Hashtable result) { >+ private TracVersion parseVersion(Map result) { > TracVersion version = new TracVersion((String) result.get("name")); > version.setTime(TracUtils.parseDate((Integer) result.get("time"))); > version.setDescription((String) result.get("description")); >@@ -306,36 +304,36 @@ > } > > @SuppressWarnings("unchecked") >- private Vector getAttributes(String attributeType) throws TracException { >- Vector ids = (Vector) call(attributeType + ".getAll"); >- Hashtable<String, Object>[] calls = new Hashtable[ids.size()]; >+ private Object[] getAttributes(String attributeType) throws TracException { >+ Object[] ids = (Object[]) call(attributeType + ".getAll"); >+ Map<String, Object>[] calls = new Map[ids.length]; > for (int i = 0; i < calls.length; i++) { >- calls[i] = createMultiCall(attributeType + ".get", ids.get(i)); >+ calls[i] = createMultiCall(attributeType + ".get", ids[i]); > } > >- Vector result = multicall(calls); >- assert result.size() == ids.size(); >+ Object[] result = multicall(calls); >+ assert result.length == ids.length; > > return result; > } > > @SuppressWarnings("unchecked") > private List<TicketAttributeResult> getTicketAttributes(String attributeType) throws TracException { >- Vector ids = (Vector) call(attributeType + ".getAll"); >- Hashtable<String, Object>[] calls = new Hashtable[ids.size()]; >+ Object[] ids = (Object[]) call(attributeType + ".getAll"); >+ Map<String, Object>[] calls = new Map[ids.length]; > for (int i = 0; i < calls.length; i++) { >- calls[i] = createMultiCall(attributeType + ".get", ids.get(i)); >+ calls[i] = createMultiCall(attributeType + ".get", ids[i]); > } > >- Vector result = multicall(calls); >- assert result.size() == ids.size(); >+ Object[] result = multicall(calls); >+ assert result.length == ids.length; > >- List<TicketAttributeResult> attributes = new ArrayList<TicketAttributeResult>(result.size()); >+ List<TicketAttributeResult> attributes = new ArrayList<TicketAttributeResult>(result.length); > for (int i = 0; i < calls.length; i++) { > try { > TicketAttributeResult attribute = new TicketAttributeResult(); >- attribute.name = (String) ids.get(i); >- attribute.value = Integer.parseInt((String) getMultiCallResult(result.get(i))); >+ attribute.name = (String) ids[i]; >+ attribute.value = Integer.parseInt((String) getMultiCallResult(result[i])); > attributes.add(attribute); > } catch (NumberFormatException e) { > MylarStatusHandler.log(e, "Invalid response from Trac repository for attribute type: '" + attributeType >@@ -354,90 +352,4 @@ > > } > >- /** >- * A custom transport factory used to establish XML-RPC connections. Uses >- * the Eclipse proxy settings. >- * >- * @author Steffen Pingel >- */ >- private class TransportFactory implements XmlRpcTransportFactory { >- >- private URL url; >- >- public TransportFactory(URL url) { >- assert url != null; >- >- this.url = url; >- } >- >- public XmlRpcTransport createTransport() throws XmlRpcClientException { >- return new XmlRpcTransport() { >- >- private HttpURLConnection connection; >- >- public void endClientRequest() throws XmlRpcClientException { >- assert connection != null; >- >- try { >- connection.getInputStream().close(); >- } catch (Exception e) { >- throw new XmlRpcClientException("Exception closing connection", e); >- } >- } >- >- public InputStream sendXmlRpc(byte[] request) throws IOException, XmlRpcClientException { >- try { >- connection = MylarTracPlugin.getHttpConnection(url); >- } catch (Exception e) { >- throw new IOException(e.toString()); >- } >- >- connection.setDoInput(true); >- connection.setDoOutput(true); >- connection.setUseCaches(false); >- connection.setAllowUserInteraction(false); >- >- connection.setRequestProperty("Content-Length", request.length + ""); >- connection.setRequestProperty("Content-Type", "text/xml"); >- if (hasAuthenticationCredentials()) { >- MylarTracPlugin.setAuthCredentials(connection, username, password); >- } >- >- OutputStream out = connection.getOutputStream(); >- out.write(request); >- out.flush(); >- out.close(); >- >- connection.connect(); >- int responseCode = connection.getResponseCode(); >- if (responseCode != HttpURLConnection.HTTP_OK) { >- throw new HttpException(responseCode); >- } >- >- return connection.getInputStream(); >- } >- >- }; >- } >- >- public void setProperty(String key, Object value) { >- // ignore, this is never called by the library >- } >- >- } >- >- private class HttpException extends IOException { >- >- private static final long serialVersionUID = 7083228933121822248L; >- >- final int responseCode; >- >- public HttpException(int responseCode) { >- super("HTTP Error " + responseCode); >- >- this.responseCode = responseCode; >- } >- >- } >- > } >Index: src/org/eclipse/mylar/internal/trac/core/TracHttpClientTransportFactory.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/trac/core/TracHttpClientTransportFactory.java >diff -N src/org/eclipse/mylar/internal/trac/core/TracHttpClientTransportFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/trac/core/TracHttpClientTransportFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,105 @@ >+/******************************************************************************* >+ * 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.internal.trac.core; >+ >+import java.io.InputStream; >+import java.lang.reflect.Field; >+import java.net.HttpURLConnection; >+import java.net.InetSocketAddress; >+import java.net.Proxy; >+ >+import org.apache.commons.httpclient.HttpClient; >+import org.apache.commons.httpclient.methods.PostMethod; >+import org.apache.xmlrpc.XmlRpcException; >+import org.apache.xmlrpc.client.XmlRpcClient; >+import org.apache.xmlrpc.client.XmlRpcCommonsTransport; >+import org.apache.xmlrpc.client.XmlRpcHttpClientConfig; >+import org.apache.xmlrpc.client.XmlRpcTransport; >+import org.apache.xmlrpc.client.XmlRpcTransportFactoryImpl; >+import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+ >+/** >+ * @author Steffen Pingel >+ */ >+public class TracHttpClientTransportFactory extends XmlRpcTransportFactoryImpl { >+ >+ public static class TracHttpException extends XmlRpcException { >+ >+ private static final long serialVersionUID = 9032521978140685830L; >+ >+ public TracHttpException(int responseCode) { >+ super(responseCode, "HTTP Error " + responseCode); >+ } >+ >+ } >+ >+ /** >+ * A transport that uses the Apache HttpClient library. >+ */ >+ public static class TracHttpClientTransport extends XmlRpcCommonsTransport { >+ >+ public TracHttpClientTransport(XmlRpcClient client) { >+ super(client); >+ >+ Proxy proxySettings = TasksUiPlugin.getDefault().getProxySettings(); >+ if (proxySettings != null && proxySettings.address() instanceof InetSocketAddress) { >+ InetSocketAddress address = (InetSocketAddress) proxySettings.address(); >+ getHttpClient().getHostConfiguration().setProxy(address.getHostName(), address.getPort()); >+ } >+ >+ XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) client.getConfig(); >+ // this needs to be set to avoid exceptions >+ getHttpClient().getParams().setAuthenticationPreemptive(config.getBasicUserName() != null); >+ } >+ >+ public HttpClient getHttpClient() { >+ return (HttpClient) getValue("client"); >+ } >+ >+ @Override >+ protected InputStream getInputStream() throws XmlRpcException { >+ int responseCode = getMethod().getStatusCode(); >+ if (responseCode != HttpURLConnection.HTTP_OK) { >+ throw new TracHttpException(responseCode); >+ } >+ >+ return super.getInputStream(); >+ } >+ >+ public PostMethod getMethod() { >+ return (PostMethod) getValue("method"); >+ } >+ >+ private Object getValue(String name) { >+ try { >+ Field field = XmlRpcCommonsTransport.class.getDeclaredField(name); >+ field.setAccessible(true); >+ return field.get(this); >+ } catch (Throwable t) { >+ throw new RuntimeException("Internal error accessing HttpClient", t); >+ } >+ } >+ >+ } >+ >+ private final TracHttpClientTransport transport; >+ >+ public TracHttpClientTransportFactory(XmlRpcClient client) { >+ super(client); >+ >+ transport = new TracHttpClientTransport(client); >+ } >+ >+ public XmlRpcTransport getTransport() { >+ return transport; >+ } >+} >#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.1 >diff -u -r1.1 TracXmlRpcClientTest.java >--- src/org/eclipse/mylar/trac/tests/TracXmlRpcClientTest.java 5 Jul 2006 05:40:29 -0000 1.1 >+++ src/org/eclipse/mylar/trac/tests/TracXmlRpcClientTest.java 27 Jul 2006 14:54:04 -0000 >@@ -12,12 +12,17 @@ > package org.eclipse.mylar.trac.tests; > > import java.net.URL; >+import java.util.Arrays; >+import java.util.Comparator; >+import java.util.Date; > >+import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.mylar.internal.trac.core.ITracClient; > import org.eclipse.mylar.internal.trac.core.TracLoginException; > import org.eclipse.mylar.internal.trac.core.TracRemoteException; > import org.eclipse.mylar.internal.trac.core.TracXmlRpcClient; > import org.eclipse.mylar.internal.trac.core.ITracClient.Version; >+import org.eclipse.mylar.internal.trac.model.TracVersion; > import org.eclipse.mylar.trac.tests.support.AbstractTracRepositoryFactory; > > /** >@@ -51,4 +56,23 @@ > } > } > >+ public void testUpdateAttributes() throws Exception { >+ factory.connectRepository1(); >+ assertNull(factory.repository.getMilestones()); >+ factory.repository.updateAttributes(new NullProgressMonitor()); >+ TracVersion[] versions = factory.repository.getVersions(); >+ assertEquals(2, versions.length); >+ Arrays.sort(versions, new Comparator<TracVersion>() { >+ public int compare(TracVersion o1, TracVersion o2) { >+ 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()); >+ } >+ > } >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.7 >diff -u -r1.7 TracXmlRpcTest.java >--- src/org/eclipse/mylar/trac/tests/TracXmlRpcTest.java 14 Jul 2006 15:40:59 -0000 1.7 >+++ src/org/eclipse/mylar/trac/tests/TracXmlRpcTest.java 27 Jul 2006 14:54:04 -0000 >@@ -13,21 +13,19 @@ > > import java.io.IOException; > import java.net.URL; >+import java.util.ArrayList; > import java.util.Date; > import java.util.Hashtable; >+import java.util.List; >+import java.util.Map; > import java.util.Random; >-import java.util.Vector; >- >-import javax.net.ssl.HttpsURLConnection; >-import javax.net.ssl.SSLContext; > > import junit.framework.TestCase; > >-import org.apache.xmlrpc.DefaultXmlRpcTransportFactory; >-import org.apache.xmlrpc.XmlRpc; >-import org.apache.xmlrpc.XmlRpcClient; > import org.apache.xmlrpc.XmlRpcException; >-import org.eclipse.mylar.internal.trac.TrustAll; >+import org.apache.xmlrpc.client.XmlRpcClient; >+import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; >+import org.eclipse.mylar.internal.trac.core.TracHttpClientTransportFactory; > > /** > * Test cases for <a href="http://trac-hacks.org/wiki/XmlRpcPlugin">Trac XML-RPC >@@ -55,33 +53,23 @@ > > random = new Random(); > >- XmlRpc.setDefaultInputEncoding("UTF-8"); >- > createConnection(new URL(Constants.TEST_REPOSITORY1_URL + XMLRPC_URL), > Constants.TEST_REPOSITORY1_ADMIN_USERNAME, Constants.TEST_REPOSITORY1_ADMIN_PASSWORD); > } > > @SuppressWarnings("deprecation") > private void createConnection(URL url, String username, String password) throws Exception { >- if (url.toString().startsWith("https")) { >- DefaultXmlRpcTransportFactory transport = new DefaultXmlRpcTransportFactory(url); >- transport.setBasicAuthentication(username, password); >- >- SSLContext ctx = SSLContext.getInstance("TLS"); >- >- javax.net.ssl.TrustManager[] tm = new javax.net.ssl.TrustManager[] { new TrustAll() }; >- ctx.init(null, tm, null); >- HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory()); >- >- xmlrpc = new XmlRpcClient(url, transport); >- } else { >- xmlrpc = new XmlRpcClient(url); >- >- // the XML-RPC library is kind of broken: setting authentication >- // credentials for >- // http connections is only possible through a deprecated method >- xmlrpc.setBasicAuthentication(username, password); >- } >+ XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); >+ config.setEncoding("UTF-8"); >+ config.setBasicUserName(username); >+ config.setBasicPassword(password); >+ config.setServerURL(url); >+ >+ xmlrpc = new XmlRpcClient(); >+ xmlrpc.setConfig(config); >+ >+ TracHttpClientTransportFactory factory = new TracHttpClientTransportFactory(xmlrpc); >+ xmlrpc.setTransportFactory(factory); > > this.username = username; > // this.password = password; >@@ -92,21 +80,16 @@ > } > > private Object call(String method, Object... parameters) throws XmlRpcException, IOException { >- Vector<Object> params = new Vector<Object>(); >- for (Object parameter : parameters) { >- params.add(parameter); >- } >- >- Object result = xmlrpc.execute(method, params); >+ Object result = xmlrpc.execute(method, parameters); > if (result instanceof XmlRpcException) { > throw (XmlRpcException) result; > } > return result; > } > >- public Hashtable<String, Object> createMultiCall(String methodName, Object... parameters) throws XmlRpcException, >+ public Map<String, Object> createMultiCall(String methodName, Object... parameters) throws XmlRpcException, > IOException { >- Hashtable<String, Object> table = new Hashtable<String, Object>(); >+ Map<String, Object> table = new Hashtable<String, Object>(); > table.put("methodName", methodName); > table.put("params", parameters); > return table; >@@ -120,7 +103,7 @@ > > call(module + ".create", "foo", "bar"); > >- assertHasValue(((Vector) call(module + ".getAll")).toArray(), "foo"); >+ assertHasValue((Object[]) call(module + ".getAll"), "foo"); > assertEquals("bar", (String) (call(module + ".get", "foo"))); > > call(module + ".update", "foo", "baz"); >@@ -151,15 +134,15 @@ > } catch (XmlRpcException e) { > } > >- Hashtable<String, Object> attributes = new Hashtable<String, Object>(); >+ Map<String, Object> attributes = new Hashtable<String, Object>(); > for (int i = 0; i < fields.length; i += 2) { > attributes.put((String) fields[i], createValue(fields[i], fields[i + 1])); > } > > call(module + ".create", "foo", attributes); > >- assertHasValue(((Vector) call(module + ".getAll")).toArray(), "foo"); >- Hashtable values = (Hashtable) call(module + ".get", "foo"); >+ 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)); > } >@@ -169,7 +152,7 @@ > } > > call(module + ".update", "foo", attributes); >- values = (Hashtable) call(module + ".get", "foo"); >+ values = (Map) call(module + ".get", "foo"); > for (String attribute : attributes.keySet()) { > assertEquals(attributes.get(attribute), values.get(attribute)); > } >@@ -186,14 +169,14 @@ > int due = (int) (System.currentTimeMillis() / 1000) + 1000; > int completed = (int) (System.currentTimeMillis() / 1000); > >- Hashtable<String, Object> attributes = new Hashtable<String, Object>(); >+ Map<String, Object> attributes = new Hashtable<String, Object>(); > attributes.put("description", "description"); > attributes.put("due", due); > attributes.put("completed", completed); > > call("ticket.milestone.create", "foo", attributes); > >- Hashtable values = (Hashtable) call("ticket.milestone.get", "foo"); >+ Map values = (Map) call("ticket.milestone.get", "foo"); > assertEquals(new Integer(due), (Integer) values.get("due")); > assertEquals(new Integer(completed), (Integer) values.get("completed")); > >@@ -209,28 +192,28 @@ > fail("Could not find expected value: " + value); > } > >- private void assertTicketHasAttributes(Hashtable<String, Object> attributes, int id, Vector ticket) { >+ private void assertTicketHasAttributes(Map<String, Object> attributes, int id, Object[] ticket) { > assertTicketHasAttributes(attributes, id, ticket, true); > } > >- private void assertTicketHasAttributes(Hashtable<String, Object> attributes, int id, Vector ticket, >+ private void assertTicketHasAttributes(Map<String, Object> attributes, int id, Object[] ticket, > boolean newTicket) { >- assertEquals(id, ticket.get(0)); >- assertTrue(ticket.get(1) instanceof Integer); // time created >+ assertEquals(id, ticket[0]); >+ assertTrue(ticket[1] instanceof Integer); // time created > // time changed > if (newTicket) { >- assertEquals(ticket.get(1), ticket.get(2)); >+ assertEquals(ticket[1], ticket[2]); > } else { >- assertTrue((Integer) ticket.get(2) >= (Integer) ticket.get(1)); >+ assertTrue((Integer) ticket[2] >= (Integer) ticket[1]); > } >- Hashtable values = (Hashtable) ticket.get(3); >+ Map values = (Map) ticket[3]; > for (String attribute : attributes.keySet()) { > assertEquals(attributes.get(attribute), values.get(attribute)); > } > } > > public void testGetTicket() throws XmlRpcException, IOException { >- Hashtable<String, Object> attributes = new Hashtable<String, Object>(); >+ 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); >@@ -238,7 +221,7 @@ > attributes.put("summary", "summary"); > attributes.put("description", "description"); > >- Vector ticket = (Vector) call("ticket.get", id); >+ Object[] ticket = (Object[]) call("ticket.get", id); > assertTicketHasAttributes(attributes, id, ticket); > > call("ticket.delete", id); >@@ -252,7 +235,7 @@ > } > > try { >- Vector ticket = (Vector) call("ticket.get", Integer.MAX_VALUE); >+ List ticket = (List) call("ticket.get", Integer.MAX_VALUE); > fail("Expected XmlRpcException, got ticket instead: " + ticket); > } catch (XmlRpcException e) { > // ignore >@@ -260,13 +243,13 @@ > } > > public void testGetTicketUmlaute() throws XmlRpcException, IOException { >- Hashtable<String, Object> attributes = new Hashtable<String, Object>(); >+ Map<String, Object> attributes = new Hashtable<String, Object>(); > int id = (Integer) call("ticket.create", "summaryäÖÜ", "ßßß", attributes); > > attributes.put("summary", "summaryäÖÜ"); > attributes.put("description", "ßßß"); > >- Vector ticket = (Vector) call("ticket.get", id); >+ Object[] ticket = (Object[]) call("ticket.get", id); > assertTicketHasAttributes(attributes, id, ticket); > > call("ticket.delete", id); >@@ -275,14 +258,14 @@ > public void testUpdateTicket() throws XmlRpcException, IOException { > int id = (Integer) call("ticket.create", "summary", "description", new Hashtable()); > >- Hashtable<String, Object> attributes = new Hashtable<String, Object>(); >+ Map<String, Object> attributes = new Hashtable<String, Object>(); > attributes.put("summary", "changed"); > call("ticket.update", id, "my comment", attributes); > > attributes.put("description", "description"); > >- Vector ticket = (Vector) call("ticket.get", id); >- Hashtable values = (Hashtable) ticket.get(3); >+ Object[] ticket = (Object[]) call("ticket.get", id); >+ Map values = (Map) ticket[3]; > for (String attribute : attributes.keySet()) { > assertEquals(attributes.get(attribute), values.get(attribute)); > } >@@ -291,7 +274,7 @@ > } > > public void testTicketCustomFields() throws XmlRpcException, IOException { >- Hashtable<String, Object> attributes = new Hashtable<String, Object>(); >+ Map<String, Object> attributes = new Hashtable<String, Object>(); > attributes.put("custom_text_field", "myvalue"); > int id = (Integer) call("ticket.create", "summary", "description", attributes); > >@@ -301,7 +284,7 @@ > attributes.put("custom_radio_field", "baz"); > attributes.put("custom_textarea_field", "default text"); > >- Vector ticket = (Vector) call("ticket.get", id); >+ Object[] ticket = (Object[]) call("ticket.get", id); > assertTicketHasAttributes(attributes, id, ticket); > > attributes.put("custom_text_field", "myvalue2"); >@@ -312,7 +295,7 @@ > > call("ticket.update", id, "my comment", attributes); > >- ticket = (Vector) call("ticket.get", id); >+ ticket = (Object[]) call("ticket.get", id); > assertTicketHasAttributes(attributes, id, ticket, false); > > call("ticket.delete", id); >@@ -321,17 +304,17 @@ > public void testGetChangeLog() throws XmlRpcException, IOException { > int id = (Integer) call("ticket.create", "summary", "description", new Hashtable()); > >- Hashtable<String, Object> attributes = new Hashtable<String, Object>(); >+ Map<String, Object> attributes = new Hashtable<String, Object>(); > attributes.put("summary", "changed"); > call("ticket.update", id, "my comment", attributes); > >- Vector log = (Vector) call("ticket.changeLog", id, 0); >- Vector entry = (Vector) log.get(0); >- assertTrue(entry.get(0) instanceof Integer); // time >- assertEquals(username, entry.get(1)); // author >- assertEquals("summary", entry.get(2)); // field >- assertEquals("summary", entry.get(3)); // old value >- assertEquals("changed", entry.get(4)); // new value >+ Object[] log = (Object[]) call("ticket.changeLog", id, 0); >+ Object[] entry = (Object[]) log[0]; >+ assertTrue(entry[0] instanceof Integer); // time >+ assertEquals(username, entry[1]); // author >+ assertEquals("summary", entry[2]); // field >+ assertEquals("summary", entry[3]); // old value >+ assertEquals("changed", entry[4]); // new value > > call("ticket.delete", id); > } >@@ -340,18 +323,18 @@ > int id1 = (Integer) call("ticket.create", "summary1", "description1", new Hashtable()); > int id2 = (Integer) call("ticket.create", "summary2", "description2", new Hashtable()); > >- Vector<Hashtable> calls = new Vector<Hashtable>(); >+ List<Map> calls = new ArrayList<Map>(); > calls.add(createMultiCall("ticket.get", id1)); > calls.add(createMultiCall("ticket.get", id2)); >- Vector ret = (Vector) call("system.multicall", calls); >+ Object[] ret = (Object[]) call("system.multicall", calls); > >- Vector ticket = (Vector) ((Vector) ret.get(0)).get(0); >- Hashtable<String, Object> attributes = new Hashtable<String, Object>(); >+ Object[] ticket = (Object[]) ((Object[]) ret[0])[0]; >+ Map<String, Object> attributes = new Hashtable<String, Object>(); > attributes.put("summary", "summary1"); > attributes.put("description", "description1"); > assertTicketHasAttributes(attributes, id1, ticket); > >- ticket = (Vector) ((Vector) ret.get(1)).get(0); >+ ticket = (Object[]) ((Object[]) ret[1])[0]; > attributes.clear(); > attributes.put("summary", "summary2"); > attributes.put("description", "description2"); >@@ -369,9 +352,9 @@ > // attachment named "attach.txt" > // assertEquals("attach.txt", filename); > >- Vector ret = (Vector) call("ticket.listAttachments", id); >- assertEquals(1, ret.size()); >- assertHasValue(ret.toArray(), filename); >+ Object[] ret = (Object[]) call("ticket.listAttachments", id); >+ assertEquals(1, ret.length); >+ assertHasValue(ret, filename); > > byte[] bytes = (byte[]) call("ticket.getAttachment", id, filename); > String data = new String(bytes); >@@ -379,16 +362,16 @@ > > String filename2 = (String) call("ticket.putAttachment", id, filename, "data".getBytes(), true); > assertEquals(filename, filename2); >- ret = (Vector) call("ticket.listAttachments", id); >- assertEquals(1, ret.size()); >- assertHasValue(ret.toArray(), filename); >+ ret = (Object[]) call("ticket.listAttachments", id); >+ assertEquals(1, ret.length); >+ assertHasValue(ret, filename); > > String filename3 = (String) call("ticket.putAttachment", id, "attach.txt", "data".getBytes(), false); > assertFalse("attach.txt".equals(filename3)); >- ret = (Vector) call("ticket.listAttachments", id); >- assertEquals(2, ret.size()); >- assertHasValue(ret.toArray(), filename); >- assertHasValue(ret.toArray(), filename3); >+ ret = (Object[]) call("ticket.listAttachments", id); >+ assertEquals(2, ret.length); >+ assertHasValue(ret, filename); >+ assertHasValue(ret, filename3); > > call("ticket.delete", id); > } >@@ -398,20 +381,20 @@ > > String filename = (String) call("ticket.putAttachment", id, "attach.txt", "data".getBytes(), true); > >- Vector ret = (Vector) call("ticket.listAttachments", id); >- assertEquals(1, ret.size()); >- assertHasValue(ret.toArray(), filename); >+ Object[] ret = (Object[]) call("ticket.listAttachments", id); >+ assertEquals(1, ret.length); >+ assertHasValue(ret, filename); > > call("ticket.deleteAttachment", id, filename); > >- ret = (Vector) call("ticket.listAttachments", id); >- assertEquals(0, ret.size()); >+ ret = (Object[]) call("ticket.listAttachments", id); >+ assertEquals(0, ret.length); > > call("ticket.delete", id); > } > > public void testQuery() throws XmlRpcException, IOException { >- Vector ret = (Vector) call("ticket.query", "summary~=foo|bar|baz|summary|ticket"); >+ Object[] ret = (Object[]) call("ticket.query", "summary~=foo|bar|baz|summary|ticket"); > for (Object id : ret) { > call("ticket.delete", (Integer) id); > } >@@ -420,25 +403,25 @@ > int id2 = (Integer) call("ticket.create", "foobaz summary2", "description", new Hashtable()); > int id3 = (Integer) call("ticket.create", "ticket3", "description3", new Hashtable()); > >- ret = (Vector) call("ticket.query", "summary=foobarsummary1|foobaz summary2"); >- assertEquals(2, ret.size()); >- assertEquals(ret.get(0), id1); >- assertEquals(ret.get(1), id2); >- >- ret = (Vector) call("ticket.query", "summary~=fooba&summary~=summary"); >- assertEquals(2, ret.size()); >- assertEquals(ret.get(0), id1); >- assertEquals(ret.get(1), id2); >+ ret = (Object[]) call("ticket.query", "summary=foobarsummary1|foobaz summary2"); >+ 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()); > >- ret = (Vector) call("ticket.query", "summary~=bar|baz"); >- assertEquals(2, ret.size()); >+ ret = (Object[]) call("ticket.query", "summary~=bar|baz"); >+ assertEquals(2, ret.length); > >- ret = (Vector) call("ticket.query", "description~=description3"); >- assertEquals(1, ret.size()); >- assertEquals(ret.get(0), id3); >+ ret = (Object[]) call("ticket.query", "description~=description3"); >+ assertEquals(1, ret.length); >+ assertEquals(id3, ret[0]); > > call("ticket.delete", id1); > call("ticket.delete", id2); >@@ -448,9 +431,9 @@ > public void testQueryAll() throws XmlRpcException, IOException { > int id = (Integer) call("ticket.create", "foo", "description", new Hashtable()); > >- Vector ret = (Vector) call("ticket.query", "order=id"); >- assertTrue(ret.size() > 0); >- assertHasValue(ret.toArray(), id); >+ Object[] ret = (Object[]) call("ticket.query", "order=id"); >+ assertTrue(ret.length > 0); >+ assertHasValue(ret, id); > > call("ticket.delete", id); > } >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.2 >diff -u -r1.2 AbstractTracClientSearchTest.java >--- src/org/eclipse/mylar/trac/tests/AbstractTracClientSearchTest.java 6 Jul 2006 15:09:13 -0000 1.2 >+++ src/org/eclipse/mylar/trac/tests/AbstractTracClientSearchTest.java 27 Jul 2006 14:54:03 -0000 >@@ -12,7 +12,6 @@ > package org.eclipse.mylar.trac.tests; > > import java.util.ArrayList; >-import java.util.Hashtable; > import java.util.List; > import java.util.Map; > >@@ -61,7 +60,7 @@ > protected void assertTicketEquals(Ticket ticket, TracTicket tracTicket) throws Exception { > assertTrue(tracTicket.isValid()); > >- Hashtable expectedValues = ticket.getValues(); >+ Map expectedValues = ticket.getValues(); > Map<String, String> values = tracTicket.getValues(); > for (String key : values.keySet()) { > assertEquals("Values for key '" + key + "' did not match", expectedValues.get(key), values.get(key)); >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.1 >diff -u -r1.1 Trac09ClientTest.java >--- src/org/eclipse/mylar/trac/tests/Trac09ClientTest.java 5 Jul 2006 05:40:29 -0000 1.1 >+++ src/org/eclipse/mylar/trac/tests/Trac09ClientTest.java 27 Jul 2006 14:54:03 -0000 >@@ -12,10 +12,14 @@ > package org.eclipse.mylar.trac.tests; > > import java.net.URL; >+import java.util.Arrays; >+import java.util.Comparator; > >+import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.mylar.internal.trac.core.ITracClient; > import org.eclipse.mylar.internal.trac.core.Trac09Client; > import org.eclipse.mylar.internal.trac.core.ITracClient.Version; >+import org.eclipse.mylar.internal.trac.model.TracVersion; > import org.eclipse.mylar.trac.tests.support.AbstractTracRepositoryFactory; > > /** >@@ -36,4 +40,20 @@ > factory.repository.validate(); > } > >+ public void testUpdateAttributes() throws Exception { >+ factory.connectRepository1(); >+ assertNull(factory.repository.getMilestones()); >+ factory.repository.updateAttributes(new NullProgressMonitor()); >+ TracVersion[] versions = factory.repository.getVersions(); >+ assertEquals(2, versions.length); >+ Arrays.sort(versions, new Comparator<TracVersion>() { >+ public int compare(TracVersion o1, TracVersion o2) { >+ return o1.getName().compareTo(o2.getName()); >+ } >+ }); >+ assertEquals("v1", versions[0].getName()); >+ assertEquals("v2", versions[1].getName()); >+ } >+ >+ > } >Index: src/org/eclipse/mylar/trac/tests/AllTracTests.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.trac.tests/src/org/eclipse/mylar/trac/tests/AllTracTests.java,v >retrieving revision 1.7 >diff -u -r1.7 AllTracTests.java >--- src/org/eclipse/mylar/trac/tests/AllTracTests.java 14 Jul 2006 15:40:59 -0000 1.7 >+++ src/org/eclipse/mylar/trac/tests/AllTracTests.java 27 Jul 2006 14:54:03 -0000 >@@ -22,8 +22,8 @@ > > public static Test suite() { > TestSuite suite = new TestSuite("Test for org.eclipse.mylar.trac.tests"); >- //$JUnit-BEGIN$ >- suite.addTestSuite(TracXmlRpcTest.class); >+ // $JUnit-BEGIN$ >+ // suite.addTestSuite(TracXmlRpcTest.class); > suite.addTestSuite(TracSearchTest.class); > suite.addTestSuite(TracTicketTest.class); > suite.addTestSuite(TracXmlRpcClientTest.class); >@@ -33,7 +33,8 @@ > suite.addTestSuite(TracClientFactoryTest.class); > suite.addTestSuite(TracRepositoryConnectorTest.class); > suite.addTestSuite(TracQueryTest.class); >- //$JUnit-END$ >+ suite.addTestSuite(TracRepositoryQueryTest.class); >+ // $JUnit-END$ > return suite; > } > >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.1 >diff -u -r1.1 TracClientFactoryTest.java >--- src/org/eclipse/mylar/trac/tests/TracClientFactoryTest.java 5 Jul 2006 05:40:29 -0000 1.1 >+++ src/org/eclipse/mylar/trac/tests/TracClientFactoryTest.java 27 Jul 2006 14:54:03 -0000 >@@ -11,6 +11,8 @@ > > package org.eclipse.mylar.trac.tests; > >+import java.net.Authenticator; >+ > import junit.framework.TestCase; > > import org.eclipse.mylar.internal.trac.core.ITracClient; >@@ -26,6 +28,14 @@ > */ > 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", > "password"); >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.8 >diff -u -r1.8 MANIFEST.MF >--- META-INF/MANIFEST.MF 14 Jul 2006 17:13:26 -0000 1.8 >+++ META-INF/MANIFEST.MF 27 Jul 2006 14:54:03 -0000 >@@ -7,7 +7,7 @@ > Require-Bundle: org.junit, > org.eclipse.ui, > org.eclipse.core.runtime, >- org.apache.xmlrpc, >+ org.eclipse.mylar.context.core, > org.eclipse.mylar.tasks.ui, > org.eclipse.mylar.trac, > org.eclipse.mylar.tasks.core >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.3 >diff -u -r1.3 XmlRpcServer.java >--- src/org/eclipse/mylar/trac/tests/support/XmlRpcServer.java 6 Jul 2006 15:09:13 -0000 1.3 >+++ src/org/eclipse/mylar/trac/tests/support/XmlRpcServer.java 27 Jul 2006 14:54:05 -0000 >@@ -18,10 +18,11 @@ > import java.util.Arrays; > import java.util.Hashtable; > import java.util.List; >+import java.util.Map; > import java.util.Vector; > >-import org.apache.xmlrpc.XmlRpcClient; > import org.apache.xmlrpc.XmlRpcException; >+import org.apache.xmlrpc.client.XmlRpcClient; > import org.eclipse.mylar.internal.trac.core.TracXmlRpcClient; > import org.eclipse.mylar.internal.trac.core.ITracClient.Version; > >@@ -80,12 +81,8 @@ > } > > public ModelEnum deleteAndCreate(Object... params) throws Exception { >- try { >- if (Arrays.asList(getAll()).contains(id)) { >- delete(); >- } >- } catch (Exception e) { >- // ignore >+ if (Arrays.asList(getAll()).contains(id)) { >+ delete(); > } > > return create(params); >@@ -102,7 +99,7 @@ > > @SuppressWarnings("unchecked") > public String[] getAll() throws Exception { >- return (String[]) ((Vector) call(module + ".getAll")).toArray(new String[0]); >+ return Arrays.asList((Object[]) call(module + ".getAll")).toArray(new String[0]); > } > > private Hashtable<String, Object> toMap(Object... params) { >@@ -178,13 +175,13 @@ > return getValues().get(key); > } > >- public Hashtable getValues() throws Exception { >- return (Hashtable) ((Vector) call("ticket.get", id)).get(3); >+ public Map getValues() throws Exception { >+ return (Map) ((Object[]) call("ticket.get", id))[3]; > } > > @SuppressWarnings("unchecked") > public Integer[] getAll() throws Exception { >- return (Integer[]) ((Vector) call("ticket.query", "order=id")).toArray(new Integer[0]); >+ return Arrays.asList((Object[]) call("ticket.query", "order=id")).toArray(new Integer[0]); > } > > public int getId() { >@@ -245,12 +242,8 @@ > } > > public TicketEnum deleteAndCreate(String param) throws Exception { >- try { >- if (Arrays.asList(getAll()).contains(id)) { >- delete(); >- } >- } catch (Exception e) { >- // ignore >+ if (Arrays.asList(getAll()).contains(id)) { >+ delete(); > } > > return create(param); >@@ -262,7 +255,7 @@ > > @SuppressWarnings("unchecked") > public String[] getAll() throws Exception { >- return (String[]) ((Vector) call(module + ".getAll")).toArray(new String[0]); >+ return Arrays.asList((Object[]) call(module + ".getAll")).toArray(new String[0]); > } > > public TicketEnum update(String param) throws Exception { >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.1 >diff -u -r1.1 TestFixture.java >--- src/org/eclipse/mylar/trac/tests/support/TestFixture.java 6 Jul 2006 15:09:13 -0000 1.1 >+++ src/org/eclipse/mylar/trac/tests/support/TestFixture.java 27 Jul 2006 14:54:04 -0000 >@@ -30,6 +30,10 @@ > 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(); >Index: src/org/eclipse/mylar/trac/tests/TracRepositoryQueryTest.java >=================================================================== >RCS file: src/org/eclipse/mylar/trac/tests/TracRepositoryQueryTest.java >diff -N src/org/eclipse/mylar/trac/tests/TracRepositoryQueryTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/trac/tests/TracRepositoryQueryTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,46 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 - 2006 Mylar eclipse.org project and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Mylar project committers - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.trac.tests; >+ >+import java.util.Arrays; >+import java.util.List; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.mylar.internal.trac.TracRepositoryQuery; >+import org.eclipse.mylar.internal.trac.core.ITracClient; >+import org.eclipse.mylar.internal.trac.model.TracSearch; >+import org.eclipse.mylar.internal.trac.model.TracSearchFilter; >+ >+public class TracRepositoryQueryTest extends TestCase { >+ >+ public void testGetFilterList() { >+ String repositoryUrl = "https://foo.bar/repo"; >+ String parameterUrl = "&status=new&status=assigned&status=reopened&milestone=0.1"; >+ String queryUrl = repositoryUrl + ITracClient.QUERY_URL + parameterUrl; >+ TracRepositoryQuery query = new TracRepositoryQuery(repositoryUrl, queryUrl, "description", null); >+ >+ TracSearch filterList = query.getTracSearch(); >+ >+ assertEquals(parameterUrl, filterList.toUrl()); >+ assertEquals("&status=new|assigned|reopened&milestone=0.1", filterList.toQuery()); >+ >+ List<TracSearchFilter> list = filterList.getFilters(); >+ TracSearchFilter filter = list.get(0); >+ assertEquals("status", filter.getFieldName()); >+ assertEquals(Arrays.asList("new", "assigned", "reopened"), filter.getValues()); >+ filter = list.get(1); >+ assertEquals("milestone", filter.getFieldName()); >+ assertEquals(Arrays.asList("0.1"), filter.getValues()); >+ } >+ >+}
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 151896
:
46883
|
46898
|
46922