1 4 package com.tc.object.tools; 5 6 import com.tc.test.TCTestCase; 7 8 import java.util.Properties ; 9 10 public class BootJarSignatureTest extends TCTestCase { 11 12 public void testExceptions() { 13 try { 14 new BootJarSignature(new Properties ()); 15 fail(); 16 } catch (UnsupportedVMException uve) { 17 } 19 20 try { 21 new BootJarSignature(makeProps(null, "Sun", "1.5.0_04", "i686")); 22 fail(); 23 } catch (UnsupportedVMException uve) { 24 } 26 27 try { 28 new BootJarSignature(makeProps("Windows NT", null, "1.5.0_04", "i686")); 29 fail(); 30 } catch (UnsupportedVMException uve) { 31 } 33 34 try { 35 new BootJarSignature(makeProps("Windows NT", "1.4.2_04", null, "i686")); 36 fail(); 37 } catch (UnsupportedVMException uve) { 38 } 40 41 } 42 43 public void testSolaris() throws UnsupportedVMException { 44 Properties 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 } 59 60 } 61 62 public void testWindows() throws UnsupportedVMException { 63 Properties 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 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 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 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 makeProps(String os, String vendor, String version, String arch) { 96 Properties props = new Properties (); 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 |