|
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", |