package org.sagebionetworks;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

/**
 * TODO instead use the Synapse Java Client for this sort of testing
 * 
 * @author deflaux
 *
 */
public class ITBasicRepository {

	private static Logger log = Logger.getLogger(ITBasicRepository.class
			.getName());
	private static List<String> urlsToTest = new ArrayList<String>();
	private static String repoBaseUrl = null;
	private static RestTemplate template;

	/**
	 * 
	 */
	@BeforeClass
	public static void beforeClass() {
		// Load the required system properties
		repoBaseUrl = Helpers.getRepositoryServiceBaseUrl();
		assertNotNull(
				"Failed to find the system property for repository service base url",
				repoBaseUrl);
		log.info("Loaded system property: " + repoBaseUrl);
		urlsToTest.add("dataset?sort=name&limit=3");
		template = new RestTemplate();
	}

	/**
	 * 
	 */
	@Test
	public void testAllURLs() {
		System.out.println("Starting the test...");
		// run each url on the list
		for (String suffix : urlsToTest) {
			String url = repoBaseUrl + suffix;
			System.out.println("Testing url: " + url);
			HttpHeaders headers = new HttpHeaders();
			headers.setContentType(MediaType.APPLICATION_JSON);
			HttpEntity<String> entity = new HttpEntity<String>("", headers);
			ResponseEntity<Object> response = template.exchange(url,
					HttpMethod.GET, entity, Object.class);
			assertNotNull(response);
			response.getStatusCode();
			System.out.println(response.getBody());
			assertEquals(HttpStatus.OK, response.getStatusCode());
		}
	}

}

@@ -116,24 +116,99 @@
 NotNull;%0D%0A%0D%0A
+import java.io.UnsupportedEncodingException;%0D%0Aimport java.net.URLEncoder;%0D%0A
 import java.
@@ -335,24 +335,89 @@
 unit.Test;%0D%0A
+import org.sagebionetworks.web.server.servlet.UserDataProvider;%0D%0A
 import org.s
@@ -1541,32 +1541,75 @@
 );%0D%0A%09%7D%0D%0A%0D%0A%09/**%0D%0A
+%09 * @throws UnsupportedEncodingException %0D%0A
 %09 * %0D%0A%09 */%0D%0A%09@Te
@@ -1638,16 +1638,52 @@
 llURLs()
+ throws UnsupportedEncodingException
  %7B%0D%0A%09%09Sy
@@ -1925,16 +1925,134 @@
 ers();%0D%0A
+%09%09%09String userId = URLEncoder.encode(%22admin%22, %22UTF-8%22);%0D%0A%09%09%09headers.add(UserDataProvider.SESSION_TOKEN_KEY, userId);%0D%0A
 %09%09%09heade

Fix for build