Package net.jini.event

Examples of net.jini.event.RemoteEventIterator


  if(tpl.verifyEvents(bogus)) {
      throw new TestException("Successfully verified bogus events");
  }

        // Get iterator handle before cancelling associated reg
        RemoteEventIterator rei = mr.getRemoteEvents();
       
  logger.log(Level.INFO, "Cancelling registration lease");
  mrl.cancel();

  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " more events");
  try {
      for (i = 0; i < NUM_EVENTS; i++) {
          events[i] = myGen.generateEvent(evtReg.getID(), 3);
      }
  } catch (ServerException se) {
      if (se.detail != null &&
          se.detail instanceof NoSuchObjectException) {
    // can safely ignore this since we expect
    // that the registration has expired.
          logger.log(Level.INFO, "Caught NoSuchObjectException - expected");
      } else { throw se; }
  }
       
        // Would like to assert that the event count hasn't changed, but
        // invoking getRemoteEvents should fail with NSOE, as above.

  try {
      logger.log(Level.INFO, "Re-cancelling registration lease");
      mrl.cancel();
      throw new TestException("Successfully cancelled a cancelled registration");
  } catch (UnknownLeaseException ule) {
      logger.log(Level.INFO, "Caught UnknownLeaseException - expected");
  }
       
  try {
      logger.log(Level.INFO, "Calling getRemoteEvents on expired reg");
      mr.getRemoteEvents();
      throw new TestException("Successfully called a cancelled registration");
  } catch (NoSuchObjectException nsoe) {
      logger.log(Level.INFO, "Caught NoSuchObjectException - expected");
  }
       
  try {
      logger.log(Level.INFO, "Calling addUnknownEvents on expired reg");
      mr.addUnknownEvents(new java.util.ArrayList());
      throw new TestException("Successfully called a cancelled registration");
  } catch (NoSuchObjectException nsoe) {
      logger.log(Level.INFO, "Caught NoSuchObjectException - expected");
  }
       
        logger.log(Level.INFO, "Calling next() on expired reg iterator");
        RemoteEvent re;
        boolean done = false;
        int exceptionCount = 0;
        while (!done) {
           try {
               re = rei.next(MAX_WAIT);
               if (re != null) {
                   logger.log(Level.INFO, "Got RemoteEvent", re);
               } else {
                   throw new TestException(
                        "Successfully iterated through an expired iter ref");
               }
            } catch (NoSuchObjectException nsoe) {
                logger.log(Level.INFO, "Caught NoSuchObjectException - expected");
                done = true;
            } catch (RemoteException rex) {
                // log and retry
                logger.log(Level.INFO, "Caught RemoteException", rex);
                if (exceptionCount++ >= 10) {
                    throw new TestException(
                        "Too many remote exceptions received");
                }
            }
        }

        logger.log(Level.INFO, "Calling close() on expired reg iterator");
  rei.close();
         try {
      logger.log(Level.INFO, "Calling close() again on expired reg iterator");
      rei.close();
      throw new TestException("Successfully called a close twice");
  } catch (InvalidIteratorException iie) {
      logger.log(Level.INFO, "Caught InvalidIteratorException - expected");
  }
