Modified: 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/leasing/LeaseUsesTestBase.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/leasing/LeaseUsesTestBase.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/leasing/LeaseUsesTestBase.java
 (original)
+++ 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/leasing/LeaseUsesTestBase.java
 Sun Oct 26 13:17:28 2014
@@ -1,296 +1,297 @@
-/*
- * 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.impl.outrigger.leasing;
-
-import java.util.logging.Level;
-
-// java classes
-import java.rmi.*;
-
-// jini classes
-import net.jini.core.lease.Lease;
-
-// Test harness specific classes
-import com.sun.jini.qa.harness.TestException;
-import com.sun.jini.qa.harness.QAConfig;
-
-// Shared classes
-import com.sun.jini.qa.harness.Test;
-import com.sun.jini.test.share.TestBase;
-import java.util.concurrent.atomic.AtomicLong;
-
-
-/**
- * Base class for tests which acquire some resource under a lease and
- * then use until the lease expires. Also tests to see if the lease
- * has the appropriate duration.  Have variations that cancel and/or
- * renew the lease.
- */
-public abstract class LeaseUsesTestBase extends LeaseGrantTestBase {
-
-    /**
-     * Lease being used
-     */
-    private Lease lease = null;
-
-    // Time lease will expire
-    private long expTime;
-
-    // Time lease of lease duration
-    private long durTime;
-
-    // How long until the lease should be renewed
-    private long renewTime;
-
-    // What to set renewTime to, if < 0 the half of duration
-    private long renewWait;
-
-    // Time to let cancel to propgate
-    private long cancelSlop;
-
-    // Set renew and exp times
-    private void setTimes() {
-        final long curTime = System.currentTimeMillis();
-        expTime = lease.getExpiration();
-        durTime = expTime - curTime;
-
-        if (renewWait < 0) {
-            renewTime = expTime - durTime / 2;
-        } else {
-            renewTime = renewWait + curTime;
-        }
-    }
-    private long renewals = 0;
-    private boolean cancel;
-    private long shutdownTime = -1;
-    private long restartSleep = 10000;
-
-    /**
-     * Method should acquire some resource under a lease and return
-     * the Lease.  Note the returned value will be stored in
-     * the <code>lease</code> field
-     * @return Lease
-     * @throws TestException 
-     * @see LeaseUsesTestBase#lease
-     */
-    protected abstract Lease acquireResource() throws TestException;
-
-    /**
-     * Method should test to see if the resource acquired by
-     * acquireResource() is still available, returning
-     * <code>true</code> if is and <code>false</code> if it is not.
-     * If some other exception occurs the method should call fail
-     * @return true if still available
-     * @throws TestException  
-     */
-    protected abstract boolean isAvailable() throws TestException;
-
-    public Test construct(QAConfig config) throws Exception {
-        super.construct(config);
-        this.parse();
-        return this;
-    }
-
-    /**
-     * Parse our args
-     * <DL>
-     *
-     * <DT>-cancel<DD> Makes the test run the cancel variation of the
-     * test where the lease is canceled before it expires.
-     *
-     * <DT>-renew <var>int</var><DD> Renew the lease <var>int</var>
-     * times using the initial duration befor letting it expire or
-     * canceling it.  Defaults to 0 (no renewals.)
-     *
-     * <DT>-cancel_slop <var>int</var><DD> Allow for a leased resource
-     * to disappear up to <var>int</var> milliseconds after cancel is
-     * called.  Provided for tests that don't directly test resource
-     * availability, most tests should not use this option. Defaults to
-     * 0.
-     * </DL>
-     * @throws Exception 
-     */
-    protected void parse() throws Exception {
-        super.parse();
-        synchronized (this){
-            // Get values from property file for this test.
-            QAConfig config = getConfig();
-            renewals = config.getIntConfigVal("com.sun.jini.test.share.renew", 
0);
-            cancel = 
config.getBooleanConfigVal("com.sun.jini.test.share.cancel", false);
-            renewWait = 
config.getLongConfigVal("com.sun.jini.test.share.renew_wait", -1);
-            shutdownTime = 
config.getLongConfigVal("com.sun.jini.test.share.shutdownTime", -1);
-            restartSleep = 
config.getLongConfigVal("com.sun.jini.test.share.restartSleep", 10000);
-            cancelSlop = 
config.getLongConfigVal("com.sun.jini.test.share.cancel_slop", 0);
-
-            // Log out test options.
-            logger.log(Level.INFO, "renewals = {0}", renewals);
-            logger.log(Level.INFO, "cancel = {0}", cancel);
-            logger.log(Level.INFO, "renewWait = {0}", renewWait);
-            logger.log(Level.INFO, "shutdownTime = {0}", shutdownTime);
-            logger.log(Level.INFO, "restartSleep = {0}", restartSleep);
-            logger.log(Level.INFO, "cancelSlop = {0}", cancelSlop);
-        }
-    }
-
-    public synchronized void run() throws Exception {
-        lease = acquireResource();
-        addLease(lease, true);
-        setTimes();
-
-        if (shutdownTime > 0) {
-            final long curTime = System.currentTimeMillis();
-            shutdownTime = curTime + shutdownTime;
-        }
-        logger.log(Level.INFO, "Resource acquired");
-        logRequest("resource", lease);
-
-        if (!isAcceptable(lease)) {
-            throw new TestException("Lease had an improper duration");
-        }
-
-        if (cancel && renewals <= 0) {
-           cancel();
-        } else {
-            logger.log(Level.INFO, "Expire Test: Slop = {0}", slop);
-
-            while (true) {
-
-                /*
-                 * We measure the time twice so propagation delays do
-                 * not cause the test to fail.  The test only fails on
-                 * availability if:
-                 *
-                 *    Before the check was made the lease had expired,
-                 *    but the resource was still available, or;
-                 *
-                 *    after the check was made the lease had not
-                 *    expired but the resource was unavailable.
-                 *
-                 * In both cases modulo slop.
-                 *
-                 * This eliminates the possibility of the test failing
-                 * because the service rightfully believes the
-                 * resource is available, but propagation delays cause
-                 * isAvailable to return after expiration, or because
-                 * isAvaialable is called before expiration, but
-                 * because of propagation delays the service thinks
-                 * the resource is unavailable.
-                 */
-                final long preTime = System.currentTimeMillis();
-                final boolean stillThere;
-                final long postTime;
-                stillThere = isAvailable();
-
-                /*
-                 * We also use postTime as an approximation of the
-                 * current time for the remainder of this iteration
-                 */
-                postTime = System.currentTimeMillis();
-
-                /*
-                 * Check for late expiration against preTime
-                 * postTime - slop eliminates overflow problems when
-                 * expTime == FOREVER
-                 */
-                if (stillThere && (preTime - slop > expTime)) {
-                    // Check for early expiration against postTime
-                    logger.log(Level.WARNING, "expTime: {0}, (preTime - slop): 
{1}, still there: {2}",
-                            new Object[]{expTime, preTime - slop, stillThere});
-                    throw new TestException(
-                            "Resource was available after lease expiration");
-                }
-
-
-                if (!stillThere && (postTime < expTime - slop)) {
-                    // Check for early expiration against postTime
-                    logger.log(Level.WARNING, "postTime: {0}, (expTime - 
slop): {1}, still there: {2}",
-                            new Object[]{postTime, expTime - slop, 
stillThere});
-                    throw new TestException(
-                            "Resource was not available before lease 
expiration");
-                }
-
-                if (!stillThere) {
-
-                    // No use testing once it is gone
-                    break;
-                }
-                // Do we need to renew
-                if (renewals > 0 && postTime > renewTime) {
-                   lease.renew(durationRequest);
-                   resourceRequested();
-                    setTimes();
-                    logRequest("renew", lease);
-
-                    if (!isAcceptable(lease)) {
-                        throw new TestException(
-                                "Renewed lease had an improper duration");
-                    }
-                    renewals--;
-                } else if (renewals == 0 && cancel) {
-                   cancel();
-
-                    /*
-                     * If we are here the cancel worked, need to break
-                     * so we don't see if it is there (which it won't be)
-                     * and fail the test
-                     */
-                    break;
-                } else if (shutdownTime > 0 && shutdownTime < postTime) {
-                    try {
-                        shutdownTime = -1; // Oneshot
-                        shutdown(0, restartSleep);
-                    } catch (InterruptedException e) {
-                        // Should never happen, and if it does we don't care
-                    }
-                }
-            }
-        }
-    }
-
-    private void cancel() throws Exception {
-
-        // Make sure the resource is there
-        logger.log(Level.INFO, "Cancel Test: checking for availability");
-
-        if (!isAvailable()) {
-            throw new TestException("Resource was never available");
-        }
-        synchronized (this){
-            logger.log(Level.INFO, "Cancel Test: canceling lease");
-            lease.cancel();
-
-            /*
-             * We could poll and loop here, but one big sleep is much
-             * easer to code
-             */
-            if (cancelSlop > 0) {
-                logger.log(Level.INFO, 
-                           "Sleeping for {0}" + " milliseconds to "
-                           + "allow cancel to propagate... time: {1}", new 
Object[] {cancelSlop, System.currentTimeMillis()});
-                Thread.sleep(cancelSlop);
-                logger.log(Level.INFO, "awake: {0}", 
System.currentTimeMillis());
-            }
-        }
-        logger.log(Level.INFO, 
-                  "Cancel Test: checking to make sure resource " + "is gone");
-
-        if (isAvailable()) {
-            throw new TestException("Resource was available after cancel");
-        }
-    }
-}
+/*
+ * 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.impl.outrigger.leasing;
+
+import java.util.logging.Level;
+
+// java classes
+import java.rmi.*;
+
+// jini classes
+import net.jini.core.lease.Lease;
+
+// Test harness specific classes
+import com.sun.jini.qa.harness.TestException;
+import com.sun.jini.qa.harness.QAConfig;
+
+// Shared classes
+import com.sun.jini.qa.harness.Test;
+import com.sun.jini.test.share.TestBase;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+/**
+ * Base class for tests which acquire some resource under a lease and
+ * then use until the lease expires. Also tests to see if the lease
+ * has the appropriate duration.  Have variations that cancel and/or
+ * renew the lease.
+ */
+public abstract class LeaseUsesTestBase extends LeaseGrantTestBase {
+
+    /**
+     * Lease being used
+     */
+    private Lease lease = null;
+
+    // Time lease will expire
+    private long expTime;
+
+    // Time lease of lease duration
+    private long durTime;
+
+    // How long until the lease should be renewed
+    private long renewTime;
+
+    // What to set renewTime to, if < 0 the half of duration
+    private long renewWait;
+
+    // Time to let cancel to propgate
+    private long cancelSlop;
+
+    // Set renew and exp times
+    private void setTimes() {
+        final long curTime = System.currentTimeMillis();
+        expTime = lease.getExpiration();
+        durTime = expTime - curTime;
+
+        if (renewWait < 0) {
+            renewTime = expTime - durTime / 2;
+        } else {
+            renewTime = renewWait + curTime;
+        }
+    }
+    private long renewals = 0;
+    private boolean cancel;
+    private long shutdownTime = -1;
+    private long restartSleep = 10000;
+
+    /**
+     * Method should acquire some resource under a lease and return
+     * the Lease.  Note the returned value will be stored in
+     * the <code>lease</code> field
+     * @return Lease
+     * @throws TestException 
+     * @see LeaseUsesTestBase#lease
+     */
+    protected abstract Lease acquireResource() throws TestException;
+
+    /**
+     * Method should test to see if the resource acquired by
+     * acquireResource() is still available, returning
+     * <code>true</code> if is and <code>false</code> if it is not.
+     * If some other exception occurs the method should call fail
+     * @return true if still available
+     * @throws TestException  
+     */
+    protected abstract boolean isAvailable() throws TestException;
+
+    public Test construct(QAConfig config) throws Exception {
+        super.construct(config);
+        this.parse();
+        return this;
+    }
+
+    /**
+     * Parse our args
+     * <DL>
+     *
+     * <DT>-cancel<DD> Makes the test run the cancel variation of the
+     * test where the lease is canceled before it expires.
+     *
+     * <DT>-renew <var>int</var><DD> Renew the lease <var>int</var>
+     * times using the initial duration befor letting it expire or
+     * canceling it.  Defaults to 0 (no renewals.)
+     *
+     * <DT>-cancel_slop <var>int</var><DD> Allow for a leased resource
+     * to disappear up to <var>int</var> milliseconds after cancel is
+     * called.  Provided for tests that don't directly test resource
+     * availability, most tests should not use this option. Defaults to
+     * 0.
+     * </DL>
+     * @throws Exception 
+     */
+    protected void parse() throws Exception {
+        super.parse();
+        synchronized (this){
+            // Get values from property file for this test.
+            QAConfig config = getConfig();
+            renewals = config.getIntConfigVal("com.sun.jini.test.share.renew", 
0);
+            cancel = 
config.getBooleanConfigVal("com.sun.jini.test.share.cancel", false);
+            renewWait = 
config.getLongConfigVal("com.sun.jini.test.share.renew_wait", -1);
+            shutdownTime = 
config.getLongConfigVal("com.sun.jini.test.share.shutdownTime", -1);
+            restartSleep = 
config.getLongConfigVal("com.sun.jini.test.share.restartSleep", 10000);
+            cancelSlop = 
config.getLongConfigVal("com.sun.jini.test.share.cancel_slop", 0);
+
+            // Log out test options.
+            logger.log(Level.INFO, "renewals = {0}", renewals);
+            logger.log(Level.INFO, "cancel = {0}", cancel);
+            logger.log(Level.INFO, "renewWait = {0}", renewWait);
+            logger.log(Level.INFO, "shutdownTime = {0}", shutdownTime);
+            logger.log(Level.INFO, "restartSleep = {0}", restartSleep);
+            logger.log(Level.INFO, "cancelSlop = {0}", cancelSlop);
+        }
+    }
+
+    public synchronized void run() throws Exception {
+        lease = acquireResource();
+        addLease(lease, true);
+        setTimes();
+
+        if (shutdownTime > 0) {
+            final long curTime = System.currentTimeMillis();
+            shutdownTime = curTime + shutdownTime;
+        }
+        logger.log(Level.INFO, "Resource acquired");
+        logRequest("resource", lease);
+
+        if (!isAcceptable(lease)) {
+            throw new TestException("Lease had an improper duration");
+        }
+
+        if (cancel && renewals <= 0) {
+           cancel();
+        } else {
+            logger.log(Level.INFO, "Expire Test: Slop = {0}", slop);
+
+            while (true) {
+
+                /*
+                 * We measure the time twice so propagation delays do
+                 * not cause the test to fail.  The test only fails on
+                 * availability if:
+                 *
+                 *    Before the check was made the lease had expired,
+                 *    but the resource was still available, or;
+                 *
+                 *    after the check was made the lease had not
+                 *    expired but the resource was unavailable.
+                 *
+                 * In both cases modulo slop.
+                 *
+                 * This eliminates the possibility of the test failing
+                 * because the service rightfully believes the
+                 * resource is available, but propagation delays cause
+                 * isAvailable to return after expiration, or because
+                 * isAvaialable is called before expiration, but
+                 * because of propagation delays the service thinks
+                 * the resource is unavailable.
+                 */
+                final long preTime = System.currentTimeMillis();
+                final boolean stillThere;
+                final long postTime;
+                stillThere = isAvailable();
+
+                /*
+                 * We also use postTime as an approximation of the
+                 * current time for the remainder of this iteration
+                 */
+                postTime = System.currentTimeMillis();
+
+                /*
+                 * Check for late expiration against preTime
+                 * postTime - slop eliminates overflow problems when
+                 * expTime == FOREVER
+                 */
+                if (stillThere && (preTime - slop > expTime)) {
+                    // Check for early expiration against postTime
+                    logger.log(Level.WARNING, "expTime: {0}, (preTime - slop): 
{1}, still there: {2}",
+                            new Object[]{expTime, preTime - slop, stillThere});
+                    throw new TestException(
+                            "Resource was available after lease expiration");
+                }
+
+
+                if (!stillThere && (postTime < expTime - slop)) {
+                    // Check for early expiration against postTime
+                    logger.log(Level.WARNING, "postTime: {0}, (expTime - 
slop): {1}, still there: {2}",
+                            new Object[]{postTime, expTime - slop, 
stillThere});
+                    throw new TestException(
+                            "Resource was not available before lease 
expiration");
+                }
+
+                if (!stillThere) {
+
+                    // No use testing once it is gone
+                    break;
+                }
+                // Do we need to renew
+                if (renewals > 0 && postTime > renewTime) {
+                   lease.renew(durationRequest);
+                   resourceRequested();
+                    setTimes();
+                    logRequest("renew", lease);
+
+                    if (!isAcceptable(lease)) {
+                        throw new TestException(
+                                "Renewed lease had an improper duration");
+                    }
+                    renewals--;
+                } else if (renewals == 0 && cancel) {
+                   cancel();
+
+                    /*
+                     * If we are here the cancel worked, need to break
+                     * so we don't see if it is there (which it won't be)
+                     * and fail the test
+                     */
+                    break;
+                } else if (shutdownTime > 0 && shutdownTime < postTime) {
+                    try {
+                        shutdownTime = -1; // Oneshot
+                        shutdown(0, restartSleep);
+                    } catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
+                        // Should never happen, and if it does we don't care
+                    }
+                }
+            }
+        }
+    }
+
+    private void cancel() throws Exception {
+
+        // Make sure the resource is there
+        logger.log(Level.INFO, "Cancel Test: checking for availability");
+
+        if (!isAvailable()) {
+            throw new TestException("Resource was never available");
+        }
+        synchronized (this){
+            logger.log(Level.INFO, "Cancel Test: canceling lease");
+            lease.cancel();
+
+            /*
+             * We could poll and loop here, but one big sleep is much
+             * easer to code
+             */
+            if (cancelSlop > 0) {
+                logger.log(Level.INFO, 
+                           "Sleeping for {0}" + " milliseconds to "
+                           + "allow cancel to propagate... time: {1}", new 
Object[] {cancelSlop, System.currentTimeMillis()});
+                Thread.sleep(cancelSlop);
+                logger.log(Level.INFO, "awake: {0}", 
System.currentTimeMillis());
+            }
+        }
+        logger.log(Level.INFO, 
+                  "Cancel Test: checking to make sure resource " + "is gone");
+
+        if (isAvailable()) {
+            throw new TestException("Resource was available after cancel");
+        }
+    }
+}

