Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/AbstractBaseTest.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/AbstractBaseTest.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/AbstractBaseTest.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/AbstractBaseTest.java Sun Oct 26 13:17:28 2014 @@ -18,36 +18,23 @@ package com.sun.jini.test.spec.servicediscovery; -import java.util.logging.Level; - -import com.sun.jini.qa.harness.TestException; -import com.sun.jini.test.share.BaseQATest; - -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.qa.harness.Test; - +import com.sun.jini.qa.harness.TestException; +import com.sun.jini.test.share.BaseQATest; import com.sun.jini.test.share.DiscoveryServiceUtil; import com.sun.jini.test.share.GroupsUtil; import com.sun.jini.test.share.LocatorsUtil; +import java.io.IOException; +import java.io.Serializable; +import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; -import com.sun.jini.qa.harness.TestException; - +import java.util.logging.Level; import net.jini.admin.Administrable; - -import net.jini.discovery.DiscoveryManagement; -import net.jini.discovery.LookupDiscoveryManager; - -import net.jini.lease.LeaseRenewalEvent; -import net.jini.lease.LeaseRenewalManager; -import net.jini.lease.DesiredExpirationListener; - -import net.jini.lookup.ServiceDiscoveryEvent; -import net.jini.lookup.ServiceDiscoveryListener; -import net.jini.lookup.ServiceDiscoveryManager; -import net.jini.lookup.ServiceItemFilter; - +import net.jini.config.ConfigurationException; import net.jini.core.discovery.LookupLocator; import net.jini.core.entry.Entry; import net.jini.core.lease.Lease; @@ -57,18 +44,15 @@ import net.jini.core.lookup.ServiceItem; import net.jini.core.lookup.ServiceRegistrar; import net.jini.core.lookup.ServiceRegistration; import net.jini.core.lookup.ServiceTemplate; - -import java.io.IOException; -import java.io.Serializable; - -import java.rmi.RemoteException; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Properties; - -import net.jini.config.ConfigurationException; +import net.jini.discovery.DiscoveryManagement; +import net.jini.discovery.LookupDiscoveryManager; +import net.jini.lease.DesiredExpirationListener; +import net.jini.lease.LeaseRenewalEvent; +import net.jini.lease.LeaseRenewalManager; +import net.jini.lookup.ServiceDiscoveryEvent; +import net.jini.lookup.ServiceDiscoveryListener; +import net.jini.lookup.ServiceDiscoveryManager; +import net.jini.lookup.ServiceItemFilter; /** * This class is an abstract class that acts as the base class which @@ -250,32 +234,38 @@ abstract public class AbstractBaseTest e this.util = util; this.classname = classname; }//end constructor + @Override public void serviceAdded(ServiceDiscoveryEvent event) { ServiceItem srvcItem = event.getPostEventServiceItem(); ServiceID srvcID = srvcItem.serviceID; + int nadded; synchronized(lock) { - logger.log(Level.FINE, "{0} -- serviceAdded()-{1}-{2}", - new Object[]{nAdded, srvcItem.service, srvcID}); - nAdded++; + nadded = nAdded++; } + logger.log(Level.FINE, "{0} -- serviceAdded()-{1}-{2}", + new Object[]{nadded, srvcItem.service, srvcID}); }//end serviceAdded + @Override public void serviceRemoved(ServiceDiscoveryEvent event) { ServiceItem srvcItem = event.getPreEventServiceItem(); ServiceID srvcID = srvcItem.serviceID; + int nremoved; synchronized(lock) { - logger.log(Level.FINE, "{0} -- serviceRemoved()-{1}-{2}", - new Object[]{nRemoved, srvcItem.service, srvcID}); - nRemoved++; + nremoved = nRemoved++; } + logger.log(Level.FINE, "{0} -- serviceRemoved()-{1}-{2}", + new Object[]{nremoved, srvcItem.service, srvcID}); }//end serviceRemoved + @Override public void serviceChanged(ServiceDiscoveryEvent event) { ServiceItem srvcItem = event.getPreEventServiceItem(); ServiceID srvcID = srvcItem.serviceID; + int nchanged; synchronized(lock) { - logger.log(Level.FINE, "{0} -- serviceChanged()-{1}-{2}", - new Object[]{nChanged, srvcItem.service, srvcID}); - nChanged++; + nchanged = nChanged++; } + logger.log(Level.FINE, "{0} -- serviceChanged()-{1}-{2}", + new Object[]{nchanged, srvcItem.service, srvcID}); }//end serviceChanged public int getNAdded() { synchronized(lock) { @@ -394,14 +384,12 @@ abstract public class AbstractBaseTest e = "AbstractBaseTest for ServiceDiscoveryManager.lookup()" +" -- number of services -- "; - protected volatile String[] subCategories; - protected volatile boolean createSDMduringConstruction = true; protected volatile boolean waitForLookupDiscovery = true; protected volatile ServiceDiscoveryManager srvcDiscoveryMgr = null; - protected final ArrayList sdmList = new ArrayList(1); - protected final ArrayList cacheList = new ArrayList(1); + protected final ArrayList<ServiceDiscoveryManager> sdmList + = new ArrayList<ServiceDiscoveryManager>(1); protected volatile ServiceTemplate template = null; protected volatile ServiceItemFilter firstStageFilter = null;
Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/cache/CacheLookup.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/cache/CacheLookup.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/cache/CacheLookup.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/cache/CacheLookup.java Sun Oct 26 13:17:28 2014 @@ -96,7 +96,6 @@ public class CacheLookup extends Abstrac cache = srvcDiscoveryMgr.createLookupCache(template, firstStageFilter, null);//listener - cacheList.add(cache); /* Query the cache for the desired registered service. */ for (int i = 0; i < 3; i++) { logger.log(Level.FINE, "waiting "+(cacheDelay/1000) Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/discovery/Discovery.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/discovery/Discovery.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/discovery/Discovery.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/discovery/Discovery.java Sun Oct 26 13:17:28 2014 @@ -1,228 +1,218 @@ -/* - * 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.servicediscovery.discovery; - -import java.util.logging.Level; - -// java packages -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.rmi.RemoteException; -import java.rmi.RMISecurityManager; -import java.rmi.activation.ActivationException; - -// Test harness imports -import com.sun.jini.qa.harness.QAConfig; -import com.sun.jini.qa.harness.TestException; -import com.sun.jini.qa.harness.QATestEnvironment; - -// jini packages -import net.jini.admin.Administrable; -import net.jini.discovery.DiscoveryEvent; -import net.jini.discovery.DiscoveryListener; -import net.jini.discovery.DiscoveryGroupManagement; -import net.jini.discovery.LookupDiscovery; -import com.sun.jini.admin.DestroyAdmin; -import com.sun.jini.qa.harness.Test; -import com.sun.jini.start.ServiceStarter; -import net.jini.lookup.DiscoveryAdmin; -import net.jini.core.lookup.ServiceRegistrar; -import net.jini.core.lookup.ServiceID; - -public class Discovery extends QATestEnvironment implements Test { - - - private class Ignorer implements DiscoveryListener { - - public Ignorer() { - } - - public void discovered(DiscoveryEvent e) { - ServiceRegistrar[] regs = e.getRegistrars(); - logger.log(Level.INFO, "discovered " + regs.length + " instance(s)"); - - // new Throwable().printStackTrace(); - } - - public void discarded(DiscoveryEvent e) { - ServiceRegistrar[] regs = e.getRegistrars(); - logger.log(Level.INFO, "discarded " + regs.length + " instance(s)"); - - // new Throwable().printStackTrace(); - } - } - - - private class Discarder implements DiscoveryListener { - ServiceID id; - LookupDiscovery disc; - public boolean discovery = false; - public boolean discardery = false; - public boolean unexpected = false; - - public Discarder(ServiceID id, LookupDiscovery disc) { - this.id = id; - this.disc = disc; - } - - public void discovered(DiscoveryEvent e) { - ServiceRegistrar[] regs = e.getRegistrars(); - logger.log(Level.INFO, "discovered " + regs.length - + " instance(s) - discarding"); - - for (int i = 0; i < regs.length; i++) { - if (id.equals(regs[i].getServiceID())) { - discovery = true; - } else { - unexpected = true; - } - disc.discard(regs[i]); - } - - // new Throwable().printStackTrace(); - } - - public void discarded(DiscoveryEvent e) { - ServiceRegistrar[] regs = e.getRegistrars(); - logger.log(Level.INFO, - "discarded " + regs.length + " instance(s) OK"); - - for (int i = 0; i < regs.length; i++) { - if (id.equals(regs[i].getServiceID())) { - discardery = true; - } else { - unexpected = true; - } - } - - // new Throwable().printStackTrace(); - } - } - - public void run() throws Exception { - LookupDiscovery disc = null; - DiscoveryAdmin admin = null; - - // Create a LookupDiscovery object. - disc = new LookupDiscovery(Util.makeGroups("start", 700), - getConfig().getConfiguration()); - logger.log(Level.INFO, - "constructed with " + disc.getGroups().length + " elements"); - Thread.sleep(10000); - disc.addDiscoveryListener(new Ignorer()); - ServiceRegistrar reg = createLookup(); - admin = getAdmin(reg); - String[] actualGroups = new String[] { - reg.getServiceID().toString() }; - admin.setMemberGroups(actualGroups); - disc.addGroups(Util.makeGroups("added", 200)); - logger.log(Level.INFO, "increased to " + disc.getGroups().length - + " elements"); - Thread.sleep(10000); - disc.removeGroups(Util.makeGroups("start", 300)); - logger.log(Level.INFO, - "reduced to " + disc.getGroups().length + " elements"); - Thread.sleep(10000); - disc.setGroups(Util.makeGroups("toasty", 100)); - logger.log(Level.INFO, - "changed to " + disc.getGroups().length + " elements"); - Thread.sleep(10000); - disc.setGroups(DiscoveryGroupManagement.ALL_GROUPS); - logger.log(Level.INFO, "set to ALL_GROUPS"); - Thread.sleep(60000); - - try { - disc.addGroups(actualGroups); - throw new TestException("addGroups to null didn't throw anything"); - } catch (UnsupportedOperationException e) { - // expected - } - - try { - disc.removeGroups(actualGroups); - throw new TestException("removeGroups from null didn't " - + "throw anything"); - } catch (UnsupportedOperationException e) { - // expected - } - - disc.setGroups(DiscoveryGroupManagement.NO_GROUPS); - logger.log(Level.INFO, "set to NO_GROUPS"); - Thread.sleep(10000); - Discarder arder = new Discarder(reg.getServiceID(), disc); - disc.addDiscoveryListener(arder); - disc.addGroups(actualGroups); - logger.log(Level.INFO, "increased to " + disc.getGroups().length - + " elements"); - Thread.sleep(30000); - - if (arder.discovery != true) { - throw new TestException("no discovered event reported"); - } - - if (arder.discardery != true) { - throw new TestException("no discarded event reported"); - } - - if (arder.unexpected == true) { - throw new TestException( "unexpected event reported"); - } - disc.terminate(); - - try { - disc.addGroups(actualGroups); - throw new TestException("addGroups after terminate didn't " - + "throw anything"); - } catch (IllegalStateException e) { - } - - try { - disc.removeGroups(actualGroups); - throw new TestException("removeGroups after terminate didn't " - + "throw anything"); - } catch (IllegalStateException e) { - } - - try { - disc.setGroups(actualGroups); - throw new TestException("setGroups after terminate didn't " - + "throw anything"); - } catch (IllegalStateException e) { - } - } - - protected ServiceRegistrar createLookup() - throws Exception { - - // Create an instance of the lookup service. - logger.log(Level.INFO, "creating lookup service"); - return getManager().startLookupService(); - } - - protected DiscoveryAdmin getAdmin(ServiceRegistrar r) - throws RemoteException { - Object admin = ((Administrable) r).getAdmin(); - try { - return (DiscoveryAdmin) - getConfig().prepare("test.reggieAdminPreparer", admin); - } catch (Exception e) { - throw new RemoteException("Problem preparing admin", e); - } - } -} +/* + * 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.servicediscovery.discovery; + +import java.util.logging.Level; + +// java packages +import java.rmi.RemoteException; +import com.sun.jini.qa.harness.TestException; +import com.sun.jini.qa.harness.QATestEnvironment; + +// jini packages +import net.jini.admin.Administrable; +import net.jini.discovery.DiscoveryEvent; +import net.jini.discovery.DiscoveryListener; +import net.jini.discovery.DiscoveryGroupManagement; +import net.jini.discovery.LookupDiscovery; +import com.sun.jini.qa.harness.Test; +import net.jini.lookup.DiscoveryAdmin; +import net.jini.core.lookup.ServiceRegistrar; +import net.jini.core.lookup.ServiceID; + +public class Discovery extends QATestEnvironment implements Test { + + + private class Ignorer implements DiscoveryListener { + + public Ignorer() { + } + + public void discovered(DiscoveryEvent e) { + ServiceRegistrar[] regs = e.getRegistrars(); + logger.log(Level.INFO, "discovered " + regs.length + " instance(s)"); + + // new Throwable().printStackTrace(); + } + + public void discarded(DiscoveryEvent e) { + ServiceRegistrar[] regs = e.getRegistrars(); + logger.log(Level.INFO, "discarded " + regs.length + " instance(s)"); + + // new Throwable().printStackTrace(); + } + } + + + private class Discarder implements DiscoveryListener { + ServiceID id; + LookupDiscovery disc; + public boolean discovery = false; + public boolean discardery = false; + public boolean unexpected = false; + + public Discarder(ServiceID id, LookupDiscovery disc) { + this.id = id; + this.disc = disc; + } + + public void discovered(DiscoveryEvent e) { + ServiceRegistrar[] regs = e.getRegistrars(); + logger.log(Level.INFO, "discovered " + regs.length + + " instance(s) - discarding"); + + for (int i = 0; i < regs.length; i++) { + if (id.equals(regs[i].getServiceID())) { + discovery = true; + } else { + unexpected = true; + } + disc.discard(regs[i]); + } + + // new Throwable().printStackTrace(); + } + + public void discarded(DiscoveryEvent e) { + ServiceRegistrar[] regs = e.getRegistrars(); + logger.log(Level.INFO, + "discarded " + regs.length + " instance(s) OK"); + + for (int i = 0; i < regs.length; i++) { + if (id.equals(regs[i].getServiceID())) { + discardery = true; + } else { + unexpected = true; + } + } + + // new Throwable().printStackTrace(); + } + } + + public void run() throws Exception { + LookupDiscovery disc = null; + DiscoveryAdmin admin = null; + + // Create a LookupDiscovery object. + disc = new LookupDiscovery(Util.makeGroups("start", 700), + getConfig().getConfiguration()); + logger.log(Level.INFO, + "constructed with " + disc.getGroups().length + " elements"); + Thread.sleep(10000); + disc.addDiscoveryListener(new Ignorer()); + ServiceRegistrar reg = createLookup(); + admin = getAdmin(reg); + String[] actualGroups = new String[] { + reg.getServiceID().toString() }; + admin.setMemberGroups(actualGroups); + disc.addGroups(Util.makeGroups("added", 200)); + logger.log(Level.INFO, "increased to " + disc.getGroups().length + + " elements"); + Thread.sleep(10000); + disc.removeGroups(Util.makeGroups("start", 300)); + logger.log(Level.INFO, + "reduced to " + disc.getGroups().length + " elements"); + Thread.sleep(10000); + disc.setGroups(Util.makeGroups("toasty", 100)); + logger.log(Level.INFO, + "changed to " + disc.getGroups().length + " elements"); + Thread.sleep(10000); + disc.setGroups(DiscoveryGroupManagement.ALL_GROUPS); + logger.log(Level.INFO, "set to ALL_GROUPS"); + Thread.sleep(60000); + + try { + disc.addGroups(actualGroups); + throw new TestException("addGroups to null didn't throw anything"); + } catch (UnsupportedOperationException e) { + // expected + } + + try { + disc.removeGroups(actualGroups); + throw new TestException("removeGroups from null didn't " + + "throw anything"); + } catch (UnsupportedOperationException e) { + // expected + } + + disc.setGroups(DiscoveryGroupManagement.NO_GROUPS); + logger.log(Level.INFO, "set to NO_GROUPS"); + Thread.sleep(10000); + Discarder arder = new Discarder(reg.getServiceID(), disc); + disc.addDiscoveryListener(arder); + disc.addGroups(actualGroups); + logger.log(Level.INFO, "increased to " + disc.getGroups().length + + " elements"); + Thread.sleep(30000); + + if (arder.discovery != true) { + throw new TestException("no discovered event reported"); + } + + if (arder.discardery != true) { + throw new TestException("no discarded event reported"); + } + + if (arder.unexpected == true) { + throw new TestException( "unexpected event reported"); + } + disc.terminate(); + + try { + disc.addGroups(actualGroups); + throw new TestException("addGroups after terminate didn't " + + "throw anything"); + } catch (IllegalStateException e) { + } + + try { + disc.removeGroups(actualGroups); + throw new TestException("removeGroups after terminate didn't " + + "throw anything"); + } catch (IllegalStateException e) { + } + + try { + disc.setGroups(actualGroups); + throw new TestException("setGroups after terminate didn't " + + "throw anything"); + } catch (IllegalStateException e) { + } + } + + protected ServiceRegistrar createLookup() + throws Exception { + + // Create an instance of the lookup service. + logger.log(Level.INFO, "creating lookup service"); + return getManager().startLookupService(); + } + + protected DiscoveryAdmin getAdmin(ServiceRegistrar r) + throws RemoteException { + Object admin = ((Administrable) r).getAdmin(); + try { + return (DiscoveryAdmin) + getConfig().prepare("test.reggieAdminPreparer", admin); + } catch (Exception e) { + throw new RemoteException("Problem preparing admin", e); + } + } +} Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/event/ModifyAttrServiceChanged.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/event/ModifyAttrServiceChanged.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/event/ModifyAttrServiceChanged.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/servicediscovery/event/ModifyAttrServiceChanged.java Sun Oct 26 13:17:28 2014 @@ -312,7 +312,6 @@ public class ModifyAttrServiceChanged ex cache = srvcDiscoveryMgr.createLookupCache(tmpl, null,//filter srvcListener); - cacheList.add(cache); delayOnCache(); verifyCurrentEvents(nAddedExpected,0,0); }//end createCacheAndVerify
