1 19 20 26 27 package projects; 28 29 import java.io.InputStream ; 30 31 import java.net.InetAddress ; 32 import java.net.UnknownHostException ; 33 import java.util.Properties ; 34 import org.netbeans.jellytools.JellyTestCase; 35 36 import org.netbeans.junit.*; 37 import junit.framework.*; 38 39 import org.netbeans.api.java.platform.JavaPlatformManager; 40 import org.netbeans.api.java.platform.JavaPlatform; 41 42 45 public class TestPlatforms extends JellyTestCase { 46 47 public static final String JDK13_NAME = "JDK1.3"; 48 public static final String JDK14_NAME = "JDK1.4"; 49 public static final String JDK15_NAME = "JDK1.5"; 50 51 public TestPlatforms(java.lang.String testName) { 52 super(testName); 53 } 54 55 public static void main(java.lang.String [] args) { 56 junit.textui.TestRunner.run(suite()); 57 } 58 59 public static Test suite() { 60 TestSuite suite = new NbTestSuite(); 62 suite.addTest(new TestPlatforms("testCreatePlatforms")); 63 suite.addTest(new TestPlatforms("testAvailablePlatforms")); 64 return suite; 65 } 66 67 69 public void testAvailablePlatforms() { 70 71 JavaPlatformManager platMan = JavaPlatformManager.getDefault(); 72 JavaPlatform platforms[] = platMan.getInstalledPlatforms(); 73 String [] platNames = new String [platforms.length]; 74 for (int i = 0; i < platforms.length; i++) { 75 System.out.println("Display Name: " + platforms[i].getDisplayName()); 76 platNames[i] = platforms[i].getDisplayName(); 77 } 78 80 } 81 82 public void testCreatePlatforms() { 84 85 String hostName = null; 87 try { 88 hostName = InetAddress.getLocalHost().getHostName(); 89 } catch (UnknownHostException uhe) { 90 fail("Cannot get hostname: " + uhe.getMessage()); } 92 hostName = hostName.replace('-', '_'); 93 94 InputStream is = this.getClass().getResourceAsStream("platforms.properties"); 96 Properties props = new Properties (); 97 try { 98 props.load(is); 99 } catch (java.io.IOException ioe) { 100 fail("Cannot load platforms properties: " + ioe.getMessage()); } 102 103 String folderJDK13Path = props.getProperty(hostName + "_jdk13_folder"); 105 TestProjectUtils.addPlatform(JDK13_NAME, folderJDK13Path); 106 String folderJDK14Path = props.getProperty(hostName + "_jdk14_folder"); 107 TestProjectUtils.addPlatform(JDK14_NAME, folderJDK14Path); 108 String folderJDK15Path = props.getProperty(hostName + "_jdk15_folder"); 109 TestProjectUtils.addPlatform(JDK15_NAME, folderJDK15Path); 110 111 } 112 113 } 114
| Popular Tags
|