diff options
author | Steffen Pingel | 2013-04-16 15:10:41 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2013-04-21 23:07:54 +0000 |
commit | a4275ac930f94ddaa2e75dc8dff860c51b43c775 (patch) | |
tree | 1fee82f5cb060cbca7691d8e4b03a81cae09954e | |
parent | 72f3117a1c2e325d823bd44c9a0c23843d93d99e (diff) | |
download | org.eclipse.mylyn.tasks-a4275ac930f94ddaa2e75dc8dff860c51b43c775.tar.gz org.eclipse.mylyn.tasks-a4275ac930f94ddaa2e75dc8dff860c51b43c775.tar.xz org.eclipse.mylyn.tasks-a4275ac930f94ddaa2e75dc8dff860c51b43c775.zip |
399803: simplify Bugzilla fixture discovery
* Discover all fixtures dynamically and remove hard coded URLs.
Change-Id: I23197e708b31a9996cf3b53558771fb06c92e77c
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=399803
13 files changed, 105 insertions, 214 deletions
diff --git a/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/manifests/defaultsites.pp b/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/manifests/defaultsites.pp index 925a76492..47b902164 100644 --- a/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/manifests/defaultsites.pp +++ b/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/manifests/defaultsites.pp @@ -28,21 +28,22 @@ define bugzilla::defaultsites($base = $bugzilla::bugzillaBase, $userOwner = $bug minor => "6", } - bugzilla::site { "bugs36-custom-wf": + bugzilla::site { "bugzilla-3.6.12-custom-wf": major => "3", minor => "6", branchTag => "bugzilla-3.6.12", custom_wf => true, } - bugzilla::site { "bugs36-custom-wf-and-status": + bugzilla::site { "bugzilla-3.6.12-custom-wf-and-status": major => "3", minor => "6", branchTag => "bugzilla-3.6.12", custom_wf_and_status => true, + desciptorfile => "DescriptorFile-custom-wf-and-status.txt" } - bugzilla::site { "bugs36-xml-rpc-disabled": + bugzilla::site { "bugzilla-3.6.12-xml-rpc-disabled": major => "3", minor => "6", branchTag => "bugzilla-3.6.12", @@ -57,16 +58,16 @@ define bugzilla::defaultsites($base = $bugzilla::bugzillaBase, $userOwner = $bug bugzilla::site { "bugzilla-4.2.5": major => "4", minor => "2", - envdefault => "1", + envdefault => true, } - bugzilla::site { "bugs44": + bugzilla::site { "bugzilla-4.4": major => "4", minor => "4", branchTag => "trunk", } - bugzilla::site { "bugshead": + bugzilla::site { "bugzilla-trunk": major => "4", minor => "5", branch => "trunk", diff --git a/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/manifests/site.pp b/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/manifests/site.pp index 2cd760298..6f055fe72 100644 --- a/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/manifests/site.pp +++ b/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/manifests/site.pp @@ -28,12 +28,13 @@ define bugzilla::site ( $userOwner = $bugzilla::userOwner, $userGroup = $bugzilla::userGroup, $envversion = "${major}.${minor}", - $envdefault = "0", + $envdefault = false, $clearDB = $bugzilla::clearDB, + $desciptorfile = " ", ) { include "bugzilla" - + $propertyanz = 0 $confDir = "$base/conf.d" if $branch == "trunk" { @@ -188,7 +189,7 @@ define bugzilla::site ( command => "$base/$version/callchecksetup.pl", cwd => "$base/$version", creates => "$base/$version/localconfig", - user => "$userOwner", +# user => "$userOwner", logoutput => true, require => [ Exec["mysql-createdb-$version"], @@ -201,7 +202,7 @@ define bugzilla::site ( command => "$base/$version/callchecksetup.pl", cwd => "$base/$version", logoutput => true, - user => "$userOwner", +# user => "$userOwner", require => [ Exec["mysql-createdb-$version"], Exec["init bugzilla_checksetup $version"], diff --git a/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/templates/Extension.pm.erb b/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/templates/Extension.pm.erb index 529f2f4ea..7b178150d 100644 --- a/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/templates/Extension.pm.erb +++ b/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/templates/Extension.pm.erb @@ -423,20 +423,18 @@ sub install_before_final_checks { WHERE old_status = ? AND new_status = ?'); my $sth_delnul = $dbh->prepare('DELETE FROM status_workflow WHERE old_status IS NULL AND new_status = ?'); - -print "before insert"; foreach my $pair (STATUS_WORKFLOW) { my $old_id = $pair->[0] ? $status_ids{$pair->[0]} : undef; my $new_id = $status_ids{$pair->[1]}; - $sth_insert->execute($old_id, $new_id); + if (!$dbh->selectrow_array('SELECT 1 FROM status_workflow where old_status ='. $old_id . ' and new_status ='.$new_id)) { + $sth_insert->execute($old_id, $new_id); + } } -print "before delete"; foreach my $pair (STATUS_WORKFLOW_DELETE) { my $old_id = $pair->[0] ? $status_ids{$pair->[0]} : undef; my $new_id = $status_ids{$pair->[1]}; $sth_delete->execute($old_id, $new_id); } -print "before delete null"; my $new_id = $status_ids{'ASSIGNED'}; $sth_delnul->execute($new_id); } diff --git a/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/templates/service.json.erb b/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/templates/service.json.erb index 59a5a5fe4..8fbbdc285 100644 --- a/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/templates/service.json.erb +++ b/org.eclipse.mylyn.bugzilla.releng/modules/bugzilla/templates/service.json.erb @@ -1,12 +1,13 @@ { -"type": "<%= envtype %>", -"url": "/<%= envid %>", -"version": "<%= envversion %>", -"info": "<%= envinfo %>" , - "properties":{ - "custom_wf": "<%= custom_wf %>", - "custom_wf_and_status": "<%= custom_wf_and_status %>", - "xmlrpc_enabled": "<%= xmlrpc_enabled %>", - "default": "<%= envdefault %>" - } + "type": "<%= envtype %>", + "url": "/<%= envid %>", + "version": "<%= envversion %>", + "info": "<%= envinfo %>", + "properties":{ +<% if @envdefault %><% if propertyanz.to_i > 0 %> ,<% else %> <% end %><% propertyanz = propertyanz.to_i -%><% propertyanz += 1 -%>"default": "<%= envdefault %>"<% end %> +<% if @custom_wf %><% if propertyanz.to_i > 0 %> ,<% else %> <% end %><% propertyanz = propertyanz.to_i -%><% propertyanz += 1 -%>"custom_wf": "<%= custom_wf %>"<% end %> +<% if @custom_wf_and_status %><% if propertyanz.to_i > 0 %> ,<% else %> <% end %><% propertyanz = propertyanz.to_i -%><% propertyanz += 1 -%>"custom_wf_and_status": "<%= custom_wf_and_status %>"<% end %> +<% if @xmlrpc_enabled %><% if propertyanz.to_i > 0 %> ,<% else %> <% end %><% propertyanz = propertyanz.to_i -%><% propertyanz += 1 -%>"xmlrpc_enabled": "<%= xmlrpc_enabled %>"<% end %> +<% if @desciptorfile > " " %><% if propertyanz.to_i > 0 %> ,<% else %> <% end %><% propertyanz = propertyanz.to_i -%><% propertyanz += 1 -%>"desciptorfile": "<%= desciptorfile %>"<% end %> + } } diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java index 3a953193e..ed07e4278 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java @@ -12,6 +12,8 @@ package org.eclipse.mylyn.bugzilla.tests; +import java.util.List; + import junit.framework.Test; import junit.framework.TestSuite; @@ -49,12 +51,9 @@ public class AllBugzillaHeadlessStandaloneTests { // network tests suite.addTestSuite(BugzillaTaskCompletionTest.class); // tests that run against all repository versions - if (configuration.isDefaultOnly()) { - addTests(suite, BugzillaFixture.DEFAULT); - } else { - for (BugzillaFixture fixture : BugzillaFixture.ALL) { - addTests(suite, fixture); - } + List<BugzillaFixture> fixtures = configuration.discover(BugzillaFixture.class, "bugzilla"); + for (BugzillaFixture fixture : fixtures) { + addTests(suite, fixture); } } return suite; 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 7fad7a747..fa4737627 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 @@ -12,6 +12,8 @@ package org.eclipse.mylyn.bugzilla.tests; +import java.util.List; + import junit.framework.Test; import junit.framework.TestSuite; @@ -24,7 +26,6 @@ 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 @@ -58,12 +59,9 @@ public class AllBugzillaTests { suite.addTestSuite(BugzillaTaskEditorTest.class); suite.addTestSuite(BugzillaSearchPageTest.class); suite.addTestSuite(BugzillaRepositorySettingsPageTest.class); - if (configuration.isDefaultOnly()) { - addTests(suite, BugzillaFixture.DEFAULT); - } else { - for (BugzillaFixture fixture : BugzillaFixture.ALL) { - addTests(suite, fixture); - } + List<BugzillaFixture> fixtures = configuration.discover(BugzillaFixture.class, "bugzilla"); + for (BugzillaFixture fixture : fixtures) { + addTests(suite, fixture); } } } @@ -83,8 +81,7 @@ public class AllBugzillaTests { fixture.add(BugzillaAttachmentHandlerTest.class); // Only run this if we have custom status and Workflow - if (BugzillaVersion.BUGZILLA_3_6.compareTo(fixture.getBugzillaVersion()) == 0 - && BugzillaFixture.CUSTOM_WF_AND_STATUS.equals(fixture.getDescription())) { + if (fixture.isCustomWorkflowAndStatus()) { fixture.add(BugzillaCustomRepositoryTest.class); } diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java index 06381dbb3..d99d53f95 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaTaskDataHandlerTest.java @@ -16,7 +16,6 @@ import junit.framework.TestCase; import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture; import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil.PrivilegeLevel; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; -import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector; import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants; import org.eclipse.mylyn.internal.tasks.core.DefaultTaskMapping; @@ -38,12 +37,9 @@ public class BugzillaTaskDataHandlerTest extends TestCase { private BugzillaRepositoryConnector connector; - private BugzillaClient client; - @Override public void setUp() throws Exception { repository = BugzillaFixture.current().repository(); - client = BugzillaFixture.current().client(); connector = BugzillaFixture.current().connector(); } diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java index 4a233ae83..be0e1af87 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaConfigurationTest.java @@ -109,46 +109,50 @@ public class BugzillaConfigurationTest extends TestCase { * included (rdfconfig218.txt) is from mylyn.eclipse.org/bugs218 */ public void testRepositoryConfigurationFromFile() throws Exception { - InputStream stream = BugzillaFixture.getResource("testdata/configuration/rdfconfig218.txt"); - BufferedReader in = new BufferedReader(new InputStreamReader(stream)); - - if (true) { + BufferedReader inCleaned = null; + try { File tempFile = File.createTempFile("XmlCleaner-", "tmp"); tempFile.deleteOnExit(); - in = XmlCleaner.clean(in, tempFile); - if (tempFile != null) { - tempFile.delete(); - } - - } - - SaxConfigurationContentHandler contentHandler = new SaxConfigurationContentHandler(); - final XMLReader reader = XMLReaderFactory.createXMLReader(); - reader.setContentHandler(contentHandler); - reader.setErrorHandler(new ErrorHandler() { - - public void error(SAXParseException exception) throws SAXException { - throw exception; - } - public void fatalError(SAXParseException exception) throws SAXException { - throw exception; + InputStream stream = BugzillaFixture.getResource("testdata/configuration/rdfconfig218.txt"); + BufferedReader in = new BufferedReader(new InputStreamReader(stream)); + try { + inCleaned = XmlCleaner.clean(in, tempFile); + if (tempFile != null) { + tempFile.delete(); + } + } finally { + in.close(); } - public void warning(SAXParseException exception) throws SAXException { - throw exception; + SaxConfigurationContentHandler contentHandler = new SaxConfigurationContentHandler(); + final XMLReader reader = XMLReaderFactory.createXMLReader(); + reader.setContentHandler(contentHandler); + reader.setErrorHandler(new ErrorHandler() { + public void error(SAXParseException exception) throws SAXException { + throw exception; + } + + public void fatalError(SAXParseException exception) throws SAXException { + throw exception; + } + + public void warning(SAXParseException exception) throws SAXException { + throw exception; + } + }); + reader.parse(new InputSource(inCleaned)); + + RepositoryConfiguration config = contentHandler.getConfiguration(); + assertNotNull(config); + + assertTrue(config.getOptionValues(BugzillaAttribute.PRODUCT).contains( + "Test-Long-Named-Product-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); + } finally { + if (inCleaned != null) { + inCleaned.close(); } - }); - reader.parse(new InputSource(in)); - - RepositoryConfiguration config = contentHandler.getConfiguration(); - assertNotNull(config); - - assertTrue(config.getOptionValues(BugzillaAttribute.PRODUCT).contains( - "Test-Long-Named-Product-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); - - // Add your additional checking for valid data here if necessary - + } } } 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 6d85d9185..acb6951f2 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,9 +14,7 @@ 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; @@ -51,25 +49,10 @@ import org.eclipse.osgi.util.NLS; /** * @author Steffen Pingel * @author Thomas Ehrnhoefer + * @author Frank Becker */ public class BugzillaFixture extends TestFixture { - public static final String TEST_BUGZILLA_34_URL = getServerUrl("bugs34"); - - public static final String TEST_BUGZILLA_36_URL = getServerUrl("bugs36"); - - public static final String TEST_BUGZILLA_40_URL = getServerUrl("bugs40"); - - public static final String TEST_BUGZILLA_42_URL = getServerUrl("bugs42"); - - public static final String TEST_BUGZILLA_44_URL = getServerUrl("bugs44"); - - public static final String TEST_BUGZILLA_HEAD_URL = getServerUrl("bugshead"); - - private static final String getServerUrl(String version) { - return TestConfiguration.getRepositoryUrl(version); - } - public static final String CUSTOM_WF = "Custom Workflow"; public static final String CUSTOM_WF_AND_STATUS = "Custom Workflow and Status"; @@ -78,47 +61,14 @@ public class BugzillaFixture extends TestFixture { private static BugzillaFixture current; - /** - * @deprecated not supported any more - */ - @Deprecated - private static BugzillaFixture BUGS_3_4 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_34_URL, // - "3.4.14", ""); - - private static BugzillaFixture BUGS_3_6 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_36_URL, // - "3.6", ""); - - private static BugzillaFixture BUGS_3_6_CUSTOM_WF = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_36_URL - + "-custom-wf", "3.6", CUSTOM_WF); - - 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); - - private static BugzillaFixture BUGS_3_6_XML_RPC_DISABLED = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_36_URL - + "-xml-rpc-disabled", "3.6", XML_RPC_DISABLED); - - private static BugzillaFixture BUGS_4_0 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_40_URL, // - "4.0", ""); - - private static BugzillaFixture BUGS_4_2 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_42_URL, // - "4.2", ""); - - private static BugzillaFixture BUGS_4_4 = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_44_URL, // - "4.4", ""); - - private static BugzillaFixture BUGS_HEAD = new BugzillaFixture(BugzillaFixture.TEST_BUGZILLA_HEAD_URL, // - "4.5", ""); - - public static BugzillaFixture DEFAULT; - - public static final List<BugzillaFixture> ALL; - private final String version; private final BugzillaVersion bugzillaVersion; private final Map<String, String> properties; + private BugzillaRepositoryConnector connector; + public BugzillaFixture(FixtureConfiguration config) { super(BugzillaCorePlugin.CONNECTOR_KIND, config.getUrl()); this.version = config.getVersion(); @@ -146,17 +96,14 @@ public class BugzillaFixture extends TestFixture { public static void cleanup010() throws Exception { } - public static BugzillaFixture current(BugzillaFixture fixture) { + public static BugzillaFixture current() { if (current == null) { - fixture.activate(); + current = TestConfiguration.getDefault().discoverDefault(BugzillaFixture.class, "bugzilla"); + current.activate(); } return current; } - public static BugzillaFixture current() { - return current(DEFAULT); - } - @Override public BugzillaFixture activate() { current = this; @@ -166,7 +113,7 @@ public class BugzillaFixture extends TestFixture { @Override protected TestFixture getDefault() { - return DEFAULT; + return TestConfiguration.getDefault().discoverDefault(BugzillaFixture.class, "bugzilla"); } public String getVersion() { @@ -190,16 +137,18 @@ public class BugzillaFixture extends TestFixture { public BugzillaClient client(AbstractWebLocation location, String encoding) throws CoreException { TaskRepository taskRepository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, location.getUrl()); - String filepath = "testdata/repository/" + getRepositoryName(location.getUrl()) + "/DesciptorFile.txt"; - try { - File file = BugzillaFixture.getFile(filepath); - if (file != null) { - taskRepository.setProperty(IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE, file.getCanonicalPath()); + if (properties.get("desciptorfile") != null) { + String filepath = "testdata/repository/" + properties.get("desciptorfile"); + try { + File file = BugzillaFixture.getFile(filepath); + if (file != null) { + taskRepository.setProperty(IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE, file.getCanonicalPath()); + } + } catch (AssertionFailedError a) { + // ignore the Exception. The BUGZILLA_DESCRIPTOR_FILE does not exist so the property is null + } catch (IOException e) { + // ignore the Exception. The BUGZILLA_DESCRIPTOR_FILE does not exist so the property is null } - } catch (AssertionFailedError a) { - // ignore the Exception. The BUGZILLA_DESCRIPTOR_FILE does not exist so the property is null - } catch (IOException e) { - // ignore the Exception. The BUGZILLA_DESCRIPTOR_FILE does not exist so the property is null } taskRepository.setCredentials(AuthenticationType.REPOSITORY, @@ -208,8 +157,7 @@ public class BugzillaFixture extends TestFixture { taskRepository.setCredentials(AuthenticationType.HTTP, location.getCredentials(AuthenticationType.HTTP), false); taskRepository.setCharacterEncoding(encoding); - BugzillaRepositoryConnector connector = new BugzillaRepositoryConnector(); - super.connector = connector; + connector = new BugzillaRepositoryConnector(); BugzillaClientManager bugzillaClientManager = connector.getClientManager(); BugzillaClient client = bugzillaClientManager.getClient(taskRepository, null); @@ -256,7 +204,7 @@ public class BugzillaFixture extends TestFixture { description = "description"; } BugzillaClient client = client(level); - AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler(); + AbstractTaskDataHandler taskDataHandler = connector().getTaskDataHandler(); TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository()); TaskData taskData = new TaskData(mapper, repository().getConnectorKind(), repository().getRepositoryUrl(), ""); taskDataHandler.initializeTaskData(repository(), taskData, null, null); @@ -279,7 +227,7 @@ public class BugzillaFixture extends TestFixture { * @throws Exception */ public TaskData getTask(String id, BugzillaClient client) throws Exception { - final AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler(); + final AbstractTaskDataHandler taskDataHandler = connector().getTaskDataHandler(); TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository()); final TaskData[] newData = new TaskData[1]; client.getTaskData(Collections.singleton(id), new TaskDataCollector() { @@ -299,15 +247,7 @@ public class BugzillaFixture extends TestFixture { @Override public BugzillaRepositoryConnector connector() { - return (BugzillaRepositoryConnector) connector; - } - - private static final String getServerUrl() { - String url = TestConfiguration.getRepositoryUrl(""); - if (url.endsWith("/")) { - return url.substring(0, url.length() - 1); - } - return url; + return connector; } public String getProperty(String key) { @@ -317,48 +257,8 @@ public class BugzillaFixture extends TestFixture { 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; + public boolean isCustomWorkflowAndStatus() { + return Boolean.parseBoolean(properties.get("custom_wf_and_status")); } - 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.getDefault().discover(BugzillaFixture.class, "bugzilla"); - DEFAULT = getDefaultFixture(fixtureList); - ALL = getAll(fixtureList); - } } diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaSearchPageTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaSearchPageTest.java index 1f9f7152d..018ff03e2 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaSearchPageTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/ui/BugzillaSearchPageTest.java @@ -31,7 +31,7 @@ public class BugzillaSearchPageTest extends TestCase { @Override public void setUp() throws Exception { - repository = BugzillaFixture.DEFAULT.singleRepository(); + repository = BugzillaFixture.current().singleRepository(); } /** diff --git a/org.eclipse.mylyn.bugzilla.tests/testdata/repository/bugs36-custom-wf-and-status/DesciptorFile.txt b/org.eclipse.mylyn.bugzilla.tests/testdata/repository/DescriptorFile-custom-wf-and-status.txt index bdbd77b37..bdbd77b37 100644 --- a/org.eclipse.mylyn.bugzilla.tests/testdata/repository/bugs36-custom-wf-and-status/DesciptorFile.txt +++ b/org.eclipse.mylyn.bugzilla.tests/testdata/repository/DescriptorFile-custom-wf-and-status.txt diff --git a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java index 387764668..dfb13655a 100644 --- a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java +++ b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java @@ -100,8 +100,6 @@ public abstract class TestFixture { TasksUiPlugin.getExternalizationManager().saveNow(); } - protected AbstractRepositoryConnector connector; - private final String connectorKind; private String repositoryName; @@ -130,7 +128,7 @@ public abstract class TestFixture { } public AbstractRepositoryConnector connector() { - return connector; + return TasksUi.getRepositoryConnector(connectorKind); } public TestSuite createSuite(TestSuite parentSuite) { diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java index ea221777c..f80294cd8 100644 --- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java +++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java @@ -30,7 +30,6 @@ import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector; import org.eclipse.mylyn.internal.trac.core.client.ITracClient; import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version; import org.eclipse.mylyn.tasks.core.TaskRepository; -import org.eclipse.mylyn.tasks.ui.TasksUi; import org.eclipse.mylyn.tests.util.TestFixture; /** @@ -47,17 +46,14 @@ public class TracFixture extends TestFixture { private static TracFixture current; - public static TracFixture current(TracFixture fixture) { + public static TracFixture current() { if (current == null) { - fixture.activate(); + current = TestConfiguration.getDefault().discoverDefault(TracFixture.class, "trac"); + current.activate(); } return current; } - public static TracFixture current() { - return current(TestConfiguration.getDefault().discoverDefault(TracFixture.class, "trac")); - } - private final Version accessMode; private final String version; @@ -177,7 +173,7 @@ public class TracFixture extends TestFixture { @Override public TracRepositoryConnector connector() { - return (TracRepositoryConnector) TasksUi.getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND); + return (TracRepositoryConnector) super.connector(); } public TracHarness createHarness() { |