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 2012/01/21 08:28:36 UTC

svn commit: r1234278 [24/29] - in /river/tck: ./ configs/ doc/ doc/api/ doc/api/com/ doc/api/com/sun/ doc/api/com/sun/jini/ doc/api/com/sun/jini/compat/ doc/api/com/sun/jini/compat/admin1/ doc/api/com/sun/jini/compat/admin2/ doc/api/com/sun/jini/compat...

Added: river/tck/src/com/sun/jini/compat/test/LeaseTest.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/test/LeaseTest.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/test/LeaseTest.java (added)
+++ river/tck/src/com/sun/jini/compat/test/LeaseTest.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,209 @@
+/*
+ * 
+ * Copyright 2005 Sun Microsystems, Inc.
+ * 
+ * Licensed 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.compat.test;
+
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+import net.jini.core.event.EventRegistration;
+import net.jini.core.event.RemoteEventListener;
+import net.jini.core.event.RemoteEvent;
+import net.jini.core.lease.UnknownLeaseException;
+import net.jini.core.lookup.ServiceRegistrar;
+import net.jini.core.lookup.ServiceTemplate;
+import net.jini.core.lookup.ServiceItem;
+import net.jini.core.lookup.ServiceEvent;
+
+import com.sun.jini.compat.harness.TestUtility;
+import com.sun.jini.compat.harness.Status;
+import com.sun.jini.compat.harness.Config;
+import com.sun.jini.compat.harness.DefaultTest;
+import com.sun.jini.compat.harness.BasicServiceAdmin;
+import com.sun.jini.compat.harness.BasicAdmin;
+
+/**
+ * Tests whether a service maintains its lookup service registration
+ * lease.
+ */
+public class LeaseTest extends DefaultTest {
+    
+    BasicServiceAdmin admin;
+    ServiceRegistrar lookup;
+    ServiceItem serviceItem;
+
+    /**
+     * Starts up a lookup service with a maximum lease time that is 
+     * set to the failureTime, and then starts up the service. The 
+     * test registers with the lookup service to be notified if the 
+     * service of interest registers, and waits for the service to
+     * register. If necessary, a query is performed as is done in the 
+     * other registration tests. Once the service has been confirmed 
+     * as registered with the lookup service, the test asks the lookup 
+     * service to notify it when the service of interest cancels its
+     * lease with the lookup service. The test then waits for three 
+     * times the provided lease duration (to avoid problems with 
+     * registration ceasing at the exact same time as the test stops 
+     * waiting and to get past network transmit times). If the test was not
+     * notified in that period it then queries the lookup service for 
+     * the service. If the test was notified of the service ceasing to 
+     * be registered, or if the service is gone when the lookup service 
+     * is queried, the service fails.
+     *
+     * @param args Command line arguments passed through
+     * @return The status of this run (failed or passed
+     *         and a comment)
+     */
+    public Status run(String[] args) {
+        int failureTime = getConfig().getFailureTime();
+
+	try {
+	    TestUtility.log(Config.ALL,"Test: starting lookup in public group");
+	    lookup = TestUtility.startLookup(new String[] {""}, failureTime,
+		"LeaseTest_RegistrarLog", getConfig());
+	} catch (Exception e) {
+            TestUtility.log(Config.ERROR,"Test: caught exception",e);
+            return Status.failed(Status.ENV,"Problem starting lookup service");
+        }
+
+	try {
+	    admin = (BasicServiceAdmin) getConfig().getAdmin();
+	    TestUtility.log(Config.ALL,"Test: starting program");
+	    admin.start();
+	} catch (RemoteException re) {
+            TestUtility.log(Config.ERROR,"Test: caught exception",re);
+            return Status.failed(Status.ENV,"Problem starting program");
+        }
+
+	try {
+            TestUtility.log(Config.ALL,"Test: waiting up to " + (4*failureTime)
+                + " milliseconds for program to register in lookup");
+	    serviceItem = TestUtility.waitForRegistration(lookup,
+		4 * failureTime, getConfig());
+	} catch (Exception e) {
+            TestUtility.log(Config.ERROR,"Test: caught exception",e);
+            return Status.failed(Status.ENV,"Problem while waiting for "
+		+ "program to register with lookup");
+        }
+
+	if (serviceItem == null) {
+	    return Status.failed(Status.TEST, "Service did not register");
+        }
+	    
+	try {
+	    boolean unregistered = waitForUnregistration(3 * failureTime);
+	    if (unregistered) {
+		return Status.failed(Status.TEST, "Service did not properly "
+                    + "maintain its lease in the lookup service");
+	    }    
+	} catch (Exception e) {
+            TestUtility.log(Config.ERROR,"Test: caught exception",e);
+            return Status.failed(Status.ENV,"Problem while waiting for "
+		+ "program to unregister with lookup");
+        }
+
+	return Status.passed("OK");
+    }
+    
+    public void tearDown() {
+	super.tearDown();
+	
+	try {
+	    if (lookup != null) {
+		TestUtility.log(Config.ALL,"Test: stopping lookup");
+		TestUtility.stopLookup(lookup, getConfig());
+	    }
+	} catch (RemoteException ignore) {}
+	try {
+	    if (admin != null) {
+		TestUtility.log(Config.ALL,"Test: stopping program");
+		admin.stop();
+	    }
+	} catch (RemoteException ignore) {}
+    }
+
+    public String[] getCategories() {
+	return (new String[] { BasicServiceAdmin.CATEGORY });
+    }
+
+    public Class[] getRequiredAdmins() {
+	return (new Class[] { BasicAdmin.class, BasicServiceAdmin.class });
+    }
+
+    public String getDescription() {
+	return "LeaseTest";
+    }
+
+    private boolean waitForUnregistration(long timeout) 
+	throws RemoteException, InterruptedException 
+    {
+       	RegistrationListener rl = new RegistrationListener();
+	EventRegistration er = null;
+	synchronized (rl) {
+	    er = lookup.notify(
+		new ServiceTemplate(serviceItem.serviceID, null, null),
+		ServiceRegistrar.TRANSITION_MATCH_NOMATCH |
+		ServiceRegistrar.TRANSITION_NOMATCH_MATCH,
+		rl, null, timeout * 2);
+
+	    TestUtility.log(Config.ALL,"Test: waiting up to " + timeout
+		+ " milliseconds for program to be unregistered");
+	    rl.wait(timeout);
+	}
+
+	try {
+	    if (er != null) {
+		er.getLease().cancel();
+	    }
+	} catch (UnknownLeaseException ignore) {
+	} catch (RemoteException ignore) {}
+	try {
+	    UnicastRemoteObject.unexportObject(rl,true);
+	} catch (RemoteException ignore) {}
+	
+	return (rl.isNotified() || 
+	       TestUtility.getService(lookup, getConfig()) == null);
+    }
+
+    private class RegistrationListener extends UnicastRemoteObject
+	implements RemoteEventListener 
+    {
+	private boolean notified = false;
+	public RegistrationListener() throws RemoteException {
+            super();
+        }
+	public boolean isNotified() {
+	    return notified;
+	}
+	public void notify(RemoteEvent re) {
+	    String type = "MATCH_NOMATCH";
+	    if (((ServiceEvent)re).getTransition() == 
+		ServiceRegistrar.TRANSITION_NOMATCH_MATCH) 
+	    {
+	        type = "NOMATCH_MATCH";
+	    }
+	    TestUtility.log(Config.ALL,"Test: received " + type + " event");
+	    if (!notified) {
+	        synchronized(this) {
+		    notified = true;
+                    this.notify();
+		}
+            }
+	}
+    }
+
+}

