Beispiel #1
0
 public void testOverrunReqOrder() {
   HashQueue q = new HashQueue();
   HashQueue.Request req1 = simpleReq(1000, 100);
   HashQueue.Request req2 = simpleReq(2000, 100);
   HashQueue.Request reqO1 = simpleReq(500, 100);
   reqO1.timeUsed = 600;
   HashQueue.Request reqO2 = simpleReq(1500, 100);
   reqO2.timeUsed = 1600;
   assertTrue(reqO1.runBefore(reqO2));
   assertFalse(reqO2.runBefore(reqO1));
   assertTrue(req1.runBefore(reqO1));
   assertTrue(req2.runBefore(reqO1));
   assertTrue(req1.runBefore(reqO2));
   assertTrue(req2.runBefore(reqO2));
 }
Beispiel #2
0
 // test request acceptance
 public void testAccept() {
   HashQueue q = new HashQueue();
   HashQueue.Request r1, r2, r3, r4, r5, r6;
   r1 = simpleReq(-1, 100);
   r2 = simpleReq(2000, 1000);
   r3 = simpleReq(3000, 2900);
   assertEquals(null, q.head());
   assertFalse(q.insert(r1));
   assertTrue(q.insert(r2));
   assertFalse(q.insert(r3));
   // change r2 to overrun
   r2.timeUsed = 1200;
   // r3 should now be accepted.  It would prevent r2 from finishing in
   // time, but sr2 should be ignored as it has overrun.
   assertTrue(q.insert(r3));
 }
Beispiel #3
0
 // test insert order
 public void testInsertOrder() throws Exception {
   HashQueue q = new HashQueue();
   HashQueue.Request r1, r2, r3, r4, r5, r6, r7;
   r1 = simpleReq(2000, 0);
   r2 = simpleReq(3000, 0);
   r3 = simpleReq(5000, 0);
   r4 = simpleReq(2500, 0);
   r5 = simpleReq(200, 0);
   r6 = simpleReq(200, 0); // identical to r5, inserted before it
   // so should go before it in queue
   // One that has overrun, should end up last
   r7 = simpleReq(200, 0);
   r7.timeUsed = 201;
   Object ord[] = {r6, r5, r1, r4, r2, r3, r7};
   assertTrue(q.insert(r1));
   assertTrue(q.insert(r2));
   assertTrue(q.insert(r3));
   assertTrue(q.insert(r6));
   assertTrue(q.insert(r4));
   assertTrue(q.insert(r5));
   assertTrue(q.insert(r7));
   assertIsomorphic(ord, (Collection) PrivilegedAccessor.getValue(q, "qlist"));
 }