// 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"));
 }
 private void measureHashSpeed(SimulatedArchivalUnit sau) throws Exception {
   MessageDigest dig = null;
   try {
     dig = MessageDigest.getInstance("SHA-1");
   } catch (NoSuchAlgorithmException ex) {
     fail("No algorithm.");
   }
   CachedUrlSet set = sau.getAuCachedUrlSet();
   CachedUrlSetHasher hasher = set.getContentHasher(dig);
   SystemMetrics metrics = theDaemon.getSystemMetrics();
   int estimate = metrics.getBytesPerMsHashEstimate(hasher, dig);
   // should be protected against this being zero by MyMockSystemMetrics,
   // but otherwise use the proper calculation.  This avoids test failure
   // due to really slow machines
   assertTrue(estimate > 0);
   long estimatedTime = set.estimatedHashDuration();
   long size = ((Long) PrivilegedAccessor.getValue(set, "totalNodeSize")).longValue();
   assertTrue(size > 0);
   System.out.println("b/ms: " + estimate);
   System.out.println("size: " + size);
   System.out.println("estimate: " + estimatedTime);
   assertEquals(estimatedTime, theDaemon.getHashService().padHashEstimate(size / estimate));
 }