Propchange: river/tck/src/com/sun/jini/compat/test/LeaseTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: river/tck/src/com/sun/jini/compat/test/LookupByClassTest.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/test/LookupByClassTest.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/test/LookupByClassTest.java (added)
+++ river/tck/src/com/sun/jini/compat/test/LookupByClassTest.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,168 @@
+/*
+ * 
+ * Copyright 2005 Sun Microsystems, Inc.
+ * 
+ * Licensed 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.compat.test;
+
+import com.sun.jini.compat.test.lookup.TestImpl;
+import com.sun.jini.compat.test.lookup.TestRegistrar;
+import com.sun.jini.compat.test.lookup.TestException;
+import com.sun.jini.compat.test.lookup.TestFailedException;
+import com.sun.jini.compat.test.lookup.TestUnresolvedException;
+import net.jini.core.lookup.ServiceRegistrar;
+import net.jini.core.lookup.ServiceItem;
+import net.jini.core.lookup.ServiceRegistration;
+import net.jini.core.lookup.ServiceMatches;
+import net.jini.core.lookup.ServiceTemplate;
+import java.rmi.RemoteException;
+
+import com.sun.jini.compat.lease.LeaseRenewalManager;
+
+/** This class is used to test that every service item registered with
+ *  the Lookup service can be successfully looked up using only its class type.
+ *
+ *  @see com.sun.jini.compat.test.lookup.Test
+ *  @see com.sun.jini.compat.test.lookup.TestImpl
+ *  @see com.sun.jini.compat.test.lookup.TestRegistrar
+ *  @see com.sun.jini.compat.test.lookup.TestUtils
+ */
+public class LookupByClassTest extends TestRegistrar {
+
+    private ServiceItem[] srvcItems ;
+    private ServiceRegistration[] srvcRegs ;
+    private ServiceTemplate[] exactClassTmpls;
+    private ServiceRegistrar proxy;
+    private int nClasses = 0;
+    private int nInstances = 0;
+    private int nInstancesPerClass = 0;
+
+    private LeaseRenewalManager lrm;
+
+    /** Performs actions necessary to prepare for execution of the 
+     *  current  test.
+     *
+     *  Creates the lookup service. Loads and instantiates all service 
+     *  classes; then registers each service class instance with the maximum
+     *  service lease duration. Creates an array of ServiceTemplates in 
+     *  which each element contains the class type of one of the registered
+     *  services.
+     *  @exception TestException will usually indicate an "unresolved"
+     *  condition because at this point the test has not yet begun.
+     */
+    public void setupQATest() throws TestException {
+	super.setupQATest();
+        nClasses = super.getNTestClasses();
+        nInstances = super.getNInstances();
+        nInstancesPerClass = super.getNInstancesPerClass();
+	srvcItems = super.createServiceItems(TEST_SRVC_CLASSES);
+	srvcRegs = super.registerAll();
+	proxy = super.getProxy();
+	exactClassTmpls = new ServiceTemplate[nClasses];
+	for(int i=0; i<nClasses; i++) {
+	    try {
+                Class c = Class.forName(TEST_SRVC_CLASSES[i]);
+                Class[] exactClassType = {c};
+	        exactClassTmpls[i] = new ServiceTemplate(null,
+                                                         exactClassType,null);
+	    } catch (ClassNotFoundException e) {
+                throw new TestUnresolvedException
+                                     ("setupQATest: ClassNotFoundException",e);
+	    }
+	}
+	lrm = new LeaseRenewalManager();
+        for(int i=0; i<srvcRegs.length; i++) {
+            lrm.renewUntil(srvcRegs[i].getLease(),
+                         Long.MAX_VALUE, null);
+        }
+    }
+
+    /** Executes the current  test.
+     *
+     *  For each service registered:  
+     *      Performs a match lookup using the corresponding template 
+     *      created during setup and then tests that the number of matches
+     *      found equals the number of matches expected; and that the set
+     *      of objects returned equals the expected set of corresponding
+     *      service items.
+     *  @exception TestException usually indicates test failure
+     */
+    public void doQATest() throws TestException {
+        ServiceMatches exactM = null;
+        for (int i=0; i<nClasses; i++) {
+	    try {
+                exactM =
+		    proxy.lookup(exactClassTmpls[i],Integer.MAX_VALUE);
+	    } catch (RemoteException e) {
+                throw new TestFailedException
+                                   ("doQATest: RemoteException from lookup",e);
+	    }
+            if (exactM.totalMatches != expectedNMatchesExact[i]) {
+                throw new TestFailedException
+                                        ("totalMatches ("+exactM.totalMatches+
+                                          ") != expectedMatches["+
+                                         i+"] ("+expectedNMatchesExact[i]+")");
+	    } else {
+	        if (!setsAreEqual(i,exactM)) {
+                    throw new TestFailedException
+                                 ("At index "+i+", the services do NOT match");
+		}
+	    }
+	}
+
+    }
+
+    /** Performs cleanup actions necessary to achieve a graceful exit of 
+     *  the current QA test.
+     *  @exception TestException will usually indicate an "unresolved"
+     *  condition because at this point the test has completed.
+     */
+    public void cleanupQATest() throws TestException {
+	super.cleanupQATest();
+	lrm.clear();
+    }
+
+    /** Tests for equality between the returned set of services and the 
+     *  expected set of services
+     */
+    private boolean setsAreEqual(int           classIndx,
+                                 ServiceMatches srvcM)
+    {
+        int     s0,si;
+        int     i,j,k;
+        s0 = nInstancesPerClass*classIndx;
+
+        iLoop:
+            for (i=0; i<srvcM.totalMatches; i++) {
+                si = s0;
+                for (j=0;(j<srvcM.totalMatches/nInstancesPerClass); j++) {
+                    si = si+(nInstancesPerClass*j);
+                    for (k=0; k<nInstancesPerClass; k++) {
+                        if ((srvcItems[si+k].service.equals
+                                                     (srvcM.items[i].service)))
+                        {
+                           continue iLoop;
+	                }
+		    }
+	        }
+                return false;
+            }
+        return true; /* success */
+    }
+
+    public String getDescription() {
+        return "LookupByClassTest";
+    }
+}

Propchange: river/tck/src/com/sun/jini/compat/test/LookupByClassTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: river/tck/src/com/sun/jini/compat/test/LookupByInterfaceTest.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/test/LookupByInterfaceTest.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/test/LookupByInterfaceTest.java (added)
+++ river/tck/src/com/sun/jini/compat/test/LookupByInterfaceTest.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,201 @@
+/*
+ * 
+ * Copyright 2005 Sun Microsystems, Inc.
+ * 
+ * Licensed 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.compat.test;
+
+import com.sun.jini.compat.test.lookup.TestImpl;
+import com.sun.jini.compat.test.lookup.TestRegistrar;
+import com.sun.jini.compat.test.lookup.TestException;
+import com.sun.jini.compat.test.lookup.TestFailedException;
+import com.sun.jini.compat.test.lookup.TestUnresolvedException;
+import net.jini.core.lookup.ServiceRegistrar;
+import net.jini.core.lookup.ServiceItem;
+import net.jini.core.lookup.ServiceRegistration;
+import net.jini.core.lookup.ServiceMatches;
+import net.jini.core.lookup.ServiceTemplate;
+import java.rmi.RemoteException;
+
+import com.sun.jini.compat.lease.LeaseRenewalManager;
+
+/** This class is used to test that every service item registered with
+ *  the Lookup service can be successfully looked up using only the 
+ *  interfaces it implements (excluding the universally-implemented
+ *  Serializable interface).
+ *
+ *  @see com.sun.jini.compat.test.lookup.Test
+ *  @see com.sun.jini.compat.test.lookup.TestImpl
+ *  @see com.sun.jini.compat.test.lookup.TestRegistrar
+ *  @see com.sun.jini.compat.test.lookup.TestUtils
+ */
+public class LookupByInterfaceTest extends TestRegistrar {
+
+    private ServiceItem[] srvcItems ;
+    private ServiceRegistration[] srvcRegs ;
+    private ServiceTemplate[][] intfcClassTmpls;
+    private ServiceRegistrar proxy;
+    private int nClasses = 0;
+    private int nInstances = 0;
+    private int nInstancesPerClass = 0;
+    private int maxNIntfcPerClass = 0;
+    private LeaseRenewalManager lrm;
+
+    /** Performs actions necessary to prepare for execution of the 
+     *  current QA test.
+     *
+     *  Creates the lookup service. Loads and instantiates all service 
+     *  classes; then registers each service class instance with the maximum
+     *  service lease duration. Creates an array of ServiceTemplates in 
+     *  which each element contains one of the interfaces, implemented
+     *  by the corresponding service, from the set of test interfaces.
+     *  @exception TestException will usually indicate an "unresolved"
+     *  condition because at this point the test has not yet begun.
+     */
+    public void setupQATest() throws TestException {
+        int j,k;
+        int indx;
+        Class sClass;
+        Class iClass[] = new Class[super.INTERFACES.length];
+
+        super.setupQATest(); 
+        nClasses = super.getNTestClasses();
+        nInstances = super.getNInstances();
+        nInstancesPerClass = super.getNInstancesPerClass();
+        maxNIntfcPerClass  = super.MAX_N_INTFC_PER_CLASS;
+
+	srvcItems = super.createServiceItems(TEST_SRVC_CLASSES);
+	srvcRegs = super.registerAll();
+	proxy = super.getProxy();
+
+	intfcClassTmpls = new ServiceTemplate[nClasses][maxNIntfcPerClass];
+	try {
+            sClass = Class.forName("java.io.Serializable");
+            for (int i=0;i<super.INTERFACES.length;i++) {
+              iClass[i] = Class.forName(super.INTERFACES[i]);
+	    }
+	    for(int i=0; i<nClasses; i++) {
+                Class c = Class.forName(TEST_SRVC_CLASSES[i]);
+                Class[] intfcClassTypes = c.getInterfaces();
+                int nInterfaces = intfcClassTypes.length;
+		//for(int a = 0; a<nInterfaces; a++)
+		//    System.out.println("Interfaces for "+c+": "+
+		//		       intfcClassTypes[a]);
+		
+                for (j=0;j<nInterfaces;j++) {
+                    if(!intfcClassTypes[j].isAssignableFrom(sClass)) {
+                        indx = 0;
+                        for (k=0;k<super.INTERFACES.length;k++) {
+			    if(intfcClassTypes[j].isAssignableFrom(iClass[k])){
+                                indx = k;
+                                break;
+			    }
+		        }
+                        Class[] classTypeArray = {intfcClassTypes[j]};
+			intfcClassTmpls[i][k] = new ServiceTemplate
+                                                    (null,classTypeArray,null);
+                    }
+                }
+	    }
+	} catch (ClassNotFoundException e) {
+            throw new TestUnresolvedException
+                                     ("setupQATest: ClassNotFoundException",e);
+	}
+	lrm = new LeaseRenewalManager();
+        for(int i=0; i<srvcRegs.length; i++) {
+            lrm.renewUntil(srvcRegs[i].getLease(),
+                         Long.MAX_VALUE, null);
+        }
+    }
+
+    /** Executes the current QA test.
+     *
+     *  For each registered service:  
+     *     For each interface in the set of test interfaces:  
+     *        Performs a match lookup using the corresponding template 
+     *        created during setup and then tests that the number of matches
+     *        found equals the number of matches expected; and that the set
+     *        of objects returned equals the expected set of corresponding
+     *        service items.
+     *  @exception TestException usually indicates test failure
+     */
+    public void doQATest() throws TestException {
+
+        ServiceMatches intfcM = null;
+        for (int i=0; i<nClasses; i++) {
+            for (int j=0; j<super.INTERFACES.length;j++) {
+                if (super.INTFC_IMPL_MATRIX[i][j] == 0)  continue;
+	            try {
+                        intfcM = proxy.lookup(intfcClassTmpls[i][j],
+                                              Integer.MAX_VALUE);
+	            } catch (RemoteException e) {
+                        throw new TestFailedException
+                                   ("doQATest: RemoteException from lookup",e);
+	            }
+                if(intfcM.totalMatches != expectedNMatchesIntfc[i][j]) {
+                    throw new TestFailedException("totalMatches ("+
+                                   intfcM.totalMatches+") != expectedMatches["+
+                               i+"]["+j+"] ("+expectedNMatchesIntfc[i][j]+")");
+	        } else {
+       	            if (!setsAreEqual(j,intfcM)) {
+                        throw new TestFailedException
+                                 ("At index "+j+", the services do NOT match");
+      	            }
+		}
+            }
+	}
+    }
+
+    /** Performs cleanup actions necessary to achieve a graceful exit of 
+     *  the current QA test.
+     *  @exception TestException will usually indicate an "unresolved"
+     *  condition because at this point the test has completed.
+     */
+    public void cleanupQATest() throws TestException {
+	super.cleanupQATest();
+	lrm.clear();
+    }
+
+    /** Tests for equality between the returned set of services and the 
+     *  expected set of services
+     */
+    private boolean setsAreEqual(int            intfcIndx,
+                                 ServiceMatches srvcM)
+    {
+        int     si;
+        int     i,j,k;
+        boolean inSet;
+        for (i=0; i<srvcM.totalMatches; i++) {
+            inSet = false;
+            for (j=0; (   (inSet==false)
+                        &&(j<srvcM.totalMatches/nInstancesPerClass)); j++) {
+                si = nInstancesPerClass*super.INTFC_TO_SI[intfcIndx][j];
+                for (k=0; ((inSet==false)&&(k<nInstancesPerClass)); k++) {
+                    if ((srvcItems[si+k].service.equals
+                                                     (srvcM.items[i].service)))
+                    {
+                        inSet = true;
+                    }
+		}
+	    }
+            if (inSet == false) return false;
+        }
+        return true; /* success */
+    }
+    
+    public String getDescription() {
+        return "LookupByInterfaceTest";
+    }
+}

