001    package org.hackystat.dailyprojectdata.resource.ping;
002    
003    import static org.junit.Assert.assertTrue;
004    import org.hackystat.dailyprojectdata.client.DailyProjectDataClient;
005    import org.hackystat.dailyprojectdata.test.DailyProjectDataTestHelper;
006    import org.hackystat.sensorbase.client.SensorBaseClient;
007    import org.junit.Test;
008    
009    /**
010     * Tests the Ping REST API.
011     * 
012     * @author Philip Johnson
013     */
014    public class TestPingRestApi extends DailyProjectDataTestHelper {
015    
016      /**
017       * Test that GET {host}/ping returns "DailyProjectData", and that
018       * GET {host}/ping?user={user}&password={password} returns "DailyProjectData authenticated". 
019       * 
020       * @throws Exception If problems occur.
021       */
022      @Test
023      public void testPing() throws Exception {
024        //First, just call isHost, which uses the standard ping. 
025        String dpdHost = getDailyProjectDataHostName();
026        assertTrue("Checking ping", DailyProjectDataClient.isHost(dpdHost));
027        //Next, check authenticated ping. 
028        String user = "TestDpdPing@hackystat.org";
029        SensorBaseClient.registerUser(getSensorBaseHostName(), user);
030        DailyProjectDataClient client = new DailyProjectDataClient(dpdHost, user, user);
031        client.authenticate();    
032      }
033    }