KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > util > SystemUtilTest


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: SystemUtilTest.java 10:27:27 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.util;
23
24 import java.io.File JavaDoc;
25
26 import junit.framework.TestCase;
27
28 /**
29  * Test of the SystemUtil
30  *
31  * @author ddesjardins - eBMWebsourcing
32  */

33 public class SystemUtilTest extends TestCase {
34
35     public void setUp() {
36         SystemUtil.petalsInstallDirectory = null;
37     }
38
39     public void testGetPetalsInstallDirectory() {
40         File JavaDoc dir = SystemUtil.petalsInstallDirectory;
41         assertNull(dir);
42     }
43
44     public void testResolveInstallDirectoryFromEnvironment() {
45         File JavaDoc 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 JavaDoc(".").getAbsolutePath());
55         File JavaDoc dir = SystemUtil.resolveInstallDirectoryFromEnvironment();
56         assertNotNull(dir);
57     }
58
59     public void testResolveInstallDirectoryFromFramework() {
60         File JavaDoc 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 JavaDoc("."));
126         assertEquals(SystemUtil.getPetalsInstallDirectory(), new File JavaDoc("."));
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