Propchange: river/tck/src/com/sun/jini/compat/test/LookupByInterfaceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: river/tck/src/com/sun/jini/compat/test/LookupByServiceIDTest.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/test/LookupByServiceIDTest.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/test/LookupByServiceIDTest.java (added)
+++ river/tck/src/com/sun/jini/compat/test/LookupByServiceIDTest.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,123 @@
+/*
+ * 
+ * Copyright 2005 Sun Microsystems, Inc.
+ * 
+ * Licensed 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.compat.test;
+
+import com.sun.jini.compat.test.lookup.TestImpl;
+import com.sun.jini.compat.test.lookup.TestRegistrar;
+import com.sun.jini.compat.test.lookup.TestUtils;
+import com.sun.jini.compat.test.lookup.TestException;
+import com.sun.jini.compat.test.lookup.TestFailedException;
+import com.sun.jini.compat.test.lookup.TestUnresolvedException;
+
+import net.jini.core.lookup.ServiceRegistrar;
+import net.jini.core.lookup.ServiceItem;
+import net.jini.core.lookup.ServiceRegistration;
+import net.jini.core.lookup.ServiceMatches;
+import net.jini.core.lookup.ServiceTemplate;
+import java.rmi.RemoteException;
+
+import com.sun.jini.compat.lease.LeaseRenewalManager;
+
+/** This class is used to test that every service item registered with
+ *  the Lookup service can be successfully looked up using only its service ID.
+ *
+ *  @see com.sun.jini.compat.test.lookup.QATest
+ *  @see com.sun.jini.compat.test.lookup.QATestImpl
+ *  @see com.sun.jini.compat.test.lookup.QATestRegistrar
+ *  @see com.sun.jini.compat.test.lookup.QATestUtils
+ */
+public class LookupByServiceIDTest extends TestRegistrar {
+
+    private ServiceItem[] srvcItems ;
+    private ServiceRegistration[] srvcRegs ;
+    private ServiceTemplate[] srvcIDTmpls;
+    private ServiceRegistrar proxy;
+    private int nInstances = 0;
+    private LeaseRenewalManager lrm;
+
+    /** the expected number of matches when testing lookup by ID */
+    private static int EXPECTED_N_MATCHES = 1;
+
+    public LookupByServiceIDTest() {
+    }
+
+    /** Performs actions necessary to prepare for execution of the 
+     *  current QA test.
+     *
+     *  Creates the lookup service. Loads and instantiates all service 
+     *  classes; then registers each service class instance with the maximum
+     *  service lease duration. Creates an array of ServiceTemplates in 
+     *  which each element contains the service ID of one of the registered
+     *  service items.
+     *  @exception QATestException will usually indicate an "unresolved"
+     *  condition because at this point the test has not yet begun.
+     */
+    public void setupQATest() throws TestException {
+	super.setupQATest();
+        nInstances = super.getNInstances();
+
+	srvcItems = super.createServiceItems(TEST_SRVC_CLASSES);
+	srvcRegs = super.registerAll();
+	proxy = super.getProxy();
+
+	srvcIDTmpls = new ServiceTemplate[nInstances];
+	for(int i=0; i<srvcIDTmpls.length; i++) {
+	    srvcIDTmpls[i] = new ServiceTemplate(srvcRegs[i].getServiceID(),
+                                                 null,null);
+	}
+	lrm = new LeaseRenewalManager();
+        for(int i=0; i<srvcRegs.length; i++) {
+            lrm.renewUntil(srvcRegs[i].getLease(),
+                         Long.MAX_VALUE, null);
+        }
+
+    }
+
+    /** Executes the current QA test.
+     *
+     *  For each service registered:  
+     *      1. Performs a simple lookup using the corresponding template 
+     *         created during setup and then tests that the object returned 
+     *         equals the service item that was registered with the 
+     *         corresponding service ID.
+     *      2. Performs a match lookup using the corresponding template 
+     *         created during setup and then tests that the number of matches
+     *         found equals 1; and that the object returned equals the 
+     *         service item that was registered with the corresponding 
+     *         service ID.
+     *  @exception QATestException usually indicates test failure
+     */
+    public void doQATest() throws TestException {
+        TestUtils.doLookup(srvcItems,srvcIDTmpls,proxy);
+    }
+
+
+    /** Performs cleanup actions necessary to achieve a graceful exit of 
+     *  the current QA test.
+     *  @exception QATestException will usually indicate an "unresolved"
+     *  condition because at this point the test has completed.
+     */
+    public void cleanupQATest() throws TestException {
+	super.cleanupQATest();
+	lrm.clear();
+    }
+   
+    public String getDescription() {
+	return "LookupByServiceIDTest";
+    }
+}

