Package net.jini.core.event

Examples of net.jini.core.event.EventRegistration


  RemoteEventListener mbRel = getPullMailboxListener(mr);

  // Create an event generator and pass it the
  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  EventRegistration evtReg =
      myGen.register(EVENT_ID,  // Event ID to use
         null,    // handback
         mbRel,    // Notification target
         DURATION1)// Lease duration
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION1);

  int goodCount = 0;

  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  RemoteEvent[] events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }

  RemoteEvent[] bogus = {
      new RemoteEvent(myGen, 9999, 9999, null),
      new RemoteEvent(myGen, 5678, 1234, null),
View Full Code Here


  RemoteEventListener mbRel = getPullMailboxListener(mr);

  // Create an event generator and pass it the
  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  EventRegistration evtReg =
      myGen.register(EVENT_ID,  // Event ID to use
         null,    // handback
         mbRel,    // Notification target
         DURATION1)// Lease duration
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION1);

  int goodCount = 0;

  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  RemoteEvent[] events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }

  RemoteEvent[] bogus = {
      new RemoteEvent(myGen, 9999, 9999, null),
      new RemoteEvent(myGen, 5678, 1234, null),
View Full Code Here

       
  // Create an event generator and pass it the
  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  logger.log(Level.INFO, "Got TestGenerator ref {0}", myGen);
  EventRegistration evtReg =
      myGen.register(EVENT_ID,       // Event ID to use
         null,      // handback
         mbRel,          // Notification target
         DURATION1)// Lease duration
  logger.log(Level.INFO, "Got EventRegistration ref {0}", evtReg);
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION1);
  logger.log(Level.INFO, "EventRegistration lease good until "
        + new Date(tgl.getExpiration()));

  // Create two listener objects
  TestListener myListener =
      TestUtils.createDisableNSOListener(manager, mr);
  logger.log(Level.INFO, "Got TestListener ref {0}", myListener);
  int eventCount = 0;

  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  RemoteEvent[] events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }

  RemoteEvent[] bogus = {
      new RemoteEvent(myGen, 9999, 9999, null),
      new RemoteEvent(myGen, 5678, 1234, null),
View Full Code Here

     * <P>Notes:<BR>For more information see the JavaSpaces specification
     * section 2.7.</P>
     */
    public void run() throws Exception {
        NotifyCounter[] ncs = new NotifyCounter[12];
        EventRegistration er;
        long[] leaseMatrix = new long[] {
            -199, -5000, -13999, Long.MIN_VALUE, -2, Long.MIN_VALUE, -345,
            -8999, -15000, -16000000, Long.MIN_VALUE, -3 };
        SimpleEntry sampleEntry1 = new SimpleEntry("TestEntry #1", 1);
        SimpleEntry sampleEntry2 = new SimpleEntry("TestEntry #2", 2);
        SimpleEntry sampleEntry3 = new SimpleEntry("TestEntry #1", 2);
        SimpleEntry template;

        // first check that space is empty
        if (!checkSpace(space)) {
            throw new TestException(
                    "Space is not empty in the beginning.");
        }

        // init 3 RemoteEvent counters for each of sample entries
        ncs[0] = new NotifyCounter(sampleEntry1, leaseMatrix[0]);
        ncs[1] = new NotifyCounter(sampleEntry2, leaseMatrix[1]);
        ncs[2] = new NotifyCounter(sampleEntry3, leaseMatrix[2]);

        // init 5 counters with wrong templates
        template = new SimpleEntry("TestEntry #3", 1);
        ncs[3] = new NotifyCounter(template, leaseMatrix[3]);

        // 2-nd wrong template
        template = new SimpleEntry("TestEntry #1", 3);
        ncs[4] = new NotifyCounter(template, leaseMatrix[4]);

        // 3-rd wrong template
        template = new SimpleEntry("TestEntry #3", 3);
        ncs[5] = new NotifyCounter(template, leaseMatrix[5]);

        // 4-th wrong template
        template = new SimpleEntry(null, 3);
        ncs[6] = new NotifyCounter(template, leaseMatrix[6]);

        // 5-th wrong template
        template = new SimpleEntry("TestEntry #3", null);
        ncs[7] = new NotifyCounter(template, leaseMatrix[7]);

        // init counter with null entry as a template
        ncs[8] = new NotifyCounter(null, leaseMatrix[8]);

        // init 3 counters with null values for different fields
        template = new SimpleEntry("TestEntry #1", null);
        ncs[9] = new NotifyCounter(template, leaseMatrix[9]);

        // 2-nd template
        template = new SimpleEntry(null, 2);
        ncs[10] = new NotifyCounter(template, leaseMatrix[10]);

        // 3-rd template
        template = new SimpleEntry(null, null);
        ncs[11] = new NotifyCounter(template, leaseMatrix[11]);

        // try to register them
        for (int i = 0; i < 12; i++) {
            try {
                er = space.notify(ncs[i].getTemplate(), null, ncs[i],
                        ncs[i].getLeaseTime(), null);
                throw new TestException( " Notify operation for "
                        + ncs[i]
                        + " has not thrown IllegalArgumentException"
                        + " and returned " + er.toString());
            } catch (IllegalArgumentException iae) {
                logDebugText("IllegalArgumentException has been caught"
                        + " while trying to register " + ncs[i]
                        + " as expected.");
            }
View Full Code Here

        JavaSpace05 space05 = (JavaSpace05) space;
        reset(txn);

        TestEventListener05 testEventListener0 = new TestEventListener05();
        templates.add((SimpleEntry) sampleEntry1.clone());
        EventRegistration er0 = space05.registerForAvailabilityEvent(templates,
                txn, true, testEventListener0, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        final long gotER0Timestamp = System.currentTimeMillis();
        List notifications = testEventListener0.getNotifications();
        expectedResult.add(sampleEntry1)// this entry is to trigger the event
        space.write(sampleEntry1, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing one entry to trigger an event");
        registrations.add(er0);
        reset(txn);

        TestEventListener05 testEventListener1 = new TestEventListener05();
        templates.add((SimpleEntry) sampleEntry1.clone());
        templates.add((SimpleEntry) sampleEntry2.clone());
        EventRegistration er1 = space05.registerForAvailabilityEvent(templates,
                txn, true, testEventListener1, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener1.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry2);
        space.write(sampleEntry1, txn, leaseForeverTime);
        space.write(sampleEntry2, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events");
        registrations.add(er1);
        reset(txn);

        TestEventListener05 testEventListener2 = new TestEventListener05();
        templates.add(new SimpleEntry(null, 2));
        EventRegistration er2 = space05.registerForAvailabilityEvent(templates,
                txn, true, testEventListener2, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener2.getNotifications();
        expectedResult.add(sampleEntry2);
        expectedResult.add(sampleEntry3);
        space.write(sampleEntry2, txn, leaseForeverTime);
        space.write(sampleEntry3, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events "
                           + "(with single template)");
        registrations.add(er2);
        reset(txn);

        TestEventListener05 testEventListener3 = new TestEventListener05();
        templates.add(new SimpleEntry(null, null));
        EventRegistration er3 = space05.registerForAvailabilityEvent(templates,
                txn, true, testEventListener3, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener3.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry2);
        expectedResult.add(sampleEntry3);
        space.write(sampleEntry1, txn, leaseForeverTime);
        space.write(sampleEntry2, txn, leaseForeverTime);
        space.write(sampleEntry3, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 3 entries to trigger 3 events "
                           + "(with single template)");
        registrations.add(er3);
        reset(txn);

        TestEventListener05 testEventListener4 = new TestEventListener05();
        templates.add(null);
        EventRegistration er4 = space05.registerForAvailabilityEvent(templates,
                txn, true, testEventListener4, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener4.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry2);
        space.write(sampleEntry1, txn, leaseForeverTime);
        space.write(sampleEntry2, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events "
                           + "(with null template)");
        registrations.add(er4);
        reset(txn);

        TestEventListener05 testEventListener5 = new TestEventListener05();
        templates.add(null);
        EventRegistration er5 = space05.registerForAvailabilityEvent(templates,
                txn, true, testEventListener5, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener5.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry1);
        space.write(sampleEntry1, txn, leaseForeverTime);
        space.write(sampleEntry1, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 duplicate entries to trigger 2 events "
                           + "(with null template)");

        /*
         * not adding this as a registration for such set
         * of templates (null) already exists
         */
        //registrations.add(er5);
        reset(txn);

        TestEventListener05 testEventListener6 = new TestEventListener05();
        templates.add(null);
        templates.add(new SimpleEntry(null, null));
        templates.add((SimpleEntry) sampleEntry2.clone());
        templates.add((SimpleEntry) sampleEntry3.clone());
        templates.add(new SimpleEntry(null, 2));
        EventRegistration er6 = space05.registerForAvailabilityEvent(templates,
                txn, true, testEventListener6, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener6.getNotifications();
        expectedResult.add(sampleEntry2);
        expectedResult.add(sampleEntry3);
        space.write(sampleEntry2, txn, leaseForeverTime);
        space.write(sampleEntry3, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events " +
                           "(with multiple matching templates)");
        registrations.add(er6);
        reset(txn);

        /*
         * Section below is the same as above but
         * with visibilityOnly flag set to false.
         * "a" stands for availability.
         */
        TestEventListener05 testEventListener0a = new TestEventListener05();
        templates.add((SimpleEntry) sampleEntry1.clone());
        EventRegistration er0a = space05.registerForAvailabilityEvent(
                templates, txn, false,
                testEventListener0a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener0a.getNotifications();
        expectedResult.add(sampleEntry1)// this entry is to trigger the event
        space.write(sampleEntry1, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing one entry to trigger an event");
        registrations.add(er0a);
        reset(txn);

        TestEventListener05 testEventListener1a = new TestEventListener05();
        templates.add((SimpleEntry) sampleEntry1.clone());
        templates.add((SimpleEntry) sampleEntry2.clone());
        EventRegistration er1a = space05.registerForAvailabilityEvent(
                templates, txn, false,
                testEventListener1a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener1a.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry2);
        space.write(sampleEntry1, txn, leaseForeverTime);
        space.write(sampleEntry2, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events");
        registrations.add(er1a);
        reset(txn);

        TestEventListener05 testEventListener2a = new TestEventListener05();
        templates.add(new SimpleEntry(null, 2));
        EventRegistration er2a = space05.registerForAvailabilityEvent(
                templates, txn, false,
                testEventListener2a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener2a.getNotifications();
        expectedResult.add(sampleEntry2);
        expectedResult.add(sampleEntry3);
        space.write(sampleEntry2, txn, leaseForeverTime);
        space.write(sampleEntry3, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events "
                           + "(with single template)");
        registrations.add(er2a);
        reset(txn);

        TestEventListener05 testEventListener3a = new TestEventListener05();
        templates.add(new SimpleEntry(null, null));
        EventRegistration er3a = space05.registerForAvailabilityEvent(
                templates, txn, false,
                testEventListener3a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener3a.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry2);
        expectedResult.add(sampleEntry3);
        space.write(sampleEntry1, txn, leaseForeverTime);
        space.write(sampleEntry2, txn, leaseForeverTime);
        space.write(sampleEntry3, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 3 entries to trigger 3 events "
                           + "(with single template)");
        registrations.add(er3a);
        reset(txn);

        TestEventListener05 testEventListener4a = new TestEventListener05();
        templates.add(null);
        EventRegistration er4a = space05.registerForAvailabilityEvent(
                templates, txn, false,
                testEventListener4a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener4a.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry2);
        space.write(sampleEntry1, txn, leaseForeverTime);
        space.write(sampleEntry2, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events "
                           + "(with null template)");
        registrations.add(er4a);
        reset(txn);

        TestEventListener05 testEventListener5a = new TestEventListener05();
        templates.add(null);
        EventRegistration er5a = space05.registerForAvailabilityEvent(
                templates, txn, false,
                testEventListener5a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener5a.getNotifications();
        expectedResult.add(sampleEntry1);
        expectedResult.add(sampleEntry1);
        space.write(sampleEntry1, txn, leaseForeverTime);
        space.write(sampleEntry1, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 duplicate entries to trigger 2 events "
                           + "(with null template)");

        /*
         * not adding this as a registration for such set
         * of templates (null) already exists
         */
        //registrations.add(er5a);
        reset(txn);

        TestEventListener05 testEventListener6a = new TestEventListener05();
        templates.add(null);
        templates.add(new SimpleEntry(null, null));
        templates.add((SimpleEntry) sampleEntry2.clone());
        templates.add((SimpleEntry) sampleEntry3.clone());
        templates.add(new SimpleEntry(null, 2));
        EventRegistration er6a = space05.registerForAvailabilityEvent(
                templates, txn, false,
                testEventListener6a, leaseForeverTime,
                new MarshalledObject("notUsedHere"));
        notifications = testEventListener6a.getNotifications();
        expectedResult.add(sampleEntry2);
        expectedResult.add(sampleEntry3);
        space.write(sampleEntry2, txn, leaseForeverTime);
        space.write(sampleEntry3, txn, leaseForeverTime);
        Thread.sleep(waitingNotificationsToComeTime);
        checkNotifications(notifications, expectedResult,
                           "Writing 2 entries to trigger 2 events " +
                           "(with multiple matching templates)");
        registrations.add(er6a);
        reset(txn);

        ArrayList eventIDs = new ArrayList();
        Iterator registrationsItr = registrations.iterator();
        while (registrationsItr.hasNext()) {
            EventRegistration er = (EventRegistration) registrationsItr.next();
            if (er == null) {
                throw new TestException("Event registration is null");
            }
            Long id = new Long(er.getID());
            if (eventIDs.contains(id)) {
                throw new TestException("Event registrations have"
                                        + " identical IDs");
            }
            eventIDs.add(id);
View Full Code Here

  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  logger.log(Level.FINEST,
      "Test generator class tree"
      + getClassLoaderTree(myGen.getClass().getClassLoader()));
  EventRegistration evtReg =
      myGen.register(EVENT_ID,  // Event ID to use
         null,    // handback
         mbRel,    // Notification target
         DURATION1)// Lease duration
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION1);

  TestListener goodListener = TestUtils.createListener(manager);
  int goodCount = 0;
        int goodPullCount = 0;

  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  RemoteEvent[] events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }

  RemoteEvent[] bogus = {
      new RemoteEvent(myGen, 9999, 9999, null),
      new RemoteEvent(myGen, 5678, 1234, null),
  };

  //
  // Kill event mailbox service
  //
  logger.log(Level.INFO, "Killing mailbox service ...");
  shutdown(0);

  // Enable good listener
  logger.log(Level.INFO, "Enabling good listener");
  mr.enableDelivery(goodListener);

  goodCount = NUM_EVENTS;
  logger.log(Level.INFO, "Wating for event delivery of " + goodCount);
        waitForEvents(goodListener, goodCount, MAX_WAIT);
  logger.log(Level.INFO, "Asserting event count");
  assertCount(goodListener, goodCount);
  logger.log(Level.INFO, "Verifying events");
  assertEvents(goodListener, events);

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

        // Should now be using recovered listener with
  // recovered preparer
  logger.log(Level.INFO, "Generating another event");
  RemoteEvent re = myGen.generateEvent(evtReg.getID(), 3);
  goodCount++;
  logger.log(Level.INFO, "Wating for event delivery" + goodCount);
        waitForEvents(goodListener, goodCount, MAX_WAIT);
  logger.log(Level.INFO, "Asserting event count");
  assertCount(goodListener, goodCount);
  logger.log(Level.INFO, "Verifying events");
  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);          
        }
       
  //
  // Kill event mailbox service
  //
  shutdown(0);
       
  logger.log(Level.INFO, "Generating another event");
  re = myGen.generateEvent(evtReg.getID(), 3);
  goodCount++;
  logger.log(Level.INFO, "Wating for event delivery" + goodCount);
        waitForEvents(goodListener, goodCount, MAX_WAIT);
  logger.log(Level.INFO, "Asserting event count");
  assertCount(goodListener, goodCount);
View Full Code Here

  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  logger.log(Level.FINEST,
      "Test generator class tree:"
      + getClassLoaderTree(myGen.getClass().getClassLoader()));
  EventRegistration evtReg =
      myGen.register(EVENT_ID,  // Event ID to use
         null,    // handback
         mbRel,    // Notification target
         DURATION1)// Lease duration
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION1);

  TestListener goodListener = TestUtils.createListener(manager);
  int goodCount = 0;

  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  RemoteEvent[] events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }

  RemoteEvent[] bogus = {
      new RemoteEvent(myGen, 9999, 9999, null),
      new RemoteEvent(myGen, 5678, 1234, null),
  };

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

  // Enable the first of our listener objects
  // Enable good listener
  logger.log(Level.INFO, "Enabling good listener");
  mr.enableDelivery(goodListener);

  goodCount = NUM_EVENTS;
  logger.log(Level.INFO, "Wating for event delivery of " + goodCount);
        waitForEvents(goodListener, goodCount, MAX_WAIT);
  logger.log(Level.INFO, "Asserting event count");
  assertCount(goodListener, goodCount);
  logger.log(Level.INFO, "Verifying events");
  assertEvents(goodListener, events);

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

        // Should now be using recovered listener with
  // recovered preparer
  logger.log(Level.INFO, "Generating another event");
  RemoteEvent re = myGen.generateEvent(evtReg.getID(), 3);
  goodCount++;
  logger.log(Level.INFO, "Wating for event delivery" + goodCount);
        waitForEvents(goodListener, goodCount, MAX_WAIT);
  logger.log(Level.INFO, "Asserting event count");
  assertCount(goodListener, goodCount);
View Full Code Here

  RemoteEventListener mbRel = getMailboxListener(mr);

  // Create an event generator and pass it the
  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  EventRegistration evtReg =
      myGen.register(EVENT_ID,  // Event ID to use
         null,    // handback
         mbRel,    // Notification target
         DURATION1)// Lease duration
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION1);

  TestListener goodListener = TestUtils.createListener(manager);
  int goodCount = 0;
  int badCount = 0;

  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  RemoteEvent[] events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }

  RemoteEvent[] bogus = {
      new RemoteEvent(myGen, 9999, 9999, null),
      new RemoteEvent(myGen, 5678, 1234, null),
View Full Code Here

  RemoteEventListener mbRel = getMailboxListener(mr);

  // Create an event generator and pass it the
  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  EventRegistration evtReg =
      myGen.register(EVENT_ID,       // Event ID to use
         null,      // handback
         mbRel,          // Notification target
         DURATION1)// Lease duration
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION1);

  // Create two listener objects
  TestListener myListener = TestUtils.createListener(manager);
  int eventCount = 0;

  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  RemoteEvent[] events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }

  RemoteEvent[] bogus = {
      new RemoteEvent(myGen, 9999, 9999, null),
      new RemoteEvent(myGen, 5678, 1234, null),
  };

  // Enable the first of our listener objects
  assertCount(myListener, eventCount);
  logger.log(Level.INFO, "Enabling delivery to our REL" + myListener);
  mr.enableDelivery(myListener);

  logger.log(Level.INFO, "Wating for event delivery");
  eventCount = NUM_EVENTS;
        waitForEvents(myListener, eventCount, MAX_WAIT);
  logger.log(Level.INFO, "Verifying event delivery count of " + eventCount);
  assertCount(myListener, eventCount);
  logger.log(Level.INFO, "Verifying events ");
  assertEvents(myListener, events);
  if(myListener.verifyEvents(bogus)) {
      throw new TestException("Successfully verified bogus events");
  }

        // Delay to ensure that we sleep past the
  // lease expiration.
  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
View Full Code Here

  RemoteEventListener mbRel = getMailboxListener(mr);

  // Create an event generator and pass it the
  // mailbox's remote event listener.
  TestGenerator myGen = TestUtils.createGenerator(manager);
  EventRegistration evtReg =
      myGen.register(EVENT_ID,       // Event ID to use
         null,      // handback
         mbRel,          // Notification target
         DURATION1)// Lease duration
  Lease tgl = evtReg.getLease();
  checkLease(tgl, DURATION1);

  // Create two listener objects
  TestListener myListener = TestUtils.createListener(manager);
  int eventCount = 0;

  // Generate some events
  logger.log(Level.INFO, "Generating " + NUM_EVENTS + " events");
  RemoteEvent[] events = new RemoteEvent[NUM_EVENTS];
  for (i = 0; i < NUM_EVENTS; i++) {
      events[i] = myGen.generateEvent(evtReg.getID(), 3);
  }

  RemoteEvent[] bogus = {
      new RemoteEvent(myGen, 9999, 9999, null),
      new RemoteEvent(myGen, 5678, 1234, null),
  };

  // Enable the first of our listener objects
  assertCount(myListener, eventCount);
  logger.log(Level.INFO, "Enabling delivery to our REL" + myListener);
  mr.enableDelivery(myListener);

  logger.log(Level.INFO, "Wating for event delivery");
  eventCount = NUM_EVENTS;
        waitForEvents(myListener, eventCount, MAX_WAIT);
  logger.log(Level.INFO, "Verifying event delivery count of " + eventCount);
  assertCount(myListener, eventCount);
  logger.log(Level.INFO, "Verifying events ");
  assertEvents(myListener, events);
  if(myListener.verifyEvents(bogus)) {
      throw new TestException("Successfully verified bogus events");
  }

        // Delay to ensure that we sleep past the
  // lease expiration.
  logger.log(Level.INFO, "Sleeping for " + DURATION1);
  try {
            Thread.sleep(DURATION1);
  } catch (InterruptedException ie) {
      logger.log(Level.INFO, "Sleep interrupted");
  }


  logger.log(Level.INFO, "Waking up at " + new Date(getTime()));

  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
View Full Code Here

TOP

Related Classes of net.jini.core.event.EventRegistration

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.