Modified: 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/matching/BlockingTest.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/matching/BlockingTest.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/matching/BlockingTest.java
 (original)
+++ 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/matching/BlockingTest.java
 Sun Oct 26 13:17:28 2014
@@ -1,150 +1,152 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.sun.jini.test.impl.outrigger.matching;
-
-import java.util.logging.Level;
-
-// Test harness specific classes
-import java.io.PrintWriter;
-import com.sun.jini.qa.harness.TestException;
-import com.sun.jini.qa.harness.QAConfig;
-
-// All other imports
-import com.sun.jini.qa.harness.Test;
-import java.util.List;
-import java.util.Iterator;
-import java.rmi.*;
-import net.jini.core.lease.Lease;
-import net.jini.core.entry.Entry;
-
-
-public class BlockingTest extends MatchTestBase {
-    private boolean useRead;
-    private long matchTimeout;
-    private long writeWait;
-    private long testTimeout;
-
-    protected void parse() throws Exception {
-        super.parse();
-        useRead = 
getConfig().getBooleanConfigVal("com.sun.jini.test.impl.outrigger."
-                + "matching.BlockingTest.useRead", false);
-        matchTimeout = 
getConfig().getLongConfigVal("com.sun.jini.test.impl.outrigger."
-                + "matching.BlockingTest.matchTimeout", 60000);
-        writeWait = 
getConfig().getLongConfigVal("com.sun.jini.test.impl.outrigger."
-                + "matching.BlockingTest.writeWait", 20000);
-    }
-
-    /**
-     * Sets up the testing environment.
-     *
-     * @param config Arguments from the runner for construct.
-     */
-    public Test construct(QAConfig config) throws Exception {
-        super.construct(config);
-        this.parse();
-        return this;
-    }
-
-    public void run() throws Exception {
-        Matcher[] matchers = new Matcher[writeList.size()];
-        Iterator i;
-        int j;
-
-        for (i = writeList.iterator(), j = 0; i.hasNext(); j++) {
-            final Entry ent = (Entry) i.next();
-            logger.log(Level.INFO, "Setup query for " + ent);
-            matchers[j] = new Matcher(ent, j);
-            matchers[j].start();
-        }
-        spaceSet();
-
-        try {
-            logger.log(Level.INFO, "sleeping for " + writeWait + "...");
-            Thread.sleep(writeWait);
-            logger.log(Level.INFO, "awake");
-        } catch (InterruptedException e) {}
-        final long writeStart = System.currentTimeMillis();
-        logger.log(Level.INFO, writeStart + " write start");
-        writeBunch();
-        final long queryStart = System.currentTimeMillis();
-        logger.log(Level.INFO, queryStart + " write end");
-
-        for (j = 0; j < matchers.length; j++) {
-            Matcher m = matchers[j];
-            m.join(matchTimeout);
-
-            if (!m.done) {
-                logger.log(Level.INFO, System.currentTimeMillis()
-                        + " failed waiting for matcher " + j);
-                throw new TestException(
-                        "Did not get entry back before timeout");
-            } else if (m.msg != null) {
-                throw new TestException( m.msg + m.thrown);
-            }
-        }
-        final long queryEnd = System.currentTimeMillis();
-        logger.log(Level.INFO, "Total Write Time:" + (queryStart - 
writeStart));
-        logger.log(Level.INFO, "Total Query Time:" + (queryEnd - queryStart));
-    }
-
-
-    private class Matcher extends Thread {
-        final private Entry tmpl;
-        final private int id;
-        private boolean done;
-        private Throwable thrown;
-        private String msg;
-
-        Matcher(Entry tmpl, int id) {
-            this.tmpl = tmpl;
-            this.id = id;
-        }
-
-        public void run() {
-            try {
-                while (true) {
-                    try {
-                        Entry rslt;
-
-                        if (useRead) {
-                            rslt = spaceRead(tmpl, null, matchTimeout);
-                        } else {
-                            rslt = spaceTake(tmpl, null, matchTimeout);
-                        }
-
-                        if (rslt == null) {
-                            msg = "Got null back from query on " + tmpl;
-                        }
-                        logger.log(Level.INFO, System.currentTimeMillis() + " 
" + id
-                                + (useRead ? " Read " : " Took ") + rslt);
-                        return;
-                    } catch (RemoteException e) {
-
-                        // Just try again
-                    } catch (Throwable t) {
-                        thrown = t;
-                        msg = "Got exception in query on " + tmpl;
-                        return;
-                    }
-                }
-            } finally {
-                done = true;
-            }
-        }
-    }
-}
+/*
+ * 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.impl.outrigger.matching;
+
+import java.util.logging.Level;
+
+// Test harness specific classes
+import java.io.PrintWriter;
+import com.sun.jini.qa.harness.TestException;
+import com.sun.jini.qa.harness.QAConfig;
+
+// All other imports
+import com.sun.jini.qa.harness.Test;
+import java.util.List;
+import java.util.Iterator;
+import java.rmi.*;
+import net.jini.core.lease.Lease;
+import net.jini.core.entry.Entry;
+
+
+public class BlockingTest extends MatchTestBase {
+    private boolean useRead;
+    private long matchTimeout;
+    private long writeWait;
+    private long testTimeout;
+
+    protected void parse() throws Exception {
+        super.parse();
+        useRead = 
getConfig().getBooleanConfigVal("com.sun.jini.test.impl.outrigger."
+                + "matching.BlockingTest.useRead", false);
+        matchTimeout = 
getConfig().getLongConfigVal("com.sun.jini.test.impl.outrigger."
+                + "matching.BlockingTest.matchTimeout", 60000);
+        writeWait = 
getConfig().getLongConfigVal("com.sun.jini.test.impl.outrigger."
+                + "matching.BlockingTest.writeWait", 20000);
+    }
+
+    /**
+     * Sets up the testing environment.
+     *
+     * @param config Arguments from the runner for construct.
+     */
+    public Test construct(QAConfig config) throws Exception {
+        super.construct(config);
+        this.parse();
+        return this;
+    }
+
+    public void run() throws Exception {
+        Matcher[] matchers = new Matcher[writeList.size()];
+        Iterator i;
+        int j;
+
+        for (i = writeList.iterator(), j = 0; i.hasNext(); j++) {
+            final Entry ent = (Entry) i.next();
+            logger.log(Level.INFO, "Setup query for " + ent);
+            matchers[j] = new Matcher(ent, j);
+            matchers[j].start();
+        }
+        spaceSet();
+
+        try {
+            logger.log(Level.INFO, "sleeping for " + writeWait + "...");
+            Thread.sleep(writeWait);
+            logger.log(Level.INFO, "awake");
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+        }
+        final long writeStart = System.currentTimeMillis();
+        logger.log(Level.INFO, writeStart + " write start");
+        writeBunch();
+        final long queryStart = System.currentTimeMillis();
+        logger.log(Level.INFO, queryStart + " write end");
+
+        for (j = 0; j < matchers.length; j++) {
+            Matcher m = matchers[j];
+            m.join(matchTimeout);
+
+            if (!m.done) {
+                logger.log(Level.INFO, System.currentTimeMillis()
+                        + " failed waiting for matcher " + j);
+                throw new TestException(
+                        "Did not get entry back before timeout");
+            } else if (m.msg != null) {
+                throw new TestException( m.msg + m.thrown);
+            }
+        }
+        final long queryEnd = System.currentTimeMillis();
+        logger.log(Level.INFO, "Total Write Time:" + (queryStart - 
writeStart));
+        logger.log(Level.INFO, "Total Query Time:" + (queryEnd - queryStart));
+    }
+
+
+    private class Matcher extends Thread {
+        final private Entry tmpl;
+        final private int id;
+        private boolean done;
+        private Throwable thrown;
+        private String msg;
+
+        Matcher(Entry tmpl, int id) {
+            this.tmpl = tmpl;
+            this.id = id;
+        }
+
+        public void run() {
+            try {
+                while (true) {
+                    try {
+                        Entry rslt;
+
+                        if (useRead) {
+                            rslt = spaceRead(tmpl, null, matchTimeout);
+                        } else {
+                            rslt = spaceTake(tmpl, null, matchTimeout);
+                        }
+
+                        if (rslt == null) {
+                            msg = "Got null back from query on " + tmpl;
+                        }
+                        logger.log(Level.INFO, System.currentTimeMillis() + " 
" + id
+                                + (useRead ? " Read " : " Took ") + rslt);
+                        return;
+                    } catch (RemoteException e) {
+
+                        // Just try again
+                    } catch (Throwable t) {
+                        thrown = t;
+                        msg = "Got exception in query on " + tmpl;
+                        return;
+                    }
+                }
+            } finally {
+                done = true;
+            }
+        }
+    }
+}

