Add initial code to verify that the server is running correctly

master
bspeice 2013-10-18 17:14:29 -04:00
parent 90aa09ae17
commit 73b0b06d02
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
package com.uncc.gameday.registration.test;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import com.uncc.gameday.R;
import com.uncc.gameday.registration.ParkingLot;
import com.uncc.gameday.registration.RegistrationClient;
import android.net.http.AndroidHttpClient;
import android.test.AndroidTestCase;
/* Tests the REST functionality */
public class RESTTest extends AndroidTestCase {
public void setUp() throws Exception {
super.setUp();
// Code run before each test goes here.
// Make sure that we can actually contact the server
/*
* Can't use InetAddress since the emulator doesn't support `ping`
InetAddress host = InetAddress.getByName(this.mContext.getString(R.string.server_hostname));
if (!host.isReachable(5000))
fail("Could not contact Gameday server!");
*/
HttpURLConnection connection = (HttpURLConnection) new URL("http", mContext.getString(R.string.server_hostname), "gameday")
.openConnection();
if (connection.getResponseCode() != connection.HTTP_OK)
fail("Could not connect to GameDay! Response code: " + connection.getResponseCode());
}
}