use of com.sun.jersey.core.util.MultivaluedMapImpl in project ORCID-Source by ORCID.
the class InternalAPITest method testGetLastModifiedDate.
@Test
public void testGetLastModifiedDate() throws JSONException {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("client_id", client1ClientId);
params.add("client_secret", client1ClientSecret);
params.add("grant_type", "client_credentials");
params.add("scope", ScopePathType.INTERNAL_PERSON_LAST_MODIFIED.value());
ClientResponse clientResponse = oauthHelper.getResponse(params, APIRequestType.INTERNAL);
assertNotNull(clientResponse);
assertEquals(Response.Status.OK.getStatusCode(), clientResponse.getStatus());
String body = clientResponse.getEntity(String.class);
JSONObject jsonObject = new JSONObject(body);
String accessToken = (String) jsonObject.get("access_token");
assertNotNull(accessToken);
assertFalse(PojoUtil.isEmpty(accessToken));
ClientResponse lastModifiedResponse = internalApiClient.viewPersonLastModified(user1OrcidId, accessToken);
assertNotNull(lastModifiedResponse);
String lastModified = lastModifiedResponse.getEntity(String.class);
jsonObject = new JSONObject(lastModified);
assertNotNull(jsonObject);
assertEquals(user1OrcidId, (String) jsonObject.getString("orcid"));
assertNotNull((String) jsonObject.getString("last-modified"));
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project hadoop by apache.
the class TestRMWebServicesSchedulerActivities method testWrongNodeId.
@Test
public void testWrongNodeId() throws Exception {
//Start RM so that it accepts app submissions
rm.start();
MockNM nm = new MockNM("127.0.0.1:1234", 24 * 1024, rm.getResourceTrackerService());
nm.registerNode();
try {
RMApp app1 = rm.submitApp(1024, "app1", "user1", null, "b1");
MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm);
am1.allocate(Arrays.asList(ResourceRequest.newInstance(Priority.UNDEFINED, "127.0.0.1", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "/default-rack", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "*", Resources.createResource(1024), 10)), null);
//Get JSON
WebResource r = resource();
MultivaluedMapImpl params = new MultivaluedMapImpl();
params.add("nodeId", "127.0.0.0");
ClientResponse response = r.path("ws").path("v1").path("cluster").path("scheduler/activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
nm.nodeHeartbeat(true);
Thread.sleep(1000);
//Get JSON
response = r.path("ws").path("v1").path("cluster").path("scheduler/activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
json = response.getEntity(JSONObject.class);
verifyNumberOfAllocations(json, 0);
} finally {
rm.stop();
}
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project hadoop by apache.
the class TestRMWebServicesSchedulerActivities method testAppActivityJSON.
@Test
public void testAppActivityJSON() throws Exception {
//Start RM so that it accepts app submissions
rm.start();
MockNM nm = new MockNM("127.0.0.1:1234", 24 * 1024, rm.getResourceTrackerService());
nm.registerNode();
try {
RMApp app1 = rm.submitApp(10, "app1", "user1", null, "b1");
//Get JSON
WebResource r = resource();
MultivaluedMapImpl params = new MultivaluedMapImpl();
params.add("appId", app1.getApplicationId().toString());
ClientResponse response = r.path("ws").path("v1").path("cluster").path("scheduler/app-activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
nm.nodeHeartbeat(true);
Thread.sleep(5000);
//Get JSON
response = r.path("ws").path("v1").path("cluster").path("scheduler/app-activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
json = response.getEntity(JSONObject.class);
verifyNumberOfAllocations(json, 1);
JSONObject allocations = json.getJSONObject("allocations");
verifyStateOfAllocations(allocations, "allocationState", "ACCEPTED");
verifyNumberOfAllocationAttempts(allocations, 1);
} finally {
rm.stop();
}
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project hadoop by apache.
the class TestRMWebServicesSchedulerActivities method testAssignMultipleContainersPerNodeHeartbeat.
@Test
public void testAssignMultipleContainersPerNodeHeartbeat() throws Exception {
//Start RM so that it accepts app submissions
rm.start();
MockNM nm = new MockNM("127.0.0.1:1234", 24 * 1024, rm.getResourceTrackerService());
nm.registerNode();
try {
RMApp app1 = rm.submitApp(10, "app1", "user1", null, "b1");
MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm);
am1.allocate(Arrays.asList(ResourceRequest.newInstance(Priority.UNDEFINED, "127.0.0.1", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "/default-rack", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "*", Resources.createResource(1024), 10)), null);
//Get JSON
WebResource r = resource();
MultivaluedMapImpl params = new MultivaluedMapImpl();
params.add("nodeId", "127.0.0.1:1234");
ClientResponse response = r.path("ws").path("v1").path("cluster").path("scheduler/activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
nm.nodeHeartbeat(true);
Thread.sleep(1000);
//Get JSON
response = r.path("ws").path("v1").path("cluster").path("scheduler/activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
json = response.getEntity(JSONObject.class);
verifyNumberOfAllocations(json, 11);
JSONArray allocations = json.getJSONArray("allocations");
for (int i = 0; i < allocations.length(); i++) {
if (i != allocations.length() - 1) {
verifyStateOfAllocations(allocations.getJSONObject(i), "finalAllocationState", "ALLOCATED");
verifyQueueOrder(allocations.getJSONObject(i), "root-a-b-b2-b3-b1");
}
}
} finally {
rm.stop();
}
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project hadoop by apache.
the class TestRMWebServicesSchedulerActivities method testAppAssignMultipleContainersPerNodeHeartbeat.
@Test
public void testAppAssignMultipleContainersPerNodeHeartbeat() throws Exception {
//Start RM so that it accepts app submissions
rm.start();
MockNM nm = new MockNM("127.0.0.1:1234", 24 * 1024, rm.getResourceTrackerService());
nm.registerNode();
try {
RMApp app1 = rm.submitApp(1024, "app1", "user1", null, "b1");
MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm);
am1.allocate(Arrays.asList(ResourceRequest.newInstance(Priority.UNDEFINED, "127.0.0.1", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "/default-rack", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "*", Resources.createResource(1024), 10)), null);
//Get JSON
WebResource r = resource();
MultivaluedMapImpl params = new MultivaluedMapImpl();
params.add("appId", app1.getApplicationId().toString());
ClientResponse response = r.path("ws").path("v1").path("cluster").path("scheduler/app-activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
nm.nodeHeartbeat(true);
Thread.sleep(5000);
//Get JSON
response = r.path("ws").path("v1").path("cluster").path("scheduler/app-activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
json = response.getEntity(JSONObject.class);
verifyNumberOfAllocations(json, 10);
JSONArray allocations = json.getJSONArray("allocations");
for (int i = 0; i < allocations.length(); i++) {
verifyStateOfAllocations(allocations.getJSONObject(i), "allocationState", "ACCEPTED");
}
} finally {
rm.stop();
}
}
Aggregations