-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#590 bugzilla rest connector #592
Changes from all commits
1eb1d26
74a4c15
83013d3
ad5b9fc
ef63dcf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Frank Becker and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Frank Becker - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.mylyn.commons.sdk.util; | ||
|
||
public class MustRunOnCIServerRule implements ConditionalIgnoreRule.IgnoreCondition { | ||
|
||
@Override | ||
public boolean isSatisfied(AbstractTestFixture fixture) { | ||
return !CommonTestUtil.runOnCIServerTestsOnly(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,24 +15,24 @@ | |
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/> | ||
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/> | ||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> | ||
<listEntry value="/org.eclipse.mylyn.bugzilla.rest.core.tests"/> | ||
<listEntry value="/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/AllBugzillaRestCoreTests.java"/> | ||
</listAttribute> | ||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> | ||
<listEntry value="4"/> | ||
<listEntry value="1"/> | ||
</listAttribute> | ||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.mylyn.bugzilla.rest.core.tests"/> | ||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> | ||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> | ||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> | ||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> | ||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/> | ||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/> | ||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/> | ||
<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]"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/> | ||
<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]"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also is specific to the one environment. Something like JavaSE-21 would be better |
||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.mylyn.bugzilla.rest.core.tests.AllBugzillaRestCoreTests"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -consolelog"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.mylyn.bugzilla.rest.core.tests"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx256m -Dorg.eclipse.mylyn.tests.all=true"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx256m -Dorg.eclipse.mylyn.ci.server.tests=true -Dorg.eclipse.mylyn.tests.all=true"/> | ||
<stringAttribute key="pde.version" value="3.3"/> | ||
<stringAttribute key="product" value="org.eclipse.platform.ide"/> | ||
<booleanAttribute key="run_in_ui_thread" value="true"/> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
import org.eclipse.mylyn.commons.sdk.util.IFixtureJUnitClass; | ||
import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner; | ||
import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner.FixtureDefinition; | ||
import org.eclipse.mylyn.commons.sdk.util.MustRunOnCIServerRule; | ||
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestAttachmentMapper; | ||
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestClient; | ||
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConfiguration; | ||
|
@@ -83,7 +84,6 @@ | |
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector; | ||
import org.eclipse.mylyn.tasks.core.data.TaskMapper; | ||
import org.junit.Before; | ||
import org.junit.Ignore; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
|
@@ -98,7 +98,7 @@ | |
// the value in the fixture. | ||
// Note: When there is no fixture with this property no tests get executed | ||
//@RunOnlyWhenProperty(property = "default", value = "1") | ||
@Ignore("No CI Server") | ||
|
||
public class BugzillaRestClientTest implements IFixtureJUnitClass { | ||
private final BugzillaRestTestFixture actualFixture; | ||
|
||
|
@@ -128,12 +128,14 @@ public AbstractTestFixture getActualFixture() { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer going straight to JUnit5 end @EnabledIf instead, like I did with #589 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we can do that. BugzillaRest Connector is special because we use here a Junit4TestFixtureRunner with a BlockJUnit4ClassRunner to group the unit test per fixture. Have you the migration of the BugzillaRest Connector on your list or should I do this because I implement the Connector? |
||
public void testConnectorClientCache() throws Exception { | ||
BugzillaRestClient client1 = connector.getClient(actualFixture.repository()); | ||
assertNotNull(client1); | ||
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testGetVersion() throws Exception { | ||
BugzillaRestClient client = new BugzillaRestClient(actualFixture.location(), connector); | ||
assertNotNull(client.getClient()); | ||
|
@@ -143,13 +145,15 @@ public void testGetVersion() throws Exception { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testValidate() throws Exception { | ||
BugzillaRestClient client = new BugzillaRestClient(actualFixture.location(), connector); | ||
assertNotNull(client.getClient()); | ||
assertTrue(client.validate(new NullOperationMonitor())); | ||
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testInvalidUserValidate() throws BugzillaRestException { | ||
RepositoryLocation location = new RepositoryLocation(); | ||
location.setUrl(actualFixture.getRepositoryUrl()); | ||
|
@@ -165,6 +169,7 @@ public void testInvalidUserValidate() throws BugzillaRestException { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testNoUserValidate() throws BugzillaRestException { | ||
RepositoryLocation location = new RepositoryLocation(); | ||
location.setUrl(actualFixture.getRepositoryUrl()); | ||
|
@@ -179,6 +184,7 @@ public void testNoUserValidate() throws BugzillaRestException { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testInvalidPasswordValidate() throws BugzillaRestException { | ||
RepositoryLocation location = new RepositoryLocation(); | ||
location.setUrl(actualFixture.getRepositoryUrl()); | ||
|
@@ -228,6 +234,7 @@ public void testInvalidApikeyValidate() throws BugzillaRestException { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testGetConfiguration() throws Exception { | ||
TaskRepository repository = actualFixture.repository(); | ||
BugzillaRestClient client = connector.getClient(repository); | ||
|
@@ -251,17 +258,17 @@ public void testGetConfiguration() throws Exception { | |
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/parameters.json"), | ||
Charset.defaultCharset()), | ||
new Gson().toJson(parameter) | ||
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url") | ||
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url/") | ||
.replaceAll(repository.getRepositoryUrl().replaceFirst("https://", "http://"), | ||
"http://dummy.url")); | ||
"http://dummy.url/")); | ||
assertEquals( | ||
IOUtils.toString( | ||
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/configuration.json"), | ||
Charset.defaultCharset()), | ||
new Gson().toJson(configuration) | ||
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url") | ||
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url/") | ||
.replaceAll(repository.getRepositoryUrl().replaceFirst("https://", "http://"), | ||
"http://dummy.url")); | ||
"http://dummy.url/")); | ||
} | ||
|
||
private void assertConfigurationFieldNames(Collection<Field> fields) throws IOException { | ||
|
@@ -278,6 +285,7 @@ private void assertConfigurationFieldNames(Collection<Field> fields) throws IOEx | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testinitializeTaskData() throws Exception { | ||
final TaskMapping taskMappingInit = new TaskMapping() { | ||
@Override | ||
|
@@ -323,6 +331,7 @@ public String getProduct() { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testPostTaskDataWithoutProduct() throws Exception { | ||
final TaskMapping taskMappingInit = new TaskMapping() { | ||
@Override | ||
|
@@ -347,12 +356,16 @@ public String getDescription() { | |
fail("never reach this!"); | ||
} catch (BugzillaRestException e) { | ||
String url = actualFixture.getRepositoryUrl(); | ||
if (url.endsWith("/")) { | ||
url= url.substring(0, url.length()-1); | ||
} | ||
assertEquals("You must select/enter a product. (status: Bad Request from " | ||
+ url.substring(url.lastIndexOf('/')) + "/rest.cgi/bug)", e.getMessage()); | ||
+ url.substring(url.lastIndexOf('/')) + "//rest.cgi/bug)", e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testPostTaskDataWithoutMilestone() throws Exception { | ||
final TaskMapping taskMappingInit = new TaskMapping() { | ||
@Override | ||
|
@@ -391,12 +404,16 @@ public String getVersion() { | |
fail("never reach this!"); | ||
} catch (BugzillaRestException e) { | ||
String url = actualFixture.getRepositoryUrl(); | ||
if (url.endsWith("/")) { | ||
url = url.substring(0, url.length() - 1); | ||
} | ||
assertEquals("You must select/enter a milestone. (status: Bad Request from " | ||
+ url.substring(url.lastIndexOf('/')) + "/rest.cgi/bug)", e.getMessage()); | ||
+ url.substring(url.lastIndexOf('/')) + "//rest.cgi/bug)", e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testPostTaskData() throws Exception { | ||
final TaskMapping taskMappingInit = new TaskMapping() { | ||
@Override | ||
|
@@ -439,6 +456,7 @@ public String getVersion() { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testPostTaskDataFromTaskdata() throws Exception { | ||
final TaskMapping taskMappingInit = new TaskMapping() { | ||
@Override | ||
|
@@ -488,6 +506,7 @@ public String getVersion() { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testGetTaskData() throws Exception { | ||
final TaskMapping taskMappingInit = new TaskMapping() { | ||
@Override | ||
|
@@ -589,6 +608,7 @@ public String getVersion() { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testUpdateTaskData() throws Exception { | ||
String taskId = harness.getNewTaksId4TestProduct(); | ||
TaskData taskDataGet = harness.getTaskFromServer(taskId); | ||
|
@@ -647,6 +667,7 @@ public void testUpdateTaskData() throws Exception { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testAddComment() throws Exception { | ||
String taskId = harness.getNewTaksId4TestProduct(); | ||
TaskData taskDataGet = harness.getTaskFromServer(taskId); | ||
|
@@ -681,6 +702,7 @@ public void testAddComment() throws Exception { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testGifAttachment() throws Exception { | ||
TaskAttribute attachmentAttribute = null; | ||
TaskRepository repository = actualFixture.repository(); | ||
|
@@ -750,6 +772,7 @@ public String getVersion() { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testTextAttachment() throws Exception { | ||
TaskAttribute attachmentAttribute = null; | ||
TaskRepository repository = actualFixture.repository(); | ||
|
@@ -838,6 +861,7 @@ public void accept(TaskData taskData) { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testCreateCCAttribute() throws Exception { | ||
final TaskMapping taskMappingInit = new TaskMapping() { | ||
@Override | ||
|
@@ -891,6 +915,7 @@ public String getVersion() { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testCreateBlocksAttribute() throws Exception { | ||
final TaskMapping taskMappingInit = new TaskMapping() { | ||
@Override | ||
|
@@ -945,6 +970,7 @@ public String getVersion() { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testCreateDependsOnAttribute() throws Exception { | ||
final TaskMapping taskMappingInit = new TaskMapping() { | ||
@Override | ||
|
@@ -999,6 +1025,7 @@ public String getVersion() { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testCCAttribute() throws Exception { | ||
String taskId = harness.getNewTaksId4TestProduct(); | ||
TaskData taskDataGet = harness.getTaskFromServer(taskId); | ||
|
@@ -1046,6 +1073,7 @@ public void testCCAttribute() throws Exception { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testBlocksAttributeV1() throws Exception { | ||
String taskId = harness.getNewTaksId4TestProduct(); | ||
String[] taskIdRel = harness.getRelationTasks(); | ||
|
@@ -1093,6 +1121,7 @@ public void testBlocksAttributeV1() throws Exception { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testBlocksAttributeV2() throws Exception { | ||
String taskId = harness.getNewTaksId4TestProduct(); | ||
String[] taskIdRel = harness.getRelationTasks(); | ||
|
@@ -1143,6 +1172,7 @@ public void testBlocksAttributeV2() throws Exception { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testDependsOnAttributeV1() throws Exception { | ||
String taskId = harness.getNewTaksId4TestProduct(); | ||
String[] taskIdRel = harness.getRelationTasks(); | ||
|
@@ -1191,6 +1221,7 @@ public void testDependsOnAttributeV1() throws Exception { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testDependsOnAttributeV2() throws Exception { | ||
String taskId = harness.getNewTaksId4TestProduct(); | ||
String[] taskIdRel = harness.getRelationTasks(); | ||
|
@@ -1242,6 +1273,7 @@ public void testDependsOnAttributeV2() throws Exception { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testFlagsSet() throws Exception { | ||
String taskId = harness.getNewTaksId4TestProduct(); | ||
|
||
|
@@ -1358,6 +1390,7 @@ public void testFlagsSet() throws Exception { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testFlagsReset() throws Exception { | ||
String taskId = harness.getNewTaksId4TestProduct(); | ||
|
||
|
@@ -1546,6 +1579,7 @@ public void testFlagsReset() throws Exception { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testFlagsChange() throws Exception { | ||
String taskId = harness.getNewTaksId4TestProduct(); | ||
|
||
|
@@ -1745,6 +1779,7 @@ public void testFlagsChange() throws Exception { | |
} | ||
|
||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = MustRunOnCIServerRule.class) | ||
public void testTextAttachmentWithFlags() throws Exception { | ||
TaskAttribute attachmentAttribute = null; | ||
TaskRepository repository = actualFixture.repository(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jenkins builds are with 17. I think we should use the same version both locally and remote.
Given that 24-09 compiler level defaults to 21 (or was it 22) do we stay with 17? What are the expectations for staying with 17?