mirror of
				https://github.com/bspeice/UNCCGameDay-Test
				synced 2025-11-03 18:00:44 -05:00 
			
		
		
		
	Add initial code to verify that the server is running correctly
This commit is contained in:
		
							
								
								
									
										36
									
								
								src/com/uncc/gameday/registration/test/RESTTest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/com/uncc/gameday/registration/test/RESTTest.java
									
									
									
									
									
										Normal 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());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user