diff options
author | relves | 2009-01-29 16:16:38 +0000 |
---|---|---|
committer | relves | 2009-01-29 16:16:38 +0000 |
commit | 1b28bebbbbee442c2d5722977a9ebebb5f9d61d8 (patch) | |
tree | b949ebfc4650c7cef8f6ef5188d282ae189014d3 /org.eclipse.mylyn.bugzilla.tests | |
parent | 762c9881a0262e37051639363db6f5ae5f9d6230 (diff) | |
download | org.eclipse.mylyn.tasks-1b28bebbbbee442c2d5722977a9ebebb5f9d61d8.tar.gz org.eclipse.mylyn.tasks-1b28bebbbbee442c2d5722977a9ebebb5f9d61d8.tar.xz org.eclipse.mylyn.tasks-1b28bebbbbee442c2d5722977a9ebebb5f9d61d8.zip |
NEW - bug 260963: [patch] string compare for Bugzilla versions is not robust
https://bugs.eclipse.org/bugs/show_bug.cgi?id=260963
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests')
3 files changed, 69 insertions, 5 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 9c6582592..455c82ebd 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 @@ -42,6 +42,7 @@ public class AllBugzillaTests { suite.addTestSuite(BugzillaSearchDialogTest.class); suite.addTestSuite(BugzillaTaskHistoryTest.class); suite.addTestSuite(BugzillaRepository32Test.class); + suite.addTestSuite(BugzillaVersionTest.class); return suite; } diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java index eb1300937..a1c2c278e 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaConfigurationTest.java @@ -71,7 +71,7 @@ public class BugzillaConfigurationTest extends TestCase { BugzillaClient client = createClient(IBugzillaConstants.TEST_BUGZILLA_222_URL, "", "", "", "", "UTF-8"); RepositoryConfiguration config = client.getRepositoryConfiguration(); assertNotNull(config); - assertEquals("2.22.1", config.getInstallVersion()); + assertEquals("2.22.1", config.getInstallVersion().toString()); assertEquals(7, config.getStatusValues().size()); assertEquals(8, config.getResolutions().size()); assertEquals(4, config.getPlatforms().size()); @@ -89,7 +89,7 @@ public class BugzillaConfigurationTest extends TestCase { BugzillaClient client = createClient(IBugzillaConstants.TEST_BUGZILLA_2201_URL, "", "", "", "", "UTF-8"); RepositoryConfiguration config = client.getRepositoryConfiguration(); assertNotNull(config); - assertEquals("2.20.1", config.getInstallVersion()); + assertEquals("2.20.1", config.getInstallVersion().toString().toString()); assertEquals(7, config.getStatusValues().size()); assertEquals(8, config.getResolutions().size()); assertEquals(4, config.getPlatforms().size()); @@ -107,7 +107,7 @@ public class BugzillaConfigurationTest extends TestCase { BugzillaClient client = createClient(IBugzillaConstants.TEST_BUGZILLA_220_URL, "", "", "", "", "UTF-8"); RepositoryConfiguration config = client.getRepositoryConfiguration(); assertNotNull(config); - assertEquals("2.20.3", config.getInstallVersion()); + assertEquals("2.20.3", config.getInstallVersion().toString()); assertEquals(7, config.getStatusValues().size()); assertEquals(8, config.getResolutions().size()); assertEquals(4, config.getPlatforms().size()); @@ -125,7 +125,7 @@ public class BugzillaConfigurationTest extends TestCase { BugzillaClient client = createClient(IBugzillaConstants.TEST_BUGZILLA_218_URL, "", "", "", "", "UTF-8"); RepositoryConfiguration config = client.getRepositoryConfiguration(); assertNotNull(config); - assertEquals("2.18.6", config.getInstallVersion()); + assertEquals("2.18.6", config.getInstallVersion().toString()); assertEquals(7, config.getStatusValues().size()); assertEquals(8, config.getResolutions().size()); assertEquals(8, config.getPlatforms().size()); @@ -143,7 +143,7 @@ public class BugzillaConfigurationTest extends TestCase { BugzillaClient client = createClient(IBugzillaConstants.ECLIPSE_BUGZILLA_URL, "", "", "", "", "UTF-8"); RepositoryConfiguration config = client.getRepositoryConfiguration(); assertNotNull(config); - assertEquals("3.0.4", config.getInstallVersion()); + assertEquals("3.0.4", config.getInstallVersion().toString()); assertEquals(7, config.getStatusValues().size()); assertEquals(9, config.getResolutions().size()); assertEquals(6, config.getPlatforms().size()); diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaVersionTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaVersionTest.java new file mode 100644 index 000000000..5778fa130 --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaVersionTest.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 Tasktop Technologies and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tasktop Technologies - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.bugzilla.tests; + +import junit.framework.TestCase; + +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaVersion; + +/** + * @author Frank Becker + */ +public class BugzillaVersionTest extends TestCase { + + public final static BugzillaVersion BUGZILLA_2_18_1 = new BugzillaVersion("2.18.1"); + + public final static BugzillaVersion BUGZILLA_2_18_2 = new BugzillaVersion("2.18.2"); + + public final static BugzillaVersion BUGZILLA_2_20_3 = new BugzillaVersion("2.20.3"); + + public final static BugzillaVersion BUGZILLA_3_0_4 = new BugzillaVersion("3.0.4"); + + public void testwrongVersion() throws Exception { + try { + new BugzillaVersion("3.2.X"); + fail("NumberFormatException expected!"); + } catch (Exception e) { + assertTrue(e instanceof NumberFormatException); + assertEquals("For input string: \"X\"", e.getMessage()); + } + } + + public void testCompareAll() throws Exception { + assertEquals(0, BUGZILLA_2_18_1.compareTo(BUGZILLA_2_18_1)); + assertEquals(-1, BUGZILLA_2_18_1.compareTo(BUGZILLA_2_18_2)); + assertEquals(1, BUGZILLA_2_18_2.compareTo(BUGZILLA_2_18_1)); + + assertEquals(-1, BUGZILLA_2_18_1.compareTo(BUGZILLA_2_20_3)); + assertEquals(1, BUGZILLA_3_0_4.compareMajorMinorOnly(BUGZILLA_2_20_3)); + } + + public void testCompareMajorMinorOnly() throws Exception { + assertEquals(0, BUGZILLA_2_18_1.compareMajorMinorOnly(BUGZILLA_2_18_1)); + assertEquals(0, BUGZILLA_2_18_1.compareMajorMinorOnly(BUGZILLA_2_18_2)); + assertEquals(0, BUGZILLA_2_18_2.compareMajorMinorOnly(BUGZILLA_2_18_1)); + + assertEquals(-1, BUGZILLA_2_18_1.compareMajorMinorOnly(BUGZILLA_2_20_3)); + assertEquals(1, BUGZILLA_3_0_4.compareMajorMinorOnly(BUGZILLA_2_20_3)); + } + + public void testToString() throws Exception { + assertEquals("2.18.1", BUGZILLA_2_18_1.toString()); + assertEquals("3.0.4", BUGZILLA_3_0_4.toString()); + } +} |