Propchange: river/tck/src/com/sun/jini/compat/test/LookupByServiceIDTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: river/tck/src/com/sun/jini/compat/test/LookupBySuperClassTest.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/test/LookupBySuperClassTest.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/test/LookupBySuperClassTest.java (added)
+++ river/tck/src/com/sun/jini/compat/test/LookupBySuperClassTest.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,201 @@
+/*
+ * 
+ * Copyright 2005 Sun Microsystems, Inc.
+ * 
+ * Licensed 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.compat.test;
+
+import com.sun.jini.compat.test.lookup.TestImpl;
+import com.sun.jini.compat.test.lookup.TestRegistrar;
+import com.sun.jini.compat.test.lookup.TestException;
+import com.sun.jini.compat.test.lookup.TestFailedException;
+import com.sun.jini.compat.test.lookup.TestUnresolvedException;
+import net.jini.core.lookup.ServiceRegistrar;
+import net.jini.core.lookup.ServiceItem;
+import net.jini.core.lookup.ServiceRegistration;
+import net.jini.core.lookup.ServiceMatches;
+import net.jini.core.lookup.ServiceTemplate;
+import java.rmi.RemoteException;
+
+import com.sun.jini.compat.lease.LeaseRenewalManager;
+
+/** This class is used to test that every service item registered with
+ *  the Lookup service can be successfully looked up using only the 
+ *  super classes it extends (excluding the universally-extended Object class).
+ *
+ *  @see com.sun.jini.compat.test.lookup.Test
+ *  @see com.sun.jini.compat.test.lookup.TestImpl
+ *  @see com.sun.jini.compat.test.lookup.TestRegistrar
+ *  @see com.sun.jini.compat.test.lookup.TestUtils
+ */
+public class LookupBySuperClassTest extends TestRegistrar {
+
+    private ServiceItem[] srvcItems ;
+    private ServiceRegistration[] srvcRegs ;
+    private ServiceTemplate[][] superClassTmpls;
+    private ServiceRegistrar proxy;
+    private int nClasses = 0;
+    private int nInstances = 0;
+    private int nInstancesPerClass = 0;
+    private int maxChainLen = 0;
+    private int[] chainLen;
+    private LeaseRenewalManager lrm;
+
+    /** Performs actions necessary to prepare for execution of the 
+     *  current  test.
+     *
+     *  Creates the lookup service. Loads and instantiates all service 
+     *  classes; then registers each service class instance with the maximum
+     *  service lease duration. For each registered service, retrieves the
+     *  "chain" of super classes and creates an array of ServiceTemplates 
+     *  in which each element contains one of the retrieved super classes 
+     *  (excluding the Object class).
+     *  @exception TestException will usually indicate an "unresolved"
+     *  condition because at this point the test has not yet begun.
+     */
+    public void setupQATest() throws TestException {
+        int j,k;
+        boolean exit_loop;
+        int indx;
+
+	super.setupQATest(); 
+        nClasses = super.getNTestClasses();
+        nInstances = super.getNInstances();
+        nInstancesPerClass = super.getNInstancesPerClass();
+        maxChainLen  = super.MAX_N_SUPER_CHAIN_LEN;
+
+	srvcItems = super.createServiceItems(TEST_SRVC_CLASSES);
+	srvcRegs = super.registerAll();
+	proxy = super.getProxy();
+
+	superClassTmpls = new ServiceTemplate[nClasses][maxChainLen];
+
+	try {
+            Class sClass[] = new Class[maxChainLen];
+            chainLen = new int[nClasses];
+	    for(int i=0; i<nClasses; i++) {
+                Class c = Class.forName(TEST_SRVC_CLASSES[i]);
+                /* build the super class "chain" corresponding to class i */
+                sClass[0] = c;
+                for (j=1,exit_loop=false;
+                      ((exit_loop==false)&&(j<maxChainLen));j++) {
+                    sClass[j] = sClass[j-1].getSuperclass();
+                    if ( !sClass[j].isAssignableFrom(Object.class) ) {
+                        Class[] superClassType = {sClass[j]};
+		        superClassTmpls[i][j] = new ServiceTemplate
+                                                    (null,superClassType,null);
+		    } else {
+                        exit_loop = true;
+                        chainLen[i] = j;
+		    }
+	        }
+	    }
+	} catch (ClassNotFoundException e) {
+            throw new TestUnresolvedException
+                                     ("setupQATest: ClassNotFoundException",e);
+	}
+	lrm = new LeaseRenewalManager();
+        for(int i=0; i<srvcRegs.length; i++) {
+            lrm.renewUntil(srvcRegs[i].getLease(),
+                         Long.MAX_VALUE, null);
+        }
+
+    }
+
+    /** Executes the current  test.
+     *
+     *  For each registered service:  
+     *     For each super class in the set of super classes:  
+     *        Performs a match lookup using the corresponding template 
+     *        created during setup and then tests that the number of matches
+     *        found equals the number of matches expected; and that the set
+     *        of objects returned equals the expected set of corresponding
+     *        service items.
+     *  @exception TestException usually indicates test failure
+     */
+    public void doQATest() throws TestException {
+        ServiceMatches superM = null;
+        for (int i=0; i<nClasses; i++) {
+	    /** Loop from j = 1 because the chain starts with the class
+             *  itself; and this test is testing only its super classes
+             */
+            for (int j=1; j<chainLen[i];j++) {
+                if (super.expectedNMatchesSuper[i][j] == 0)  continue;
+	        try {
+                    superM = proxy.lookup(superClassTmpls[i][j],
+                                          Integer.MAX_VALUE);
+	        } catch (RemoteException e) {
+                    throw new TestFailedException
+                                   ("doQATest: RemoteException from lookup",e);
+	        }
+		System.out.println("Matches: "+superM.totalMatches);
+                if(superM.totalMatches != expectedNMatchesSuper[i][j]) {
+                    throw new TestFailedException("totalMatches ("+
+                                   superM.totalMatches+") != expectedMatches["+
+                               i+"]["+j+"] ("+expectedNMatchesSuper[i][j]+")");
+		} else {
+       	            if (!setsAreEqual(i,superM)) {
+                        throw new TestFailedException
+                                 ("At index "+i+", the services do NOT match");
+		    }
+		}
+            }
+	}
+    }
+
+    /** Performs cleanup actions necessary to achieve a graceful exit of 
+     *  the current  test.
+     *  @exception TestException will usually indicate an "unresolved"
+     *  condition because at this point the test has completed.
+     */
+    public void cleanupQATest() throws TestException {
+	super.cleanupQATest();
+	lrm.clear();
+    }
+
+    /** Tests for equality between the returned set of services and the 
+     *  expected set of services
+     */
+    private boolean setsAreEqual(int            classIndx,
+                                 ServiceMatches srvcM)
+    {
+        int     s0,si;
+        int     n;
+        int     i,j,k;
+        n  = classIndx - (classIndx%chainLen[classIndx]);
+        s0 = nInstancesPerClass*n;
+
+        iLoop:
+            for (i=0; i<srvcM.totalMatches; i++) {
+                si = s0;
+                for (j=0; (j<srvcM.totalMatches/nInstancesPerClass); j++) {
+                    si = si+(nInstancesPerClass*j);
+                    for (k=0; k<nInstancesPerClass; k++) {
+                        if ((srvcItems[si+k].service.equals
+                                                     (srvcM.items[i].service)))
+                        {
+                           continue iLoop;
+	                }
+		    }
+	        }
+                return false;
+	    }
+        return true; /* success */
+    }
+
+    public String getDescription() {
+        return "LookupBySuperClassTest";
+    }
+}

