1 package net.sf.openrocket.arch;
3 import static org.junit.Assert.assertEquals;
10 * Note: These tests have not been tested on Windows, they might fail there
11 * due to a different directory separator character.
13 public class TestSystemInfo {
15 private String osname;
16 private String userhome;
20 this.osname = System.getProperty("os.name");
21 this.userhome = System.getProperty("user.home");
24 public void tearDown() {
25 System.setProperty("os.name", this.osname);
26 System.setProperty("user.home", this.userhome);
30 public void testWindows() {
33 System.setProperty("os.name", "Windows Me");
34 System.setProperty("user.home", "C:/Users/my user");
35 assertEquals(SystemInfo.Platform.WINDOWS, SystemInfo.getPlatform());
36 if (System.getenv("APPDATA") != null) {
37 assertEquals(new File(System.getenv("APPDATA") + "/OpenRocket/"), SystemInfo.getUserApplicationDirectory());
39 assertEquals(new File("C:/Users/my user/OpenRocket/"), SystemInfo.getUserApplicationDirectory());
46 public void testMacOS() {
49 System.setProperty("os.name", "Mac OS X");
50 System.setProperty("user.home", "/Users/My User");
51 assertEquals(SystemInfo.Platform.MAC_OS, SystemInfo.getPlatform());
52 assertEquals(new File("/Users/My User/Library/Application Support/OpenRocket/"),
53 SystemInfo.getUserApplicationDirectory());
59 public void testUnix() {
62 System.setProperty("user.home", "/home/myuser");
63 for (String os : new String[] { "Linux", "Solaris", "Foobar" }) {
64 System.setProperty("os.name", os);
66 assertEquals(SystemInfo.Platform.UNIX, SystemInfo.getPlatform());
67 assertEquals(new File("/home/myuser/.openrocket"), SystemInfo.getUserApplicationDirectory());