Skip to content

Commit 0940b27

Browse files
committed
reenable Bugzilla Rest Connnector Tests (#590)
1 parent 4ae350a commit 0940b27

File tree

11 files changed

+122
-35
lines changed

11 files changed

+122
-35
lines changed

mylyn.commons/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/CommonTestUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ public static boolean runHeartbeatTestsOnly() {
366366
* Returns whether to run a limited suite of tests. Returns true, unless a system property has been set to force running of all network
367367
* tests (using CI Server).
368368
*/
369-
public static boolean runNonCIServerTestsOnly() {
370-
return !Boolean.getBoolean("org.eclipse.mylyn.ci.server.tests");
369+
public static boolean runOnCIServerTestsOnly() {
370+
return Boolean.getBoolean("org.eclipse.mylyn.ci.server.tests");
371371
}
372372

373373
/**

mylyn.commons/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/ConditionalIgnoreRule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ IgnoreCondition create() {
9191
private IgnoreCondition createCondition() throws Exception {
9292
IgnoreCondition result;
9393
if (isConditionTypeStandalone()) {
94-
result = conditionType.newInstance();
94+
result = conditionType.getDeclaredConstructor().newInstance();
9595
} else {
9696
result = conditionType.getDeclaredConstructor(testClass).newInstance(testClass);
9797
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Frank Becker and others.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* https://www.eclipse.org/legal/epl-2.0
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Frank Becker - initial API and implementation
12+
*******************************************************************************/
13+
14+
package org.eclipse.mylyn.commons.sdk.util;
15+
16+
public class MustRunOnCIServerRule implements ConditionalIgnoreRule.IgnoreCondition {
17+
18+
@Override
19+
public boolean isSatisfied(AbstractTestFixture fixture) {
20+
return !CommonTestUtil.runOnCIServerTestsOnly();
21+
}
22+
23+
}

mylyn.tasks/connectors/bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/config/local-All-BugzillaRestCoreTests.launch

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@
1515
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
1616
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
1717
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
18-
<listEntry value="/org.eclipse.mylyn.bugzilla.rest.core.tests"/>
18+
<listEntry value="/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/AllBugzillaRestCoreTests.java"/>
1919
</listAttribute>
2020
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
21-
<listEntry value="4"/>
21+
<listEntry value="1"/>
2222
</listAttribute>
23-
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.mylyn.bugzilla.rest.core.tests"/>
23+
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
2424
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
2525
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
2626
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
2727
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
2828
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
2929
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
30-
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/OpenJDK 17.0.4 [17.0.4]"/>
31-
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
30+
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/OpenJDK 21.0.3 [21.0.3]"/>
31+
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.mylyn.bugzilla.rest.core.tests.AllBugzillaRestCoreTests"/>
3232
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -consolelog"/>
3333
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.mylyn.bugzilla.rest.core.tests"/>
3434
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
35-
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx256m&#10;-Dorg.eclipse.mylyn.tests.all=true"/>
35+
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx256m&#10;-Dorg.eclipse.mylyn.ci.server.tests=true&#10;-Dorg.eclipse.mylyn.tests.all=true"/>
3636
<stringAttribute key="pde.version" value="3.3"/>
3737
<stringAttribute key="product" value="org.eclipse.platform.ide"/>
3838
<booleanAttribute key="run_in_ui_thread" value="true"/>

mylyn.tasks/connectors/bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestClientTest.java

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.eclipse.mylyn.commons.sdk.util.IFixtureJUnitClass;
5454
import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner;
5555
import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner.FixtureDefinition;
56+
import org.eclipse.mylyn.commons.sdk.util.MustRunOnCIServerRule;
5657
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestAttachmentMapper;
5758
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestClient;
5859
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConfiguration;
@@ -83,7 +84,6 @@
8384
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
8485
import org.eclipse.mylyn.tasks.core.data.TaskMapper;
8586
import org.junit.Before;
86-
import org.junit.Ignore;
8787
import org.junit.Rule;
8888
import org.junit.Test;
8989
import org.junit.rules.ExpectedException;
@@ -98,7 +98,7 @@
9898
// the value in the fixture.
9999
// Note: When there is no fixture with this property no tests get executed
100100
//@RunOnlyWhenProperty(property = "default", value = "1")
101-
@Ignore("No CI Server")
101+
102102
public class BugzillaRestClientTest implements IFixtureJUnitClass {
103103
private final BugzillaRestTestFixture actualFixture;
104104

@@ -128,12 +128,14 @@ public AbstractTestFixture getActualFixture() {
128128
}
129129

130130
@Test
131+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
131132
public void testConnectorClientCache() throws Exception {
132133
BugzillaRestClient client1 = connector.getClient(actualFixture.repository());
133134
assertNotNull(client1);
134135
}
135136

136137
@Test
138+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
137139
public void testGetVersion() throws Exception {
138140
BugzillaRestClient client = new BugzillaRestClient(actualFixture.location(), connector);
139141
assertNotNull(client.getClient());
@@ -143,13 +145,15 @@ public void testGetVersion() throws Exception {
143145
}
144146

145147
@Test
148+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
146149
public void testValidate() throws Exception {
147150
BugzillaRestClient client = new BugzillaRestClient(actualFixture.location(), connector);
148151
assertNotNull(client.getClient());
149152
assertTrue(client.validate(new NullOperationMonitor()));
150153
}
151154

152155
@Test
156+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
153157
public void testInvalidUserValidate() throws BugzillaRestException {
154158
RepositoryLocation location = new RepositoryLocation();
155159
location.setUrl(actualFixture.getRepositoryUrl());
@@ -165,6 +169,7 @@ public void testInvalidUserValidate() throws BugzillaRestException {
165169
}
166170

167171
@Test
172+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
168173
public void testNoUserValidate() throws BugzillaRestException {
169174
RepositoryLocation location = new RepositoryLocation();
170175
location.setUrl(actualFixture.getRepositoryUrl());
@@ -179,6 +184,7 @@ public void testNoUserValidate() throws BugzillaRestException {
179184
}
180185

181186
@Test
187+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
182188
public void testInvalidPasswordValidate() throws BugzillaRestException {
183189
RepositoryLocation location = new RepositoryLocation();
184190
location.setUrl(actualFixture.getRepositoryUrl());
@@ -228,6 +234,7 @@ public void testInvalidApikeyValidate() throws BugzillaRestException {
228234
}
229235

230236
@Test
237+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
231238
public void testGetConfiguration() throws Exception {
232239
TaskRepository repository = actualFixture.repository();
233240
BugzillaRestClient client = connector.getClient(repository);
@@ -251,17 +258,17 @@ public void testGetConfiguration() throws Exception {
251258
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/parameters.json"),
252259
Charset.defaultCharset()),
253260
new Gson().toJson(parameter)
254-
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url")
261+
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url/")
255262
.replaceAll(repository.getRepositoryUrl().replaceFirst("https://", "http://"),
256-
"http://dummy.url"));
263+
"http://dummy.url/"));
257264
assertEquals(
258265
IOUtils.toString(
259266
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/configuration.json"),
260267
Charset.defaultCharset()),
261268
new Gson().toJson(configuration)
262-
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url")
269+
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url/")
263270
.replaceAll(repository.getRepositoryUrl().replaceFirst("https://", "http://"),
264-
"http://dummy.url"));
271+
"http://dummy.url/"));
265272
}
266273

267274
private void assertConfigurationFieldNames(Collection<Field> fields) throws IOException {
@@ -278,6 +285,7 @@ private void assertConfigurationFieldNames(Collection<Field> fields) throws IOEx
278285
}
279286

280287
@Test
288+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
281289
public void testinitializeTaskData() throws Exception {
282290
final TaskMapping taskMappingInit = new TaskMapping() {
283291
@Override
@@ -323,6 +331,7 @@ public String getProduct() {
323331
}
324332

325333
@Test
334+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
326335
public void testPostTaskDataWithoutProduct() throws Exception {
327336
final TaskMapping taskMappingInit = new TaskMapping() {
328337
@Override
@@ -347,12 +356,16 @@ public String getDescription() {
347356
fail("never reach this!");
348357
} catch (BugzillaRestException e) {
349358
String url = actualFixture.getRepositoryUrl();
359+
if (url.endsWith("/")) {
360+
url= url.substring(0, url.length()-1);
361+
}
350362
assertEquals("You must select/enter a product. (status: Bad Request from "
351-
+ url.substring(url.lastIndexOf('/')) + "/rest.cgi/bug)", e.getMessage());
363+
+ url.substring(url.lastIndexOf('/')) + "//rest.cgi/bug)", e.getMessage());
352364
}
353365
}
354366

355367
@Test
368+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
356369
public void testPostTaskDataWithoutMilestone() throws Exception {
357370
final TaskMapping taskMappingInit = new TaskMapping() {
358371
@Override
@@ -391,12 +404,16 @@ public String getVersion() {
391404
fail("never reach this!");
392405
} catch (BugzillaRestException e) {
393406
String url = actualFixture.getRepositoryUrl();
407+
if (url.endsWith("/")) {
408+
url = url.substring(0, url.length() - 1);
409+
}
394410
assertEquals("You must select/enter a milestone. (status: Bad Request from "
395-
+ url.substring(url.lastIndexOf('/')) + "/rest.cgi/bug)", e.getMessage());
411+
+ url.substring(url.lastIndexOf('/')) + "//rest.cgi/bug)", e.getMessage());
396412
}
397413
}
398414

399415
@Test
416+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
400417
public void testPostTaskData() throws Exception {
401418
final TaskMapping taskMappingInit = new TaskMapping() {
402419
@Override
@@ -439,6 +456,7 @@ public String getVersion() {
439456
}
440457

441458
@Test
459+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
442460
public void testPostTaskDataFromTaskdata() throws Exception {
443461
final TaskMapping taskMappingInit = new TaskMapping() {
444462
@Override
@@ -488,6 +506,7 @@ public String getVersion() {
488506
}
489507

490508
@Test
509+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
491510
public void testGetTaskData() throws Exception {
492511
final TaskMapping taskMappingInit = new TaskMapping() {
493512
@Override
@@ -589,6 +608,7 @@ public String getVersion() {
589608
}
590609

591610
@Test
611+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
592612
public void testUpdateTaskData() throws Exception {
593613
String taskId = harness.getNewTaksId4TestProduct();
594614
TaskData taskDataGet = harness.getTaskFromServer(taskId);
@@ -647,6 +667,7 @@ public void testUpdateTaskData() throws Exception {
647667
}
648668

649669
@Test
670+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
650671
public void testAddComment() throws Exception {
651672
String taskId = harness.getNewTaksId4TestProduct();
652673
TaskData taskDataGet = harness.getTaskFromServer(taskId);
@@ -681,6 +702,7 @@ public void testAddComment() throws Exception {
681702
}
682703

683704
@Test
705+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
684706
public void testGifAttachment() throws Exception {
685707
TaskAttribute attachmentAttribute = null;
686708
TaskRepository repository = actualFixture.repository();
@@ -750,6 +772,7 @@ public String getVersion() {
750772
}
751773

752774
@Test
775+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
753776
public void testTextAttachment() throws Exception {
754777
TaskAttribute attachmentAttribute = null;
755778
TaskRepository repository = actualFixture.repository();
@@ -838,6 +861,7 @@ public void accept(TaskData taskData) {
838861
}
839862

840863
@Test
864+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
841865
public void testCreateCCAttribute() throws Exception {
842866
final TaskMapping taskMappingInit = new TaskMapping() {
843867
@Override
@@ -891,6 +915,7 @@ public String getVersion() {
891915
}
892916

893917
@Test
918+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
894919
public void testCreateBlocksAttribute() throws Exception {
895920
final TaskMapping taskMappingInit = new TaskMapping() {
896921
@Override
@@ -945,6 +970,7 @@ public String getVersion() {
945970
}
946971

947972
@Test
973+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
948974
public void testCreateDependsOnAttribute() throws Exception {
949975
final TaskMapping taskMappingInit = new TaskMapping() {
950976
@Override
@@ -999,6 +1025,7 @@ public String getVersion() {
9991025
}
10001026

10011027
@Test
1028+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
10021029
public void testCCAttribute() throws Exception {
10031030
String taskId = harness.getNewTaksId4TestProduct();
10041031
TaskData taskDataGet = harness.getTaskFromServer(taskId);
@@ -1046,6 +1073,7 @@ public void testCCAttribute() throws Exception {
10461073
}
10471074

10481075
@Test
1076+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
10491077
public void testBlocksAttributeV1() throws Exception {
10501078
String taskId = harness.getNewTaksId4TestProduct();
10511079
String[] taskIdRel = harness.getRelationTasks();
@@ -1093,6 +1121,7 @@ public void testBlocksAttributeV1() throws Exception {
10931121
}
10941122

10951123
@Test
1124+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
10961125
public void testBlocksAttributeV2() throws Exception {
10971126
String taskId = harness.getNewTaksId4TestProduct();
10981127
String[] taskIdRel = harness.getRelationTasks();
@@ -1143,6 +1172,7 @@ public void testBlocksAttributeV2() throws Exception {
11431172
}
11441173

11451174
@Test
1175+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
11461176
public void testDependsOnAttributeV1() throws Exception {
11471177
String taskId = harness.getNewTaksId4TestProduct();
11481178
String[] taskIdRel = harness.getRelationTasks();
@@ -1191,6 +1221,7 @@ public void testDependsOnAttributeV1() throws Exception {
11911221
}
11921222

11931223
@Test
1224+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
11941225
public void testDependsOnAttributeV2() throws Exception {
11951226
String taskId = harness.getNewTaksId4TestProduct();
11961227
String[] taskIdRel = harness.getRelationTasks();
@@ -1242,6 +1273,7 @@ public void testDependsOnAttributeV2() throws Exception {
12421273
}
12431274

12441275
@Test
1276+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
12451277
public void testFlagsSet() throws Exception {
12461278
String taskId = harness.getNewTaksId4TestProduct();
12471279

@@ -1358,6 +1390,7 @@ public void testFlagsSet() throws Exception {
13581390
}
13591391

13601392
@Test
1393+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
13611394
public void testFlagsReset() throws Exception {
13621395
String taskId = harness.getNewTaksId4TestProduct();
13631396

@@ -1546,6 +1579,7 @@ public void testFlagsReset() throws Exception {
15461579
}
15471580

15481581
@Test
1582+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
15491583
public void testFlagsChange() throws Exception {
15501584
String taskId = harness.getNewTaksId4TestProduct();
15511585

@@ -1745,6 +1779,7 @@ public void testFlagsChange() throws Exception {
17451779
}
17461780

17471781
@Test
1782+
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class)
17481783
public void testTextAttachmentWithFlags() throws Exception {
17491784
TaskAttribute attachmentAttribute = null;
17501785
TaskRepository repository = actualFixture.repository();

0 commit comments

Comments
 (0)