|
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; |
|
|
30 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaVersion; |
| 26 |
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants; |
31 |
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants; |
| 27 |
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration; |
32 |
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration; |
|
|
33 |
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery; |
| 34 |
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; |
| 35 |
import org.eclipse.mylyn.tasks.core.RepositoryResponse; |
| 28 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
36 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
|
|
37 |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
| 38 |
import org.eclipse.mylyn.tasks.core.data.TaskData; |
| 39 |
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector; |
| 40 |
import org.eclipse.mylyn.tasks.ui.TasksUi; |
| 29 |
|
41 |
|
| 30 |
/** |
42 |
/** |
| 31 |
* @author Robert Elves |
43 |
* @author Robert Elves |
|
Lines 34-41
Link Here
|
| 34 |
|
46 |
|
| 35 |
private BugzillaClient client; |
47 |
private BugzillaClient client; |
| 36 |
|
48 |
|
|
|
49 |
private TaskRepository repository; |
| 50 |
|
| 37 |
@Override |
51 |
@Override |
| 38 |
protected void setUp() throws Exception { |
52 |
protected void setUp() throws Exception { |
|
|
53 |
repository = BugzillaFixture.current().singleRepository(); |
| 39 |
client = BugzillaFixture.current().client(); |
54 |
client = BugzillaFixture.current().client(); |
| 40 |
} |
55 |
} |
| 41 |
|
56 |
|
|
Lines 79-84
Link Here
|
| 79 |
client.validate(new NullProgressMonitor()); |
94 |
client.validate(new NullProgressMonitor()); |
| 80 |
} |
95 |
} |
| 81 |
|
96 |
|
|
|
97 |
public void testCommentQuery() throws Exception { |
| 98 |
BugzillaAttributeMapper mapper = new BugzillaAttributeMapper(repository); |
| 99 |
TaskData newData = new TaskData(mapper, BugzillaFixture.current().getConnectorKind(), BugzillaFixture.current() |
| 100 |
.getRepositoryUrl(), ""); |
| 101 |
|
| 102 |
AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(BugzillaFixture.current() |
| 103 |
.getConnectorKind()); |
| 104 |
connector.getTaskDataHandler().initializeTaskData(repository, newData, null, new NullProgressMonitor()); |
| 105 |
newData.getRoot().getMappedAttribute(TaskAttribute.SUMMARY).setValue("testCommentQuery()"); |
| 106 |
newData.getRoot().getMappedAttribute(TaskAttribute.PRODUCT).setValue("TestProduct"); |
| 107 |
newData.getRoot().getMappedAttribute(TaskAttribute.COMPONENT).setValue("TestComponent"); |
| 108 |
newData.getRoot().getMappedAttribute(BugzillaAttribute.VERSION.getKey()).setValue("1"); |
| 109 |
newData.getRoot().getMappedAttribute(BugzillaAttribute.OP_SYS.getKey()).setValue("All"); |
| 110 |
long timestamp = System.currentTimeMillis(); |
| 111 |
newData.getRoot().getMappedAttribute(TaskAttribute.DESCRIPTION).setValue("" + timestamp); |
| 112 |
RepositoryResponse response = client.postTaskData(newData, new NullProgressMonitor()); |
| 113 |
|
| 114 |
String bugid = response.getTaskId(); |
| 115 |
RepositoryQuery query = new RepositoryQuery(BugzillaFixture.current().getConnectorKind(), "123"); |
| 116 |
query.setRepositoryUrl(BugzillaFixture.current().getRepositoryUrl()); |
| 117 |
query.setUrl("?short_desc_type=allwordssubstr&short_desc=&long_desc_type=allwordssubstr&long_desc=" + timestamp |
| 118 |
+ "&bug_status=NEW"); |
| 119 |
|
| 120 |
final Set<TaskData> returnedData = new HashSet<TaskData>(); |
| 121 |
|
| 122 |
TaskDataCollector collector = new TaskDataCollector() { |
| 123 |
|
| 124 |
@Override |
| 125 |
public void accept(TaskData taskData) { |
| 126 |
returnedData.add(taskData); |
| 127 |
} |
| 128 |
}; |
| 129 |
|
| 130 |
client.getSearchHits(query, collector, mapper, new NullProgressMonitor()); |
| 131 |
assertEquals(1, returnedData.size()); |
| 132 |
assertEquals(bugid, returnedData.iterator().next().getTaskId()); |
| 133 |
if (!client.getRepositoryConfiguration().getInstallVersion().isSmallerOrEquals(BugzillaVersion.BUGZILLA_3_4)) { |
| 134 |
query.setUrl("?short_desc_type=allwordssubstr&short_desc=&longdesc_type=allwordssubstr&longdesc=" |
| 135 |
+ timestamp + "&bug_status=NEW"); |
| 136 |
|
| 137 |
returnedData.clear(); |
| 138 |
|
| 139 |
collector = new TaskDataCollector() { |
| 140 |
|
| 141 |
@Override |
| 142 |
public void accept(TaskData taskData) { |
| 143 |
returnedData.add(taskData); |
| 144 |
} |
| 145 |
}; |
| 146 |
|
| 147 |
client.getSearchHits(query, collector, mapper, new NullProgressMonitor()); |
| 148 |
assertEquals(1, returnedData.size()); |
| 149 |
assertEquals(bugid, returnedData.iterator().next().getTaskId()); |
| 150 |
} |
| 151 |
|
| 152 |
} |
| 153 |
|
| 82 |
// public void testCredentialsEncoding() throws IOException, BugzillaException, KeyManagementException, |
154 |
// public void testCredentialsEncoding() throws IOException, BugzillaException, KeyManagementException, |
| 83 |
// GeneralSecurityException { |
155 |
// GeneralSecurityException { |
| 84 |
// String poundSignUTF8 = BugzillaClient.addCredentials(IBugzillaTestConstants.TEST_BUGZILLA_222_URL, "UTF-8", |
156 |
// String poundSignUTF8 = BugzillaClient.addCredentials(IBugzillaTestConstants.TEST_BUGZILLA_222_URL, "UTF-8", |