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; }
/** * Creates a <tt>RegistrationStateChangeEvent</tt> corresponding to the specified old and new * states and notifies all currently registered listeners. * * @param oldState the state that the provider had before the change occurred * @param newState the state that the provider is currently in. * @param reasonCode a value corresponding to one of the REASON_XXX fields of the * RegistrationStateChangeEvent class, indicating the reason for this state transition. * @param reason a String further explaining the reason code or null if no such explanation is * necessary. */ private void fireRegistrationStateChanged( RegistrationState oldState, RegistrationState newState, int reasonCode, String reason) { RegistrationStateChangeEvent event = new RegistrationStateChangeEvent(this, oldState, newState, reasonCode, reason); logger.debug( "Dispatching " + event + " to " + registrationStateListeners.size() + " listeners."); Iterator listeners = null; synchronized (registrationStateListeners) { listeners = new ArrayList(registrationStateListeners).iterator(); } while (listeners.hasNext()) { RegistrationStateChangeListener listener = (RegistrationStateChangeListener) listeners.next(); listener.registrationStateChanged(event); } logger.trace("Done."); }