Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 289155 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java (+51 lines)
Lines 13-18 Link Here
13
13
14
import java.net.InetSocketAddress;
14
import java.net.InetSocketAddress;
15
import java.net.Proxy;
15
import java.net.Proxy;
16
import java.util.HashSet;
17
import java.util.Set;
16
18
17
import junit.framework.TestCase;
19
import junit.framework.TestCase;
18
20
Lines 20-31 Link Here
20
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
22
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
21
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
23
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
22
import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
24
import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
25
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
26
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttributeMapper;
23
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
27
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
24
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientFactory;
28
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientFactory;
25
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
29
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
26
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
30
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
27
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
31
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
32
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
33
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
34
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
28
import org.eclipse.mylyn.tasks.core.TaskRepository;
35
import org.eclipse.mylyn.tasks.core.TaskRepository;
36
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
37
import org.eclipse.mylyn.tasks.core.data.TaskData;
38
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
39
import org.eclipse.mylyn.tasks.ui.TasksUi;
29
40
30
/**
41
/**
31
 * @author Robert Elves
42
 * @author Robert Elves
Lines 34-41 Link Here
34
45
35
	private BugzillaClient client;
46
	private BugzillaClient client;
36
47
48
	private TaskRepository repository;
49
37
	@Override
50
	@Override
38
	protected void setUp() throws Exception {
51
	protected void setUp() throws Exception {
52
		repository = BugzillaFixture.current().singleRepository();
39
		client = BugzillaFixture.current().client();
53
		client = BugzillaFixture.current().client();
40
	}
54
	}
41
55
Lines 79-84 Link Here
79
		client.validate(new NullProgressMonitor());
93
		client.validate(new NullProgressMonitor());
80
	}
94
	}
81
95
96
	public void testCommentQuery() throws Exception {
97
		BugzillaAttributeMapper mapper = new BugzillaAttributeMapper(repository);
98
		TaskData newData = new TaskData(mapper, BugzillaFixture.current().getConnectorKind(), BugzillaFixture.current()
99
				.getRepositoryUrl(), "");
100
101
		AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(BugzillaFixture.current()
102
				.getConnectorKind());
103
		connector.getTaskDataHandler().initializeTaskData(repository, newData, null, new NullProgressMonitor());
104
		newData.getRoot().getMappedAttribute(TaskAttribute.SUMMARY).setValue("testCommentQuery()");
105
		newData.getRoot().getMappedAttribute(TaskAttribute.PRODUCT).setValue("TestProduct");
106
		newData.getRoot().getMappedAttribute(TaskAttribute.COMPONENT).setValue("TestComponent");
107
		newData.getRoot().getMappedAttribute(BugzillaAttribute.VERSION.getKey()).setValue("1");
108
		newData.getRoot().getMappedAttribute(BugzillaAttribute.OP_SYS.getKey()).setValue("All");
109
		long timestamp = System.currentTimeMillis();
110
		newData.getRoot().getMappedAttribute(TaskAttribute.DESCRIPTION).setValue("" + timestamp);
111
		RepositoryResponse response = client.postTaskData(newData, new NullProgressMonitor());
112
113
		String bugid = response.getTaskId();
114
		RepositoryQuery query = new RepositoryQuery(BugzillaFixture.current().getConnectorKind(), "123");
115
		query.setRepositoryUrl(BugzillaFixture.current().getRepositoryUrl());
116
		query.setUrl("?long_desc_type=allwordssubstr&long_desc=" + timestamp + "&bug_status=NEW&");
117
118
		final Set<TaskData> returnedData = new HashSet<TaskData>();
119
120
		TaskDataCollector collector = new TaskDataCollector() {
121
122
			@Override
123
			public void accept(TaskData taskData) {
124
				returnedData.add(taskData);
125
			}
126
		};
127
128
		client.getSearchHits(query, collector, mapper, new NullProgressMonitor());
129
		assertEquals(1, returnedData.size());
130
		assertEquals(bugid, returnedData.iterator().next().getTaskId());
131
	}
132
82
//	public void testCredentialsEncoding() throws IOException, BugzillaException, KeyManagementException,
133
//	public void testCredentialsEncoding() throws IOException, BugzillaException, KeyManagementException,
83
//			GeneralSecurityException {
134
//			GeneralSecurityException {
84
//		String poundSignUTF8 = BugzillaClient.addCredentials(IBugzillaTestConstants.TEST_BUGZILLA_222_URL, "UTF-8",
135
//		String poundSignUTF8 = BugzillaClient.addCredentials(IBugzillaTestConstants.TEST_BUGZILLA_222_URL, "UTF-8",
(-)src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java (-1 / +5 lines)
Lines 22-27 Link Here
22
import org.eclipse.mylyn.bugzilla.tests.BugzillaTestConstants;
22
import org.eclipse.mylyn.bugzilla.tests.BugzillaTestConstants;
23
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
23
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
24
import org.eclipse.mylyn.commons.net.AuthenticationType;
24
import org.eclipse.mylyn.commons.net.AuthenticationType;
25
import org.eclipse.mylyn.context.tests.support.TestUtil;
26
import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
27
import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
25
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
28
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
26
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientManager;
29
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientManager;
27
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
30
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
Lines 97-103 Link Here
97
	}
100
	}
98
101
99
	public BugzillaClient client() throws CoreException, IOException {
102
	public BugzillaClient client() throws CoreException, IOException {
100
		return client(getRepositoryUrl(), "", "", "", "", "UTF-8");
103
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
104
		return client(getRepositoryUrl(), credentials.username, credentials.password, "", "", "UTF-8");
101
	}
105
	}
102
106
103
	public BugzillaClient client(String hostUrl, String username, String password, String htAuthUser,
107
	public BugzillaClient client(String hostUrl, String username, String password, String htAuthUser,
(-)src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties (-1 / +1 lines)
Lines 97-103 Link Here
97
BugzillaOperation_Resolve_as=Resolve as
97
BugzillaOperation_Resolve_as=Resolve as
98
BugzillaOperation_Reassign_to_default_assignee=Reassign to default assignee
98
BugzillaOperation_Reassign_to_default_assignee=Reassign to default assignee
99
99
100
BugzillaRepositoryConnector_BUGZILLA_SUPPORTS_2_18_TO_3_0=Bugzilla (supports uncustomized 2.18-3.2)
100
BugzillaRepositoryConnector_BUGZILLA_CONNECTOR_LABEL=Bugzilla (supports 3.0 and later)
101
BugzillaRepositoryConnector_Check_repository_configuration=Check repository configuration: {0}
101
BugzillaRepositoryConnector_Check_repository_configuration=Check repository configuration: {0}
102
BugzillaRepositoryConnector_checking_for_changed_tasks=Checking for changed tasks
102
BugzillaRepositoryConnector_checking_for_changed_tasks=Checking for changed tasks
103
BugzillaRepositoryConnector_Query_for_changed_tasks=Query for changed tasks
103
BugzillaRepositoryConnector_Query_for_changed_tasks=Query for changed tasks
(-)src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java (-1 / +1 lines)
Lines 199-205 Link Here
199
199
200
	public static String BugzillaOperation_Reassign_to_default_assignee;
200
	public static String BugzillaOperation_Reassign_to_default_assignee;
201
201
202
	public static String BugzillaRepositoryConnector_BUGZILLA_SUPPORTS_2_18_TO_3_0;
202
	public static String BugzillaRepositoryConnector_BUGZILLA_CONNECTOR_LABEL;
203
203
204
	public static String BugzillaRepositoryConnector_Check_repository_configuration;
204
	public static String BugzillaRepositoryConnector_Check_repository_configuration;
205
205
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java (-1 / +1 lines)
Lines 62-68 Link Here
62
62
63
	private static final String CHANGED_BUGS_CGI_QUERY = "/buglist.cgi?query_format=advanced&chfieldfrom="; //$NON-NLS-1$
63
	private static final String CHANGED_BUGS_CGI_QUERY = "/buglist.cgi?query_format=advanced&chfieldfrom="; //$NON-NLS-1$
64
64
65
	private static final String CLIENT_LABEL = Messages.BugzillaRepositoryConnector_BUGZILLA_SUPPORTS_2_18_TO_3_0;
65
	private static final String CLIENT_LABEL = Messages.BugzillaRepositoryConnector_BUGZILLA_CONNECTOR_LABEL;
66
66
67
	private static final String COMMENT_FORMAT = "yyyy-MM-dd HH:mm"; //$NON-NLS-1$
67
	private static final String COMMENT_FORMAT = "yyyy-MM-dd HH:mm"; //$NON-NLS-1$
68
68
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java (+7 lines)
Lines 446-451 Link Here
446
						if (nameValue.length == 1) {
446
						if (nameValue.length == 1) {
447
							pairs.add(new NameValuePair(nameValue[0].trim(), "")); //$NON-NLS-1$
447
							pairs.add(new NameValuePair(nameValue[0].trim(), "")); //$NON-NLS-1$
448
						} else if (nameValue.length == 2 && nameValue[0] != null && nameValue[1] != null) {
448
						} else if (nameValue.length == 2 && nameValue[0] != null && nameValue[1] != null) {
449
450
							//Hack around bugzilla's change of attribute name for comment search field bug#289155
451
							if (nameValue[0].startsWith("long_desc")) {
452
								pairs.add(new NameValuePair(nameValue[0].replace("long_desc", "longdesc"),
453
										URLDecoder.decode(nameValue[1].trim(), getCharacterEncoding())));
454
							}
455
449
							pairs.add(new NameValuePair(nameValue[0].trim(), URLDecoder.decode(nameValue[1].trim(),
456
							pairs.add(new NameValuePair(nameValue[0].trim(), URLDecoder.decode(nameValue[1].trim(),
450
									getCharacterEncoding())));
457
									getCharacterEncoding())));
451
						}
458
						}

Return to bug 289155