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 [7/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/SetGroupsReplaceSome.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetGroupsReplaceSome.java?rev=1452708&r1=1452707&r2=1452708&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetGroupsReplaceSome.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetGroupsReplaceSome.java Tue Mar  5 09:22:30 2013
@@ -1,203 +1,201 @@
-/*
- * 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.GroupsUtil;
-
-import net.jini.discovery.LookupDiscoveryRegistration;
-
-import net.jini.core.lookup.ServiceRegistrar;
-
-import java.io.IOException;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * 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 SetGroupsReplaceSome extends AbstractBaseTest {
-
-    protected String[] newGroupsToDiscover = new String[] {"SetGroups_newSet"};
-    protected Map groupsMap = new HashMap(1);
-    protected HashMap regInfoMap = registrationMap;
-    protected HashSet proxiesReplaced = new HashSet(11);
-
-    /** 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);
-        useDiscoveryList = useGroupAndLocDiscovery0;
-        groupsMap        = getPassiveCommDiscardMap(useDiscoveryList);
-        discardType      = ACTIVE_DISCARDED;
-        regInfoMap       = registrationMap;
-        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 {
-        setNewGroups(groupsMap);
-        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();
-        setGroupsDo(newGroupsToDiscover);
-        waitForDiscard(discardType);
-    }//end run
-
-    /** Common code, shared by this class and its sub-classes, that is 
-     *  invoked by the run() method. This method constructs the new
-     *  set of groups with which to re-configure the each registration for
-     *  discovery.
-     */
-    void setNewGroups(Map groupsMap) {
-        ArrayList groupsList = new ArrayList();
-        Iterator iter = genMap.keySet().iterator();
-        for(int i=0;iter.hasNext();i++) {
-            DiscoveryProtocolSimulator curGen = 
-                                       (DiscoveryProtocolSimulator)iter.next();
-            String[]         curGroups   = curGen.getMemberGroups();
-            ServiceRegistrar lookupProxy = curGen.getLookupProxy();
-            if( groupsMap.containsKey(lookupProxy) ) {
-                for(int j=0;j<curGroups.length;j++) {
-                    groupsList.add(curGroups[j]+"_new");
-                }//end loop
-                proxiesReplaced.add(lookupProxy);
-            } else {
-                for(int j=0;j<curGroups.length;j++) {
-                    groupsList.add(curGroups[j]);
-                }//end loop
-	    }//endif
-        }//end loop
-        newGroupsToDiscover = (String[])(groupsList).toArray
-                                              (new String[groupsList.size()]);
-    }//end setNewGroups
-
-    /** Common code, shared by this class and its sub-classes, that is 
-     *  invoked by the run() method. This method invokes the setGroups()
-     *  method on each registration.
-     */
-    void setGroupsDo(String[] newGroups) throws Exception {
-        Set eSet = regInfoMap.entrySet();
-        Iterator iter = eSet.iterator();
-        for(int j=0;iter.hasNext();j++) {
-            Map.Entry pair = (Map.Entry)iter.next();
-            LookupDiscoveryRegistration ldsReg =
-                                    (LookupDiscoveryRegistration)pair.getKey();
-
-            LDSEventListener regListener = (LDSEventListener)pair.getValue();
-            RegistrationInfo regInfo = regListener.getRegInfo();
-            int rID = regInfo.handback;
-	    logger.log(Level.FINE, 
-		       "registration_"+rID
-		       +" -- request discovery of new groups");
-	    if((newGroups != null)&&(newGroups.length <= 0)) {
-		logger.log(Level.FINE, "   NO_GROUPS");
-	    } else {
-		GroupsUtil.displayGroupSet(newGroups,
-					   "   newGroup",Level.FINE);
-	    }//endif
-	    setExpectedDiscardedMap(regInfo);
-	    ldsReg.setGroups(newGroups);
-        }//end loop(j)
-    }//end setGroupsDo
-
-    void setExpectedDiscardedMap(RegistrationInfo regInfo) {
-        Map gMap = getPassiveCommDiscardMap
-                              ( getGroupListToUseByIndex(regInfo.handback) );
-        Map expectedMap = getExpectedDiscardedMap(regInfo,discardType);
-        Set kSet = expectedMap.keySet();
-        Iterator iter = kSet.iterator();
-        for(int j=0;iter.hasNext();j++) {
-            ServiceRegistrar lookupProxy = (ServiceRegistrar)iter.next();
-            if(    !gMap.containsKey(lookupProxy)
-                || !proxiesReplaced.contains(lookupProxy)
-                || (    (regInfo.groupsToDiscover!=null)
-                     && (regInfo.groupsToDiscover).length == 0) )
-            {
-                iter.remove();
-	    }//endif
-	}//end loop
-    }//end setExpectedDiscardedMap
-
-} //end class SetGroupsReplaceSome
-
+/*
+ * 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.GroupsUtil;
+
+import net.jini.discovery.LookupDiscoveryRegistration;
+
+import net.jini.core.lookup.ServiceRegistrar;
+
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * 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 SetGroupsReplaceSome extends AbstractBaseTest {
+
+    protected volatile String[] newGroupsToDiscover = new String[] {"SetGroups_newSet"};
+    protected volatile Map groupsMap = new HashMap(1);
+    protected final HashSet proxiesReplaced = new HashSet(11);
+
+    /** 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);
+        useDiscoveryList = getUseGroupAndLocDiscovery0();
+        groupsMap        = getPassiveCommDiscardMap(useDiscoveryList);
+        discardType      = ACTIVE_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 {
+        setNewGroups(groupsMap);
+        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();
+        setGroupsDo(newGroupsToDiscover);
+        waitForDiscard(discardType);
+    }//end run
+
+    /** Common code, shared by this class and its sub-classes, that is 
+     *  invoked by the run() method. This method constructs the new
+     *  set of groups with which to re-configure the each registration for
+     *  discovery.
+     */
+    void setNewGroups(Map groupsMap) {
+        ArrayList groupsList = new ArrayList();
+        Iterator iter = getGenMap().keySet().iterator();
+        for(int i=0;iter.hasNext();i++) {
+            DiscoveryProtocolSimulator curGen = 
+                                       (DiscoveryProtocolSimulator)iter.next();
+            String[]         curGroups   = curGen.getMemberGroups();
+            ServiceRegistrar lookupProxy = curGen.getLookupProxy();
+            if( groupsMap.containsKey(lookupProxy) ) {
+                for(int j=0;j<curGroups.length;j++) {
+                    groupsList.add(curGroups[j]+"_new");
+                }//end loop
+                proxiesReplaced.add(lookupProxy);
+            } else {
+                for(int j=0;j<curGroups.length;j++) {
+                    groupsList.add(curGroups[j]);
+                }//end loop
+	    }//endif
+        }//end loop
+        newGroupsToDiscover = (String[])(groupsList).toArray
+                                              (new String[groupsList.size()]);
+    }//end setNewGroups
+
+    /** Common code, shared by this class and its sub-classes, that is 
+     *  invoked by the run() method. This method invokes the setGroups()
+     *  method on each registration.
+     */
+    void setGroupsDo(String[] newGroups) throws Exception {
+        Set eSet = getRegistrationMap().entrySet();
+        Iterator iter = eSet.iterator();
+        for(int j=0;iter.hasNext();j++) {
+            Map.Entry pair = (Map.Entry)iter.next();
+            LookupDiscoveryRegistration ldsReg =
+                                    (LookupDiscoveryRegistration)pair.getKey();
+
+            LDSEventListener regListener = (LDSEventListener)pair.getValue();
+            RegistrationInfo regInfo = regListener.getRegInfo();
+            int rID = regInfo.getHandback();
+	    logger.log(Level.FINE, 
+		       "registration_"+rID
+		       +" -- request discovery of new groups");
+	    if((newGroups != null)&&(newGroups.length <= 0)) {
+		logger.log(Level.FINE, "   NO_GROUPS");
+	    } else {
+		GroupsUtil.displayGroupSet(newGroups,
+					   "   newGroup",Level.FINE);
+	    }//endif
+	    setExpectedDiscardedMap(regInfo);
+	    ldsReg.setGroups(newGroups);
+        }//end loop(j)
+    }//end setGroupsDo
+
+    void setExpectedDiscardedMap(RegistrationInfo regInfo) {
+        Map gMap = getPassiveCommDiscardMap
+                              ( getGroupListToUseByIndex(regInfo.getHandback()) );
+        Map expectedMap = getExpectedDiscardedMap(regInfo,discardType);
+        Set kSet = expectedMap.keySet();
+        Iterator iter = kSet.iterator();
+        for(int j=0;iter.hasNext();j++) {
+            ServiceRegistrar lookupProxy = (ServiceRegistrar)iter.next();
+            if(    !gMap.containsKey(lookupProxy)
+                || !proxiesReplaced.contains(lookupProxy)
+                || (    (regInfo.getGroupsToDiscover()!=null)
+                     && (regInfo.getGroupsToDiscover()).length == 0) )
+            {
+                iter.remove();
+	    }//endif
+	}//end loop
+    }//end setExpectedDiscardedMap
+
+} //end class SetGroupsReplaceSome
+

Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsFullyQualified.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsFullyQualified.java?rev=1452708&r1=1452707&r2=1452708&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsFullyQualified.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsFullyQualified.java Tue Mar  5 09:22:30 2013
@@ -1,153 +1,152 @@
-/*
- * 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 com.sun.jini.test.spec.discoveryservice.AbstractBaseTest;
-
-import java.util.logging.Logger;
-import java.util.logging.Level;
-
-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.GroupsUtil;
-import com.sun.jini.test.share.LocatorsUtil;
-
-import net.jini.discovery.LookupDiscoveryRegistration;
-
-import net.jini.discovery.DiscoveryGroupManagement;
-import net.jini.core.discovery.LookupLocator;
-import net.jini.discovery.ConstrainableLookupLocator;
-import net.jini.core.lookup.ServiceRegistrar;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * This class verifies that the lookup discovery service operates in a manner
- * consistent with the specification. In particular, this class verifies
- * that when a registered client calls setLocators() with locators having
- * fully-qualified host names, the lookup discovery service will successfully
- * discover the associated lookup services.
- *
- * The environment in which this class expects to operate is as follows:
- * <p><ul>
- *   <li> one or more lookup services, each associated with a locator
- *   <li> one instance of the lookup discovery service
- *   <li> one or more registrations with the lookup discovery service, each
- *        initially configured to discover no lookup services
- *   <li> each registration with the lookup discovery service invokes the
- *        setLocators() method -- requesting that the set of locators-of-
- *        interest be replaced with a set in which each element is a locator
- *        having a fully-qualified host name
- *   <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 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.
- *
- * Related bug ids: 4979612
- * 
- */
-public class SetLocatorsFullyQualified extends AbstractBaseTest {
-
-    protected static Logger logger = 
-                            Logger.getLogger("com.sun.jini.qa.harness.test");
-    protected LookupLocator[] locsStarted;
-    protected LookupLocator[] locsToSet;
-    protected LookupLocator[] expectedLocs;
-    protected HashMap regInfoMap = registrationMap;
-
-    /** Retrieves additional configuration values. */
-    public Test construct(QAConfig config) throws Exception {
-        super.construct(config);
-//      debugFlag = true;
-//      displayOn = true;
-        useDiscoveryList = useOnlyLocDiscovery;
-        locsStarted = getLocatorsToDiscover(useDiscoveryList);
-        locsToSet   = new LookupLocator[locsStarted.length];
-        String domain = ( config.getStringConfigVal("com.sun.jini.jsk.domain",
-                                                    null) ).toLowerCase();
-        /* This test wishes to discover-by-locator, each of the lookup services
-         * that were configured to be started for this test. Thus, the set of
-         * locators to discover that is supplied to the lookup discovery
-         * service is created using the host and port of the locators of
-         * the lookups that are started. One difference is that the host
-         * names used to create the locators supplied to the lookup discovery
-         * service should each be fully-qualified names; that is, containing
-         * the domain of the host. 
-         *
-         * The loop below constructs that set of locators; extracting the
-         * host and port of the locator of each lookup service that was
-         * started, concatenating the host and domain when appropriate, and
-         * using the fully-qualified host and port to create the locator to
-         * discover.
-         */
-        for(int i=0; i<locsStarted.length; i++) {
-            String host = (locsStarted[i].getHost()).toLowerCase();
-            if( host.indexOf(domain) == -1 ) {//host does not contain domain
-                host = new String(host+"."+domain);//add domain
-            }//endif
-            if (locsStarted[i] instanceof ConstrainableLookupLocator) {
-                locsToSet[i] = new ConstrainableLookupLocator(
-                    host, locsStarted[i].getPort(),
-                    ((ConstrainableLookupLocator)locsStarted[i]).getConstraints());
-            } else {
-                locsToSet[i] = new LookupLocator(host,locsStarted[i].getPort());
-            }
-            logger.log(Level.FINE, "locsToSet["+i+"] = "+locsToSet[i]);
-        }//end loop
-        return this;
-    }//end construct
-
-    public void run() throws Exception {
-        logger.log(Level.FINE, "run()");
-        /* Register with the discovery service, initially requesting the 
-         * discovery of NO_GROUPS and NO_LOCATORS.
-         */
-        for(int i=0;i<nRegistrations;i++) {
-            logger.log(Level.FINE, 
-                      "lookup discovery service registration_"+i+" --");
-            doRegistration(DiscoveryGroupManagement.NO_GROUPS,
-                           new LookupLocator[0],
-                           i, leaseDuration);
-        }//end loop
-        logger.log(Level.FINE, "setting the new locators to discover");
-        /* Invoke the setLocators() method on each registration and set the
-         * locators that are expected to be discovered, based on the locators
-         * that are set.
-         */
-        setLocatorsAllRegs(locsToSet);
-        logger.log(Level.FINE, "waiting for discovery events");
-        waitForDiscovery();
-    }//end run
-
-}//end class SetLocatorsFullyQualified
-
+/*
+ * 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 com.sun.jini.test.spec.discoveryservice.AbstractBaseTest;
+
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+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.GroupsUtil;
+import com.sun.jini.test.share.LocatorsUtil;
+
+import net.jini.discovery.LookupDiscoveryRegistration;
+
+import net.jini.discovery.DiscoveryGroupManagement;
+import net.jini.core.discovery.LookupLocator;
+import net.jini.discovery.ConstrainableLookupLocator;
+import net.jini.core.lookup.ServiceRegistrar;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This class verifies that the lookup discovery service operates in a manner
+ * consistent with the specification. In particular, this class verifies
+ * that when a registered client calls setLocators() with locators having
+ * fully-qualified host names, the lookup discovery service will successfully
+ * discover the associated lookup services.
+ *
+ * The environment in which this class expects to operate is as follows:
+ * <p><ul>
+ *   <li> one or more lookup services, each associated with a locator
+ *   <li> one instance of the lookup discovery service
+ *   <li> one or more registrations with the lookup discovery service, each
+ *        initially configured to discover no lookup services
+ *   <li> each registration with the lookup discovery service invokes the
+ *        setLocators() method -- requesting that the set of locators-of-
+ *        interest be replaced with a set in which each element is a locator
+ *        having a fully-qualified host name
+ *   <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 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.
+ *
+ * Related bug ids: 4979612
+ * 
+ */
+public class SetLocatorsFullyQualified extends AbstractBaseTest {
+
+    protected static Logger logger = 
+                            Logger.getLogger("com.sun.jini.qa.harness.test");
+    protected volatile LookupLocator[] locsStarted;
+    protected volatile LookupLocator[] locsToSet;
+    protected volatile LookupLocator[] expectedLocs;
+
+    /** Retrieves additional configuration values. */
+    public Test construct(QAConfig config) throws Exception {
+        super.construct(config);
+//      debugFlag = true;
+//      displayOn = true;
+        useDiscoveryList = getUseOnlyLocDiscovery();
+        locsStarted = getLocatorsToDiscover(useDiscoveryList);
+        locsToSet   = new LookupLocator[locsStarted.length];
+        String domain = ( config.getStringConfigVal("com.sun.jini.jsk.domain",
+                                                    null) ).toLowerCase();
+        /* This test wishes to discover-by-locator, each of the lookup services
+         * that were configured to be started for this test. Thus, the set of
+         * locators to discover that is supplied to the lookup discovery
+         * service is created using the host and port of the locators of
+         * the lookups that are started. One difference is that the host
+         * names used to create the locators supplied to the lookup discovery
+         * service should each be fully-qualified names; that is, containing
+         * the domain of the host. 
+         *
+         * The loop below constructs that set of locators; extracting the
+         * host and port of the locator of each lookup service that was
+         * started, concatenating the host and domain when appropriate, and
+         * using the fully-qualified host and port to create the locator to
+         * discover.
+         */
+        for(int i=0; i<locsStarted.length; i++) {
+            String host = (locsStarted[i].getHost()).toLowerCase();
+            if( host.indexOf(domain) == -1 ) {//host does not contain domain
+                host = new String(host+"."+domain);//add domain
+            }//endif
+            if (locsStarted[i] instanceof ConstrainableLookupLocator) {
+                locsToSet[i] = new ConstrainableLookupLocator(
+                    host, locsStarted[i].getPort(),
+                    ((ConstrainableLookupLocator)locsStarted[i]).getConstraints());
+            } else {
+                locsToSet[i] = new LookupLocator(host,locsStarted[i].getPort());
+            }
+            logger.log(Level.FINE, "locsToSet["+i+"] = "+locsToSet[i]);
+        }//end loop
+        return this;
+    }//end construct
+
+    public void run() throws Exception {
+        logger.log(Level.FINE, "run()");
+        /* Register with the discovery service, initially requesting the 
+         * discovery of NO_GROUPS and NO_LOCATORS.
+         */
+        for(int i=0;i<nRegistrations;i++) {
+            logger.log(Level.FINE, 
+                      "lookup discovery service registration_"+i+" --");
+            doRegistration(DiscoveryGroupManagement.NO_GROUPS,
+                           new LookupLocator[0],
+                           i, leaseDuration);
+        }//end loop
+        logger.log(Level.FINE, "setting the new locators to discover");
+        /* Invoke the setLocators() method on each registration and set the
+         * locators that are expected to be discovered, based on the locators
+         * that are set.
+         */
+        setLocatorsAllRegs(locsToSet);
+        logger.log(Level.FINE, "waiting for discovery events");
+        waitForDiscovery();
+    }//end run
+
+}//end class SetLocatorsFullyQualified
+

Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsReplaceAll.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsReplaceAll.java?rev=1452708&r1=1452707&r2=1452708&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsReplaceAll.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsReplaceAll.java Tue Mar  5 09:22:30 2013
@@ -1,97 +1,96 @@
-/*
- * 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.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.GroupsUtil;
-import com.sun.jini.test.share.LocatorsUtil;
-
-import net.jini.discovery.LookupDiscoveryRegistration;
-
-import net.jini.core.discovery.LookupLocator;
-import net.jini.core.lookup.ServiceRegistrar;
-
-import java.io.IOException;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * 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 locators 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 locators
- *   <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 locator
- *        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 SetLocatorsReplaceAll extends SetLocatorsReplaceSome {
-
-    protected LookupLocator[] newLocatorsToDiscover = new LookupLocator[0];
-    protected Map locatorsMap = new HashMap(1);
-    protected HashMap regInfoMap = registrationMap;
-    protected HashSet proxiesReplaced = new HashSet(11);
-
-    /** 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);
-        locatorsMap = getModLocatorsDiscardMap(useOnlyLocDiscovery);
-        return this;
-    }//end construct
-
-} //end class SetLocatorsReplaceAll
-
+/*
+ * 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.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.GroupsUtil;
+import com.sun.jini.test.share.LocatorsUtil;
+
+import net.jini.discovery.LookupDiscoveryRegistration;
+
+import net.jini.core.discovery.LookupLocator;
+import net.jini.core.lookup.ServiceRegistrar;
+
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * 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 locators 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 locators
+ *   <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 locator
+ *        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 SetLocatorsReplaceAll extends SetLocatorsReplaceSome {
+
+    protected volatile LookupLocator[] newLocatorsToDiscover = new LookupLocator[0];
+    protected volatile Map locatorsMap = new HashMap(1);
+    protected volatile HashSet proxiesReplaced = new HashSet(11);
+
+    /** 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);
+        locatorsMap = getModLocatorsDiscardMap(getUseOnlyLocDiscovery());
+        return this;
+    }//end construct
+
+} //end class SetLocatorsReplaceAll
+

Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsReplaceSome.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsReplaceSome.java?rev=1452708&r1=1452707&r2=1452708&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsReplaceSome.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsReplaceSome.java Tue Mar  5 09:22:30 2013
@@ -1,202 +1,200 @@
-/*
- * 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.GroupsUtil;
-import com.sun.jini.test.share.LocatorsUtil;
-
-import net.jini.discovery.LookupDiscoveryRegistration;
-
-import net.jini.core.discovery.LookupLocator;
-import net.jini.core.lookup.ServiceRegistrar;
-
-import java.io.IOException;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * 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 locators 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 locators
- *   <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 locator
- *        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 SetLocatorsReplaceSome extends AbstractBaseTest {
-
-    protected LookupLocator[] newLocatorsToDiscover = new LookupLocator[0];
-    protected Map locatorsMap = new HashMap(1);
-    protected HashMap regInfoMap = registrationMap;
-    protected HashSet proxiesReplaced = new HashSet(11);
-
-    /** 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);
-        useDiscoveryList = useGroupAndLocDiscovery0;
-        locatorsMap      = getModLocatorsDiscardMap(useDiscoveryList);
-        discardType      = ACTIVE_DISCARDED; // want groups and locators
-        regInfoMap       = registrationMap;
-        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 {
-        setNewLocators(locatorsMap);
-        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();
-        setLocatorsDo(newLocatorsToDiscover);
-        waitForDiscard(discardType);
-    }//end run
-
-    /** Common code, shared by this class and its sub-classes, that is 
-     *  invoked by the run() method. This method constructs the new
-     *  set of locators with which to re-configure the each registration for
-     *  discovery.
-     */
-    void setNewLocators(Map locatorsMap) {
-        ArrayList locatorsList = new ArrayList();
-        int portBase = 5000;
-        Iterator iter = genMap.keySet().iterator();
-        for(int i=0;iter.hasNext();i++) {
-            DiscoveryProtocolSimulator curGen = 
-                                       (DiscoveryProtocolSimulator)iter.next();
-            String[]         curGroups   = curGen.getMemberGroups();
-            ServiceRegistrar lookupProxy = curGen.getLookupProxy();
-            if( locatorsMap.containsKey(lookupProxy) ) {
-                locatorsList.add(QAConfig.getConstrainedLocator("newHost",(portBase+i)));
-                proxiesReplaced.add(lookupProxy);
-            } else {
-                locatorsList.add( curGen.getLookupLocator() );// no change here
-	    }//endif
-        }//end loop
-        newLocatorsToDiscover = (LookupLocator[])(locatorsList).toArray
-                                      (new LookupLocator[locatorsList.size()]);
-    }//end setNewLocators
-
-    /** Common code, shared by this class and its sub-classes, that is 
-     *  invoked by the run() method. This method invokes the setLocators()
-     *  method on each registration.
-     */
-    void setLocatorsDo(LookupLocator[] newLocators) throws Exception {
-        Set eSet = regInfoMap.entrySet();
-        Iterator iter = eSet.iterator();
-        for(int j=0;iter.hasNext();j++) {
-            Map.Entry pair = (Map.Entry)iter.next();
-            LookupDiscoveryRegistration ldsReg =
-                                    (LookupDiscoveryRegistration)pair.getKey();
-
-            LDSEventListener regListener = (LDSEventListener)pair.getValue();
-            RegistrationInfo regInfo = regListener.getRegInfo();
-            int rID = regInfo.handback;
-	    logger.log(Level.FINE, 
-		       "  registration_"+rID
-		       +" -- request discovery of new locators");
-	    
-	    if((newLocators != null)&&(newLocators.length <= 0)) {
-		logger.log(Level.FINE, "   NO_LOCATORS");
-	    } else {
-		LocatorsUtil.displayLocatorSet(newLocators,
-                                               "   newLocator",Level.FINE);
-	    }//endif
-	    setExpectedDiscardedMap(regInfo);
-	    ldsReg.setLocators(newLocators);
-        }//end loop(j)
-    }//end setLocatorsDo
-
-    void setExpectedDiscardedMap(RegistrationInfo regInfo) {
-        Map locMap = getModLocatorsDiscardMap
-                              ( getLocatorListToUseByIndex(regInfo.handback) );
-        Map expectedMap = getExpectedDiscardedMap(regInfo,discardType);
-        Set kSet = expectedMap.keySet();
-        Iterator iter = kSet.iterator();
-        for(int j=0;iter.hasNext();j++) {
-            ServiceRegistrar lookupProxy = (ServiceRegistrar)iter.next();
-            if(    !locMap.containsKey(lookupProxy)
-                || !proxiesReplaced.contains(lookupProxy)
-                || ((regInfo.locatorsToDiscover).length == 0) )
-            {
-                iter.remove();
-	    }//endif
-	}//end loop
-    }//end setExpectedDiscardedMap
-
-} //end class SetLocatorsReplaceSome
-
+/*
+ * 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.GroupsUtil;
+import com.sun.jini.test.share.LocatorsUtil;
+
+import net.jini.discovery.LookupDiscoveryRegistration;
+
+import net.jini.core.discovery.LookupLocator;
+import net.jini.core.lookup.ServiceRegistrar;
+
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * 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 locators 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 locators
+ *   <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 locator
+ *        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 SetLocatorsReplaceSome extends AbstractBaseTest {
+
+    protected volatile LookupLocator[] newLocatorsToDiscover = new LookupLocator[0];
+    protected volatile Map locatorsMap = new HashMap(1);
+    protected final HashSet proxiesReplaced = new HashSet(11);
+
+    /** 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);
+        useDiscoveryList = getUseGroupAndLocDiscovery0();
+        locatorsMap      = getModLocatorsDiscardMap(useDiscoveryList);
+        discardType      = ACTIVE_DISCARDED; // want groups and locators
+        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 {
+        setNewLocators(locatorsMap);
+        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();
+        setLocatorsDo(newLocatorsToDiscover);
+        waitForDiscard(discardType);
+    }//end run
+
+    /** Common code, shared by this class and its sub-classes, that is 
+     *  invoked by the run() method. This method constructs the new
+     *  set of locators with which to re-configure the each registration for
+     *  discovery.
+     */
+    void setNewLocators(Map locatorsMap) {
+        ArrayList locatorsList = new ArrayList();
+        int portBase = 5000;
+        Iterator iter = getGenMap().keySet().iterator();
+        for(int i=0;iter.hasNext();i++) {
+            DiscoveryProtocolSimulator curGen = 
+                                       (DiscoveryProtocolSimulator)iter.next();
+            String[]         curGroups   = curGen.getMemberGroups();
+            ServiceRegistrar lookupProxy = curGen.getLookupProxy();
+            if( locatorsMap.containsKey(lookupProxy) ) {
+                locatorsList.add(QAConfig.getConstrainedLocator("newHost",(portBase+i)));
+                proxiesReplaced.add(lookupProxy);
+            } else {
+                locatorsList.add( curGen.getLookupLocator() );// no change here
+	    }//endif
+        }//end loop
+        newLocatorsToDiscover = (LookupLocator[])(locatorsList).toArray
+                                      (new LookupLocator[locatorsList.size()]);
+    }//end setNewLocators
+
+    /** Common code, shared by this class and its sub-classes, that is 
+     *  invoked by the run() method. This method invokes the setLocators()
+     *  method on each registration.
+     */
+    void setLocatorsDo(LookupLocator[] newLocators) throws Exception {
+        Set eSet = getRegistrationMap().entrySet();
+        Iterator iter = eSet.iterator();
+        for(int j=0;iter.hasNext();j++) {
+            Map.Entry pair = (Map.Entry)iter.next();
+            LookupDiscoveryRegistration ldsReg =
+                                    (LookupDiscoveryRegistration)pair.getKey();
+
+            LDSEventListener regListener = (LDSEventListener)pair.getValue();
+            RegistrationInfo regInfo = regListener.getRegInfo();
+            int rID = regInfo.getHandback();
+	    logger.log(Level.FINE, 
+		       "  registration_"+rID
+		       +" -- request discovery of new locators");
+	    
+	    if((newLocators != null)&&(newLocators.length <= 0)) {
+		logger.log(Level.FINE, "   NO_LOCATORS");
+	    } else {
+		LocatorsUtil.displayLocatorSet(newLocators,
+                                               "   newLocator",Level.FINE);
+	    }//endif
+	    setExpectedDiscardedMap(regInfo);
+	    ldsReg.setLocators(newLocators);
+        }//end loop(j)
+    }//end setLocatorsDo
+
+    void setExpectedDiscardedMap(RegistrationInfo regInfo) {
+        Map locMap = getModLocatorsDiscardMap
+                              ( getLocatorListToUseByIndex(regInfo.getHandback()) );
+        Map expectedMap = getExpectedDiscardedMap(regInfo,discardType);
+        Set kSet = expectedMap.keySet();
+        Iterator iter = kSet.iterator();
+        for(int j=0;iter.hasNext();j++) {
+            ServiceRegistrar lookupProxy = (ServiceRegistrar)iter.next();
+            if(    !locMap.containsKey(lookupProxy)
+                || !proxiesReplaced.contains(lookupProxy)
+                || ((regInfo.getLocatorsToDiscover()).length == 0) )
+            {
+                iter.remove();
+	    }//endif
+	}//end loop
+    }//end setExpectedDiscardedMap
+
+} //end class SetLocatorsReplaceSome
+

Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsToNone.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsToNone.java?rev=1452708&r1=1452707&r2=1452708&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsToNone.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/event/SetLocatorsToNone.java Tue Mar  5 09:22:30 2013
@@ -1,166 +1,165 @@
-/*
- * 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 com.sun.jini.test.spec.discoveryservice.AbstractBaseTest;
-
-import java.util.logging.Logger;
-import java.util.logging.Level;
-
-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.GroupsUtil;
-import com.sun.jini.test.share.LocatorsUtil;
-
-import net.jini.discovery.LookupDiscoveryRegistration;
-
-import net.jini.core.discovery.LookupLocator;
-import net.jini.core.lookup.ServiceRegistrar;
-
-import java.io.IOException;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * This class verifies that the lookup discovery service operates in a manner
- * consistent with the specification. In particular, this class verifies
- * that when a registered client requests that the lookup discovery service
- * replace all locators-of-interest with 'NO_LOCATORS', that the lookup
- * discovery service effectively turns off discovery by locator.
- *
- * The environment in which this class expects to operate is as follows:
- * <p><ul>
- *   <li> one or more lookup services, each associated with a locator
- *   <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
- *        the lookup services be discovered through only locator discovery
- *   <li> each registration with the lookup discovery service will receive
- *        remote discovery events through an instance of RemoteEventListener
- *   <li> each registration with the lookup discovery service invokes the
- *        setLocators() method -- requesting that the set of locators-of-
- *        interest be replaced with the emtpy set
- *   <li> each registration with the lookup discovery service will receive
- *        remote discard 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. And
- * upon invoking the setLocators() method, for each discovered lookup service,
- * a <code>RemoteDiscoveryEvent</code> instance indicating a discarded event
- * will be sent to the listener of each registration that originally requested
- * discovery of the lookup service.
- *
- * Related bug ids: 5042473
- * 
- */
-public class SetLocatorsToNone extends AbstractBaseTest {
-
-    protected static Logger logger = 
-                            Logger.getLogger("com.sun.jini.qa.harness.test");
-    protected LookupLocator[] newLocatorsToDiscover = new LookupLocator[0];
-    protected HashMap regInfoMap = registrationMap;
-
-    /** Retrieves additional configuration values. */
-    public Test construct(QAConfig config) throws Exception {
-        super.construct(config);
-//      debugFlag = true;
-//      displayOn = true;
-        useDiscoveryList = useOnlyLocDiscovery;
-        discardType      = ACTIVE_DISCARDED;
-        return this;
-    }//end construct
-
-    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
-                      (net.jini.discovery.DiscoveryGroupManagement.NO_GROUPS,
-                       getLocatorsToDiscover(useDiscoveryList),
-                       i, leaseDuration);
-        }//end loop
-        logger.log(Level.FINE, "waiting for initial discovery");
-        waitForDiscovery();
-        logger.log(Level.FINE, 
-                   "replacing the locators to discover with the EMPTY set");
-        setLocatorsDo(newLocatorsToDiscover);
-        logger.log(Level.FINE, "waiting for discard events");
-        waitForDiscard(discardType);
-    }//end run
-
-    /** Invokes the setLocators() method on each registration. */
-    void setLocatorsDo(LookupLocator[] newLocators) throws Exception {
-        Set eSet = regInfoMap.entrySet();
-        Iterator iter = eSet.iterator();
-        for(int j=0;iter.hasNext();j++) {
-            Map.Entry pair = (Map.Entry)iter.next();
-            LookupDiscoveryRegistration ldsReg =
-                                    (LookupDiscoveryRegistration)pair.getKey();
-
-            LDSEventListener regListener = (LDSEventListener)pair.getValue();
-            RegistrationInfo regInfo = regListener.getRegInfo();
-            int rID = regInfo.handback;
-	    logger.log(Level.FINE, 
-		       "  registration_"+rID
-		       +" -- request discovery of new locators");
-	    
-	    if((newLocators != null)&&(newLocators.length <= 0)) {
-		logger.log(Level.FINE, "   NO_LOCATORS");
-	    } else {
-		LocatorsUtil.displayLocatorSet(newLocators,
-                                               "   newLocator",Level.FINE);
-	    }//endif
-	    setExpectedDiscardedMap(regInfo);
-	    ldsReg.setLocators(newLocators);
-        }//end loop(j)
-    }//end setLocatorsDo
-
-    /** Populates the map containing the locators that are expected to be
-     *  discarded, based on what was originally discovered and what is
-     *  now supposed to be discovered after the call to setLocators().
-     */
-    void setExpectedDiscardedMap(RegistrationInfo regInfo) {
-        Map locMap = getModLocatorsDiscardMap(useDiscoveryList);
-        Map expectedMap = getExpectedDiscardedMap(regInfo,discardType);
-        Set kSet = expectedMap.keySet();
-        Iterator iter = kSet.iterator();
-        for(int j=0;iter.hasNext();j++) {
-            ServiceRegistrar lookupProxy = (ServiceRegistrar)iter.next();
-            if(    !locMap.containsKey(lookupProxy)
-                || ((regInfo.locatorsToDiscover).length == 0) )
-            {
-                iter.remove();
-	    }//endif
-	}//end loop
-    }//end setExpectedDiscardedMap
-
-}//end class SetLocatorsToNone
-
+/*
+ * 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 com.sun.jini.test.spec.discoveryservice.AbstractBaseTest;
+
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+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.GroupsUtil;
+import com.sun.jini.test.share.LocatorsUtil;
+
+import net.jini.discovery.LookupDiscoveryRegistration;
+
+import net.jini.core.discovery.LookupLocator;
+import net.jini.core.lookup.ServiceRegistrar;
+
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This class verifies that the lookup discovery service operates in a manner
+ * consistent with the specification. In particular, this class verifies
+ * that when a registered client requests that the lookup discovery service
+ * replace all locators-of-interest with 'NO_LOCATORS', that the lookup
+ * discovery service effectively turns off discovery by locator.
+ *
+ * The environment in which this class expects to operate is as follows:
+ * <p><ul>
+ *   <li> one or more lookup services, each associated with a locator
+ *   <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
+ *        the lookup services be discovered through only locator discovery
+ *   <li> each registration with the lookup discovery service will receive
+ *        remote discovery events through an instance of RemoteEventListener
+ *   <li> each registration with the lookup discovery service invokes the
+ *        setLocators() method -- requesting that the set of locators-of-
+ *        interest be replaced with the emtpy set
+ *   <li> each registration with the lookup discovery service will receive
+ *        remote discard 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. And
+ * upon invoking the setLocators() method, for each discovered lookup service,
+ * a <code>RemoteDiscoveryEvent</code> instance indicating a discarded event
+ * will be sent to the listener of each registration that originally requested
+ * discovery of the lookup service.
+ *
+ * Related bug ids: 5042473
+ * 
+ */
+public class SetLocatorsToNone extends AbstractBaseTest {
+
+    protected static Logger logger = 
+                            Logger.getLogger("com.sun.jini.qa.harness.test");
+    protected volatile LookupLocator[] newLocatorsToDiscover = new LookupLocator[0];
+
+    /** Retrieves additional configuration values. */
+    public Test construct(QAConfig config) throws Exception {
+        super.construct(config);
+//      debugFlag = true;
+//      displayOn = true;
+        useDiscoveryList = getUseOnlyLocDiscovery();
+        discardType      = ACTIVE_DISCARDED;
+        return this;
+    }//end construct
+
+    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
+                      (net.jini.discovery.DiscoveryGroupManagement.NO_GROUPS,
+                       getLocatorsToDiscover(useDiscoveryList),
+                       i, leaseDuration);
+        }//end loop
+        logger.log(Level.FINE, "waiting for initial discovery");
+        waitForDiscovery();
+        logger.log(Level.FINE, 
+                   "replacing the locators to discover with the EMPTY set");
+        setLocatorsDo(newLocatorsToDiscover);
+        logger.log(Level.FINE, "waiting for discard events");
+        waitForDiscard(discardType);
+    }//end run
+
+    /** Invokes the setLocators() method on each registration. */
+    void setLocatorsDo(LookupLocator[] newLocators) throws Exception {
+        Set eSet = getRegistrationMap().entrySet();
+        Iterator iter = eSet.iterator();
+        for(int j=0;iter.hasNext();j++) {
+            Map.Entry pair = (Map.Entry)iter.next();
+            LookupDiscoveryRegistration ldsReg =
+                                    (LookupDiscoveryRegistration)pair.getKey();
+
+            LDSEventListener regListener = (LDSEventListener)pair.getValue();
+            RegistrationInfo regInfo = regListener.getRegInfo();
+            int rID = regInfo.getHandback();
+	    logger.log(Level.FINE, 
+		       "  registration_"+rID
+		       +" -- request discovery of new locators");
+	    
+	    if((newLocators != null)&&(newLocators.length <= 0)) {
+		logger.log(Level.FINE, "   NO_LOCATORS");
+	    } else {
+		LocatorsUtil.displayLocatorSet(newLocators,
+                                               "   newLocator",Level.FINE);
+	    }//endif
+	    setExpectedDiscardedMap(regInfo);
+	    ldsReg.setLocators(newLocators);
+        }//end loop(j)
+    }//end setLocatorsDo
+
+    /** Populates the map containing the locators that are expected to be
+     *  discarded, based on what was originally discovered and what is
+     *  now supposed to be discovered after the call to setLocators().
+     */
+    void setExpectedDiscardedMap(RegistrationInfo regInfo) {
+        Map locMap = getModLocatorsDiscardMap(useDiscoveryList);
+        Map expectedMap = getExpectedDiscardedMap(regInfo,discardType);
+        Set kSet = expectedMap.keySet();
+        Iterator iter = kSet.iterator();
+        for(int j=0;iter.hasNext();j++) {
+            ServiceRegistrar lookupProxy = (ServiceRegistrar)iter.next();
+            if(    !locMap.containsKey(lookupProxy)
+                || ((regInfo.getLocatorsToDiscover()).length == 0) )
+            {
+                iter.remove();
+	    }//endif
+	}//end loop
+    }//end setExpectedDiscardedMap
+
+}//end class SetLocatorsToNone
+