Propchange: river/tck/src/com/sun/jini/compat/test/LookupBySuperClassTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: river/tck/src/com/sun/jini/compat/test/MultipleEventLeaseRenewalTest.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/test/MultipleEventLeaseRenewalTest.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/test/MultipleEventLeaseRenewalTest.java (added)
+++ river/tck/src/com/sun/jini/compat/test/MultipleEventLeaseRenewalTest.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,369 @@
+/*
+ * 
+ * Copyright 2005 Sun Microsystems, Inc.
+ * 
+ * Licensed 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.compat.test;
+
+import com.sun.jini.compat.test.lookup.TestRegistrar;
+import com.sun.jini.compat.test.lookup.TestException;
+import com.sun.jini.compat.test.lookup.TestFailedException;
+import com.sun.jini.compat.test.lookup.TestUnresolvedException;
+import com.sun.jini.compat.test.lookup.TestUtils;
+import com.sun.jini.compat.harness.Config;
+
+import com.sun.jini.compat.lease.LeaseRenewalManager;
+
+import net.jini.core.lookup.ServiceRegistrar;
+import net.jini.core.lookup.ServiceItem;
+import net.jini.core.lookup.ServiceRegistration;
+import net.jini.core.lookup.ServiceMatches;
+import net.jini.core.lookup.ServiceEvent;
+import net.jini.core.lookup.ServiceTemplate;
+import net.jini.core.event.*;
+import net.jini.core.lease.*;
+import java.rmi.Remote;
+import java.rmi.MarshalledObject;
+import java.rmi.server.UnicastRemoteObject;
+import java.rmi.RemoteException;
+import java.rmi.NoSuchObjectException;
+import java.io.IOException;
+
+/** This class is used to test that event lease renewal works as expected for
+ *  N (currently N = 5) successive lease renewal attempts.
+ *
+ *  @see com.sun.jini.compat.test.lookup.Test
+ *  @see com.sun.jini.compat.test.lookup.TestImpl
+ *  @see com.sun.jini.compat.test.lookup.TestRegistrar
+ *  @see com.sun.jini.compat.test.lookup.TestUtils
+ */
+public class MultipleEventLeaseRenewalTest extends TestRegistrar {
+    /** the expected number of matches when testing lookup by ID */
+    private static int EXPECTED_N_MATCHES = 1;
+    private final static int DEFAULT_LOOP_COUNT = 5;
+    private static int  loopCount= DEFAULT_LOOP_COUNT; 
+    private long requestedLeaseDuration;  
+    private long leaseDuration;
+    private long leaseWaitTime;
+    private long halfDurationTime;
+    private ServiceItem[] srvcItems ;
+    private ServiceRegistration[] srvcRegs ;
+    private ServiceTemplate[] srvcIDTmpls;
+    private ServiceRegistrar proxy;
+    private int nInstances = 0;
+    private LeaseRenewalManager lrm;
+
+    private long leaseStartTime;
+
+    private ServiceEvent[] notificationEvnt;
+    private int numEvnt = 0;
+    private Lease[] evntLeases ;
+    private EventRegistration[] evntRegs;
+    
+    /** Class which handles all events sent by the lookup service */
+    private class Listener implements RemoteEventListener {
+        Object proxy;
+	Listener() throws RemoteException {
+	    proxy = UnicastRemoteObject.exportObject((Remote)this);
+	}
+        /** Method called remotely by lookup to handle the generated event. */
+	public void notify(RemoteEvent theEvent)
+	    throws UnknownEventException, RemoteException 
+	{
+	    notificationEvnt[numEvnt++] = (ServiceEvent) theEvent;
+	}
+        public Object getProxy() {
+            return proxy;
+        }
+    }
+
+    /** The event handler for the services registered by this class */
+    private static Listener listener;
+
+    /** Performs actions necessary to prepare for execution of the 
+     *  current  test.
+     *
+     *  Creates a single event handler to handle all events generated
+     *  by any of the registered service items. Creates the lookup
+     *  service. Loads and instantiates all service classes. Registers 
+     *  each service class instance with the maximum service lease duration. 
+     *  Retrieves the proxy to the lookup Registrar. Creates an array of 
+     *  ServiceTemplate objects in which each element contains the service ID
+     *  of one of the registered service items. Associates with each service
+     *  item, the corresponding service ID returned by the registration 
+     *  process; to enable reuse of the service IDs during the re-registration 
+     *  of the services. Establishes an approximate event lease start time 
+     *  for each event lease by retrieving the current system time. For
+     *  each registered service, registers an event notification request,
+     *  with a specified lease duration, based on the contents of the 
+     *  corresponding template created previously and the appropriate 
+     *  transition mask. Creates an array of Leases in which each element 
+     *  contains one of the event leases created during the event 
+     *  notification registration process.
+     *  @exception TestException will usually indicate an "unresolved"
+     *  condition because at this point the test has not yet begun.
+     */
+    public void setupQATest() throws TestException {
+	try {
+	    listener = new Listener();
+	} catch (RemoteException e) {
+            throw new TestUnresolvedException
+                     ("setupQATest: RemoteException from listener creation",e);
+	}
+	super.setupQATest();
+
+	Config conf = getConfig();
+	requestedLeaseDuration = 8*conf.getFailureTime();
+
+        nInstances = super.getNInstances();
+	srvcItems = super.createServiceItems(TEST_SRVC_CLASSES);
+	srvcRegs = registerAll();
+	proxy = super.getProxy();
+	srvcIDTmpls = new ServiceTemplate[nInstances];
+	for(int i=0; i<srvcIDTmpls.length; i++) {
+	    srvcIDTmpls[i] = new ServiceTemplate(srvcRegs[i].getServiceID(),
+                                                 null,null);
+	}
+	reuseServiceID();
+	evntRegs = new EventRegistration[nInstances];
+	evntLeases = new Lease[nInstances];
+	notificationEvnt = new ServiceEvent[nInstances];
+	leaseStartTime = TestUtils.getCurTime();
+	registerAllEvents();
+
+	lrm = new LeaseRenewalManager();
+	for(int i=0; i<srvcRegs.length; i++) {
+	    lrm.renewUntil(srvcRegs[i].getLease(),
+			 Long.MAX_VALUE, null);
+	}
+	leaseDuration = findMinLeaseDuration(evntLeases);
+	leaseWaitTime = leaseDuration*3/4;
+	halfDurationTime = leaseDuration/2;
+    }
+
+    /** Executes the current  test.
+     *
+     *  Repeats the following steps N times:
+     *     Waits for three-fourths of the current lease duration time.
+     *     Sets the new (approximate) lease start time to the current time.
+     *     Renews all event leases; requesting the new lease duration.
+     *     Verifies that the lease duration returned is the duration requested.
+     *     Waits for one-half of the current lease duration time.
+     *     If the loop index is even, cancels each service lease (to generate 
+     *     an event).
+     *     If the loop index is odd, re-registers each instance of each service
+     *     class that was previously registered (also to generate an event).
+     *     Waits for a specified amount of time to allow time for any events
+     *     to be generated, sent and collected.
+     *     Performs a simple lookup of each registered service item.
+     *     Verifies that the set of events sent by the lookup service is
+     *     the set of events expected. 
+     *     Verifies that each event corresponds to the expected service ID 
+     *     and that the transition is the expected transition (MATCH_NOMATCH
+     *     if the service lease was cancelled, NOMATCH_MATCH if the service
+     *     was re-registered).
+     *  @exception TestException usually indicates test failure
+     */
+
+    /*  The time-line diagram below shows the steps of this test:
+     *
+     *                                                     Renewal
+     *                                                    NR4 |---------------|
+     *                                        Renewal         :       ^  ^    .
+     *                                        NR3 |---------------|   :  :    .
+     *                            Renewal         :      ^  ^     .   :  :    .
+     *                            NR2 |---------------|  :  :     .   :  :    .
+     *                Renewal         :     ^  ^      .  :  :     .   :  :    .
+     *                NR1 |---------------| :  :      .  :  :     .   :  :    .
+     *    Renewal         :      ^  ^     . :  :      .  :  :     .   :  :    .
+     *    NR0 |---------------|  :  :     . :  :      .  :  :     .   :  :    .
+     *        :      ^  ^     .  :  :     . :  :      .  :  :     .   :  :    .
+  |---------------|  :  :     .  :  :     . :  :      .  :  :     .   :  :    .
+  0      0.5      1  :  :   1.75 :  :   2.5 :  :    3.25 :  :     4   :  :  4.75
+     *               :  :        :  :       :  :         :  :         :  :
+     *               :  :        :  :       :  :         :  :         :  :
+     *               :  A0       :  A1      :  A2        :  A3        :  A4
+     *               :           :          :            :            :
+     *               :           :          :            :            :
+     *              P0          P1         P2           P3           P4
+     */
+    public void doQATest() throws TestException {
+	for(int i =0; i<loopCount; i++) {
+	    numEvnt = 0;
+	    TestUtils.computeDurAndWait(leaseStartTime, leaseWaitTime);
+	    leaseStartTime = TestUtils.getCurTime();
+	    TestUtils.doRenewLease(evntLeases,
+				   requestedLeaseDuration);
+	    leaseDuration = findMinLeaseDuration(evntLeases);
+	    leaseWaitTime = leaseDuration*3/4;
+	    halfDurationTime = leaseDuration/2;
+	 
+	    TestUtils.computeDurAndWait(leaseStartTime, halfDurationTime);
+	    int transition;
+	    if( TestUtils.isEven(i) ) {
+		cancelAllLeases(srvcRegs);
+		transition = ServiceRegistrar.TRANSITION_MATCH_NOMATCH;
+	    } else {
+		srvcRegs = registerAll();
+		for(int j=0; j<srvcRegs.length; j++) {
+		    lrm.renewUntil(srvcRegs[j].getLease(),
+				 Long.MAX_VALUE, null);
+		}
+	      	transition = ServiceRegistrar.TRANSITION_NOMATCH_MATCH;
+	    }
+	    try {
+		Thread.sleep(leaseDuration/8);
+	    } catch (InterruptedException e) {
+	    }
+	    verifyNotification(transition);
+	}
+    }
+
+    /** Performs cleanup actions necessary to achieve a graceful exit of 
+     *  the current  test.
+     *
+     *  Unexports the listener and then performs any remaining standard
+     *  cleanup duties.
+     *  @exception TestException will usually indicate an "unresolved"
+     *  condition because at this point the test has completed.
+     */
+    public void cleanupQATest() throws TestException  {
+	try {
+	    UnicastRemoteObject.unexportObject((Remote)listener, true);
+	} catch (NoSuchObjectException e) {
+        }
+	super.cleanupQATest();
+	
+	lrm.clear();
+    }
+    
+    private long findMinLeaseDuration(Lease[] ls) {
+	long minExp = Long.MAX_VALUE;
+	for(int i=0; i<ls.length; i++) {
+	    long tempExp = ls[i].getExpiration();
+	    if(tempExp < minExp)
+		minExp = tempExp;
+	}
+       
+	long startTime = TestUtils.getCurTime();
+	return minExp-startTime;
+    }
+    
+    /* For each registered service, registers an event notification request,
+     * with a specified lease duration, based on the contents of the 
+     * corresponding template created during setup and corresponding to
+     * the appropriate transition mask. Populates the array of Leases so
+     * that each element contains one of the event leases returned by the 
+     * event notification registration process.
+     */
+    private void registerAllEvents() throws TestException {
+        for(int i=0; i<evntRegs.length; i++) {
+	    try {
+		evntRegs[i] = proxy.notify(srvcIDTmpls[i],
+		    ServiceRegistrar.TRANSITION_NOMATCH_MATCH  |
+		        ServiceRegistrar.TRANSITION_MATCH_NOMATCH |
+		        ServiceRegistrar.TRANSITION_MATCH_MATCH,
+		    (RemoteEventListener) listener.getProxy(),
+		    null,
+		    requestedLeaseDuration);
+		evntLeases[i] = evntRegs[i].getLease();
+	    } catch (RemoteException e) {
+                throw new TestUnresolvedException
+                    ("registerAllEvents: RemoteException from notify (index = "
+                      +i+")",e);
+	    } catch (IOException e) {
+                throw new TestUnresolvedException
+     ("registerAllEvents: IOException from MarshalledObject creation (index = "
+                                                                     +i+")",e);
+	    }
+	}
+    }
+
+    /* Cancels the service lease of each registered service item. */
+    private void cancelAllLeases(ServiceRegistration[] regs)
+                                                         throws TestException
+    {
+        for(int i=0; i<regs.length; i++) {
+	    try {
+		lrm.cancel(regs[i].getLease());
+	    } catch (UnknownLeaseException e) {
+                throw new TestUnresolvedException
+                           ("cancelAllLeases: lease["+i+"] -- unknown lease",e);
+	    } catch (RemoteException e) {
+                throw new TestUnresolvedException
+                    ("cancelAllLeases: RemoteException while cancelling lease["
+                     +i+"]",e);
+	    }
+	}
+    }
+
+    /* Associates with each registered service item, the corresponding 
+     * service ID returned by the registration process; so as to enable 
+     * reuse of the service IDs during the re-registration process.
+     */
+    private void reuseServiceID() {
+        for(int i=0; i< srvcItems.length; i++) {
+	    srvcItems[i].serviceID = srvcRegs[i].getServiceID();
+	}
+    }
+  
+    /* Verifies that the number of events received equals the number of
+     * events expected. For each registered service item, verifies that
+     * service's ID equals the service ID associated with the corresponding
+     * event; and that the transition associated with the event equals
+     * the expected transition.
+     */
+    private void verifyNotification(int transition) throws TestException {
+	if(srvcItems.length != numEvnt )
+            throw new TestFailedException("# of Events Received ("+
+                                             numEvnt+
+                                             ") != # of Events Expected ("+
+                                             srvcItems.length+")");
+
+	for(int i=0; i <srvcItems.length; i++) {
+	    if(!verifyServiceItemTransition(srvcItems[i],transition)) {
+                throw new TestFailedException
+                                         ("transition mismatch (index "+i+")");
+	    }
+	}	
+    }
+
+    /* For each event associated with the given service item, verifies that
+     * verifies that service's ID equals the service ID associated with the 
+     * event; and that the transition associated with the event equals
+     * the expected transition.
+     */
+    private boolean verifyServiceItemTransition(ServiceItem serviceItem,
+                                                int transition)
+    {
+	for(int i=0; i<numEvnt; i++ ) {
+	    if(    (notificationEvnt[i].getServiceID().equals
+                                                       (serviceItem.serviceID))
+                && (notificationEvnt[i].getTransition() == transition) )
+            {
+		return true;
+	    }
+	}
+	//System.out.println("verifyServiceItemTransition failed");
+	return false;
+    }
+    
+    public String getDescription() {
+	return "MultipleEventLeaseRenewalTest";
+    }  
+}
+
+
+

