public void multipleRequests() throws Exception {
logger.debug("multipleRequests");
Caller caller1 = this.populator().getCaller("CALLER1");
Caller caller2 = this.populator().getCaller("CALLER2");
Manager rm = this.locator.getManager();
Double previousPrice = rm.getSpotPrice();
final Double bid1 = previousPrice + 3;
final Double bid2 = previousPrice + 1;
final Double bid3 = previousPrice + 1;
SpotCreateRequest req1 = this.populator().getBasicRequestSI("req1", 1, bid1, false);
SpotCreateRequest req2 = this.populator().getBasicRequestSI("req1", 3, bid2, false);
SpotCreateRequest req3 = this.populator().getBasicRequestSI("req1", 4, bid3, false);
SpotRequestInfo result1 = rm.requestSpotInstances(req1, caller1);
SpotRequestInfo result2 = rm.requestSpotInstances(req2, caller2);
SpotRequestInfo result3 = rm.requestSpotInstances(req3, caller1);
assertEquals(result1, rm.getSpotRequest(result1.getRequestID(), caller1));
assertEquals(result2, rm.getSpotRequest(result2.getRequestID(), caller2));
assertEquals(result3, rm.getSpotRequest(result3.getRequestID(), caller1));
//New spot price is equal largest bid + 0.1 (since there are 0 resources)
assertEquals(bid1 + 0.1, rm.getSpotPrice());
SpotRequestInfo[] spotRequestByCaller1 = rm.getSpotRequestsByCaller(caller1);
assertEquals(2, spotRequestByCaller1.length);
SpotRequestInfo[] spotRequestByCaller2 = rm.getSpotRequestsByCaller(caller2);
assertEquals(1, spotRequestByCaller2.length);
//Cancel requests
rm.cancelSpotInstanceRequests(new String[]{result1.getRequestID(), result3.getRequestID()}, caller1);
SpotRequestInfo[] cancelledReqs = rm.cancelSpotInstanceRequests(new String[]{result2.getRequestID()}, caller2);
//Check if requests were really cancelled
assertEquals(RequestState.STATE_Canceled, cancelledReqs[0].getState().getStateStr());
spotRequestByCaller1 = rm.getSpotRequestsByCaller(caller1);
assertEquals(RequestState.STATE_Canceled, spotRequestByCaller1[0].getState().getStateStr());
assertEquals(RequestState.STATE_Canceled, spotRequestByCaller1[1].getState().getStateStr());
}