public boolean checkEvents(BundleEvent[] expevents) {
   boolean res = true;
   for (int i = 0; i < 20; i++) {
     try {
       Thread.sleep(100);
     } catch (InterruptedException ignore) {
     }
     if (events.size() == expevents.length) {
       break;
     }
   }
   if (events.size() == expevents.length) {
     for (int i = 0; i < events.size(); i++) {
       BundleEvent be = (BundleEvent) events.elementAt(i);
       if (!(be.getBundle().equals(expevents[i].getBundle())
           && be.getType() == expevents[i].getType())) {
         res = false;
       }
     }
   } else {
     res = false;
   }
   if (!res) {
     out.println("Real events");
     for (int i = 0; i < events.size(); i++) {
       BundleEvent be = (BundleEvent) events.elementAt(i);
       out.println("Event " + be.getBundle() + ", Type " + be.getType());
     }
     out.println("Expected events");
     for (int i = 0; i < expevents.length; i++) {
       out.println("Event " + expevents[i].getBundle() + ", Type " + expevents[i].getType());
     }
   }
   return res;
 }
Пример #2
0
  public long[] getBundleEvents() {
    synchronized (bundleEvents) {
      long[] r = new long[bundleEvents.size() * 2];
      int i = 0;

      for (Iterator it = bundleEvents.iterator(); it.hasNext(); ) {
        BundleEvent ev = (BundleEvent) it.next();
        r[i * 2] = ev.getBundle().getBundleId();
        r[i * 2 + 1] = ev.getType();
        i++;
      }
      bundleEvents.clear();
      return r;
    }
  }