01: //////////////////////////////////////////////////////////////////////////////
02: //Clirr: compares two versions of a java library for binary compatibility
03: //Copyright (C) 2004 Lars Kühne
04: //
05: //This library is free software; you can redistribute it and/or
06: //modify it under the terms of the GNU Lesser General Public
07: //License as published by the Free Software Foundation; either
08: //version 2.1 of the License, or (at your option) any later version.
09: //
10: //This library is distributed in the hope that it will be useful,
11: //but WITHOUT ANY WARRANTY; without even the implied warranty of
12: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: //Lesser General Public License for more details.
14: //
15: //You should have received a copy of the GNU Lesser General Public
16: //License along with this library; if not, write to the Free Software
17: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: //////////////////////////////////////////////////////////////////////////////
19:
20: package net.sf.clirr.maven;
21:
22: import java.util.ArrayList;
23:
24: import org.apache.maven.project.Version;
25:
26: import junit.framework.TestCase;
27:
28: /**
29: * Unit tests for {@link ClirrUtils}.
30: *
31: * @author Vincent Massol
32: */
33: public class ClirrUtilsTest extends TestCase {
34: public void testGetLatestVersionWhenNoVersionElementsDefined() {
35: String result = ClirrUtils.getLatestVersion(new ArrayList());
36: assertNull(result);
37: }
38:
39: public void testGetLatestVersionWhenNoReleasedVersionElementDefined() {
40: Version unreleasedVersion = new Version();
41: unreleasedVersion.setId("0.1");
42: unreleasedVersion.setTag("HEAD");
43:
44: ArrayList versions = new ArrayList();
45: versions.add(unreleasedVersion);
46:
47: String result = ClirrUtils.getLatestVersion(versions);
48: assertNull(result);
49: }
50:
51: public void testGetLatestVersionWhenReleasedVersionElementsDefined() {
52: Version releasedVersion = new Version();
53: releasedVersion.setId("0.1");
54: releasedVersion.setTag("RELEASE_DUMMY_0_1");
55:
56: Version unreleasedVersion = new Version();
57: unreleasedVersion.setId("0.2");
58: unreleasedVersion.setTag("HEAD");
59:
60: ArrayList versions = new ArrayList();
61: versions.add(releasedVersion);
62: versions.add(unreleasedVersion);
63:
64: String result = ClirrUtils.getLatestVersion(versions);
65: assertEquals("0.1", result);
66: }
67: }
|