Modified: 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/matching/NotifyTestUtil.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/matching/NotifyTestUtil.java?rev=1634322&r1=1634321&r2=1634322&view=diff
==============================================================================
--- 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/matching/NotifyTestUtil.java
 (original)
+++ 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/matching/NotifyTestUtil.java
 Sun Oct 26 13:17:28 2014
@@ -1,129 +1,130 @@
-/*
- * 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.impl.outrigger.matching;
-
-import java.util.logging.Level;
-
-// Test harness specific classes
-import com.sun.jini.qa.harness.QAConfig;
-import com.sun.jini.qa.harness.QATestEnvironment;
-import com.sun.jini.qa.harness.TestException;
-import java.io.PrintWriter;
-
-// All other imports
-import java.rmi.*;
-import net.jini.core.transaction.TransactionException;
-import net.jini.core.lease.Lease;
-import net.jini.core.entry.Entry;
-import net.jini.core.event.EventRegistration;
-import net.jini.space.JavaSpace;
-import com.sun.jini.qa.harness.QAConfig;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-/**
- * Utility class for writing notify tests.
- */
-class NotifyTestUtil {
-
-    private static Logger logger = 
Logger.getLogger("com.sun.jini.qa.harness.test");
-
-    private long wait = 60000;
-    private JavaSpaceAuditor space;
-    private MatchTestBase base;
-    private QAConfig config;
-
-    /**
-     * Creates a NotifyTestUtil(). Parses the <code>argv</code>
-     * as a list of command line parameters as follows:
-     *
-     * <DL>
-     * <DT>-notify_wait<DD> Set the amount of time (in milliseconds)
-     * the test will wait for after the writes are done before
-     * checking to see if the test has passed
-     * </DL>
-     */
-    NotifyTestUtil(QAConfig sysConfig, MatchTestBase base) {
-        wait = 
sysConfig.getLongConfigVal("com.sun.jini.test.impl.outrigger.matching"
-                + ".NotifyTestUtil.notify_wait", 60000);
-        this.config = (QAConfig) sysConfig;
-        this.base = base;
-    }
-
-    void init(JavaSpaceAuditor space) {
-        this.space = space;
-    }
-
-    /**
-     * Convince function that registers a
-     * <code>TestSpaceListener</code> with the space using the passed
-     * <code>Entry</code> as the match template.  The lease is
-     * requested to be <code>Lease.ANY</code>, and the template
-     * is passed as the passback object.
-     * @see TestSpaceLease;
-     */
-    void registerForNotify(Entry tmpl)
-            throws TransactionException, RemoteException, java.io.IOException {
-       try {
-            TestSpaceListener tsl = 
-                    new TestSpaceListener(config.getConfiguration(), tmpl);
-            tsl.export();
-           EventRegistration er = 
-               space.notify(tmpl,
-                            null, 
-                            tsl,
-                            Lease.ANY, 
-                            new MarshalledObject(tmpl));
-           QAConfig c = QAConfig.getConfig();
-           if (c.getConfiguration() instanceof 
com.sun.jini.qa.harness.QAConfiguration) {
-               er = (EventRegistration) 
c.prepare("test.outriggerEventRegistrationPreparer", er);
-           }
-           Lease l = er.getLease();
-           if (c.getConfiguration() instanceof 
com.sun.jini.qa.harness.QAConfiguration) {
-               l = (Lease) c.prepare("test.outriggerLeasePreparer", l);
-           }
-            base.addLease(l, false);
-       } catch (TestException e) {
-           throw new RemoteException("Configuration error", e);
-       }
-    }
-
-    /**
-     * Waits, and then check with the auditor to see if we pass
-     */
-    String waitAndCheck() {
-        try {
-            Thread.sleep(wait);
-        } catch (InterruptedException e) {
-            final String msg = "Sleep was interrupted";
-            logger.log(Level.INFO, msg);
-            e.printStackTrace();
-            return msg;
-        }
-        final AuditorSummary summery = space.summarize();
-
-        if (summery.eventFailures != null) {
-            summery.dump();
-            final String msg = "Event errors";
-            logger.log(Level.INFO, msg);
-            return msg;
-        }
-        return null;
-    }
-}
+/*
+ * 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.impl.outrigger.matching;
+
+import java.util.logging.Level;
+
+// Test harness specific classes
+import com.sun.jini.qa.harness.QAConfig;
+import com.sun.jini.qa.harness.QATestEnvironment;
+import com.sun.jini.qa.harness.TestException;
+import java.io.PrintWriter;
+
+// All other imports
+import java.rmi.*;
+import net.jini.core.transaction.TransactionException;
+import net.jini.core.lease.Lease;
+import net.jini.core.entry.Entry;
+import net.jini.core.event.EventRegistration;
+import net.jini.space.JavaSpace;
+import com.sun.jini.qa.harness.QAConfig;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+/**
+ * Utility class for writing notify tests.
+ */
+class NotifyTestUtil {
+
+    private static Logger logger = 
Logger.getLogger("com.sun.jini.qa.harness.test");
+
+    private long wait = 60000;
+    private JavaSpaceAuditor space;
+    private MatchTestBase base;
+    private QAConfig config;
+
+    /**
+     * Creates a NotifyTestUtil(). Parses the <code>argv</code>
+     * as a list of command line parameters as follows:
+     *
+     * <DL>
+     * <DT>-notify_wait<DD> Set the amount of time (in milliseconds)
+     * the test will wait for after the writes are done before
+     * checking to see if the test has passed
+     * </DL>
+     */
+    NotifyTestUtil(QAConfig sysConfig, MatchTestBase base) {
+        wait = 
sysConfig.getLongConfigVal("com.sun.jini.test.impl.outrigger.matching"
+                + ".NotifyTestUtil.notify_wait", 60000);
+        this.config = (QAConfig) sysConfig;
+        this.base = base;
+    }
+
+    void init(JavaSpaceAuditor space) {
+        this.space = space;
+    }
+
+    /**
+     * Convince function that registers a
+     * <code>TestSpaceListener</code> with the space using the passed
+     * <code>Entry</code> as the match template.  The lease is
+     * requested to be <code>Lease.ANY</code>, and the template
+     * is passed as the passback object.
+     * @see TestSpaceLease;
+     */
+    void registerForNotify(Entry tmpl)
+            throws TransactionException, RemoteException, java.io.IOException {
+       try {
+            TestSpaceListener tsl = 
+                    new TestSpaceListener(config.getConfiguration(), tmpl);
+            tsl.export();
+           EventRegistration er = 
+               space.notify(tmpl,
+                            null, 
+                            tsl,
+                            Lease.ANY, 
+                            new MarshalledObject(tmpl));
+           QAConfig c = QAConfig.getConfig();
+           if (c.getConfiguration() instanceof 
com.sun.jini.qa.harness.QAConfiguration) {
+               er = (EventRegistration) 
c.prepare("test.outriggerEventRegistrationPreparer", er);
+           }
+           Lease l = er.getLease();
+           if (c.getConfiguration() instanceof 
com.sun.jini.qa.harness.QAConfiguration) {
+               l = (Lease) c.prepare("test.outriggerLeasePreparer", l);
+           }
+            base.addLease(l, false);
+       } catch (TestException e) {
+           throw new RemoteException("Configuration error", e);
+       }
+    }
+
+    /**
+     * Waits, and then check with the auditor to see if we pass
+     */
+    String waitAndCheck() {
+        try {
+            Thread.sleep(wait);
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            final String msg = "Sleep was interrupted";
+            logger.log(Level.INFO, msg);
+            e.printStackTrace();
+            return msg;
+        }
+        final AuditorSummary summery = space.summarize();
+
+        if (summery.eventFailures != null) {
+            summery.dump();
+            final String msg = "Event errors";
+            logger.log(Level.INFO, msg);
+            return msg;
+        }
+        return null;
+    }
+}


Reply via email to