1 22 package org.objectweb.petals.util; 23 24 import java.io.File ; 25 26 import junit.framework.TestCase; 27 28 33 public class SystemUtilTest extends TestCase { 34 35 public void setUp() { 36 SystemUtil.petalsInstallDirectory = null; 37 } 38 39 public void testGetPetalsInstallDirectory() { 40 File dir = SystemUtil.petalsInstallDirectory; 41 assertNull(dir); 42 } 43 44 public void testResolveInstallDirectoryFromEnvironment() { 45 File dir = SystemUtil.resolveInstallDirectoryFromEnvironment(); 46 if (System.getenv().get("PETALS_HOME") != null) { 47 assertNotNull(dir); 48 } else { 49 assertNull(dir); 50 } 51 } 52 53 public void testResolveInstallDirectoryFromEnvironment1() { 54 System.setProperty("petals.home", new File (".").getAbsolutePath()); 55 File dir = SystemUtil.resolveInstallDirectoryFromEnvironment(); 56 assertNotNull(dir); 57 } 58 59 public void testResolveInstallDirectoryFromFramework() { 60 File dir = SystemUtil.resolveInstallDirectoryFromFramework(); 61 assertNotNull(dir); 62 } 63 64 public void testGettersSetters() { 65 assertNotNull(SystemUtil.getContainerName()); 66 SystemUtil.setContainerName("cont"); 67 assertEquals(SystemUtil.getContainerName(), "cont"); 68 69 assertNotNull(SystemUtil.getContainerUID()); 70 SystemUtil.setContainerUID(1); 71 assertEquals(SystemUtil.getContainerUID(), 1); 72 73 assertNotNull(SystemUtil.getHost()); 74 SystemUtil.setHost("127.0.0.1"); 75 assertEquals(SystemUtil.getHost(), "127.0.0.1"); 76 77 assertNotNull(SystemUtil.getHtmlPort()); 78 SystemUtil.setHtmlPort("8082"); 79 assertEquals(SystemUtil.getHtmlPort(), "8082"); 80 81 assertNotNull(SystemUtil.getJmxPassword()); 82 SystemUtil.setJmxPassword("pass"); 83 assertEquals(SystemUtil.getJmxPassword(), "pass"); 84 85 assertNotNull(SystemUtil.getJmxPort()); 86 SystemUtil.setJmxPort("8081"); 87 assertEquals("8081", SystemUtil.getJmxPort()); 88 89 assertNotNull(SystemUtil.getJmxUser()); 90 SystemUtil.setJmxUser("user"); 91 assertEquals(SystemUtil.getJmxUser(), "user"); 92 93 assertNotNull(SystemUtil.getJndiFactory()); 94 SystemUtil.setJndiFactory("test"); 95 assertEquals(SystemUtil.getJndiFactory(), "test"); 96 97 assertNotNull(SystemUtil.getJndiPort()); 98 SystemUtil.setJndiPort("16400"); 99 assertEquals(SystemUtil.getJndiPort(), "16400"); 100 101 assertNotNull(SystemUtil.getJoramDomain()); 102 SystemUtil.setJoramDomain("test"); 103 assertEquals(SystemUtil.getJoramDomain(), "test"); 104 105 assertNotNull(SystemUtil.getJoramDomainPort()); 106 SystemUtil.setJoramDomainPort("16200"); 107 assertEquals(SystemUtil.getJoramDomainPort(), "16200"); 108 109 assertNotNull(SystemUtil.getJoramId()); 110 SystemUtil.setJoramId("1"); 111 assertEquals(SystemUtil.getJoramId(), "1"); 112 113 assertNotNull(SystemUtil.getJoramPassword()); 114 SystemUtil.setJoramPassword("foo"); 115 assertEquals(SystemUtil.getJoramPassword(), "foo"); 116 117 assertNotNull(SystemUtil.getJoramTCPPort()); 118 SystemUtil.setJoramTCPPort("16300"); 119 assertEquals(SystemUtil.getJoramTCPPort(), "16300"); 120 121 assertNotNull(SystemUtil.getJoramUser()); 122 SystemUtil.setJoramUser("bar"); 123 assertEquals(SystemUtil.getJoramUser(), "bar"); 124 125 SystemUtil.setPetalsInstallDirectory(new File (".")); 126 assertEquals(SystemUtil.getPetalsInstallDirectory(), new File (".")); 127 128 assertNotNull(SystemUtil.getTribeMulticastAddress()); 129 SystemUtil.setTribeMulticastAddress("214.0.0.1"); 130 assertEquals(SystemUtil.getTribeMulticastAddress(), "214.0.0.1"); 131 132 SystemUtil.setExchangeValidation("true"); 133 assertTrue(SystemUtil.isExchangeValidation()); 134 } 135 } 136 | Popular Tags |