You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2013/03/05 10:22:31 UTC
svn commit: r1452708 [5/7] - in
/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini: qa/resources/
test/impl/fiddler/event/ test/share/ test/spec/discoveryservice/
test/spec/discoveryservice/event/
Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/MulticastMonitorTerminate.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/MulticastMonitorTerminate.java?rev=1452708&r1=1452707&r2=1452708&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/MulticastMonitorTerminate.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/MulticastMonitorTerminate.java Tue Mar 5 09:22:30 2013
@@ -1,204 +1,204 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.jini.test.spec.discoveryservice.event;
-
-import java.util.logging.Level;
-
-import com.sun.jini.test.spec.discoveryservice.AbstractBaseTest;
-
-import com.sun.jini.qa.harness.TestException;
-import com.sun.jini.qa.harness.QAConfig;
-import com.sun.jini.qa.harness.Test;
-
-import com.sun.jini.test.share.DiscoveryProtocolSimulator;
-import com.sun.jini.test.share.DiscoveryServiceUtil;
-
-import net.jini.core.lookup.ServiceRegistrar;
-
-import java.io.IOException;
-import java.rmi.RemoteException;
-import java.util.Iterator;
-
-/**
- * This class verifies that the lookup discovery service operates in a manner
- * consistent with the specification. In particular, this class verifies
- * that the lookup discovery service can successfully employ both the
- * multicast and unicast discovery protocols on behalf of one or more clients
- * registered with that service to discover a number of pre-determined lookup
- * services and then, for each discovered lookup service, send to the
- * appropriate registration listener, the appropriate remote event containing
- * the set of member groups with which the discovered lookup service was
- * configured.
- *
- * The environment in which this class expects to operate is as follows:
- * <p><ul>
- * <li> one or more lookup services, each belonging to a finite set of
- * member groups
- * <li> one instance of the lookup discovery service
- * <li> one or more registrations with the lookup discovery service
- * <li> each registration with the lookup discovery service requests that
- * some of the lookup services be discovered through only group
- * discovery, some through only locator discovery, and some through
- * both group and locator discovery
- * <li> each registration with the lookup discovery service will receive
- * remote discovery events through an instance of RemoteEventListener
- * </ul><p>
- *
- * If the lookup discovery service utility functions as specified, then
- * for each discovered lookup service, a <code>RemoteDiscoveryEvent</code>
- * instance indicating a discovered event will be sent to the listener of
- * each registration that requested discovery of the lookup service.
- * Additionally, each event received will accurately reflect the new set
- * of member groups.
- */
-public class MulticastMonitorTerminate extends AbstractBaseTest {
-
- protected boolean terminate = true;
-
- /** Performs actions necessary to prepare for execution of the
- * current test (refer to the description of this method in the
- * parent class).
- *
- * Retrieves additional configuration values.
- */
- public Test construct(QAConfig config) throws Exception {
- super.construct(config);
- logger.log(Level.FINE,
- "number of announcements to wait for -- "
- +minNAnnouncements);
- logger.log(Level.FINE,
- "number of intervals to wait through -- "
- +nIntervalsToWait);
- if(terminate) {
- logger.log(Level.FINE,
- "stop announcements and destroy lookups -- "
- +terminate);
- } else {
- logger.log(Level.FINE,
- "stop announcements, will not destroy lookups");
- }
- discardType = COMM_DISCARDED;
- return this;
- }//end construct
-
- /** Executes the current test by doing the following:
- * <p>
- * <ul>
- * <li> registers with the lookup discovery service, requesting
- * the discovery of the the desired lookup services using the
- * desired discovery protocol
- * <li> verifies that the discovery process is working by waiting
- * for the expected discovery events
- * <li> verifies that the lookup discovery service utility under test
- * sends the expected number of events - containing the expected
- * set of member groups
- * </ul>
- */
- public void run() throws Exception {
- logger.log(Level.FINE, "run()");
- for(int i=0;i<nRegistrations;i++) {
- logger.log(Level.FINE,
- "lookup discovery service registration_"+i+" --");
- doRegistration(getGroupsToDiscoverByIndex(i),
- getLocatorsToDiscoverByIndex(i),
- i, leaseDuration);
- }//end loop
- waitForDiscovery();
- stopAnnouncements();
- waitForDiscard(discardType);
- }//end run
-
- /** Common code, shared by this class and its sub-classes, that is
- * invoked by the run() method. This method stops the generation of
- * multicast announcements by terminating each announcement generator
- * and, depending on the value of the terminate configuration flag,
- * may also destroy the corresponding simulated lookup service
- *
- * If terminate is true, then both the multicast announcement generators
- * and their associated lookup services will be terminated; otherwise,
- * only the generators will be terminated, leaving each corresponding
- * lookup service still reachable. If the only the multicast announcements
- * stopped, then the member groups of each lookup
- *
- * @throws com.sun.jini.qa.harness.TestException
- */
- void stopAnnouncements() throws TestException, IOException {
- Iterator iter = genMap.keySet().iterator();
- for(int i=0;iter.hasNext();i++) {
- logger.log(Level.FINE, "stop multicast announcements "
- +"from lookup service "+i+" ...");
- Object curObj = iter.next();
- ServiceRegistrar regProxy = null;
- /* Since LookupDiscovery sends a unicast announcement, at
- * startup, typically resulting in immediate discovery by
- * unicast, the generator won't send its first multicast
- * announcement until after net.jini.discovery.announce
- * number of milliseconds. Thus, before stopping multicast
- * announcements, wait until at least N multicast
- * announcements have been sent.
- */
- if(curObj instanceof DiscoveryProtocolSimulator) {//simulated LUS
- DiscoveryProtocolSimulator curGen
- = (DiscoveryProtocolSimulator)curObj;
- regProxy = curGen.getLookupProxy();
- logger.log(Level.FINE, "lookup "+i
- +" - waiting ... announcements so far -- "
- +curGen.getNAnnouncementsSent());
- for(int j=0; ((j<nIntervalsToWait)
- &&(curGen.getNAnnouncementsSent()< minNAnnouncements));j++)
- {
- DiscoveryServiceUtil.delayMS(announceInterval);
- logger.log(Level.FINE, "lookup "+i
- +" - waiting ... announcements so far -- "
- +curGen.getNAnnouncementsSent());
- }//end loop
- logger.log(Level.FINE,
- "lookup "+i
- +" - wait complete ... announcements -- "
- +curGen.getNAnnouncementsSent());
- curGen.stopAnnouncements();
- } else {//non-simulated LUS
- logger.log(Level.FINE, "lookup "+i+" - waiting "
- +(nIntervalsToWait*announceInterval/1000)
- +" seconds for "+minNAnnouncements
- +" announcements ... ");
- for(int j=0;j<nIntervalsToWait;j++) {
- DiscoveryServiceUtil.delayMS(announceInterval);
- logger.log(Level.FINE, "lookup "+i
- +" - still waiting for "
- +minNAnnouncements+" announcements ...");
- }//end loop
- logger.log(Level.FINE, "lookup "+i+" - wait complete");
- /* cannot stop the announcements without destroying */
- regProxy = (ServiceRegistrar)curObj;
- }//endif
- if(terminate) {//destroy lookups individually
- getManager().destroyService(regProxy);
- } else {//don't terminate, replace member groups to gen discard evt
- logger.log(Level.FINE, "lookup service "+i+" -- "
- +"replace member groups to "
- +"generate discard event ...");
- replaceGroups(regProxy,i,null,false,discardType);
- }//endif(terminate)
- }//end loop
- announcementsStopped = true;
- }//end stopAnnouncements
-
-}//end class MulticastMonitorTerminate
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.jini.test.spec.discoveryservice.event;
+
+import java.util.logging.Level;
+
+import com.sun.jini.test.spec.discoveryservice.AbstractBaseTest;
+
+import com.sun.jini.qa.harness.TestException;
+import com.sun.jini.qa.harness.QAConfig;
+import com.sun.jini.qa.harness.Test;
+
+import com.sun.jini.test.share.DiscoveryProtocolSimulator;
+import com.sun.jini.test.share.DiscoveryServiceUtil;
+
+import net.jini.core.lookup.ServiceRegistrar;
+
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.util.Iterator;
+
+/**
+ * This class verifies that the lookup discovery service operates in a manner
+ * consistent with the specification. In particular, this class verifies
+ * that the lookup discovery service can successfully employ both the
+ * multicast and unicast discovery protocols on behalf of one or more clients
+ * registered with that service to discover a number of pre-determined lookup
+ * services and then, for each discovered lookup service, send to the
+ * appropriate registration listener, the appropriate remote event containing
+ * the set of member groups with which the discovered lookup service was
+ * configured.
+ *
+ * The environment in which this class expects to operate is as follows:
+ * <p><ul>
+ * <li> one or more lookup services, each belonging to a finite set of
+ * member groups
+ * <li> one instance of the lookup discovery service
+ * <li> one or more registrations with the lookup discovery service
+ * <li> each registration with the lookup discovery service requests that
+ * some of the lookup services be discovered through only group
+ * discovery, some through only locator discovery, and some through
+ * both group and locator discovery
+ * <li> each registration with the lookup discovery service will receive
+ * remote discovery events through an instance of RemoteEventListener
+ * </ul><p>
+ *
+ * If the lookup discovery service utility functions as specified, then
+ * for each discovered lookup service, a <code>RemoteDiscoveryEvent</code>
+ * instance indicating a discovered event will be sent to the listener of
+ * each registration that requested discovery of the lookup service.
+ * Additionally, each event received will accurately reflect the new set
+ * of member groups.
+ */
+public class MulticastMonitorTerminate extends AbstractBaseTest {
+
+ protected volatile boolean terminate = true;
+
+ /** Performs actions necessary to prepare for execution of the
+ * current test (refer to the description of this method in the
+ * parent class).
+ *
+ * Retrieves additional configuration values.
+ */
+ public Test construct(QAConfig config) throws Exception {
+ super.construct(config);
+ logger.log(Level.FINE,
+ "number of announcements to wait for -- "
+ +getMinNAnnouncements());
+ logger.log(Level.FINE,
+ "number of intervals to wait through -- "
+ +getnIntervalsToWait());
+ if(terminate) {
+ logger.log(Level.FINE,
+ "stop announcements and destroy lookups -- "
+ +terminate);
+ } else {
+ logger.log(Level.FINE,
+ "stop announcements, will not destroy lookups");
+ }
+ discardType = COMM_DISCARDED;
+ return this;
+ }//end construct
+
+ /** Executes the current test by doing the following:
+ * <p>
+ * <ul>
+ * <li> registers with the lookup discovery service, requesting
+ * the discovery of the the desired lookup services using the
+ * desired discovery protocol
+ * <li> verifies that the discovery process is working by waiting
+ * for the expected discovery events
+ * <li> verifies that the lookup discovery service utility under test
+ * sends the expected number of events - containing the expected
+ * set of member groups
+ * </ul>
+ */
+ public void run() throws Exception {
+ logger.log(Level.FINE, "run()");
+ for(int i=0;i<nRegistrations;i++) {
+ logger.log(Level.FINE,
+ "lookup discovery service registration_"+i+" --");
+ doRegistration(getGroupsToDiscoverByIndex(i),
+ getLocatorsToDiscoverByIndex(i),
+ i, leaseDuration);
+ }//end loop
+ waitForDiscovery();
+ stopAnnouncements();
+ waitForDiscard(discardType);
+ }//end run
+
+ /** Common code, shared by this class and its sub-classes, that is
+ * invoked by the run() method. This method stops the generation of
+ * multicast announcements by terminating each announcement generator
+ * and, depending on the value of the terminate configuration flag,
+ * may also destroy the corresponding simulated lookup service
+ *
+ * If terminate is true, then both the multicast announcement generators
+ * and their associated lookup services will be terminated; otherwise,
+ * only the generators will be terminated, leaving each corresponding
+ * lookup service still reachable. If the only the multicast announcements
+ * stopped, then the member groups of each lookup
+ *
+ * @throws com.sun.jini.qa.harness.TestException
+ */
+ void stopAnnouncements() throws TestException, IOException {
+ Iterator iter = getGenMap().keySet().iterator();
+ for(int i=0;iter.hasNext();i++) {
+ logger.log(Level.FINE, "stop multicast announcements "
+ +"from lookup service "+i+" ...");
+ Object curObj = iter.next();
+ ServiceRegistrar regProxy = null;
+ /* Since LookupDiscovery sends a unicast announcement, at
+ * startup, typically resulting in immediate discovery by
+ * unicast, the generator won't send its first multicast
+ * announcement until after net.jini.discovery.announce
+ * number of milliseconds. Thus, before stopping multicast
+ * announcements, wait until at least N multicast
+ * announcements have been sent.
+ */
+ if(curObj instanceof DiscoveryProtocolSimulator) {//simulated LUS
+ DiscoveryProtocolSimulator curGen
+ = (DiscoveryProtocolSimulator)curObj;
+ regProxy = curGen.getLookupProxy();
+ logger.log(Level.FINE, "lookup "+i
+ +" - waiting ... announcements so far -- "
+ +curGen.getNAnnouncementsSent());
+ for(int j=0; ((j<getnIntervalsToWait())
+ &&(curGen.getNAnnouncementsSent()< getMinNAnnouncements()));j++)
+ {
+ DiscoveryServiceUtil.delayMS(getAnnounceInterval());
+ logger.log(Level.FINE, "lookup "+i
+ +" - waiting ... announcements so far -- "
+ +curGen.getNAnnouncementsSent());
+ }//end loop
+ logger.log(Level.FINE,
+ "lookup "+i
+ +" - wait complete ... announcements -- "
+ +curGen.getNAnnouncementsSent());
+ curGen.stopAnnouncements();
+ } else {//non-simulated LUS
+ logger.log(Level.FINE, "lookup "+i+" - waiting "
+ +(getnIntervalsToWait()*getAnnounceInterval()/1000)
+ +" seconds for "+getMinNAnnouncements()
+ +" announcements ... ");
+ for(int j=0;j<getnIntervalsToWait();j++) {
+ DiscoveryServiceUtil.delayMS(getAnnounceInterval());
+ logger.log(Level.FINE, "lookup "+i
+ +" - still waiting for "
+ +getMinNAnnouncements()+" announcements ...");
+ }//end loop
+ logger.log(Level.FINE, "lookup "+i+" - wait complete");
+ /* cannot stop the announcements without destroying */
+ regProxy = (ServiceRegistrar)curObj;
+ }//endif
+ if(terminate) {//destroy lookups individually
+ getManager().destroyService(regProxy);
+ } else {//don't terminate, replace member groups to gen discard evt
+ logger.log(Level.FINE, "lookup service "+i+" -- "
+ +"replace member groups to "
+ +"generate discard event ...");
+ replaceGroups(regProxy,i,null,false,discardType);
+ }//endif(terminate)
+ }//end loop
+ announcementsStopped = true;
+ }//end stopAnnouncements
+
+}//end class MulticastMonitorTerminate
+
Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/RegsNotifiedOnRemoveGroups.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/RegsNotifiedOnRemoveGroups.java?rev=1452708&r1=1452707&r2=1452708&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/RegsNotifiedOnRemoveGroups.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/RegsNotifiedOnRemoveGroups.java Tue Mar 5 09:22:30 2013
@@ -1,229 +1,229 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.jini.test.spec.discoveryservice.event;
-
-import java.util.logging.Level;
-
-import com.sun.jini.test.spec.discoveryservice.AbstractBaseTest;
-import com.sun.jini.test.share.GroupsUtil;
-
-import net.jini.discovery.DiscoveryGroupManagement;
-
-import net.jini.core.discovery.LookupLocator;
-
-import java.rmi.RemoteException;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * This class verifies that when the <code>removeGroups</code> method is used
- * to remove already-discovered groups from a number of registrations at
- * different times, the lookup discovery service sends the appropriate remote
- * discard events to the listener of each such registration.
- *
- * This test was written to test the lookup discovery service when it is
- * used in the following way:
- * <p><ul>
- * <li> a lookup service is started belonging to some group, say 'g0'
- * <li> a second lookup service is started belonging to some group, say 'g1'
- * <li> two separate sets of registrations are made with the lookup
- * discovery service, requesting that both group 'g0' and group 'g1'
- * be discovered
- * <li> the listeners for the registrations in each set should receive the
- * expected remote discovery events for groups 'g0' and 'g1'
- * <li> removeGroups is invoked on each registration in the first set of
- * registrations, requesting that group 'g0' be removed from the
- * the set of groups to discover for each such registration
- * <li> the listeners for the registrations in the first set should then
- * receive the expected remote discard events for group 'g0'
- * <li> removeGroups is again invoked on each registration in the first set
- * of registrations, this time requesting that group 'g1' be removed
- * <li> the listeners for the registrations in the first set should then
- * receive the expected remote discard events for group 'g1'
- * <li> removeGroups is then invoked on each registration in the second set
- * of registrations, requesting that group 'g0' be removed from the
- * the set of groups to discover for each such registration
- * <li> the listeners for the registrations in the second set should then
- * receive the expected remote discard events for group 'g0'
- * <li> removeGroups is again invoked on each registration in the second set
- * of registrations, this time requesting that group 'g1' be removed
- * <li> the listeners for the registrations in the first set should then
- * receive the expected remote discard events for group 'g1'
- * </ul><p>
- *
- * If the lookup discovery service functions as specified, then upon invoking
- * <code>removeGroups</code> for each registration, the listener of each
- * registration will receive an instance of <code>RemoteDiscoveryEvent</code>
- * indicating that a discard has occurred, and which accurately reflects the
- * correct set of member groups.
- *
- * Specification test for LD3.2 and LD4.1.1 (Group Mutator Methods)
- */
-public class RegsNotifiedOnRemoveGroups extends LateRegsNotifiedOn2SetGroups {
-
- /** Executes the current test by doing the following:
- * <p><ul>
- * <li> creates two separate sets of registrations with the lookup
- * discovery service, requesting the discovery of both sets of groups
- * which should, respectively, equal the member groups of both
- * lookup services started in construct
- * <li> verifies that the listeners for the registrations in either set
- * receive the appropriate remote discovery event for the both sets
- * of groups
- * <li> on each registration in the first set of registrations, calls
- * removeGroups, requesting the removal of the first set of groups
- * from the set of groups to discover for those registrations
- * <li> verifies that the listener for each registration in the first set
- * receives the appropriate remote discard event for the groups that
- * were removed
- * <li> on each registration in the first set of registrations, calls
- * removeGroups, requesting the removal of the second set of groups
- * from the set of groups to discover for those registrations
- * <li> verifies that the listener for each registration in the first set
- * receives the appropriate remote discard event for the groups that
- * were removed
- * <li> on each registration in the second set of registrations, calls
- * removeGroups, requesting the removal of the first set of groups
- * from the set of groups to discover for those registrations
- * <li> verifies that the listener for each registration in the second set
- * receives the appropriate remote discard event for the groups that
- * were removed
- * <li> on each registration in the second set of registrations, calls
- * removeGroups, requesting the removal of the second set of groups
- * from the set of groups to discover for those registrations
- * <li> verifies that the listener for each registration in the second set
- * receives the appropriate remote discard event for the groups that
- * were removed
- * </ul>
- */
- public void run() throws Exception {
- logger.log(Level.FINE, "run()");
- String[] totalGroups = getGroupsToDiscover(useOnlyGroupDiscovery);
- LookupLocator[] noLocs = getLocatorsToDiscover(useOnlyGroupDiscovery);
- /* create first set of registrations */
- for(int i=0;i<nRegistrations;i++) {
- logger.log(Level.FINE,
- "lookup discovery service registration_"+i+" --");
- doRegistration(totalGroups,noLocs,i,leaseDuration);
- }//end loop
-
- HashMap regMap0 = (HashMap)registrationMap.clone();
-
- /* create 2nd set of registrations */
- int totalRegs = nRegistrations+nAddRegistrations;
- for(int i=nRegistrations;i<totalRegs;i++) {
- logger.log(Level.FINE,
- "lookup discovery service registration_"+i+" --");
- doRegistration(totalGroups,noLocs,i,leaseDuration);
- }//end loop
- nRegistrations = registrationMap.size();
- /* Construct a map containing the second set of registrations */
- HashMap regMap1 = new HashMap(1);
- Set eSet = registrationMap.entrySet();
- Iterator iter = eSet.iterator();
- for(int i=0;iter.hasNext();i++) {
- /* Skip registrations from the first set of registrations */
- Map.Entry regListenerPair = (Map.Entry)iter.next();
- if( regMap0.containsKey(regListenerPair.getKey()) ) continue;
- regMap1.put( regListenerPair.getKey(),
- regListenerPair.getValue() );
- }//end loop
- /* verify discovery of each group for each registration */
- logger.log(Level.FINE, "wait for discovery -- each "
- +"group, each registration(s)");
- waitForDiscovery();
- logger.log(Level.FINE, "wait period complete");
- /* Must clear discard event info for the second set of
- * registrations. This is because groups are removed only from
- * the first set of registrations; thus, only the first set of
- * registrations will be expecting discard events.
- */
- resetDiscardEventInfoRegMap(regMap1);
-
-
- /* remove 1st set of groups from the 1st set of registrations */
- logger.log(Level.FINE, "remove first group set from "
- +"the first registration(s)");
- removeGroupsRegMap(regMap0,groups0);
- /* verify discard of 1st group set from 1st registrations */
- logger.log(Level.FINE, "wait for discard -- first "
- +"group set, first registration(s)");
- waitForDiscard(NO_INTEREST_DISCARDED);
- logger.log(Level.FINE, "wait period complete");
- /* Must clear discard event info for all registrations before
- * removing groups from the first set of registrations and
- * calling waitForDiscard(). This is because when the discard
- * events arrived for the first set of registrations, the
- * 'discardedMap' associated with each of those registrations
- * was populated with the new discard events. Before again removing
- * groups from the first set of registrations and then calling
- * waitForDiscard(), the 'discardMap' for each registration must
- * be cleared so the next call to waitForDiscard() is not
- * affected by old data in the 'discardMap'.
- *
- * Additionally, the previous call to waitForDiscard() set the
- * 'discardComplete' flag on each of the registrations from the
- * second set of registrations. Thus, those 'discardComplete'
- * flags must be cleared; otherwise, waitForDiscard() will
- * process registrations that shouldn't be expecting any
- * discard events as if they are expecting discard events.
- */
- resetDiscardEventInfoAllRegs();
- /* remove 2nd set of groups from the 1st set of registrations */
- logger.log(Level.FINE, "remove second group set from "
- +"the first registration(s)");
- removeGroupsRegMap(regMap0,groups1);
- /* verify discard of 2nd group set from 1st registrations */
- logger.log(Level.FINE, "wait for discard -- second "
- +"group set, first registration(s)");
- waitForDiscard(NO_INTEREST_DISCARDED);
- logger.log(Level.FINE, "wait period complete");
- /* Clear all discardMap's and all 'discardComplete' flags */
- resetDiscardEventInfoAllRegs();
-
-
- /* remove 1st set of groups from the 2nd set of registrations */
- logger.log(Level.FINE, "remove first group set from "
- +"the second registration(s)");
- removeGroupsRegMap(regMap1,groups0);
- /* verify discard of 1st group set from 2nd registrations */
- logger.log(Level.FINE, "wait for discard -- first "
- +"group set, second registration(s)");
- waitForDiscard(NO_INTEREST_DISCARDED);
- logger.log(Level.FINE, "wait period complete");
- /* Clear all discardMap's and all 'discardComplete' flags */
- resetDiscardEventInfoAllRegs();
-
-
- /* remove 2nd set of groups from the 2nd set of registrations */
- logger.log(Level.FINE, "remove second group set from "
- +"the second registration(s)");
- removeGroupsRegMap(regMap1,groups1);
- /* verify discard of 2nd group set from 2nd registrations */
- logger.log(Level.FINE, "wait for discard -- second "
- +"group set, 2nd registration(s)");
- waitForDiscard(NO_INTEREST_DISCARDED);
- logger.log(Level.FINE, "wait period complete");
- }//end run
-
-} //end class RegsNotifiedOnRemoveGroups
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.jini.test.spec.discoveryservice.event;
+
+import java.util.logging.Level;
+
+import com.sun.jini.test.spec.discoveryservice.AbstractBaseTest;
+import com.sun.jini.test.share.GroupsUtil;
+
+import net.jini.discovery.DiscoveryGroupManagement;
+
+import net.jini.core.discovery.LookupLocator;
+
+import java.rmi.RemoteException;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This class verifies that when the <code>removeGroups</code> method is used
+ * to remove already-discovered groups from a number of registrations at
+ * different times, the lookup discovery service sends the appropriate remote
+ * discard events to the listener of each such registration.
+ *
+ * This test was written to test the lookup discovery service when it is
+ * used in the following way:
+ * <p><ul>
+ * <li> a lookup service is started belonging to some group, say 'g0'
+ * <li> a second lookup service is started belonging to some group, say 'g1'
+ * <li> two separate sets of registrations are made with the lookup
+ * discovery service, requesting that both group 'g0' and group 'g1'
+ * be discovered
+ * <li> the listeners for the registrations in each set should receive the
+ * expected remote discovery events for groups 'g0' and 'g1'
+ * <li> removeGroups is invoked on each registration in the first set of
+ * registrations, requesting that group 'g0' be removed from the
+ * the set of groups to discover for each such registration
+ * <li> the listeners for the registrations in the first set should then
+ * receive the expected remote discard events for group 'g0'
+ * <li> removeGroups is again invoked on each registration in the first set
+ * of registrations, this time requesting that group 'g1' be removed
+ * <li> the listeners for the registrations in the first set should then
+ * receive the expected remote discard events for group 'g1'
+ * <li> removeGroups is then invoked on each registration in the second set
+ * of registrations, requesting that group 'g0' be removed from the
+ * the set of groups to discover for each such registration
+ * <li> the listeners for the registrations in the second set should then
+ * receive the expected remote discard events for group 'g0'
+ * <li> removeGroups is again invoked on each registration in the second set
+ * of registrations, this time requesting that group 'g1' be removed
+ * <li> the listeners for the registrations in the first set should then
+ * receive the expected remote discard events for group 'g1'
+ * </ul><p>
+ *
+ * If the lookup discovery service functions as specified, then upon invoking
+ * <code>removeGroups</code> for each registration, the listener of each
+ * registration will receive an instance of <code>RemoteDiscoveryEvent</code>
+ * indicating that a discard has occurred, and which accurately reflects the
+ * correct set of member groups.
+ *
+ * Specification test for LD3.2 and LD4.1.1 (Group Mutator Methods)
+ */
+public class RegsNotifiedOnRemoveGroups extends LateRegsNotifiedOn2SetGroups {
+
+ /** Executes the current test by doing the following:
+ * <p><ul>
+ * <li> creates two separate sets of registrations with the lookup
+ * discovery service, requesting the discovery of both sets of groups
+ * which should, respectively, equal the member groups of both
+ * lookup services started in construct
+ * <li> verifies that the listeners for the registrations in either set
+ * receive the appropriate remote discovery event for the both sets
+ * of groups
+ * <li> on each registration in the first set of registrations, calls
+ * removeGroups, requesting the removal of the first set of groups
+ * from the set of groups to discover for those registrations
+ * <li> verifies that the listener for each registration in the first set
+ * receives the appropriate remote discard event for the groups that
+ * were removed
+ * <li> on each registration in the first set of registrations, calls
+ * removeGroups, requesting the removal of the second set of groups
+ * from the set of groups to discover for those registrations
+ * <li> verifies that the listener for each registration in the first set
+ * receives the appropriate remote discard event for the groups that
+ * were removed
+ * <li> on each registration in the second set of registrations, calls
+ * removeGroups, requesting the removal of the first set of groups
+ * from the set of groups to discover for those registrations
+ * <li> verifies that the listener for each registration in the second set
+ * receives the appropriate remote discard event for the groups that
+ * were removed
+ * <li> on each registration in the second set of registrations, calls
+ * removeGroups, requesting the removal of the second set of groups
+ * from the set of groups to discover for those registrations
+ * <li> verifies that the listener for each registration in the second set
+ * receives the appropriate remote discard event for the groups that
+ * were removed
+ * </ul>
+ */
+ public void run() throws Exception {
+ logger.log(Level.FINE, "run()");
+ String[] totalGroups = getGroupsToDiscover(getUseOnlyGroupDiscovery());
+ LookupLocator[] noLocs = getLocatorsToDiscover(getUseOnlyGroupDiscovery());
+ /* create first set of registrations */
+ for(int i=0;i<nRegistrations;i++) {
+ logger.log(Level.FINE,
+ "lookup discovery service registration_"+i+" --");
+ doRegistration(totalGroups,noLocs,i,leaseDuration);
+ }//end loop
+
+ Map regMap0 = new HashMap(getRegistrationMap());
+
+ /* create 2nd set of registrations */
+ int totalRegs = nRegistrations+nAddRegistrations;
+ for(int i=nRegistrations;i<totalRegs;i++) {
+ logger.log(Level.FINE,
+ "lookup discovery service registration_"+i+" --");
+ doRegistration(totalGroups,noLocs,i,leaseDuration);
+ }//end loop
+ nRegistrations = getRegistrationMap().size();
+ /* Construct a map containing the second set of registrations */
+ HashMap regMap1 = new HashMap(1);
+ Set eSet = getRegistrationMap().entrySet();
+ Iterator iter = eSet.iterator();
+ for(int i=0;iter.hasNext();i++) {
+ /* Skip registrations from the first set of registrations */
+ Map.Entry regListenerPair = (Map.Entry)iter.next();
+ if( regMap0.containsKey(regListenerPair.getKey()) ) continue;
+ regMap1.put( regListenerPair.getKey(),
+ regListenerPair.getValue() );
+ }//end loop
+ /* verify discovery of each group for each registration */
+ logger.log(Level.FINE, "wait for discovery -- each "
+ +"group, each registration(s)");
+ waitForDiscovery();
+ logger.log(Level.FINE, "wait period complete");
+ /* Must clear discard event info for the second set of
+ * registrations. This is because groups are removed only from
+ * the first set of registrations; thus, only the first set of
+ * registrations will be expecting discard events.
+ */
+ resetDiscardEventInfoRegMap(regMap1);
+
+
+ /* remove 1st set of groups from the 1st set of registrations */
+ logger.log(Level.FINE, "remove first group set from "
+ +"the first registration(s)");
+ removeGroupsRegMap(regMap0,groups0);
+ /* verify discard of 1st group set from 1st registrations */
+ logger.log(Level.FINE, "wait for discard -- first "
+ +"group set, first registration(s)");
+ waitForDiscard(NO_INTEREST_DISCARDED);
+ logger.log(Level.FINE, "wait period complete");
+ /* Must clear discard event info for all registrations before
+ * removing groups from the first set of registrations and
+ * calling waitForDiscard(). This is because when the discard
+ * events arrived for the first set of registrations, the
+ * 'discardedMap' associated with each of those registrations
+ * was populated with the new discard events. Before again removing
+ * groups from the first set of registrations and then calling
+ * waitForDiscard(), the 'discardMap' for each registration must
+ * be cleared so the next call to waitForDiscard() is not
+ * affected by old data in the 'discardMap'.
+ *
+ * Additionally, the previous call to waitForDiscard() set the
+ * 'discardComplete' flag on each of the registrations from the
+ * second set of registrations. Thus, those 'discardComplete'
+ * flags must be cleared; otherwise, waitForDiscard() will
+ * process registrations that shouldn't be expecting any
+ * discard events as if they are expecting discard events.
+ */
+ resetDiscardEventInfoAllRegs();
+ /* remove 2nd set of groups from the 1st set of registrations */
+ logger.log(Level.FINE, "remove second group set from "
+ +"the first registration(s)");
+ removeGroupsRegMap(regMap0,groups1);
+ /* verify discard of 2nd group set from 1st registrations */
+ logger.log(Level.FINE, "wait for discard -- second "
+ +"group set, first registration(s)");
+ waitForDiscard(NO_INTEREST_DISCARDED);
+ logger.log(Level.FINE, "wait period complete");
+ /* Clear all discardMap's and all 'discardComplete' flags */
+ resetDiscardEventInfoAllRegs();
+
+
+ /* remove 1st set of groups from the 2nd set of registrations */
+ logger.log(Level.FINE, "remove first group set from "
+ +"the second registration(s)");
+ removeGroupsRegMap(regMap1,groups0);
+ /* verify discard of 1st group set from 2nd registrations */
+ logger.log(Level.FINE, "wait for discard -- first "
+ +"group set, second registration(s)");
+ waitForDiscard(NO_INTEREST_DISCARDED);
+ logger.log(Level.FINE, "wait period complete");
+ /* Clear all discardMap's and all 'discardComplete' flags */
+ resetDiscardEventInfoAllRegs();
+
+
+ /* remove 2nd set of groups from the 2nd set of registrations */
+ logger.log(Level.FINE, "remove second group set from "
+ +"the second registration(s)");
+ removeGroupsRegMap(regMap1,groups1);
+ /* verify discard of 2nd group set from 2nd registrations */
+ logger.log(Level.FINE, "wait for discard -- second "
+ +"group set, 2nd registration(s)");
+ waitForDiscard(NO_INTEREST_DISCARDED);
+ logger.log(Level.FINE, "wait period complete");
+ }//end run
+
+} //end class RegsNotifiedOnRemoveGroups
+
Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/RegsNotifiedOnRemoveLocs.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/RegsNotifiedOnRemoveLocs.java?rev=1452708&r1=1452707&r2=1452708&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/RegsNotifiedOnRemoveLocs.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/RegsNotifiedOnRemoveLocs.java Tue Mar 5 09:22:30 2013
@@ -1,235 +1,235 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.jini.test.spec.discoveryservice.event;
-
-import java.util.logging.Level;
-
-import com.sun.jini.test.spec.discoveryservice.AbstractBaseTest;
-import com.sun.jini.test.share.LocatorsUtil;
-
-import net.jini.discovery.DiscoveryGroupManagement;
-
-import net.jini.core.discovery.LookupLocator;
-
-import java.rmi.RemoteException;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * This class verifies that when the <code>removeLocators</code> method is used
- * to remove already-discovered locators from a number of registrations at
- * different times, the lookup discovery service sends the appropriate remote
- * discard events to the listener of each such registration.
- *
- * This test was written to test the lookup discovery service when it is
- * used in the following way:
- * <p><ul>
- * <li> a lookup service is started having locator, say 'l0'
- * <li> a second lookup service is started having locator, say 'l1'
- * <li> two separate sets of registrations are made with the lookup
- * discovery service, requesting that both locator 'l0' and locator 'l1'
- * be discovered
- * <li> the listeners for the registrations in each set should receive the
- * expected remote discovery events for locators 'l0' and 'l1'
- * <li> removeLocators is invoked on each registration in the first set of
- * registrations, requesting that locator 'l0' be removed from the
- * the set of locators to discover for each such registration
- * <li> the listeners for the registrations in the first set should then
- * receive the expected remote discard events for locator 'l0'
- * <li> removeLocators is again invoked on each registration in the first set
- * of registrations, this time requesting that locator 'l1' be removed
- * <li> the listeners for the registrations in the first set should then
- * receive the expected remote discard events for locator 'l1'
- * <li> removeLocators is then invoked on each registration in the second set
- * of registrations, requesting that locator 'l0' be removed from the
- * the set of locators to discover for each such registration
- * <li> the listeners for the registrations in the second set should then
- * receive the expected remote discard events for locator 'l0'
- * <li> removeLocators is again invoked on each registration in the second
- * set of registrations, this time requesting that locator 'l1' be
- * removed
- * <li> the listeners for the registrations in the first set should then
- * receive the expected remote discard events for locator 'l1'
- * </ul><p>
- *
- * If the lookup discovery service functions as specified, then upon invoking
- * <code>removeLocators</code> for each registration, the listener of each
- * registration will receive an instance of <code>RemoteDiscoveryEvent</code>
- * indicating that a discard has occurred, and which accurately reflects the
- * correct set of discarded lookup services.
- *
- * Specification test for LD3.2 and LD4.1.1 (Locator Mutator Methods)
- */
-public class RegsNotifiedOnRemoveLocs extends LateRegsNotifiedOn2SetLocs {
-
- /** Executes the current test by doing the following:
- * <p><ul>
- * <li> creates two separate sets of registrations with the lookup
- * discovery service, requesting the discovery of both sets of
- * locators which should, respectively, equal the locators of the
- * lookup services started in construct
- * <li> verifies that the listeners for the registrations in either set
- * receive the appropriate remote discovery event for the both sets
- * of locators
- * <li> on each registration in the first set of registrations, calls
- * removeLocators, requesting the removal of the first set of locators
- * from the set of locators to discover for those registrations
- * <li> verifies that the listener for each registration in the first set
- * receives the appropriate remote discard event for the locators that
- * were removed
- * <li> on each registration in the first set of registrations, calls
- * removeLocators, requesting the removal of the second set of
- * locators from the set of locators to discover for those
- * registrations
- * <li> verifies that the listener for each registration in the first set
- * receives the appropriate remote discard event for the locators that
- * were removed
- * <li> on each registration in the second set of registrations, calls
- * removeLocators, requesting the removal of the first set of locators
- * from the set of locators to discover for those registrations
- * <li> verifies that the listener for each registration in the second set
- * receives the appropriate remote discard event for the locators that
- * were removed
- * <li> on each registration in the second set of registrations, calls
- * removeLocators, requesting the removal of the second set of
- * locators from the set of locators to discover for those
- * registrations
- * <li> verifies that the listener for each registration in the second set
- * receives the appropriate remote discard event for the locators that
- * were removed
- * </ul>
- */
- public void run() throws Exception {
- logger.log(Level.FINE, "run()");
- String[] noGroups = DiscoveryGroupManagement.NO_GROUPS;
- LookupLocator[] totalLocators = getLocatorsToDiscover
- (useOnlyLocDiscovery);
- /* create first set of registrations */
- for(int i=0;i<nRegistrations;i++) {
- logger.log(Level.FINE,
- "lookup discovery service registration_"+i+" --");
- doRegistration(noGroups,totalLocators,i,leaseDuration);
- }//end loop
-
- HashMap regMap0 = (HashMap)registrationMap.clone();
-
- /* create 2nd set of registrations */
- int totalRegs = nRegistrations+nAddRegistrations;
- for(int i=nRegistrations;i<totalRegs;i++) {
- logger.log(Level.FINE,
- "lookup discovery service registration_"+i+" --");
- doRegistration(noGroups,totalLocators,i,leaseDuration);
- }//end loop
- nRegistrations = registrationMap.size();
- /* Construct a map containing the second set of registrations */
- HashMap regMap1 = new HashMap(1);
- Set eSet = registrationMap.entrySet();
- Iterator iter = eSet.iterator();
- for(int i=0;iter.hasNext();i++) {
- /* Skip registrations from the first set of registrations */
- Map.Entry regListenerPair = (Map.Entry)iter.next();
- if( regMap0.containsKey(regListenerPair.getKey()) ) continue;
- regMap1.put( regListenerPair.getKey(),
- regListenerPair.getValue() );
- }//end loop
- /* verify discovery of each locator for each registration */
- logger.log(Level.FINE, "wait for discovery -- each "
- +"locator, each registration(s)");
- waitForDiscovery();
- logger.log(Level.FINE, "wait period complete");
- /* Must clear discard event info for the second set of
- * registrations. This is because locators are removed only from
- * the first set of registrations; thus, only the first set of
- * registrations will be expecting discard events.
- */
- resetDiscardEventInfoRegMap(regMap1);
-
-
- /* remove 1st set of locators from the 1st set of registrations */
- logger.log(Level.FINE, "remove first locator set from "
- +"the first registration(s)");
- removeLocatorsRegMap(regMap0,locs0);
- /* verify discard of 1st locator set from 1st registrations */
- logger.log(Level.FINE, "wait for discard -- first "
- +"locator set, first registration(s)");
- waitForDiscard(NO_INTEREST_DISCARDED);
- logger.log(Level.FINE, "wait period complete");
- /* Must clear discard event info for all registrations before
- * removing locators from the first set of registrations and
- * calling waitForDiscard(). This is because when the discard
- * events arrived for the first set of registrations, the
- * 'discardedMap' associated with each of those registrations
- * was populated with the new discard events. Before again removing
- * locators from the first set of registrations and then calling
- * waitForDiscard(), the 'discardMap' for each registration must
- * be cleared so the next call to waitForDiscard() is not
- * affected by old data in the 'discardMap'.
- *
- * Additionally, the previous call to waitForDiscard() set the
- * 'discardComplete' flag on each of the registrations from the
- * second set of registrations. Thus, those 'discardComplete'
- * flags must be cleared; otherwise, waitForDiscard() will
- * process registrations that shouldn't be expecting any
- * discard events as if they are expecting discard events.
- */
- resetDiscardEventInfoAllRegs();
- /* remove 2nd set of locators from the 1st set of registrations */
- logger.log(Level.FINE,
- "remove second locator set from "
- +"the first registration(s)");
- removeLocatorsRegMap(regMap0,locs1);
- /* verify discard of 2nd locator set from 1st registrations */
- logger.log(Level.FINE, "wait for discard -- second "
- +"locator set, first registration(s)");
- waitForDiscard(NO_INTEREST_DISCARDED);
- logger.log(Level.FINE, "wait period complete");
- /* Clear all discardMap's and all 'discardComplete' flags */
- resetDiscardEventInfoAllRegs();
-
-
- /* remove 1st set of locators from the 2nd set of registrations */
- logger.log(Level.FINE, "remove first locator set from "
- +"the second registration(s)");
- removeLocatorsRegMap(regMap1,locs0);
- /* verify discard of 1st locator set from 2nd registrations */
- logger.log(Level.FINE, "wait for discard -- first "
- +"locator set, second registration(s)");
- waitForDiscard(NO_INTEREST_DISCARDED);
- logger.log(Level.FINE, "wait period complete");
- /* Clear all discardMap's and all 'discardComplete' flags */
- resetDiscardEventInfoAllRegs();
-
-
- /* remove 2nd set of locators from the 2nd set of registrations */
- logger.log(Level.FINE,
- "remove second locator set from "
- +"the second registration(s)");
- removeLocatorsRegMap(regMap1,locs1);
- /* verify discard of 2nd locator set from 2nd registrations */
- logger.log(Level.FINE, "wait for discard -- second "
- +"locator set, 2nd registration(s)");
- waitForDiscard(NO_INTEREST_DISCARDED);
- logger.log(Level.FINE, "wait period complete");
- }//end run
-
-} //end class RegsNotifiedOnRemoveLocs
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.jini.test.spec.discoveryservice.event;
+
+import java.util.logging.Level;
+
+import com.sun.jini.test.spec.discoveryservice.AbstractBaseTest;
+import com.sun.jini.test.share.LocatorsUtil;
+
+import net.jini.discovery.DiscoveryGroupManagement;
+
+import net.jini.core.discovery.LookupLocator;
+
+import java.rmi.RemoteException;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This class verifies that when the <code>removeLocators</code> method is used
+ * to remove already-discovered locators from a number of registrations at
+ * different times, the lookup discovery service sends the appropriate remote
+ * discard events to the listener of each such registration.
+ *
+ * This test was written to test the lookup discovery service when it is
+ * used in the following way:
+ * <p><ul>
+ * <li> a lookup service is started having locator, say 'l0'
+ * <li> a second lookup service is started having locator, say 'l1'
+ * <li> two separate sets of registrations are made with the lookup
+ * discovery service, requesting that both locator 'l0' and locator 'l1'
+ * be discovered
+ * <li> the listeners for the registrations in each set should receive the
+ * expected remote discovery events for locators 'l0' and 'l1'
+ * <li> removeLocators is invoked on each registration in the first set of
+ * registrations, requesting that locator 'l0' be removed from the
+ * the set of locators to discover for each such registration
+ * <li> the listeners for the registrations in the first set should then
+ * receive the expected remote discard events for locator 'l0'
+ * <li> removeLocators is again invoked on each registration in the first set
+ * of registrations, this time requesting that locator 'l1' be removed
+ * <li> the listeners for the registrations in the first set should then
+ * receive the expected remote discard events for locator 'l1'
+ * <li> removeLocators is then invoked on each registration in the second set
+ * of registrations, requesting that locator 'l0' be removed from the
+ * the set of locators to discover for each such registration
+ * <li> the listeners for the registrations in the second set should then
+ * receive the expected remote discard events for locator 'l0'
+ * <li> removeLocators is again invoked on each registration in the second
+ * set of registrations, this time requesting that locator 'l1' be
+ * removed
+ * <li> the listeners for the registrations in the first set should then
+ * receive the expected remote discard events for locator 'l1'
+ * </ul><p>
+ *
+ * If the lookup discovery service functions as specified, then upon invoking
+ * <code>removeLocators</code> for each registration, the listener of each
+ * registration will receive an instance of <code>RemoteDiscoveryEvent</code>
+ * indicating that a discard has occurred, and which accurately reflects the
+ * correct set of discarded lookup services.
+ *
+ * Specification test for LD3.2 and LD4.1.1 (Locator Mutator Methods)
+ */
+public class RegsNotifiedOnRemoveLocs extends LateRegsNotifiedOn2SetLocs {
+
+ /** Executes the current test by doing the following:
+ * <p><ul>
+ * <li> creates two separate sets of registrations with the lookup
+ * discovery service, requesting the discovery of both sets of
+ * locators which should, respectively, equal the locators of the
+ * lookup services started in construct
+ * <li> verifies that the listeners for the registrations in either set
+ * receive the appropriate remote discovery event for the both sets
+ * of locators
+ * <li> on each registration in the first set of registrations, calls
+ * removeLocators, requesting the removal of the first set of locators
+ * from the set of locators to discover for those registrations
+ * <li> verifies that the listener for each registration in the first set
+ * receives the appropriate remote discard event for the locators that
+ * were removed
+ * <li> on each registration in the first set of registrations, calls
+ * removeLocators, requesting the removal of the second set of
+ * locators from the set of locators to discover for those
+ * registrations
+ * <li> verifies that the listener for each registration in the first set
+ * receives the appropriate remote discard event for the locators that
+ * were removed
+ * <li> on each registration in the second set of registrations, calls
+ * removeLocators, requesting the removal of the first set of locators
+ * from the set of locators to discover for those registrations
+ * <li> verifies that the listener for each registration in the second set
+ * receives the appropriate remote discard event for the locators that
+ * were removed
+ * <li> on each registration in the second set of registrations, calls
+ * removeLocators, requesting the removal of the second set of
+ * locators from the set of locators to discover for those
+ * registrations
+ * <li> verifies that the listener for each registration in the second set
+ * receives the appropriate remote discard event for the locators that
+ * were removed
+ * </ul>
+ */
+ public void run() throws Exception {
+ logger.log(Level.FINE, "run()");
+ String[] noGroups = DiscoveryGroupManagement.NO_GROUPS;
+ LookupLocator[] totalLocators = getLocatorsToDiscover
+ (getUseOnlyLocDiscovery());
+ /* create first set of registrations */
+ for(int i=0;i<nRegistrations;i++) {
+ logger.log(Level.FINE,
+ "lookup discovery service registration_"+i+" --");
+ doRegistration(noGroups,totalLocators,i,leaseDuration);
+ }//end loop
+
+ Map regMap0 = new HashMap(getRegistrationMap());
+
+ /* create 2nd set of registrations */
+ int totalRegs = nRegistrations+nAddRegistrations;
+ for(int i=nRegistrations;i<totalRegs;i++) {
+ logger.log(Level.FINE,
+ "lookup discovery service registration_"+i+" --");
+ doRegistration(noGroups,totalLocators,i,leaseDuration);
+ }//end loop
+ nRegistrations = getRegistrationMap().size();
+ /* Construct a map containing the second set of registrations */
+ HashMap regMap1 = new HashMap(1);
+ Set eSet = getRegistrationMap().entrySet();
+ Iterator iter = eSet.iterator();
+ for(int i=0;iter.hasNext();i++) {
+ /* Skip registrations from the first set of registrations */
+ Map.Entry regListenerPair = (Map.Entry)iter.next();
+ if( regMap0.containsKey(regListenerPair.getKey()) ) continue;
+ regMap1.put( regListenerPair.getKey(),
+ regListenerPair.getValue() );
+ }//end loop
+ /* verify discovery of each locator for each registration */
+ logger.log(Level.FINE, "wait for discovery -- each "
+ +"locator, each registration(s)");
+ waitForDiscovery();
+ logger.log(Level.FINE, "wait period complete");
+ /* Must clear discard event info for the second set of
+ * registrations. This is because locators are removed only from
+ * the first set of registrations; thus, only the first set of
+ * registrations will be expecting discard events.
+ */
+ resetDiscardEventInfoRegMap(regMap1);
+
+
+ /* remove 1st set of locators from the 1st set of registrations */
+ logger.log(Level.FINE, "remove first locator set from "
+ +"the first registration(s)");
+ removeLocatorsRegMap(regMap0,locs0);
+ /* verify discard of 1st locator set from 1st registrations */
+ logger.log(Level.FINE, "wait for discard -- first "
+ +"locator set, first registration(s)");
+ waitForDiscard(NO_INTEREST_DISCARDED);
+ logger.log(Level.FINE, "wait period complete");
+ /* Must clear discard event info for all registrations before
+ * removing locators from the first set of registrations and
+ * calling waitForDiscard(). This is because when the discard
+ * events arrived for the first set of registrations, the
+ * 'discardedMap' associated with each of those registrations
+ * was populated with the new discard events. Before again removing
+ * locators from the first set of registrations and then calling
+ * waitForDiscard(), the 'discardMap' for each registration must
+ * be cleared so the next call to waitForDiscard() is not
+ * affected by old data in the 'discardMap'.
+ *
+ * Additionally, the previous call to waitForDiscard() set the
+ * 'discardComplete' flag on each of the registrations from the
+ * second set of registrations. Thus, those 'discardComplete'
+ * flags must be cleared; otherwise, waitForDiscard() will
+ * process registrations that shouldn't be expecting any
+ * discard events as if they are expecting discard events.
+ */
+ resetDiscardEventInfoAllRegs();
+ /* remove 2nd set of locators from the 1st set of registrations */
+ logger.log(Level.FINE,
+ "remove second locator set from "
+ +"the first registration(s)");
+ removeLocatorsRegMap(regMap0,locs1);
+ /* verify discard of 2nd locator set from 1st registrations */
+ logger.log(Level.FINE, "wait for discard -- second "
+ +"locator set, first registration(s)");
+ waitForDiscard(NO_INTEREST_DISCARDED);
+ logger.log(Level.FINE, "wait period complete");
+ /* Clear all discardMap's and all 'discardComplete' flags */
+ resetDiscardEventInfoAllRegs();
+
+
+ /* remove 1st set of locators from the 2nd set of registrations */
+ logger.log(Level.FINE, "remove first locator set from "
+ +"the second registration(s)");
+ removeLocatorsRegMap(regMap1,locs0);
+ /* verify discard of 1st locator set from 2nd registrations */
+ logger.log(Level.FINE, "wait for discard -- first "
+ +"locator set, second registration(s)");
+ waitForDiscard(NO_INTEREST_DISCARDED);
+ logger.log(Level.FINE, "wait period complete");
+ /* Clear all discardMap's and all 'discardComplete' flags */
+ resetDiscardEventInfoAllRegs();
+
+
+ /* remove 2nd set of locators from the 2nd set of registrations */
+ logger.log(Level.FINE,
+ "remove second locator set from "
+ +"the second registration(s)");
+ removeLocatorsRegMap(regMap1,locs1);
+ /* verify discard of 2nd locator set from 2nd registrations */
+ logger.log(Level.FINE, "wait for discard -- second "
+ +"locator set, 2nd registration(s)");
+ waitForDiscard(NO_INTEREST_DISCARDED);
+ logger.log(Level.FINE, "wait period complete");
+ }//end run
+
+} //end class RegsNotifiedOnRemoveLocs
+
Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/RemoveGroupsAll.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/RemoveGroupsAll.java?rev=1452708&r1=1452707&r2=1452708&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/RemoveGroupsAll.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/RemoveGroupsAll.java Tue Mar 5 09:22:30 2013
@@ -60,7 +60,7 @@ public class RemoveGroupsAll extends Rem
*/
public Test construct(QAConfig config) throws Exception {
super.construct(config);
- groupsMap = getPassiveCommDiscardMap(useOnlyGroupDiscovery);
+ groupsMap = getPassiveCommDiscardMap(getUseOnlyGroupDiscovery());
return this;
}//end construct