From 73b0b06d0228902312cc785701b5e2d13a6e36fa Mon Sep 17 00:00:00 2001 From: bspeice Date: Fri, 18 Oct 2013 17:14:29 -0400 Subject: [PATCH] Add initial code to verify that the server is running correctly --- .../gameday/registration/test/RESTTest.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/com/uncc/gameday/registration/test/RESTTest.java diff --git a/src/com/uncc/gameday/registration/test/RESTTest.java b/src/com/uncc/gameday/registration/test/RESTTest.java new file mode 100644 index 0000000..ca62405 --- /dev/null +++ b/src/com/uncc/gameday/registration/test/RESTTest.java @@ -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()); + } + +}