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