1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.core.api.util;
17
18 import junit.framework.TestCase;
19 import org.junit.Test;
20
21
22
23
24
25
26
27
28
29 public class VersionHelperTest extends TestCase
30 {
31
32 @Test
33 public void testVersionHelper() {
34 String verOne[] = {"1.2.3","6.8.83.4","5.0","snapshot-2.3.5", "something-0.333.447...-nice" };
35 String verTwo[] = {"1.2.1","6.8.83","5.9","2.3-snapshot", "0.345...777" };
36 boolean results[] = {false, false, true, false, true, false};
37 int intResults[] = {1,1,-1,1,-1};
38
39 for(int i=0;i<verOne.length;i++) {
40 assertEquals(VersionHelper.compareVersion(verOne[i],verTwo[i]), intResults[i]);
41 }
42
43 for(int i=0;i<verOne.length;i++) {
44 assertEquals(VersionHelper.compareVersion(verTwo[i],verOne[i]), -1*intResults[i]);
45 }
46
47
48
49 assertEquals(VersionHelper.compareVersion("7.7.7","7.7.7"), 0);
50 }
51
52 @Test
53 public void testUndefined() {
54 assertEquals(VersionHelper.compareVersion("undefined", "2.1.3-snapshot"), -1);
55 assertEquals(VersionHelper.compareVersion("2.1.3", "undefined"), -1);
56
57 }
58
59 }