KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > tools > BootJarSignatureTest


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.tools;
5
6 import com.tc.test.TCTestCase;
7
8 import java.util.Properties JavaDoc;
9
10 public class BootJarSignatureTest extends TCTestCase {
11
12   public void testExceptions() {
13     try {
14       new BootJarSignature(new Properties JavaDoc());
15       fail();
16     } catch (UnsupportedVMException uve) {
17       // expected
18
}
19
20     try {
21       new BootJarSignature(makeProps(null, "Sun", "1.5.0_04", "i686"));
22       fail();
23     } catch (UnsupportedVMException uve) {
24       // expected
25
}
26
27     try {
28       new BootJarSignature(makeProps("Windows NT", null, "1.5.0_04", "i686"));
29       fail();
30     } catch (UnsupportedVMException uve) {
31       // expected
32
}
33
34     try {
35       new BootJarSignature(makeProps("Windows NT", "1.4.2_04", null, "i686"));
36       fail();
37     } catch (UnsupportedVMException uve) {
38       // expected
39
}
40
41   }
42
43   public void testSolaris() throws UnsupportedVMException {
44     Properties JavaDoc props = makeProps("SunOS", "Sun Microsystems Inc.", "1.5.0_06", "sparc");
45     BootJarSignature sig = new BootJarSignature(props);
46     assertEquals("hotspot_solaris_150_06", sig.getSignature());
47
48     props = makeProps("SunOS", "Sun Microsystems Inc.", "1.4.2_12", "x86");
49     sig = new BootJarSignature(props);
50     assertEquals("hotspot_solaris-x86_142_12", sig.getSignature());
51
52     try {
53       props = makeProps("SunOS", "Sun Microsystems Inc.", "1.5.0_06", null);
54       new BootJarSignature(props);
55       fail();
56     } catch (UnsupportedVMException uve) {
57       // expected (since os.arch was null)
58
}
59
60   }
61
62   public void testWindows() throws UnsupportedVMException {
63     Properties JavaDoc props = makeProps("Windows XP", "Sun Microsystems Inc.", "1.5.0_06", null);
64     BootJarSignature sig = new BootJarSignature(props);
65     assertEquals("hotspot_win32_150_06", sig.getSignature());
66
67     props = makeProps("Windows 2000", "Sun Microsystems Inc.", "1.4.2_12", null);
68     sig = new BootJarSignature(props);
69     assertEquals("hotspot_win32_142_12", sig.getSignature());
70   }
71
72   public void testMac() throws UnsupportedVMException {
73     Properties JavaDoc props = makeProps("Mac OS X", "Apple Computer, Inc.", "1.5.0_05", null);
74     BootJarSignature sig = new BootJarSignature(props);
75     assertEquals("hotspot_osx_150_05", sig.getSignature());
76   }
77
78   public void testLinux() throws UnsupportedVMException {
79     Properties JavaDoc props = makeProps("Linux", "Sun Microsystems, Inc.", "1.5.0_01", null);
80     BootJarSignature sig = new BootJarSignature(props);
81     assertEquals("hotspot_linux_150_01", sig.getSignature());
82
83     props = makeProps("Linux", "BEA Systems, Inc.", "1.5.0_03", null);
84     sig = new BootJarSignature(props);
85     assertEquals("jrockit_linux_150_03", sig.getSignature());
86
87     // test this exceptional case
88
props = makeProps("Linux", "Sun Microsystems, Inc.", "1.4.2_05", null);
89     props.setProperty("java.vm.name", "BEA WebLogic JRockit(TM) 1.4.2_05 JVM R24.5.0-0");
90     props.setProperty("jrockit.version", "ari-41062-20050215-0919-linux-ia32");
91     sig = new BootJarSignature(props);
92     assertEquals("jrockit_linux_142_05", sig.getSignature());
93   }
94
95   private Properties JavaDoc makeProps(String JavaDoc os, String JavaDoc vendor, String JavaDoc version, String JavaDoc arch) {
96     Properties JavaDoc props = new Properties JavaDoc();
97     if (version != null) props.put("java.version", version);
98     if (os != null) props.put("os.name", os);
99     if (arch != null) props.put("os.arch", arch);
100     if (vendor != null) props.put("java.vendor", vendor);
101     return props;
102   }
103
104 }
105
Popular Tags