View Full Code Here


  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }

        // Get iterator handle and exercise it
        RemoteEventIterator rei = mr.getRemoteEvents();
        rei.next(MAX_WAIT); // ignore result
       
  // Generate some more events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }
       
        // Get new iterator handle and exercise it
        RemoteEventIterator rei_2 = mr.getRemoteEvents();
        rei_2.next(MAX_WAIT); // ignore result
       
        if (rei == rei_2 ||
            rei.equals(rei_2) ||
            rei_2.equals(rei)) {
                throw new TestException(
                    "Remote event iterators weren't unique");
        }
       
        //New iterator should eventually invalidate the old iterator
        try {
            RemoteEvent ev;
            while ((ev = rei.next(MAX_WAIT)) != null) {
          logger.log(Level.INFO,
                    "Retreived event through invalid iter: {0}", ev);
            }
            throw new TestException(
                "Successfully iterated through invalid iterator");
        } catch (InvalidIteratorException iie) {
      logger.log(Level.INFO,
                "Caught InvalidIteratorException -- expected", iie);
        }
       
        //New iterator should still be valid
        rei_2.next(MAX_WAIT);
       
        //Verify that old iterator is still invalid for all methods
        try {
            RemoteEvent ev;
            while ((ev = rei.next(MAX_WAIT)) != null) {
View Full Code Here

  assertEvent(goodListener, re);

        // Switch to pull interface -- should disable event listener
  logger.log(Level.INFO, "Switching to pull listener -- not expecting any events.");
  goodPullCount = 0;       
        RemoteEventIterator rei = mr.getRemoteEvents();
        RemoteEvent rei_event = rei.next(MAX_WAIT);
        if (rei_event != null) {
            throw new TestException("Got event from empty iterator " + rei_event);
        }
  logger.log(Level.INFO, "Event iterator was empty -- OK");

  //
  // Kill event mailbox service
  //
  shutdown(0);

        // Generate another event and verify that it isn't delivered
  logger.log(Level.INFO, "Generating another event");
  re = myGen.generateEvent(evtReg.getID(), 3);
  // Don't bump goodCount because it shouldn't be delivered
  logger.log(Level.INFO, "Wating for event delivery" + goodCount);
        // Force delay by waiting for goodCount+1 -- should not get an event, though
        waitForEvents(goodListener, goodCount+1, MAX_WAIT/NUM_EVENTS);
  logger.log(Level.INFO, "Asserting event count");
  assertCount(goodListener, goodCount);
       
  //
  // Kill event mailbox service
  //
  shutdown(0);

  goodPullCount++;
  logger.log(Level.INFO, "Getting events. Expecting " + goodPullCount);
        rei_event  = rei.next(MAX_WAIT/NUM_EVENTS);
        if (rei_event == null ||
            !new RemoteEventHandle(rei_event).equals(new RemoteEventHandle(re))) {
            throw new TestException(
                "Didn't get expected event from iterator: " + rei_event);
        }
  logger.log(Level.INFO, "Got expected event from iterator");
 
        // Note checking for "empty" also forces the proxy the call the
        // the service back to see if there are anymore events, which will
        // also advance the read pointer past the last returned event. This
        // will prevent the "push" listener from seeing an extra event later on.
        rei_event  = rei.next(MAX_WAIT/NUM_EVENTS);
        if (rei_event != null) {
            throw new TestException(
                "Got unexpected event from empty iterator: " + rei_event);
        }
  logger.log(Level.INFO, "Verified iterator is empty");
 
        // Re-enable good listener. Should invalidate the iterator.
  logger.log(Level.INFO, "Re-enabling good listener");
  mr.enableDelivery(goodListener);
       
  logger.log(Level.INFO, "Trying to pull events from invalid iterator reference");
        try {
            rei.next(MAX_WAIT/NUM_EVENTS);
            throw new TestException("Successfully called invalid iterator.");
        } catch (InvalidIteratorException iie) {
       logger.log(Level.INFO, "Caught expected IllegalIteratorException", iie);          
        }
       
View Full Code Here

                    dAdmin, logger, MAX_WAIT_SEND_DESTROY ));
        t.start();
       
        // Get events and verify
  logger.log(Level.INFO, "Getting events from empty mailbox.");
        RemoteEventIterator rei = mr.getRemoteEvents();
        RemoteEvent rei_event = null;
        Date before = new Date();
  logger.log(Level.INFO, "Calling next() on empty set @ {0}", before);       
        try {
            rei_event = rei.next(MAX_WAIT_GET_EVENT);
            throw new TestException("Did not receive expected exception");
        } catch (NoSuchObjectException nsoe) {
            logger.log(Level.INFO, "Caught expected exception", nsoe);
        }
        Date after = new Date();
View Full Code Here

  else
      throw new TestException("Identity property doesn't hold "
          + "for the registration objects");
       
        // Check secondary I/Fs
        RemoteEventIterator rei = mr1.getRemoteEvents();
        try {
            rei.next(-1L);
      throw new TestException("Successfully called iterator "
          + "with negative timeout.");
  } catch (IllegalArgumentException iae) {
      logger.log(Level.INFO,
           "Caught expected IllegalArgumentException for next()");
View Full Code Here

TOP

Related Classes of net.jini.event.RemoteEventIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.