Propchange: river/tck/src/com/sun/jini/compat/test/MultipleEventLeaseRenewalTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: river/tck/src/com/sun/jini/compat/test/MultipleGroupTest.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/test/MultipleGroupTest.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/test/MultipleGroupTest.java (added)
+++ river/tck/src/com/sun/jini/compat/test/MultipleGroupTest.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,173 @@
+/*
+ * 
+ * Copyright 2005 Sun Microsystems, Inc.
+ * 
+ * Licensed 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.compat.test;
+
+import java.io.IOException;
+
+import java.rmi.RemoteException;
+
+import com.sun.jini.compat.harness.TestUtility;
+import com.sun.jini.compat.harness.Status;
+import com.sun.jini.compat.harness.DefaultTest;
+import com.sun.jini.compat.harness.BasicServiceAdmin;
+import com.sun.jini.compat.harness.BasicAdmin;
+import com.sun.jini.compat.harness.Config;
+
+import net.jini.core.lookup.ServiceRegistrar;
+import net.jini.core.lookup.ServiceItem;
+
+/**
+ * Tests whether a service registers with a lookup service that 
+ * belongs to multiple groups, including the public group.
+ */
+public class MultipleGroupTest extends DefaultTest {
+    
+    /**
+     * Starts up the service and waits quietTime
+     * so that (hopefully) there are no further multicast 
+     * requests, and then starts up a lookup service that belongs to 
+     * three groups. The lookup service belongs to the public
+     * group and two groups whose names are ten randomly generated 
+     * characters. The test then registers with the 
+     * lookup service to be notified if the service of interest registers. 
+     * If notification does not happen within six times the
+     * failureTime, the test queries the lookup service to make sure 
+     * the event wasn't lost or delayed and that the service really 
+     * did register. If the service did not register, the service fails. 
+     * The service and the lookup service are stopped. If the service
+     * didn't fail, the process of starting a lookup service and waiting 
+     * for a notification repeats two more times with the public group 
+     * being the second, and then the third, group in the lookup 
+     * service's group list.
+     *
+     * @param args Command line arguments passed through
+     * @return The status of this run (failed or passed
+     *         and a comment)
+     */
+    public Status run(String[] args) {
+	String nonpub1 = TestUtility.randomString(10);
+	String nonpub2 = TestUtility.randomString(10);
+
+	try {
+	    String[] groups1 = {"", nonpub1, nonpub2};
+	    if (!registers(groups1)) {
+		return Status.failed(Status.TEST, "Service did not register "
+		    + "with the lookup which is in the following groups: "
+		    + groupsString(groups1));
+	    }
+	    
+	    String[] groups2 = {nonpub1, "", nonpub2};
+	    if (!registers(groups2)) {
+		return Status.failed(Status.TEST, "Service did not register "
+		    + "with the lookup which is in the following groups: "
+		    + groupsString(groups2));
+	    }
+
+	    String[] groups3 = {nonpub1, nonpub2, ""};
+	    if (!registers(groups3)) {
+		return Status.failed(Status.TEST, "Service did not register "
+		    + "with the lookup which is in the following groups: "
+		    + groupsString(groups3));
+	    }
+	} catch (Exception e) {
+            TestUtility.log(Config.ERROR,"Test: exception caught",e);
+	    return Status.failed(Status.ENV, "Problem while waiting for "
+		+ "program to register with lookup");
+	}
+
+	return Status.passed("OK");
+    }   
+
+    private boolean registers(String[] groups) throws Exception {
+	ServiceRegistrar lookup = null;
+	Config conf = getConfig();
+	BasicServiceAdmin admin = (BasicServiceAdmin) conf.getAdmin();
+
+	try {
+            try {
+                TestUtility.log(Config.ALL,"Test: starting program");
+                admin.start();
+            } catch (RemoteException re) {
+                TestUtility.log(Config.ERROR,"Test: caught exception",re);
+                return false;
+            }
+
+	    /* Try to wait through all the multicast requests so that
+	     * the registration is more likely to be from announcements */
+	    try {
+		TestUtility.log(Config.ALL,"Test: waiting " 
+		    + conf.getQuietTime() + " milliseconds for (hopefully) "
+		    + "all multicast requests");
+                Thread.sleep(conf.getQuietTime());
+            } catch (InterruptedException ie) {
+		TestUtility.log(Config.ERROR,"Test: caught exception",ie);
+		return false;
+	    }
+	    	   
+	    String logSuffix = TestUtility.randomString(4);
+	    TestUtility.log(Config.ALL,"Test: starting lookup which is in "
+		+ "the following groups: " + groupsString(groups));
+	    lookup = TestUtility.startLookup(groups, conf.getQuietTime(), 
+			"MultipleGroupTest_RegistrarLog" + logSuffix, conf);
+	    
+	    long timeout = 6 * conf.getFailureTime();
+            TestUtility.log(Config.ALL,"Test: waiting up to " + timeout 
+                + " milliseconds for program to register in lookup");
+	    ServiceItem serviceItem = TestUtility.waitForRegistration(lookup,
+			timeout, conf);
+	
+	    return (serviceItem != null);
+	} finally {
+            try {
+                if (lookup != null) {
+		    TestUtility.log(Config.ALL,"Test: stopping lookup");
+                    TestUtility.stopLookup(lookup, conf);
+                }
+            } catch (RemoteException ignore) {}
+            try {
+                if (admin != null) {
+		    TestUtility.log(Config.ALL,"Test: stopping program");
+                    admin.stop();
+                }
+            } catch (RemoteException ignore) {}
+	}
+    }
+
+    private String groupsString(String[] groups) {
+	StringBuffer buf = new StringBuffer("");
+	for (int i = 0; i < groups.length; i++) {
+	    if (groups[i].equals(""))
+		buf.append("<public> ");
+	    else
+		buf.append(groups[i] + " ");
+	}
+	return buf.toString();
+    }
+
+    public String[] getCategories() {
+	return (new String[] { BasicServiceAdmin.CATEGORY });
+    }
+
+    public Class[] getRequiredAdmins() {
+	return (new Class[] { BasicAdmin.class, BasicServiceAdmin.class });
+    }
+
+    public String getDescription() {
+	return "MultipleGroupTest";
+    }
+}

