KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > agent > client > util > UtilsTest


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program 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
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.agent.client.util;
21
22 import static org.junit.Assert.assertFalse;
23 import static org.junit.Assert.assertTrue;
24
25 import org.junit.Test;
26
27 public class UtilsTest {
28
29     @Test
30     public void testIsSupportedJREGreatherThan() {
31         System.setProperty("java.version", "1.4");
32         assertTrue("1.3 supported by 1.4", Utils.isSupportedJRE("+1.3"));
33         assertTrue("1.4 supported by 1.4", Utils.isSupportedJRE("+1.4"));
34         assertFalse("1.4.5 not supported by 1.4", Utils.isSupportedJRE("+1.4.5"));
35         assertFalse("1.5 not supported by 1.4", Utils.isSupportedJRE("+1.5"));
36         assertFalse("1.5.0 not supported by 1.4", Utils.isSupportedJRE("+1.5.0"));
37
38         System.setProperty("java.version", "1.1.1");
39         assertTrue("1.0 is supported by 1.1.1", Utils.isSupportedJRE("+1.0"));
40         assertTrue("1.1.1 supported by 1.1.1", Utils.isSupportedJRE("1.1.1"));
41         assertTrue("1.1.1 supported by 1.1.1", Utils.isSupportedJRE("+1.1.1"));
42         assertFalse("1.1.2 not supported by 1.1.1", Utils.isSupportedJRE("+1.1.2"));
43         assertFalse("1.4.5 not supported by 1.1.1", Utils.isSupportedJRE("+1.4.5"));
44     }
45
46     @Test
47     public void testIsSupportedJRELessThan() {
48         System.setProperty("java.version", "1.4");
49         assertFalse("-1.3 not supported by 1.4", Utils.isSupportedJRE("-1.3"));
50         assertTrue("-1.4 supported by 1.4", Utils.isSupportedJRE("-1.4"));
51         assertTrue("-1.5 supported by 1.4", Utils.isSupportedJRE("-1.5"));
52
53         System.setProperty("java.version", "1.1.4");
54         assertTrue("-1.3 not supported by 1.1.4", Utils.isSupportedJRE("-1.3"));
55         assertFalse("+1.3 not supported by 1.1.4", Utils.isSupportedJRE("+1.3"));
56     }
57
58     @Test
59     public void testIsSupportedOSVersionLessThan() {
60         System.setProperty("os.version", "6.0");
61         assertFalse("-5.0 not supported by 6.0", Utils.isSupportedOSVersion("-5.0"));
62         assertFalse("-5.9 not supported by 6.0", Utils.isSupportedOSVersion("-5.9"));
63         assertTrue("6.0 supported by 6.0", Utils.isSupportedOSVersion("-6.0"));
64         assertTrue("6.1 supported by 6.0", Utils.isSupportedOSVersion("-6.1"));
65     }
66 }
67
Popular Tags