KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > util > PlatformTest


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package test.util;
8
9 import org.ejtools.util.Platform;
10
11 import junit.framework.TestCase;
12
13 /**
14  * @author letiemble
15  * @version $Revision: 1.2 $
16  */

17 public class PlatformTest extends TestCase
18 {
19    /** Constructor for the ClassToolsTest object */
20    public PlatformTest()
21    {
22       super();
23    }
24
25
26    /**
27     * Constructor for the ClassToolsTest object
28     *
29     * @param name Description of the Parameter
30     */

31    public PlatformTest(String JavaDoc name)
32    {
33       super(name);
34    }
35
36
37    /** A unit test for JUnit */
38    public void testJavaVersion()
39    {
40       assertEquals("Version is wrong", Platform.getJavaVersion(), "1.4.5");
41
42       assertFalse("Version is not 1.1", Platform.IS_JAVA_1_1);
43       assertFalse("Version is not 1.2", Platform.IS_JAVA_1_2);
44       assertFalse("Version is not 1.3", Platform.IS_JAVA_1_3);
45       assertTrue("Version is not 1.4", Platform.IS_JAVA_1_4);
46       assertFalse("Version is not 1.5", Platform.IS_JAVA_1_5);
47    }
48
49
50    /** A unit test for JUnit */
51    public void testJavaVersionCompatiblity()
52    {
53       assertTrue("Version is compatible with 1.1", Platform.isJavaVersionCompatible(Platform.JAVA_1_1));
54       assertTrue("Version is compatible with 1.2", Platform.isJavaVersionCompatible(Platform.JAVA_1_2));
55       assertTrue("Version is compatible with 1.3", Platform.isJavaVersionCompatible(Platform.JAVA_1_3));
56       assertTrue("Version is compatible with 1.4", Platform.isJavaVersionCompatible(Platform.JAVA_1_4));
57       assertFalse("Version is compatible with 1.5", Platform.isJavaVersionCompatible(Platform.JAVA_1_5));
58    }
59
60
61    /**
62     * The JUnit setup method
63     *
64     * @exception Exception Description of the Exception
65     */

66    protected void setUp()
67       throws Exception JavaDoc
68    {
69       System.setProperty("java.version", "1.4.5");
70    }
71 }
72
Popular Tags