Propchange: river/tck/src/com/sun/jini/compat/test/MultipleGroupTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: river/tck/src/com/sun/jini/compat/test/MultipleRegistrationTest.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/test/MultipleRegistrationTest.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/test/MultipleRegistrationTest.java (added)
+++ river/tck/src/com/sun/jini/compat/test/MultipleRegistrationTest.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,282 @@
+/*
+ * 
+ * Copyright 2005 Sun Microsystems, Inc.
+ * 
+ * Licensed 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.compat.test;
+
+import java.io.IOException;
+
+import java.rmi.MarshalledObject;
+import java.rmi.server.UnicastRemoteObject;
+import java.rmi.RemoteException;
+
+import com.sun.jini.compat.harness.TestUtility;
+import com.sun.jini.compat.harness.Status;
+import com.sun.jini.compat.harness.DefaultTest;
+import com.sun.jini.compat.harness.BasicServiceAdmin;
+import com.sun.jini.compat.harness.BasicAdmin;
+import com.sun.jini.compat.harness.Config;
+import com.sun.jini.compat.harness.RegistrationListener;
+
+import com.sun.jini.lookup.entry.LookupAttributes;
+
+import net.jini.core.lookup.ServiceRegistrar;
+import net.jini.core.lookup.ServiceItem;
+import net.jini.core.event.EventRegistration;
+import net.jini.core.lease.UnknownLeaseException;
+
+/**
+ * Tests whether a service registers with multiple lookup services 
+ * properly, including registering the same information (ServiceID 
+ * and attributes) with all of the lookup services.
+ */
+public class MultipleRegistrationTest extends DefaultTest {
+    
+    private BasicServiceAdmin admin;
+    private ServiceRegistrar[] lookups;
+    private EventRegistration[] er;
+    private RegistrationListener[] rl;
+
+    /**
+     * Starts up three lookup services, all of which are at least in 
+     * the public group (some are in multiple groups), and then starts 
+     * up the service being tested. The test then registers with all 
+     * three of the lookup services to be notified when the service of
+     * interest registers. If the test is not notified within twelve 
+     * times the failureTime by all three lookup services, it queries 
+     * the lookup services. Finally, if the service is in all three 
+     * lookup services, the test compares the ServiceID and the attributes
+     * that are registered with the three lookup services to make sure 
+     * they are the same.  If the service isn't registered in all 
+     * three of the lookup services, or the registration information 
+     * is different between the three lookup services, the service fails.
+     *
+     * @param args Command line arguments passed through
+     * @return The status of this run (failed or passed
+     *         and a comment)
+     */
+    public Status run(String[] args){
+	String[][] groups = {{""},
+			    {"tck-random-group-1", ""},
+			    {"tck-random-group-1", "tck-random-group-2", ""}};
+	lookups = new ServiceRegistrar[groups.length];
+
+	Config conf = getConfig();
+	admin = (BasicServiceAdmin) conf.getAdmin();
+
+	try {
+	    for (int i = 0; i < lookups.length; i++) {
+		TestUtility.log(Config.ALL,"Test: starting lookup " + i);
+	        lookups[i] = TestUtility.startLookup(groups[i], 
+		    conf.getQuietTime(),
+		    "MultipleRegistrationTest_RegistrarLog" + i, conf);
+	    }
+	} catch (Exception e) {
+            TestUtility.log(Config.ERROR,"Test: caught exception",e);
+            return Status.failed(Status.ENV,"Problem starting lookup services");
+        }
+
+	try {
+	    TestUtility.log(Config.ALL,"Test: starting program");
+	    admin.start();
+	} catch (RemoteException re) {
+            TestUtility.log(Config.ERROR,"Test: caught exception",re);
+            return Status.failed(Status.ENV,"Problem starting program");
+        }
+	    
+	ServiceItem[] theService = null;
+	try {
+	    long timeout = 12 * conf.getFailureTime();
+	    TestUtility.log(Config.ALL,"Test: waiting up to " + (timeout * 3)
+		+ " milliseconds for program to register in all lookups");
+	    theService = waitForAllRegistrations(lookups,timeout);
+	} catch (Exception e) {
+            TestUtility.log(Config.ERROR,"Test: caught exception",e);
+            return Status.failed(Status.ENV,"Problem while waiting for "
+                + "program to register with all lookups");
+        }
+	    
+	if (theService == null) {
+	    return Status.failed(Status.TEST, "Service not found "
+		+ "in all lookups");
+	}
+	    
+	TestUtility.log(Config.ALL,"Test: checking that the registrations "
+	    + "are consistent");
+	if (!registrationsAreConsistent(theService)) {
+	    return Status.failed(Status.TEST, "Service registered "
+		+ "inconsistently in lookups");
+	}
+	    
+	return Status.passed("OK");
+    }
+
+    public void tearDown() {
+        super.tearDown();
+
+	for (int i = 0; i < lookups.length; i++) {
+	    if (er != null && er[i] != null) {
+		try {
+		    er[i].getLease().cancel();
+		} catch (UnknownLeaseException ignore) {
+		} catch (RemoteException ignore) {}
+	    }
+	    if (rl != null && rl[i] != null) {
+		try {
+		    UnicastRemoteObject.unexportObject(rl[i],true);
+		} catch (RemoteException ignore) {}
+	    }
+            if (lookups != null && lookups[i] != null) {
+                try {
+		    TestUtility.log(Config.ALL,"Test: stopping lookup " + i);
+                    TestUtility.stopLookup(lookups[i], getConfig());
+                } catch (RemoteException ignore) {}
+            }
+	}
+        try {
+            if (admin != null) {
+		TestUtility.log(Config.ALL,"Test: stopping program");
+                admin.stop();
+            }
+        } catch (RemoteException ignore) {}
+    }
+
+    public String[] getCategories() {
+	return (new String[] { BasicServiceAdmin.CATEGORY });
+    }
+
+    public Class[] getRequiredAdmins() {
+	return (new Class[] { BasicAdmin.class,
+			      BasicServiceAdmin.class });
+    }
+
+    public String getDescription() {
+	return "MultipleRegistrationTest";
+    }
+
+    private boolean registrationsAreConsistent(ServiceItem[] si) {
+	TestUtility.log(Config.ALL,"Test: checking ServiceIDs are identical");
+	if (!si[0].serviceID.equals(si[1].serviceID))
+	    return false;
+	if (!si[1].serviceID.equals(si[2].serviceID))
+	    return false;
+	
+	try {
+	    TestUtility.log(Config.ALL,"Test: checking service objects are "
+		+ "identical");
+	    MarshalledObject mo0 = new MarshalledObject(si[0].service);
+	    MarshalledObject mo1 = new MarshalledObject(si[1].service);
+	    MarshalledObject mo2 = new MarshalledObject(si[2].service);
+	    
+	    if (!mo0.equals(mo1))
+		return false;
+	    if (!mo0.equals(mo2))
+		return false;
+	} catch (IOException ioe) {
+	    return false;
+	}
+
+	TestUtility.log(Config.ALL,"Test: checking number of attributes "
+	    + "are identical");
+	int len0 = -1;
+	int len1 = -1;
+	int len2 = -1;
+	if (si[0].attributeSets != null)
+	    len0 = si[0].attributeSets.length;
+	if (si[1].attributeSets != null)
+	    len1 = si[1].attributeSets.length;
+	if (si[2].attributeSets != null)
+	    len2 = si[2].attributeSets.length;
+	if (len0 != len1 || len0 != len2 || len0 == -1)
+	    return false;
+
+	TestUtility.log(Config.ALL,"Test: checking attributes are identical");
+	try {
+            return (LookupAttributes.equal(
+                        si[0].attributeSets,si[1].attributeSets)
+                && LookupAttributes.equal(
+                        si[0].attributeSets,si[2].attributeSets));
+        } catch (NullPointerException npe) {
+	    TestUtility.log(Config.ERROR,"Test: received NullPointerException "
+		+ "while comparing attributes; most likely found a null "
+		+ "ServiceItem.attributeSets array entry which indicates "
+		+ "that an entry cannot be deserialized");
+            return false;
+        }
+    }
+
+    /**
+     * This method registers a listener with the 
+     * ServiceRegistrars provided and then waits for notification.  
+     * If they don't all notify then the ServiceRegistrars are polled to
+     * see if the event was lost but the service still registered.
+     * The method returns the ServiceItems from ServiceRegistrars
+     * provided.
+     *
+     * @param lookups an array of the lookup services
+     * @param timeOut the amount of milliseconds to wait for the
+     *                service to register 
+     * @return the ServiceItems from all ServiceRegistrars provided;
+     *         null if the service did not register with all of them
+     */
+    public ServiceItem[] waitForAllRegistrations(ServiceRegistrar[] lookups,
+	long timeOut) throws RemoteException, InterruptedException
+    {
+	BasicServiceAdmin bsa = (BasicServiceAdmin) getConfig().getAdmin();
+	rl = new RegistrationListener[lookups.length];
+	er = new EventRegistration[lookups.length];
+	ServiceItem[] theService = new ServiceItem[lookups.length];
+
+	for (int i = 0; i < lookups.length; i++) {
+	    rl[i] = new RegistrationListener(this, bsa);
+	}
+	
+	synchronized (this) {
+	    for (int i = 0; i < lookups.length; i++) {
+		er[i] = lookups[i].notify(bsa.getTemplate(),
+		    ServiceRegistrar.TRANSITION_NOMATCH_MATCH, rl[i], null, 
+		    timeOut * 3);
+	    }
+	    for (int i = 0; i < lookups.length; i++) {
+	        TestUtility.log(Config.ALL,"Test: waiting up to " + timeOut 
+		    + " milliseconds for program to register in lookup " + i);
+	        wait(timeOut);
+	    }
+	}
+	
+	int count = 0;
+	for (int i = 0; i < lookups.length; i++) {
+	    if (rl[i].getNotified()) {
+		count++;
+		theService[i] = rl[i].getServiceItem();
+	    } else {
+		ServiceItem temp = TestUtility.getService(lookups[i],
+							  getConfig());
+		if (temp != null) {
+		    count++;
+		    theService[i] = temp;
+		}
+	    }
+	}
+
+	TestUtility.log(Config.ALL,"Test: program registered with "
+	    + count + " of " + lookups.length + " lookups");	
+	if (count != lookups.length)
+	    return null;
+	
+	return theService;
+    }
+}

