diff options
author | Frank Becker | 2013-02-07 19:01:58 +0000 |
---|---|---|
committer | Frank Becker | 2013-02-07 19:01:58 +0000 |
commit | 47e2efed0f501a86b140b9ec72ec73854f284543 (patch) | |
tree | 0fcf0a97da8419fdb0a9f22ac27a60b0f26524f6 /org.eclipse.mylyn.bugzilla.tests | |
parent | 9b4d906102d2ff7b822e25851531abd3e67fc898 (diff) | |
download | org.eclipse.mylyn.tasks-47e2efed0f501a86b140b9ec72ec73854f284543.tar.gz org.eclipse.mylyn.tasks-47e2efed0f501a86b140b9ec72ec73854f284543.tar.xz org.eclipse.mylyn.tasks-47e2efed0f501a86b140b9ec72ec73854f284543.zip |
394053: Bugzilla setup for FixtureConfiguration
Change-Id: Id220e4c6b5a83f8f532dd20d907218501fc97287
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=394053
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests')
5 files changed, 117 insertions, 57 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java index 465e9879e..7fad7a747 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java @@ -24,6 +24,7 @@ import org.eclipse.mylyn.bugzilla.tests.ui.BugzillaTaskEditorTest; import org.eclipse.mylyn.bugzilla.tests.ui.BugzillaTaskHyperlinkDetectorTest; import org.eclipse.mylyn.commons.sdk.util.ManagedTestSuite; import org.eclipse.mylyn.commons.sdk.util.TestConfiguration; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaVersion; /** * @author Mik Kersten @@ -81,13 +82,9 @@ public class AllBugzillaTests { fixture.add(BugzillaRepositoryConnectorTest.class); fixture.add(BugzillaAttachmentHandlerTest.class); - // Move any tests here that are resulting in spurious failures - // due to recent changes in Bugzilla Server head. - if (fixture != BugzillaFixture.BUGS_HEAD) { - } - // Only run this if we have custom status and Workflow - if (fixture.equals(BugzillaFixture.BUGS_3_6_CUSTOM_WF_AND_STATUS)) { + if (BugzillaVersion.BUGZILLA_3_6.compareTo(fixture.getBugzillaVersion()) == 0 + && BugzillaFixture.CUSTOM_WF_AND_STATUS.equals(fixture.getDescription())) { fixture.add(BugzillaCustomRepositoryTest.class); } diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java index 14c67cc52..bb5a88b3d 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java @@ -348,8 +348,12 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { // public void testStdWorkflow() throws Exception { if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_4_0) < 0) { - if (BugzillaFixture.current() != BugzillaFixture.BUGS_3_6_CUSTOM_WF - && BugzillaFixture.current() != BugzillaFixture.BUGS_3_6_CUSTOM_WF_AND_STATUS) { + if (!(BugzillaVersion.BUGZILLA_3_6.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0 && BugzillaFixture.CUSTOM_WF.equals(BugzillaFixture.current() + .getDescription())) + && !(BugzillaVersion.BUGZILLA_3_6.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0 && BugzillaFixture.CUSTOM_WF_AND_STATUS.equals(BugzillaFixture.current() + .getDescription())) + + ) { doStdWorkflow32("3"); } } else { @@ -1113,7 +1117,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { public void testSynchChangedReports() throws Exception { TaskData data = BugzillaFixture.current().createTask(PrivilegeLevel.USER, null, null); - if (BugzillaFixture.current().equals(BugzillaFixture.BUGS_HEAD) + if (BugzillaVersion.BUGZILLA_HEAD.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0 && BugzillaFixture.current().getRepositoryUrl().contains("mylyn.eclipse.org")) { //FIXME: for some actual unknown reason // connector.preSynchronization(event, null); @@ -1607,7 +1611,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { } }; - if (BugzillaFixture.current().equals(BugzillaFixture.BUGS_3_4)) { + if (BugzillaVersion.BUGZILLA_3_4.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0) { return; } final TaskData[] taskDataNew = new TaskData[1]; @@ -1692,7 +1696,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { } }; - if (BugzillaFixture.current().equals(BugzillaFixture.BUGS_3_4)) { + if (BugzillaVersion.BUGZILLA_3_4.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0) { return; } diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java index 98574cc39..1f45acd79 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java @@ -62,13 +62,19 @@ public class BugzillaClientTest extends TestCase { } public void testRDFProductConfig() throws Exception { + if (BugzillaVersion.BUGZILLA_4_4.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0 + || BugzillaVersion.BUGZILLA_HEAD.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0) { + // FIXME: need fix of bug#372600 + return; + } RepositoryConfiguration config = client.getRepositoryConfiguration(); assertNotNull(config); assertEquals( 0, config.getInstallVersion().compareMajorMinorOnly( new BugzillaVersion(BugzillaFixture.current().getVersion()))); - if (BugzillaFixture.current() == BugzillaFixture.BUGS_3_6_CUSTOM_WF_AND_STATUS) { + if (BugzillaVersion.BUGZILLA_3_6.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0 + && BugzillaFixture.CUSTOM_WF_AND_STATUS.equals(BugzillaFixture.current().getDescription())) { assertEquals(10, config.getOptionValues(BugzillaAttribute.BUG_STATUS).size()); } else if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_4_0) < 0) { assertEquals(7, config.getOptionValues(BugzillaAttribute.BUG_STATUS).size()); @@ -93,7 +99,8 @@ public class BugzillaClientTest extends TestCase { } assertEquals(7, config.getOptionValues(BugzillaAttribute.BUG_SEVERITY).size()); assertEquals(3, config.getOptionValues(BugzillaAttribute.PRODUCT).size()); - if (BugzillaFixture.current() == BugzillaFixture.BUGS_3_6_CUSTOM_WF_AND_STATUS) { + if (BugzillaVersion.BUGZILLA_3_6.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0 + && BugzillaFixture.CUSTOM_WF_AND_STATUS.equals(BugzillaFixture.current().getDescription())) { assertEquals(6, config.getOpenStatusValues().size()); assertEquals(1, config.getClosedStatusValues().size()); } else if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_4_0) < 0) { @@ -107,15 +114,9 @@ public class BugzillaClientTest extends TestCase { assertEquals(2, config.getProductOptionValues(BugzillaAttribute.COMPONENT, "ManualTest").size()); assertEquals(4, config.getProductOptionValues(BugzillaAttribute.VERSION, "ManualTest").size()); assertEquals(4, config.getProductOptionValues(BugzillaAttribute.TARGET_MILESTONE, "ManualTest").size()); - if (BugzillaFixture.current().getRepositoryUrl().contains("localhost")) { - assertEquals(1, config.getProductOptionValues(BugzillaAttribute.COMPONENT, "TestProduct").size()); - assertEquals(1, config.getProductOptionValues(BugzillaAttribute.VERSION, "TestProduct").size()); - assertEquals(1, config.getProductOptionValues(BugzillaAttribute.TARGET_MILESTONE, "TestProduct").size()); - } else { - assertEquals(2, config.getProductOptionValues(BugzillaAttribute.COMPONENT, "TestProduct").size()); - assertEquals(4, config.getProductOptionValues(BugzillaAttribute.VERSION, "TestProduct").size()); - assertEquals(4, config.getProductOptionValues(BugzillaAttribute.TARGET_MILESTONE, "TestProduct").size()); - } + assertEquals(1, config.getProductOptionValues(BugzillaAttribute.COMPONENT, "TestProduct").size()); + assertEquals(1, config.getProductOptionValues(BugzillaAttribute.VERSION, "TestProduct").size()); + assertEquals(1, config.getProductOptionValues(BugzillaAttribute.TARGET_MILESTONE, "TestProduct").size()); assertEquals(2, config.getProductOptionValues(BugzillaAttribute.COMPONENT, "Product with Spaces").size()); assertEquals(4, config.getProductOptionValues(BugzillaAttribute.VERSION, "Product with Spaces").size()); assertEquals(4, config.getProductOptionValues(BugzillaAttribute.TARGET_MILESTONE, "Product with Spaces").size()); @@ -202,9 +203,6 @@ public class BugzillaClientTest extends TestCase { newData.getRoot().getMappedAttribute(TaskAttribute.SUMMARY).setValue("testCommentQuery()"); newData.getRoot().getMappedAttribute(TaskAttribute.PRODUCT).setValue("TestProduct"); newData.getRoot().getMappedAttribute(TaskAttribute.COMPONENT).setValue("TestComponent"); - if (!BugzillaFixture.current().getRepositoryUrl().contains("localhost")) { - newData.getRoot().getMappedAttribute(BugzillaAttribute.VERSION.getKey()).setValue("1"); - } newData.getRoot().getMappedAttribute(BugzillaAttribute.OP_SYS.getKey()).setValue("All"); long timestamp = System.currentTimeMillis(); newData.getRoot().getMappedAttribute(TaskAttribute.DESCRIPTION).setValue("" + timestamp); diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaXmlRpcClientTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaXmlRpcClientTest.java index ec10dbe89..19af49035 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaXmlRpcClientTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaXmlRpcClientTest.java @@ -343,7 +343,7 @@ public class BugzillaXmlRpcClientTest extends AbstractBugzillaTest { // HashMap<?, ?> x1 = bugzillaClient.getTime(monitor); // Date x2 = bugzillaClient.getDBTime(monitor); // Date x3 = bugzillaClient.getWebTime(monitor); -// if (BugzillaFixture.current() != BugzillaFixture.BUGS_3_4) { +// if (BugzillaVersion.BUGZILLA_3_4.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0) { // Object[] xx3 = bugzillaClient.getAllFields(monitor); // Object[] xx4 = bugzillaClient.getFieldsWithNames(monitor, new String[] { "qa_contact" }); // Object[] xx5 = bugzillaClient.getFieldsWithIDs(monitor, new Integer[] { 12, 18 }); @@ -395,22 +395,6 @@ public class BugzillaXmlRpcClientTest extends AbstractBugzillaTest { assertEquals("tests@mylyn.eclipse.org", ((HashMap<String, String>) userList1[0]).get("name")); assertEquals("Mylyn Test", ((HashMap<String, String>) userList1[0]).get("real_name")); assertEquals(((Boolean) true), ((HashMap<String, Boolean>) userList1[0]).get("can_login")); - - if (BugzillaFixture.current() != BugzillaFixture.BUGS_3_4) { - Object[] userList2 = bugzillaClient.getUserInfoWithMatch(monitor, new String[] { "est" }); - assertEquals(2, userList2.length); - assertEquals(((Integer) 3), ((HashMap<String, Integer>) userList2[0]).get("id")); - assertEquals("guest@mylyn.eclipse.org", ((HashMap<String, String>) userList2[0]).get("email")); - assertEquals("guest@mylyn.eclipse.org", ((HashMap<String, String>) userList2[0]).get("name")); - assertEquals("Mylyn guest", ((HashMap<String, String>) userList2[0]).get("real_name")); - assertEquals(((Boolean) true), ((HashMap<String, Boolean>) userList2[0]).get("can_login")); - - assertEquals(((Integer) 2), ((HashMap<String, Integer>) userList2[1]).get("id")); - assertEquals("tests@mylyn.eclipse.org", ((HashMap<String, String>) userList2[1]).get("email")); - assertEquals("tests@mylyn.eclipse.org", ((HashMap<String, String>) userList2[1]).get("name")); - assertEquals("Mylyn Test", ((HashMap<String, String>) userList2[1]).get("real_name")); - assertEquals(((Boolean) true), ((HashMap<String, Boolean>) userList2[1]).get("can_login")); - } } } @@ -519,7 +503,7 @@ public class BugzillaXmlRpcClientTest extends AbstractBugzillaTest { public void testXmlRpcBugGet() throws Exception { if (BugzillaFixture.current().getDescription().equals(BugzillaFixture.XML_RPC_DISABLED) - || BugzillaFixture.current() == BugzillaFixture.BUGS_3_4) { + || BugzillaVersion.BUGZILLA_3_4.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0) { return; } else { Set<String> taskIds = new HashSet<String>(); @@ -692,7 +676,7 @@ public class BugzillaXmlRpcClientTest extends AbstractBugzillaTest { public void testUpdateProductInfo() throws Exception { if (BugzillaFixture.current().getDescription().equals(BugzillaFixture.XML_RPC_DISABLED) - || BugzillaFixture.current() == BugzillaFixture.BUGS_3_4) { + || BugzillaVersion.BUGZILLA_3_4.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0) { return; } RepositoryConfiguration repositoryConfiguration = connector.getRepositoryConfiguration(repository.getRepositoryUrl()); diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java index 7df14261b..098180e6b 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java @@ -14,7 +14,10 @@ package org.eclipse.mylyn.bugzilla.tests.support; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; import java.util.Collections; +import java.util.List; +import java.util.Map; import junit.framework.AssertionFailedError; @@ -26,6 +29,7 @@ import org.eclipse.mylyn.commons.net.WebLocation; import org.eclipse.mylyn.commons.repositories.core.auth.UserCredentials; import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil; import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil.PrivilegeLevel; +import org.eclipse.mylyn.commons.sdk.util.FixtureConfiguration; import org.eclipse.mylyn.commons.sdk.util.TestConfiguration; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient; @@ -78,54 +82,67 @@ public class BugzillaFixture extends TestFixture { * @deprecated not supported any more */ @Deprecated - public static BugzillaFixture BUGS_3_4 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_34_URL, // + private static BugzillaFixture BUGS_3_4 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_34_URL, // "3.4.14", ""); - public static BugzillaFixture BUGS_3_6 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_36_URL, // + private static BugzillaFixture BUGS_3_6 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_36_URL, // "3.6", ""); - public static BugzillaFixture BUGS_3_6_CUSTOM_WF = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_36_URL + private static BugzillaFixture BUGS_3_6_CUSTOM_WF = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_36_URL + "-custom-wf", "3.6", CUSTOM_WF); - public static BugzillaFixture BUGS_3_6_CUSTOM_WF_AND_STATUS = new BugzillaFixture( + private static BugzillaFixture BUGS_3_6_CUSTOM_WF_AND_STATUS = new BugzillaFixture( BugzillaFixture.TEST_BUGZILLA_36_URL + "-custom-wf-and-status", "3.6", CUSTOM_WF_AND_STATUS); - public static BugzillaFixture BUGS_3_6_XML_RPC_DISABLED = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_36_URL + private static BugzillaFixture BUGS_3_6_XML_RPC_DISABLED = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_36_URL + "-xml-rpc-disabled", "3.6", XML_RPC_DISABLED); - public static BugzillaFixture BUGS_4_0 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_40_URL, // + private static BugzillaFixture BUGS_4_0 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_40_URL, // "4.0", ""); - public static BugzillaFixture BUGS_4_2 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_42_URL, // + private static BugzillaFixture BUGS_4_2 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_42_URL, // "4.2", ""); - public static BugzillaFixture BUGS_4_4 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_44_URL, // + private static BugzillaFixture BUGS_4_4 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_44_URL, // "4.4", ""); - public static BugzillaFixture BUGS_HEAD = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_HEAD_URL, // + private static BugzillaFixture BUGS_HEAD = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_HEAD_URL, // "4.5", ""); - public static BugzillaFixture DEFAULT = BUGS_4_2; + public static BugzillaFixture DEFAULT; - public static final BugzillaFixture[] ALL = new BugzillaFixture[] { BUGS_3_4, // - BUGS_3_6, BUGS_3_6_XML_RPC_DISABLED, BUGS_3_6_CUSTOM_WF, BUGS_3_6_CUSTOM_WF_AND_STATUS, // - BUGS_4_0, BUGS_4_2, BUGS_4_4, BUGS_HEAD }; + public static final List<BugzillaFixture> ALL; private final String version; private final BugzillaVersion bugzillaVersion; + private final Map<String, String> properties; + + public BugzillaFixture(FixtureConfiguration config) { + super(BugzillaCorePlugin.CONNECTOR_KIND, config.getUrl()); + this.version = config.getVersion(); + this.bugzillaVersion = new BugzillaVersion(version); + setInfo("Bugzilla", version, config.getInfo()); + this.properties = config.getProperties(); + } + public BugzillaFixture(String url, String version, String info) { super(BugzillaCorePlugin.CONNECTOR_KIND, url); this.version = version; this.bugzillaVersion = new BugzillaVersion(version); setInfo("Bugzilla", version, info); + this.properties = null; } public BugzillaVersion getBugzillaVersion() { return bugzillaVersion; } + public Map<String, String> getProperties() { + return properties; + } + public static void cleanup010() throws Exception { } @@ -285,4 +302,64 @@ public class BugzillaFixture extends TestFixture { return (BugzillaRepositoryConnector) connector; } + private static final String getServerUrl() { + String url = TestConfiguration.getRepositoryUrl(""); + if (url.endsWith("/")) { + return url.substring(0, url.length() - 1); + } + return url; + } + + public String getProperty(String key) { + if (properties != null) { + return properties.get(key); + } + return null; + } + + private static BugzillaFixture getDefaultFixture(List<BugzillaFixture> fixtureList) { + if (fixtureList != null && fixtureList.size() > 0) { + String defaultFixture = System.getProperty("mylyn.test.default", ""); + for (BugzillaFixture fixture : fixtureList) { + if (!"".equals(defaultFixture)) { + if (defaultFixture.equals(fixture.getRepositoryUrl())) { + return fixture; + } + } else { + Map<String, String> property = fixture.getProperties(); + if (property != null) { + String defaultProperty = property.get("default"); + if (defaultProperty != null && "1".equals(defaultProperty)) { + return fixture; + } + } + } + } + } + return BUGS_4_2; + } + + private static List<BugzillaFixture> getAll(List<BugzillaFixture> fixtureList) { + if (fixtureList != null && fixtureList.size() > 0) { + return fixtureList; + } + List<BugzillaFixture> result = new ArrayList<BugzillaFixture>(9); + result.add(BUGS_3_4); + result.add(BUGS_3_6); + result.add(BUGS_3_6_XML_RPC_DISABLED); + result.add(BUGS_3_6_CUSTOM_WF); + result.add(BUGS_3_6_CUSTOM_WF_AND_STATUS); + result.add(BUGS_4_0); + result.add(BUGS_4_2); + result.add(BUGS_4_4); + result.add(BUGS_HEAD); + return result; + } + + static { + List<BugzillaFixture> fixtureList = TestConfiguration.discover(BugzillaFixture.getServerUrl(), + BugzillaFixture.class, "bugzilla"); + DEFAULT = getDefaultFixture(fixtureList); + ALL = getAll(fixtureList); + } } |