001 package org.hackystat.telemetry.service.test; 002 003 import org.hackystat.telemetry.service.server.Server; 004 import org.junit.BeforeClass; 005 006 import static org.hackystat.telemetry.service.server.ServerProperties.SENSORBASE_FULLHOST_KEY; 007 import static org.hackystat.telemetry.service.server.ServerProperties.DAILYPROJECTDATA_FULLHOST_KEY; 008 009 /** 010 * Provides a helper class to facilitate JUnit testing. 011 * @author Philip Johnson 012 */ 013 public class TelemetryTestHelper { 014 015 /** The Sensorbase server used in these tests. */ 016 @SuppressWarnings("unused") 017 private static org.hackystat.sensorbase.server.Server sensorbaseServer; 018 /** The DailyProjectData server used in these tests. */ 019 @SuppressWarnings("unused") 020 private static org.hackystat.dailyprojectdata.server.Server dpdServer; 021 /** The Telemetry server used in these tests. */ 022 private static org.hackystat.telemetry.service.server.Server server; 023 024 025 /** 026 * Constructor. 027 */ 028 public TelemetryTestHelper () { 029 // Does nothing. 030 } 031 032 /** 033 * Starts the server going for these tests. 034 * @throws Exception If problems occur setting up the server. 035 */ 036 @BeforeClass public static void setupServer() throws Exception { 037 // Create testing versions of the Sensorbase, DPD, and Telemetry servers. 038 TelemetryTestHelper.sensorbaseServer = org.hackystat.sensorbase.server.Server.newTestInstance(); 039 TelemetryTestHelper.dpdServer = org.hackystat.dailyprojectdata.server.Server.newTestInstance(); 040 TelemetryTestHelper.server = Server.newTestInstance(); 041 } 042 043 044 /** 045 * Returns the hostname associated with this Telemetry test server. 046 * @return The host name, including the context root. 047 */ 048 protected String getTelemetryHostName() { 049 return TelemetryTestHelper.server.getHostName(); 050 } 051 052 /** 053 * Returns the sensorbase hostname that this Telemetry server communicates with. 054 * @return The host name, including the context root. 055 */ 056 protected String getSensorBaseHostName() { 057 return TelemetryTestHelper.server.getServerProperties().get(SENSORBASE_FULLHOST_KEY); 058 } 059 060 /** 061 * Returns the DPD hostname that this Telemetry server communicates with. 062 * @return The host name, including the context root. 063 */ 064 protected String getDailyProjectDataHostName() { 065 return TelemetryTestHelper.server.getServerProperties().get(DAILYPROJECTDATA_FULLHOST_KEY); 066 } 067 } 068