Propchange: river/tck/src/com/sun/jini/compat/test/MultipleRegistrationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: river/tck/src/com/sun/jini/compat/test/MultipleServiceLeaseRenewalTest.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/test/MultipleServiceLeaseRenewalTest.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/test/MultipleServiceLeaseRenewalTest.java (added)
+++ river/tck/src/com/sun/jini/compat/test/MultipleServiceLeaseRenewalTest.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,176 @@
+/*
+ * 
+ * Copyright 2005 Sun Microsystems, Inc.
+ * 
+ * Licensed 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.compat.test;
+
+import com.sun.jini.compat.test.lookup.TestImpl;
+import com.sun.jini.compat.test.lookup.TestRegistrar;
+import com.sun.jini.compat.test.lookup.TestException;
+import com.sun.jini.compat.test.lookup.TestFailedException;
+import com.sun.jini.compat.test.lookup.TestUnresolvedException;
+import com.sun.jini.compat.test.lookup.TestUtils;
+import com.sun.jini.compat.harness.Config;
+
+import net.jini.core.lookup.ServiceRegistrar;
+import net.jini.core.lookup.ServiceItem;
+import net.jini.core.lookup.ServiceRegistration;
+import net.jini.core.lookup.ServiceMatches;
+import net.jini.core.lookup.ServiceTemplate;
+import net.jini.core.lease.*;
+import java.rmi.RemoteException;
+
+/** This class is used to test that service lease renewal works as expected for
+ *  N (currently N = 5) successive lease renewal attempts.
+ *
+ *  @see com.sun.jini.compat.test.lookup.Test
+ *  @see com.sun.jini.compat.test.lookup.TestImpl
+ *  @see com.sun.jini.compat.test.lookup.TestRegistrar
+ *  @see com.sun.jini.compat.test.lookup.TestUtils
+ */
+public class MultipleServiceLeaseRenewalTest extends TestRegistrar {
+    /** the expected number of matches when testing lookup by ID */
+    private static int EXPECTED_N_MATCHES = 1;
+    private final static int DEFAULT_LOOP_COUNT = 5;
+    private static int  loopCount= DEFAULT_LOOP_COUNT; 
+    private long requestedLeaseDuration;
+    private long leaseDuration;
+    private long leaseWaitTime;
+    private long halfDurationTime;
+    private ServiceItem[] srvcItems ;
+    private ServiceRegistration[] srvcRegs ;
+    private Lease[] srvcLeases ;
+    private ServiceTemplate[] srvcIDTmpls;
+    private ServiceRegistrar proxy;
+    private int nInstances = 0;
+    private long leaseStartTime;
+
+    /** Performs actions necessary to prepare for execution of the 
+     *  current  test.
+     *
+     *  Creates the lookup service. Loads and instantiates all service 
+     *  classes. Retrieves the proxy to the lookup Registrar. Establishes 
+     *  an approximate service lease start time for each service item by 
+     *  retrieving the current system time. Registers each service class 
+     *  instance with a specified lease duration. Creates an array of 
+     *  Leases in which each element contains the service lease of one 
+     *  of the registered services. Creates an array of ServiceTemplate objects 
+     *  in which each element contains the service ID of one of the 
+     *  registered service items.
+     *  @exception TestException will usually indicate an "unresolved"
+     *  condition because at this point the test has not yet begun.
+     */
+    public void setupQATest() throws TestException {
+        int i;
+	super.setupQATest();
+
+	Config conf = getConfig();
+	requestedLeaseDuration = 4*conf.getFailureTime();
+
+        nInstances = super.getNInstances();
+	srvcItems = super.createServiceItems(TEST_SRVC_CLASSES);
+	proxy = super.getProxy();
+	srvcIDTmpls = new ServiceTemplate[nInstances];
+	leaseStartTime = TestUtils.getCurTime();
+ 	srvcRegs = registerAll(requestedLeaseDuration);
+	
+	long minExp = leaseStartTime+requestedLeaseDuration;
+ 
+        srvcLeases = new Lease[srvcRegs.length];
+	for(i=0; i<srvcLeases.length; i++) {
+	    srvcLeases[i] = srvcRegs[i].getLease();
+	}
+	// The minimum lease duration granted
+	leaseDuration = findMinLeaseDuration(srvcLeases);
+	leaseWaitTime = leaseDuration*3/4;
+	halfDurationTime = leaseDuration/2;
+
+	for(i=0; i<srvcIDTmpls.length; i++) {
+	    srvcIDTmpls[i] = new ServiceTemplate(srvcRegs[i].getServiceID(),
+                                                 null,null);
+	}
+    }
+
+    /** Executes the current  test.
+     *
+     *  Repeats the following steps N times:
+     *     Waits for three-fourths of the current lease duration time.
+     *     Sets the new (approximate) lease start time to the current time.
+     *     Renews all service leases; requesting the new lease duration.
+     *     Waits for one-half of the current lease duration time.
+     *     Performs a simple lookup of each registered service item.
+     *     Verifies that the set of service items returned by the lookup 
+     *     operation equals the expected set of service items.
+     *  @exception TestException usually indicates test failure
+     */
+
+    /*  The time-line diagram below shows the steps of this test:
+     *
+     *                                                     Renewal
+     *                                                     R4 |---------------|
+     *                                         Renewal        :        ^      .
+     *                                         R3 |---------------|    :      .
+     *                             Renewal        :       ^       .    :      .
+     *                             R2 |---------------|   :       .    :      .
+     *                 Renewal        :       ^       .   :       .    :      .
+     *                 R1 |---------------|   :       .   :       .    :      .
+     *     Renewal        :       ^       .   :       .   :       .    :      .
+     *     R0 |---------------|   :       .   :       .   :       .    :      .
+     *        :       ^       .   :       .   :       .   :       .    :      .
+  |---------------|   :       .   :       .   :       .   :       .    :      .
+  0      0.5      1   :      1.75 :      2.5  :     3.25  :       4    :    4.75
+     *                :           :           :           :            :
+     *                :           :           :           :            :
+     *               L0          L1          L2          L3           L4
+     */
+    public void doQATest() throws TestException {
+	for(int i =0; i<loopCount; i++) {
+	    TestUtils.computeDurAndWait(leaseStartTime, leaseWaitTime);
+	    leaseStartTime = TestUtils.getCurTime();
+	    TestUtils.doRenewLease(srvcLeases, leaseDuration);
+	    leaseDuration = findMinLeaseDuration(srvcLeases);
+	    leaseWaitTime = leaseDuration*3/4;
+	    halfDurationTime = leaseDuration/2;
+	    TestUtils.computeDurAndWait(leaseStartTime, halfDurationTime);
+	    TestUtils.doLookup(srvcItems, srvcIDTmpls, proxy ); 
+	}
+    }
+
+    private long findMinLeaseDuration(Lease[] ls) {
+	long minExp = Long.MAX_VALUE;
+	for(int i=0; i<ls.length; i++) {
+	    long tempExp = ls[i].getExpiration();
+	    if(tempExp < minExp)
+		minExp = tempExp;
+	}
+       
+	long startTime = TestUtils.getCurTime();
+	return minExp-startTime;
+    }
+
+    /** Performs cleanup actions necessary to achieve a graceful exit of 
+     *  the current  test.
+     *  @exception TestException will usually indicate an "unresolved"
+     *  condition because at this point the test has completed.
+     */
+    public void cleanupQATest() throws TestException {
+	super.cleanupQATest();
+    }
+    
+    public String getDescription() {
+	return "MultipleServiceLeaseRenewalTest";
+    }   
+}

Propchange: river/tck/src/com/sun/jini/compat/test/MultipleServiceLeaseRenewalTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: river/tck/src/com/sun/jini/compat/test/NonPublicGroupTest.java
URL: http://svn.apache.org/viewvc/river/tck/src/com/sun/jini/compat/test/NonPublicGroupTest.java?rev=1234278&view=auto
==============================================================================
--- river/tck/src/com/sun/jini/compat/test/NonPublicGroupTest.java (added)
+++ river/tck/src/com/sun/jini/compat/test/NonPublicGroupTest.java Sat Jan 21 07:28:27 2012
@@ -0,0 +1,145 @@
+/*
+ * 
+ * Copyright 2005 Sun Microsystems, Inc.
+ * 
+ * Licensed 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.compat.test;
+
+import java.io.IOException;
+
+import java.rmi.RemoteException;
+
+import com.sun.jini.compat.harness.TestUtility;
+import com.sun.jini.compat.harness.Status;
+import com.sun.jini.compat.harness.DefaultTest;
+import com.sun.jini.compat.harness.BasicServiceAdmin;
+import com.sun.jini.compat.harness.BasicAdmin;
+import com.sun.jini.compat.harness.Config;
+
+import net.jini.core.lookup.ServiceRegistrar;
+import net.jini.core.lookup.ServiceItem;
+
+/**
+ * Tests whether a service does not register with a lookup service 
+ * that only belongs to groups that are not of interest to the service.
+ */
+public class NonPublicGroupTest extends DefaultTest {
+
+    private BasicAdmin admin;
+    private ServiceRegistrar lookup;
+
+    /**
+     * Starts up the service and waits quietTime
+     * so that (hopefully) there are no further multicast 
+     * requests. The test then starts a lookup service that belongs 
+     * to a group whose name is eight randomly generated
+     * non-letter characters. The test registers with the 
+     * lookup service to be notified when a service of interest 
+     * registers and then the test waits. If no notification is
+     * received during the value of the quietTime, it follows up 
+     * with a query to the lookup service to make sure the event 
+     * wasn't lost or missed. If the service has not registered with 
+     * the lookup service during that time, the service passes.
+     *
+     * @param args Command line arguments passed through
+     * @return The status of this run (failed or passed
+     *         and a comment)
+     */
+    public Status run(String[] args) {
+	Config conf = getConfig();
+	admin = (BasicServiceAdmin) conf.getAdmin();
+
+	try {
+            TestUtility.log(Config.ALL,"Test: starting program");
+            admin.start();
+        } catch (RemoteException re) {
+            TestUtility.log(Config.ERROR,"Test: caught exception",re);
+            return Status.failed(Status.ENV,"Problem starting program");
+        }
+
+        /* Try to wait through all the multicast requests so that
+         * the registration is more likely to be from announcements */
+        try {
+            TestUtility.log(Config.ALL,"Test: waiting "
+                + conf.getQuietTime() + " milliseconds for (hopefully) "
+                + "all multicast requests");
+            Thread.sleep(conf.getQuietTime());
+        } catch (InterruptedException ie) {
+            TestUtility.log(Config.ERROR,"Test: caught exception",ie);
+            return Status.failed(Status.ENV,"Test interrupted");
+        }
+	    
+	try {
+	    String group = TestUtility.randomString(10);
+	    TestUtility.log(Config.ALL,"Test: starting lookup in "
+		+ group + " group");
+	    lookup = TestUtility.startLookup(new String[] {group}, 
+		conf.getQuietTime(), "NonPublicGroupTest_RegistrarLog", conf);
+	} catch (Exception e) {
+            TestUtility.log(Config.ERROR,"Test: caught exception",e);
+            return Status.failed(Status.ENV,"Problem starting lookup service");
+        }
+
+	ServiceItem serviceItem = null;
+	try {
+	    long timeout = conf.getQuietTime();
+            TestUtility.log(Config.ALL,"Test: waiting up to " + timeout 
+                + " milliseconds to see if program registers in lookup");
+	    serviceItem = TestUtility.waitForRegistration(lookup,timeout,conf);
+	} catch (Exception e) {
+            TestUtility.log(Config.ERROR,"Test: caught exception",e);
+            return Status.failed(Status.ENV,"Problem while waiting for "
+                + "program to register with lookup");
+        }
+	    
+	if (serviceItem != null) {
+	    return Status.failed(Status.TEST, "Service registered in "
+		+ "lookup when it shouldn't have");
+	}
+
+	return Status.passed("OK");
+    }
+
+    public void tearDown() {
+        super.tearDown();
+
+        try {
+            if (lookup != null) {
+                TestUtility.log(Config.ALL,"Test: stopping lookup");
+                TestUtility.stopLookup(lookup, getConfig());
+            }
+        } catch (RemoteException ignore) {}
+        try {
+            if (admin != null) {
+                TestUtility.log(Config.ALL,"Test: stopping program");
+                admin.stop();
+            }
+        } catch (RemoteException ignore) {}
+    }
+       
+    public String[] getCategories() {
+	return (new String[] { BasicServiceAdmin.CATEGORY });
+    }
+
+    public Class[] getRequiredAdmins() {
+	return (new Class[] { BasicAdmin.class, BasicServiceAdmin.class });
+    }
+
+    public String getDescription() {
+	return "NonPublicGroupTest";
+    }
+
+}
+

Propchange: river/tck/src/com/sun/jini/compat/test/NonPublicGroupTest.java
------------------------------------------------------------------------------
    svn:eol-style = native