001: /*
002: * To change this template, choose Tools | Templates
003: * and open the template in the editor.
004: */
005:
006: package org.netbeans.modules.sun.manager.jbi.util;
007:
008: import java.io.File;
009: import java.net.URI;
010: import java.net.URISyntaxException;
011: import java.util.List;
012: import org.junit.After;
013: import org.junit.AfterClass;
014: import org.junit.Before;
015: import org.junit.BeforeClass;
016: import org.junit.Test;
017: import static org.junit.Assert.*;
018:
019: /**
020: *
021: * @author jqian
022: */
023: public class ServerInstanceTest {
024:
025: List<ServerInstance> instances;
026:
027: public ServerInstanceTest() {
028: }
029:
030: @BeforeClass
031: public static void setUpClass() throws Exception {
032: }
033:
034: @AfterClass
035: public static void tearDownClass() throws Exception {
036: }
037:
038: @Before
039: public void setUp() throws URISyntaxException {
040: URI xmlURI = getClass().getResource("resources/nbattrs")
041: .toURI();
042: File xmlFile = new File(xmlURI);
043: ServerInstanceReader reader = new ServerInstanceReader(xmlFile
044: .getAbsolutePath());
045: instances = reader.getServerInstances();
046: }
047:
048: @After
049: public void tearDown() {
050: }
051:
052: /**
053: * Test of getDisplayName method, of class ServerInstance.
054: */
055: @Test
056: public void getDisplayName() {
057: System.out.println("getDisplayName");
058:
059: assertEquals("GlassFish V2 (b54)", instances.get(0)
060: .getDisplayName());
061: assertEquals("GlassFish V2 (b54 personal domain 2)", instances
062: .get(1).getDisplayName());
063: assertEquals("GlassFish V2", instances.get(2).getDisplayName());
064: }
065:
066: /**
067: * Test of getDomain method, of class ServerInstance.
068: */
069: @Test
070: public void getDomain() {
071: System.out.println("getDomain");
072:
073: assertEquals("domain1", instances.get(0).getDomain());
074: assertEquals("GFb54_PersonalDomain2", instances.get(1)
075: .getDomain());
076: assertEquals("", instances.get(2).getDomain());
077: }
078:
079: /**
080: * Test of getHttpMonitorOn method, of class ServerInstance.
081: */
082: @Test
083: public void getHttpMonitorOn() {
084: System.out.println("getHttpMonitorOn");
085:
086: assertEquals("true", instances.get(0).getHttpMonitorOn());
087: assertEquals("true", instances.get(1).getHttpMonitorOn());
088: assertEquals(null, instances.get(2).getHttpMonitorOn());
089: }
090:
091: /**
092: * Test of getHttpPortNumber method, of class ServerInstance.
093: */
094: @Test
095: public void getHttpPortNumber() {
096: System.out.println("getHttpPortNumber");
097:
098: assertEquals("8080", instances.get(0).getHttpPortNumber());
099: assertEquals("8105", instances.get(1).getHttpPortNumber());
100: assertEquals("2848", instances.get(2).getHttpPortNumber());
101: }
102:
103: /**
104: * Test of getLocation method, of class ServerInstance.
105: */
106: @Test
107: public void getLocation() {
108: System.out.println("getLocation");
109:
110: assertEquals("C:\\Glassfish-v2-b54\\glassfish\\domains",
111: instances.get(0).getLocation());
112: assertEquals("C:\\tmp", instances.get(1).getLocation());
113: assertEquals("", instances.get(2).getLocation());
114: }
115:
116: /**
117: * Test of getPassword method, of class ServerInstance.
118: */
119: @Test
120: public void getPassword() {
121: System.out.println("getPassword");
122:
123: assertEquals("adminadmin", instances.get(0).getPassword());
124: assertEquals("adminadmin", instances.get(1).getPassword());
125: assertEquals("adminadmin", instances.get(2).getPassword());
126: }
127:
128: /**
129: * Test of getUrl method, of class ServerInstance.
130: */
131: @Test
132: public void getUrl() {
133: System.out.println("getUrl");
134:
135: assertEquals(
136: "[C:\\Glassfish-v2-b54\\glassfish]deployer:Sun:AppServer::localhost:4848",
137: instances.get(0).getUrl());
138: assertEquals(
139: "[C:\\Glassfish-v2-b54\\glassfish]deployer:Sun:AppServer::localhost:4873",
140: instances.get(1).getUrl());
141: assertEquals(
142: "[C:\\Glassfish-v2-b54\\glassfish]deployer:Sun:AppServer::cordova.stc.com:2848",
143: instances.get(2).getUrl());
144: }
145:
146: /**
147: * Test of getUrlLocation method, of class ServerInstance.
148: */
149: @Test
150: public void getUrlLocation() {
151: System.out.println("getUrlLocation");
152:
153: assertEquals("C:\\Glassfish-v2-b54\\glassfish", instances
154: .get(0).getUrlLocation());
155: assertEquals("C:\\Glassfish-v2-b54\\glassfish", instances
156: .get(1).getUrlLocation());
157: assertEquals("C:\\Glassfish-v2-b54\\glassfish", instances
158: .get(2).getUrlLocation());
159: }
160:
161: /**
162: * Test of getUserName method, of class ServerInstance.
163: */
164: @Test
165: public void getUserName() {
166: System.out.println("getUserName");
167:
168: assertEquals("admin", instances.get(0).getUserName());
169: assertEquals("admin", instances.get(1).getUserName());
170: assertEquals("admin", instances.get(2).getUserName());
171: }
172:
173: /**
174: * Test of getAdminPort method, of class ServerInstance.
175: */
176: @Test
177: public void getAdminPort() {
178: System.out.println("getAdminPort");
179:
180: assertEquals("4848", instances.get(0).getAdminPort());
181: assertEquals("4873", instances.get(1).getAdminPort());
182: assertEquals("2848", instances.get(2).getAdminPort());
183: }
184:
185: /**
186: * Test of getHostName method, of class ServerInstance.
187: */
188: @Test
189: public void getHostName() {
190: System.out.println("getHostName");
191:
192: assertEquals("localhost", instances.get(0).getHostName());
193: assertEquals("localhost", instances.get(1).getHostName());
194: assertEquals("cordova.stc.com", instances.get(2).getHostName());
195: }
196: }
|