Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/transaction/NotifyTransactionTest.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/transaction/NotifyTransactionTest.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/transaction/NotifyTransactionTest.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/transaction/NotifyTransactionTest.java Sun Oct 26 13:17:28 2014 @@ -1,158 +1,160 @@ -/* - * 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.transaction; - -import java.util.logging.Level; - -// Test harness specific classes -import com.sun.jini.qa.harness.TestException; - -// All other imports -import net.jini.space.JavaSpace; -import net.jini.core.lease.Lease; -import net.jini.core.event.RemoteEvent; -import net.jini.core.event.EventRegistration; -import net.jini.core.event.RemoteEventListener; -import net.jini.core.transaction.Transaction; -import net.jini.core.transaction.TransactionException; -import java.rmi.RemoteException; - - -/** - * <code>NotifyTransactionTest</code> tests basic functions of event/notify - * under transaction. - * - * Test steps are as follows: - * <ol> - * <li> Event listener (A) regsiters an interest with a transaction. - * <li> Event listener (B) regsiters an interest without transaction. - * <li> Writes some entries with the transaction(1), without transaction(2), - * and with another transaction(3). - * <li> Check number of delivered events to the listener-A. - * The number should be the same with events related (1) and (2). - * <li> Check number of delivered events to the listener-B. - * The number should be the same with events related (2). - * </ol> - * - * @author H.Fukuda - */ -public class NotifyTransactionTest extends TransactionTestBase { - - // Number of writes with each condition - private final static int NUM_SAME = 4; - private final static int NUM_NULL = 8; - private final static int NUM_DIFF = 16; - - public void run() throws Exception { - simpleSetup(); - - // create entry and template - SimpleEntry wentry = new SimpleEntry(); - wentry.string = "foo"; - wentry.stage = new Integer(1); - wentry.id = new Integer(4); - SimpleEntry template = new SimpleEntry(); - template.string = "foo"; - - // create transaction - Transaction txn = createTransaction(); - - // generate EventListeners - SimpleEventListener tCatcher = null; - SimpleEventListener nCatcher = null; - EventRegistration tReg = null; - EventRegistration nReg = null; - - try { - tCatcher = new SimpleEventListener(getConfig().getConfiguration()); - nCatcher = new SimpleEventListener(getConfig().getConfiguration()); - tReg = getSpace().notify(template, txn, tCatcher, Lease.FOREVER, - null); - nReg = getSpace().notify(template, null, nCatcher, Lease.FOREVER, - null); - // preparation added for completeness. No remote calls are made on these - tReg = (EventRegistration) - getConfig().prepare("test.outriggerEventRegistrationPreparer", - tReg); - nReg = (EventRegistration) - getConfig().prepare("test.outriggerEventRegistrationPreparer", - nReg); - } catch (Exception e) { - throw new TestException( - "Exception thrown while registering interests" + e); - } - - /* - * write entries - * (a) write with the same transaction - */ - wentry.stage = new Integer(1); - - for (int i = 0; i < NUM_SAME; i++) { - writeEntry(txn, wentry); - } - - // (b) write without transaction - wentry.stage = new Integer(2); - - for (int i = 0; i < NUM_NULL; i++) { - writeEntry(null, wentry); - } - - // (c) write with other transaction - Transaction txn2 = createTransaction(); - wentry.stage = new Integer(3); - - for (int i = 0; i < NUM_DIFF; i++) { - writeEntry(txn2, wentry); - } - - // give time for events to arrive - try { - Thread.sleep(5000); - } catch (InterruptedException e) {} - - // check results - if (tCatcher.getNotifyCount(tReg) != (NUM_SAME + NUM_NULL)) { - throw new TestException( - "generated events for txn [" - + tCatcher.getNotifyCount(tReg) - + "] != expected events [" + (NUM_SAME + NUM_NULL) - + "]"); - } else { - pass("Pass: transaction control"); - } - - if (nCatcher.getNotifyCount(nReg) != NUM_NULL) { - throw new TestException( - "generated events for null [" - + nCatcher.getNotifyCount(nReg) - + "] != expected events [" + NUM_NULL + "]"); - } else { - pass("Pass: without transaction"); - } - } - - /** - * Return a String which describes this test - */ - public String getDescription() { - return "Test Name = NotifyTransactionTest : \n" - + "tests basic functions of event/notify under transaction."; - } -} +/* + * 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.transaction; + +import java.util.logging.Level; + +// Test harness specific classes +import com.sun.jini.qa.harness.TestException; + +// All other imports +import net.jini.space.JavaSpace; +import net.jini.core.lease.Lease; +import net.jini.core.event.RemoteEvent; +import net.jini.core.event.EventRegistration; +import net.jini.core.event.RemoteEventListener; +import net.jini.core.transaction.Transaction; +import net.jini.core.transaction.TransactionException; +import java.rmi.RemoteException; + + +/** + * <code>NotifyTransactionTest</code> tests basic functions of event/notify + * under transaction. + * + * Test steps are as follows: + * <ol> + * <li> Event listener (A) regsiters an interest with a transaction. + * <li> Event listener (B) regsiters an interest without transaction. + * <li> Writes some entries with the transaction(1), without transaction(2), + * and with another transaction(3). + * <li> Check number of delivered events to the listener-A. + * The number should be the same with events related (1) and (2). + * <li> Check number of delivered events to the listener-B. + * The number should be the same with events related (2). + * </ol> + * + * @author H.Fukuda + */ +public class NotifyTransactionTest extends TransactionTestBase { + + // Number of writes with each condition + private final static int NUM_SAME = 4; + private final static int NUM_NULL = 8; + private final static int NUM_DIFF = 16; + + public void run() throws Exception { + simpleSetup(); + + // create entry and template + SimpleEntry wentry = new SimpleEntry(); + wentry.string = "foo"; + wentry.stage = new Integer(1); + wentry.id = new Integer(4); + SimpleEntry template = new SimpleEntry(); + template.string = "foo"; + + // create transaction + Transaction txn = createTransaction(); + + // generate EventListeners + SimpleEventListener tCatcher = null; + SimpleEventListener nCatcher = null; + EventRegistration tReg = null; + EventRegistration nReg = null; + + try { + tCatcher = new SimpleEventListener(getConfig().getConfiguration()); + nCatcher = new SimpleEventListener(getConfig().getConfiguration()); + tReg = getSpace().notify(template, txn, tCatcher, Lease.FOREVER, + null); + nReg = getSpace().notify(template, null, nCatcher, Lease.FOREVER, + null); + // preparation added for completeness. No remote calls are made on these + tReg = (EventRegistration) + getConfig().prepare("test.outriggerEventRegistrationPreparer", + tReg); + nReg = (EventRegistration) + getConfig().prepare("test.outriggerEventRegistrationPreparer", + nReg); + } catch (Exception e) { + throw new TestException( + "Exception thrown while registering interests" + e); + } + + /* + * write entries + * (a) write with the same transaction + */ + wentry.stage = new Integer(1); + + for (int i = 0; i < NUM_SAME; i++) { + writeEntry(txn, wentry); + } + + // (b) write without transaction + wentry.stage = new Integer(2); + + for (int i = 0; i < NUM_NULL; i++) { + writeEntry(null, wentry); + } + + // (c) write with other transaction + Transaction txn2 = createTransaction(); + wentry.stage = new Integer(3); + + for (int i = 0; i < NUM_DIFF; i++) { + writeEntry(txn2, wentry); + } + + // give time for events to arrive + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + + // check results + if (tCatcher.getNotifyCount(tReg) != (NUM_SAME + NUM_NULL)) { + throw new TestException( + "generated events for txn [" + + tCatcher.getNotifyCount(tReg) + + "] != expected events [" + (NUM_SAME + NUM_NULL) + + "]"); + } else { + pass("Pass: transaction control"); + } + + if (nCatcher.getNotifyCount(nReg) != NUM_NULL) { + throw new TestException( + "generated events for null [" + + nCatcher.getNotifyCount(nReg) + + "] != expected events [" + NUM_NULL + "]"); + } else { + pass("Pass: without transaction"); + } + } + + /** + * Return a String which describes this test + */ + public String getDescription() { + return "Test Name = NotifyTransactionTest : \n" + + "tests basic functions of event/notify under transaction."; + } +}
Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/transaction/PreparedTransactionTest.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/transaction/PreparedTransactionTest.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/transaction/PreparedTransactionTest.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/transaction/PreparedTransactionTest.java Sun Oct 26 13:17:28 2014 @@ -1,205 +1,206 @@ -/* - * 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.transaction; - -import java.util.logging.Level; - -// Test harness specific classes -import com.sun.jini.qa.harness.TestException; -import com.sun.jini.qa.harness.QAConfig; - -// All other imports -import net.jini.core.entry.*; -import net.jini.core.transaction.*; -import net.jini.core.transaction.server.*; -import com.sun.jini.constants.TxnConstants; -import com.sun.jini.qa.harness.Test; -import com.sun.jini.test.share.TesterTransaction; -import com.sun.jini.test.share.TesterTransactionManager; - - -/** - * This tests to see if a prepared transaction that is hanging - * around after a crash behaves properly. - * <dl> - * - * <dt><code>-abort</code> - * <dd>Abort the transaction (default is to commit it). - * - * <dt><code>-wait</code> - * <dd>Wait -- set the transaction status, but let the particpant query - * for the state instead of sending it - * - * <dt><code>-active</code> - * <dd>Active -- don't send the prepare method -- go straight to - * <code>COMMITED</code> or <code>ABORTED</code>. This implies - * <code>-abort</code>, since any active transaction is aborted - * by a crash. - * - * <dt><code>-throw_remote</code> <i>cnt</i> - * <dd>Throw <code>RemoteException</code> <i>cnt</i> times - * (implies <code>-wait</code>) - * - * </dl> - * - * @author Ken Arnold - */ -public abstract class PreparedTransactionTest extends TransactionTestBase - implements TransactionConstants, com.sun.jini.constants.TimeConstants { - - /** Should we abort the transaction? */ - private boolean abort; - - /** Should we wait, letting the particpant query? */ - private boolean wait; - - /** Don't even send the prepared() message -- go straight from ACTIVE. */ - private boolean active; - - /** - * Number of times that <code>getState</code> should throw - * <code>RemoteException</code>. - */ - private int throwRemote; - - /** - * 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; - } - - /** - * Parse non-generic option(s). - */ - protected void parse() throws Exception { - super.parse(); - abort = getConfig().getBooleanConfigVal("com.sun.jini.qa.outrigger." - + "transaction.PreparedTransactionTest.abort", false); - wait = getConfig().getBooleanConfigVal("com.sun.jini.qa.outrigger." - + "transaction.PreparedTransactionTest.wait", false); - active = getConfig().getBooleanConfigVal("com.sun.jini.qa.outrigger." - + "transaction.PreparedTransactionTest.active", false); - throwRemote = getConfig().getIntConfigVal("com.sun.jini.qa.outrigger." - + "transaction.PreparedTransactionTest.throw_remote", 0); - - if (throwRemote > 0) { - - // implies -wait - wait = true; - } - - if (active) { - - // implies -abort - abort = true; - } - } - - public void run() throws Exception { - spaceOnlySetup(); - TesterTransactionManager mgr = new TesterTransactionManager(); - TesterTransaction tt = mgr.create(); - - // an entry that should be there at the start - SimpleEntry toTake = new SimpleEntry("toTake", 1, 13); - writeEntry(null, toTake); - logger.log(Level.INFO, "wrote entry " + toTake); - - // the entry written under the transaction - SimpleEntry written = new SimpleEntry("tester", 17, 29); - logger.log(Level.INFO, "wrote entry " + written); - writeEntry(tt.transaction, written); - tt.assertParticipants(1); // just to be sure - Entry taken = getSpace().take(toTake, tt.transaction, 0); - assertEquals(taken, toTake, "reading 'toTake' entry"); - - if (!active) { - tt.sendPrepare(); // get the transaction prepared - - if (tt.localGetState() != PREPARED) { - throw new TestException( - "state is " - + TxnConstants.getName(tt.localGetState()) - + ", should be " + TxnConstants.getName(PREPARED)); - } - } - shutdown(0); // shut down the space - - /* - * Only do this test if we're not active -- active txns should - * be effectively aborted at this point, so they have no stage - * that exists after a shutdown and before the transaction - * completion - */ - if (!active) { - - /* - * try to see transacted stuff under a null transaction: - * should fail - */ - canSee(toTake, null, "txn not yet completed"); - canSee(written, null, "txn not yet completed"); - - if (wait) { - - /* - * sleep long enough for the 15-second retries plus - * 5 for slop - */ - long sleepTime = (15 * SECONDS * (throwRemote + 1) - + 5 * SECONDS); - tt.setState(abort ? ABORTED : COMMITTED); - logger.log(Level.INFO, "transaction state set to " - + TxnConstants.getName(tt.localGetState()) - + ", sleeping " + sleepTime); - - if (throwRemote > 0) { - tt.getStateFailCnt(throwRemote); - } - - // give the participant a chance to ask - Thread.sleep(sleepTime); - } else { - if (abort) { - tt.sendAbort(); - } else { - tt.sendCommit(); - } - } - } - - if (abort) { - canSee(toTake, toTake, "txn aborted"); - canSee(written, null, "txn aborted"); - } else { - canSee(toTake, null, "txn committed"); - canSee(written, written, "txn committed"); - } - } - - private void canSee(Entry tmpl, Entry shouldMatch, String desc) - throws Exception { - Entry e = getSpace().read(tmpl, null, 0); - assertEquals(e, shouldMatch, desc); - } -} +/* + * 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.transaction; + +import java.util.logging.Level; + +// Test harness specific classes +import com.sun.jini.qa.harness.TestException; +import com.sun.jini.qa.harness.QAConfig; + +// All other imports +import net.jini.core.entry.*; +import net.jini.core.transaction.*; +import net.jini.core.transaction.server.*; +import com.sun.jini.constants.TxnConstants; +import com.sun.jini.qa.harness.Test; +import com.sun.jini.test.share.TesterTransaction; +import com.sun.jini.test.share.TesterTransactionManager; + + +/** + * This tests to see if a prepared transaction that is hanging + * around after a crash behaves properly. + * <dl> + * + * <dt><code>-abort</code> + * <dd>Abort the transaction (default is to commit it). + * + * <dt><code>-wait</code> + * <dd>Wait -- set the transaction status, but let the particpant query + * for the state instead of sending it + * + * <dt><code>-active</code> + * <dd>Active -- don't send the prepare method -- go straight to + * <code>COMMITED</code> or <code>ABORTED</code>. This implies + * <code>-abort</code>, since any active transaction is aborted + * by a crash. + * + * <dt><code>-throw_remote</code> <i>cnt</i> + * <dd>Throw <code>RemoteException</code> <i>cnt</i> times + * (implies <code>-wait</code>) + * + * </dl> + * + * @author Ken Arnold + */ +public abstract class PreparedTransactionTest extends TransactionTestBase + implements TransactionConstants, com.sun.jini.constants.TimeConstants { + + /** Should we abort the transaction? */ + private boolean abort; + + /** Should we wait, letting the particpant query? */ + private boolean wait; + + /** Don't even send the prepared() message -- go straight from ACTIVE. */ + private boolean active; + + /** + * Number of times that <code>getState</code> should throw + * <code>RemoteException</code>. + */ + private int throwRemote; + + /** + * 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; + } + + /** + * Parse non-generic option(s). + */ + protected void parse() throws Exception { + super.parse(); + abort = getConfig().getBooleanConfigVal("com.sun.jini.qa.outrigger." + + "transaction.PreparedTransactionTest.abort", false); + wait = getConfig().getBooleanConfigVal("com.sun.jini.qa.outrigger." + + "transaction.PreparedTransactionTest.wait", false); + active = getConfig().getBooleanConfigVal("com.sun.jini.qa.outrigger." + + "transaction.PreparedTransactionTest.active", false); + throwRemote = getConfig().getIntConfigVal("com.sun.jini.qa.outrigger." + + "transaction.PreparedTransactionTest.throw_remote", 0); + + if (throwRemote > 0) { + + // implies -wait + wait = true; + } + + if (active) { + + // implies -abort + abort = true; + } + } + + public void run() throws Exception { + spaceOnlySetup(); + TesterTransactionManager mgr = new TesterTransactionManager(); + mgr.start(); + TesterTransaction tt = mgr.create(); + + // an entry that should be there at the start + SimpleEntry toTake = new SimpleEntry("toTake", 1, 13); + writeEntry(null, toTake); + logger.log(Level.INFO, "wrote entry " + toTake); + + // the entry written under the transaction + SimpleEntry written = new SimpleEntry("tester", 17, 29); + logger.log(Level.INFO, "wrote entry " + written); + writeEntry(tt.transaction, written); + tt.assertParticipants(1); // just to be sure + Entry taken = getSpace().take(toTake, tt.transaction, 0); + assertEquals(taken, toTake, "reading 'toTake' entry"); + + if (!active) { + tt.sendPrepare(); // get the transaction prepared + + if (tt.localGetState() != PREPARED) { + throw new TestException( + "state is " + + TxnConstants.getName(tt.localGetState()) + + ", should be " + TxnConstants.getName(PREPARED)); + } + } + shutdown(0); // shut down the space + + /* + * Only do this test if we're not active -- active txns should + * be effectively aborted at this point, so they have no stage + * that exists after a shutdown and before the transaction + * completion + */ + if (!active) { + + /* + * try to see transacted stuff under a null transaction: + * should fail + */ + canSee(toTake, null, "txn not yet completed"); + canSee(written, null, "txn not yet completed"); + + if (wait) { + + /* + * sleep long enough for the 15-second retries plus + * 5 for slop + */ + long sleepTime = (15 * SECONDS * (throwRemote + 1) + + 5 * SECONDS); + tt.setState(abort ? ABORTED : COMMITTED); + logger.log(Level.INFO, "transaction state set to " + + TxnConstants.getName(tt.localGetState()) + + ", sleeping " + sleepTime); + + if (throwRemote > 0) { + tt.getStateFailCnt(throwRemote); + } + + // give the participant a chance to ask + Thread.sleep(sleepTime); + } else { + if (abort) { + tt.sendAbort(); + } else { + tt.sendCommit(); + } + } + } + + if (abort) { + canSee(toTake, toTake, "txn aborted"); + canSee(written, null, "txn aborted"); + } else { + canSee(toTake, null, "txn committed"); + canSee(written, written, "txn committed"); + } + } + + private void canSee(Entry tmpl, Entry shouldMatch, String desc) + throws Exception { + Entry e = getSpace().read(tmpl, null, 0); + assertEquals(e, shouldMatch, desc); + } +} Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/reliability/AppleUserImpl.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/reliability/AppleUserImpl.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/reliability/AppleUserImpl.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/reliability/AppleUserImpl.java Sun Oct 26 13:17:28 2014 @@ -1,322 +1,323 @@ -/* - * 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. - */ -/* @test 1.6 03/10/28 - * - * @summary The juicer is the classic RMI stress test. The juicer makes - * a large number of concurrent, long running, remote method invocations - * between many threads which have exported remote objects. These - * threads use remote objects that carry on deep "two party" - * recursion. The juicer relies on Distributed Garbage Collection to - * unexport these remote objects when no more references are held to them - * (thus in JERI, dgc must be enabled for this test to function). - * The two parties in the recursion are OrangeImpl and - * OrangeEchoImpl. OrangeImpl checks the base case of the recursion - * so that the program will exit. - * - * When the run() method is invoked, the class binds an - * instance of itself in a registry. A second server process, - * an ApplicationServer, is started which looks up the recently - * bound AppleUser object. The default is to start the server in - * the same VM. If the test is being run in distributed mode, then - * the server will be started in a separate VM on a different host. - * - * The second server process instructs the AppleUserImpl to "use" some apples. - * AppleUserImpl creates a new thread for each apple. These threads - * initiate the two party recursion. - * - * Each recursive call nests to a depth determined by this - * expression: (2 + Math.abs(random.nextInt() % (maxLevel + 1)), - * where maxLevel is defined by the property - * com.sun.jini.test.impl.reliabililty.maxLevel. Thus each recursive - * call nests a random number of levels between 2 and maxLevel. - * - * The test ends when an exception is encountered or the stop time - * has been reached. - * - * Test properties are: - * - * com.sun.jini.test.impl.reliabililty.minutes - * The number of minutes to run the juicer. - * The default is 1 minute. - * com.sun.jini.test.impl.reliabililty.maxLevel - * The maximum number of levels to - * recurse on each call. - * The default is 7 levels. - * - * @author Peter Jones, Nigel Daley - */ -package com.sun.jini.test.impl.reliability; - -import java.rmi.RemoteException; -import java.rmi.NoSuchObjectException; -import java.rmi.registry.LocateRegistry; -import java.util.Random; -import java.util.logging.Level; -import java.net.InetAddress; - -import net.jini.config.Configuration; -import net.jini.export.Exporter; - -import com.sun.jini.qa.harness.QATestEnvironment; -import com.sun.jini.qa.harness.QAConfig; -import com.sun.jini.qa.harness.SlaveRequest; -import com.sun.jini.qa.harness.SlaveTest; -import com.sun.jini.qa.harness.Test; - -/** - * The AppleUserImpl class implements the behavior of the remote - * "apple user" objects exported by the server. The application server - * passes each of its remote "apple" objects to an apple user, and an - * AppleUserThread is created for each apple. - */ -public class AppleUserImpl extends QATestEnvironment implements AppleUser, Test { - - private int threadNum = 0; - private long testDuration; - private int maxLevel; - private Exception status = null; - private boolean finished = false; - private boolean startTestNotified = false; - private final Random random = new Random(); - private final Object lock = new Object(); - private long startTime = 0; - private Exporter exporter; - - /** - * Allows the other server process to indicate that it is ready - * to start "juicing". - */ - public synchronized void startTest() throws RemoteException { - startTestNotified = true; - this.notifyAll(); - } - - /** - * Allows the other server process to report an exception to this - * process and thereby terminate the test. - */ - public void reportException(Exception status) throws RemoteException { - synchronized (lock) { - this.status = status; - lock.notifyAll(); - } - } - - /** - * "Use" supplied apple object. Create an AppleUserThread to - * stress it out. - */ - public synchronized void useApple(Apple apple) throws RemoteException { - String threadName = Thread.currentThread().getName(); - logger.log(Level.FINEST, - threadName + ": AppleUserImpl.useApple(): BEGIN"); - - AppleUserThread t = - new AppleUserThread("AppleUserThread-" + (++threadNum), apple); - t.start(); - - logger.log(Level.FINEST, - threadName + ": AppleUserImpl.useApple(): END"); - } - - /** - * The AppleUserThread class repeatedly invokes calls on its associated - * Apple object to stress the RMI system. - */ - class AppleUserThread extends Thread { - - final Apple apple; - - public AppleUserThread(String name, Apple apple) { - super(name); - this.apple = apple; - } - - public void run() { - int orangeNum = 0; - long stopTime = System.currentTimeMillis() + testDuration; - - try { - do { // loop until stopTime is reached - - /* - * Notify apple with some apple events. This tests - * serialization of arrays. - */ - int numEvents = Math.abs(random.nextInt() % 5); - AppleEvent[] events = new AppleEvent[numEvents]; - for (int i = 0; i < events.length; i++) { - events[i] = new AppleEvent(orangeNum % 3); - } - apple.notify(events); - - /* - * Request a new orange object be created in - * the application server. - */ - Orange orange = apple.newOrange( - "Orange(" + getName() + ")-" + (++orangeNum)); - - /* - * Create a large message of random ints to pass to orange. - */ - int msgLength = 1000 + Math.abs(random.nextInt() % 3000); - int[] message = new int[msgLength]; - for (int i = 0; i < message.length; i++) { - message[i] = random.nextInt(); - } - - /* - * Invoke recursive call on the orange. Base case - * of recursion inverts messgage. - */ - OrangeEcho orangeEchoProxy = ( - new OrangeEchoImpl( - "OrangeEcho(" + getName() + ")-" + orangeNum) - ).export(); - int[] response = orange.recurse(orangeEchoProxy, message, - 2 + Math.abs(random.nextInt() % (maxLevel + 1))); - - /* - * Verify message was properly inverted and not corrupted - * through all the recursive method invocations. - */ - if (response.length != message.length) { - throw new RuntimeException( - "ERROR: CORRUPTED RESPONSE: " + - "wrong length of returned array " + "(should be " + - message.length + ", is " + response.length + ")"); - } - for (int i = 0; i < message.length; i++) { - if (~message[i] != response[i]) { - throw new RuntimeException( - "ERROR: CORRUPTED RESPONSE: " + - "at element " + i + "/" + message.length + - " of returned array (should be " + - Integer.toHexString(~message[i]) + ", is " + - Integer.toHexString(response[i]) + ")"); - } - } - - try { - Thread.sleep(Math.abs(random.nextInt() % 10) * 1000); - } catch (InterruptedException e) { - } - - } while (System.currentTimeMillis() < stopTime); - - } catch (Exception e) { - status = e; - } - finished = true; - synchronized (lock) { - lock.notifyAll(); - } - } - } - - // inherit javadoc - public Test construct(QAConfig sysConfig) throws Exception { - super.construct(sysConfig); - return this; - } - - /** - * Entry point for the "juicer" server process. Create and export - * an apple user implementation in an rmiregistry running on localhost. - */ - public void run() throws Exception { - // run ApplicationServer on a separate host if running distributed - boolean othervm = (QAConfig.getConfig().getHostList().size() > 1); - maxLevel = getConfig().getIntConfigVal( - "com.sun.jini.test.impl.reliability.maxLevel",7); - testDuration = getConfig().getIntConfigVal( - "com.sun.jini.test.impl.reliability.minutes",1) * 60 * 1000; - - Configuration c = QAConfig.getConfig().getConfiguration(); - exporter = (Exporter) c.getEntry("test", - "reliabilityExporter", - Exporter.class); - AppleUser appleUserProxy = (AppleUser) exporter.export(this); - - Thread server = null; - synchronized (this) { - // create new registry and bind new AppleUserImpl in registry - LocateRegistry.createRegistry(2006); - LocateRegistry.getRegistry(2006).rebind( - "AppleUser",appleUserProxy); - - // start the other server if applicable - if (othervm) { - // the other server must be running in a separate process - logger.log(Level.INFO, "Application server will be " + - "started on a separate host"); - SlaveRequest sr = new StartApplicationServerRequest( - InetAddress.getLocalHost().getHostName()); - SlaveTest.broadcast(sr); - } else { - Class app = Class.forName( - "com.sun.jini.test.impl.reliability.ApplicationServer"); - server = new Thread((Runnable) app.newInstance()); - logger.log(Level.INFO, "Starting application server " + - "in same process"); - server.start(); - } - - // wait for other server to call startTest method - logger.log(Level.INFO, "Waiting for application server " + - "process to start"); - while (!startTestNotified) { - this.wait(); - } - } - - startTime = System.currentTimeMillis(); - logger.log(Level.INFO, "Test starting"); - - // wait for exception to be reported or first thread to complete - logger.log(Level.INFO, "Waiting " + (testDuration/60000) + - " minutes for test to complete or exception to be thrown"); - - synchronized (lock) { - while (status == null && !finished) { - lock.wait(); - } - } - - if (status != null) { - throw new RuntimeException("TEST FAILED: " - + "juicer server reported an exception", status); - } else { - logger.log(Level.INFO, "TEST PASSED"); - } - } - - // inherit javadoc - public void tearDown() { - long actualDuration = System.currentTimeMillis() - startTime; - logger.log(Level.INFO, "Test finished"); - exporter.unexport(true); - logger.log(Level.INFO, "Test duration was " + - (actualDuration/1000) + " seconds " + - "(" + (actualDuration/60000) + " minutes or " + - (actualDuration/3600000) + " hours)"); - super.tearDown(); - } - -} +/* + * 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. + */ +/* @test 1.6 03/10/28 + * + * @summary The juicer is the classic RMI stress test. The juicer makes + * a large number of concurrent, long running, remote method invocations + * between many threads which have exported remote objects. These + * threads use remote objects that carry on deep "two party" + * recursion. The juicer relies on Distributed Garbage Collection to + * unexport these remote objects when no more references are held to them + * (thus in JERI, dgc must be enabled for this test to function). + * The two parties in the recursion are OrangeImpl and + * OrangeEchoImpl. OrangeImpl checks the base case of the recursion + * so that the program will exit. + * + * When the run() method is invoked, the class binds an + * instance of itself in a registry. A second server process, + * an ApplicationServer, is started which looks up the recently + * bound AppleUser object. The default is to start the server in + * the same VM. If the test is being run in distributed mode, then + * the server will be started in a separate VM on a different host. + * + * The second server process instructs the AppleUserImpl to "use" some apples. + * AppleUserImpl creates a new thread for each apple. These threads + * initiate the two party recursion. + * + * Each recursive call nests to a depth determined by this + * expression: (2 + Math.abs(random.nextInt() % (maxLevel + 1)), + * where maxLevel is defined by the property + * com.sun.jini.test.impl.reliabililty.maxLevel. Thus each recursive + * call nests a random number of levels between 2 and maxLevel. + * + * The test ends when an exception is encountered or the stop time + * has been reached. + * + * Test properties are: + * + * com.sun.jini.test.impl.reliabililty.minutes + * The number of minutes to run the juicer. + * The default is 1 minute. + * com.sun.jini.test.impl.reliabililty.maxLevel + * The maximum number of levels to + * recurse on each call. + * The default is 7 levels. + * + * @author Peter Jones, Nigel Daley + */ +package com.sun.jini.test.impl.reliability; + +import java.rmi.RemoteException; +import java.rmi.NoSuchObjectException; +import java.rmi.registry.LocateRegistry; +import java.util.Random; +import java.util.logging.Level; +import java.net.InetAddress; + +import net.jini.config.Configuration; +import net.jini.export.Exporter; + +import com.sun.jini.qa.harness.QATestEnvironment; +import com.sun.jini.qa.harness.QAConfig; +import com.sun.jini.qa.harness.SlaveRequest; +import com.sun.jini.qa.harness.SlaveTest; +import com.sun.jini.qa.harness.Test; + +/** + * The AppleUserImpl class implements the behavior of the remote + * "apple user" objects exported by the server. The application server + * passes each of its remote "apple" objects to an apple user, and an + * AppleUserThread is created for each apple. + */ +public class AppleUserImpl extends QATestEnvironment implements AppleUser, Test { + + private int threadNum = 0; + private long testDuration; + private int maxLevel; + private Exception status = null; + private boolean finished = false; + private boolean startTestNotified = false; + private final Random random = new Random(); + private final Object lock = new Object(); + private long startTime = 0; + private Exporter exporter; + + /** + * Allows the other server process to indicate that it is ready + * to start "juicing". + */ + public synchronized void startTest() throws RemoteException { + startTestNotified = true; + this.notifyAll(); + } + + /** + * Allows the other server process to report an exception to this + * process and thereby terminate the test. + */ + public void reportException(Exception status) throws RemoteException { + synchronized (lock) { + this.status = status; + lock.notifyAll(); + } + } + + /** + * "Use" supplied apple object. Create an AppleUserThread to + * stress it out. + */ + public synchronized void useApple(Apple apple) throws RemoteException { + String threadName = Thread.currentThread().getName(); + logger.log(Level.FINEST, + threadName + ": AppleUserImpl.useApple(): BEGIN"); + + AppleUserThread t = + new AppleUserThread("AppleUserThread-" + (++threadNum), apple); + t.start(); + + logger.log(Level.FINEST, + threadName + ": AppleUserImpl.useApple(): END"); + } + + /** + * The AppleUserThread class repeatedly invokes calls on its associated + * Apple object to stress the RMI system. + */ + class AppleUserThread extends Thread { + + final Apple apple; + + public AppleUserThread(String name, Apple apple) { + super(name); + this.apple = apple; + } + + public void run() { + int orangeNum = 0; + long stopTime = System.currentTimeMillis() + testDuration; + + try { + do { // loop until stopTime is reached + + /* + * Notify apple with some apple events. This tests + * serialization of arrays. + */ + int numEvents = Math.abs(random.nextInt() % 5); + AppleEvent[] events = new AppleEvent[numEvents]; + for (int i = 0; i < events.length; i++) { + events[i] = new AppleEvent(orangeNum % 3); + } + apple.notify(events); + + /* + * Request a new orange object be created in + * the application server. + */ + Orange orange = apple.newOrange( + "Orange(" + getName() + ")-" + (++orangeNum)); + + /* + * Create a large message of random ints to pass to orange. + */ + int msgLength = 1000 + Math.abs(random.nextInt() % 3000); + int[] message = new int[msgLength]; + for (int i = 0; i < message.length; i++) { + message[i] = random.nextInt(); + } + + /* + * Invoke recursive call on the orange. Base case + * of recursion inverts messgage. + */ + OrangeEcho orangeEchoProxy = ( + new OrangeEchoImpl( + "OrangeEcho(" + getName() + ")-" + orangeNum) + ).export(); + int[] response = orange.recurse(orangeEchoProxy, message, + 2 + Math.abs(random.nextInt() % (maxLevel + 1))); + + /* + * Verify message was properly inverted and not corrupted + * through all the recursive method invocations. + */ + if (response.length != message.length) { + throw new RuntimeException( + "ERROR: CORRUPTED RESPONSE: " + + "wrong length of returned array " + "(should be " + + message.length + ", is " + response.length + ")"); + } + for (int i = 0; i < message.length; i++) { + if (~message[i] != response[i]) { + throw new RuntimeException( + "ERROR: CORRUPTED RESPONSE: " + + "at element " + i + "/" + message.length + + " of returned array (should be " + + Integer.toHexString(~message[i]) + ", is " + + Integer.toHexString(response[i]) + ")"); + } + } + + try { + Thread.sleep(Math.abs(random.nextInt() % 10) * 1000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + + } while (System.currentTimeMillis() < stopTime); + + } catch (Exception e) { + status = e; + } + finished = true; + synchronized (lock) { + lock.notifyAll(); + } + } + } + + // inherit javadoc + public Test construct(QAConfig sysConfig) throws Exception { + super.construct(sysConfig); + return this; + } + + /** + * Entry point for the "juicer" server process. Create and export + * an apple user implementation in an rmiregistry running on localhost. + */ + public void run() throws Exception { + // run ApplicationServer on a separate host if running distributed + boolean othervm = (QAConfig.getConfig().getHostList().size() > 1); + maxLevel = getConfig().getIntConfigVal( + "com.sun.jini.test.impl.reliability.maxLevel",7); + testDuration = getConfig().getIntConfigVal( + "com.sun.jini.test.impl.reliability.minutes",1) * 60 * 1000; + + Configuration c = QAConfig.getConfig().getConfiguration(); + exporter = (Exporter) c.getEntry("test", + "reliabilityExporter", + Exporter.class); + AppleUser appleUserProxy = (AppleUser) exporter.export(this); + + Thread server = null; + synchronized (this) { + // create new registry and bind new AppleUserImpl in registry + LocateRegistry.createRegistry(2006); + LocateRegistry.getRegistry(2006).rebind( + "AppleUser",appleUserProxy); + + // start the other server if applicable + if (othervm) { + // the other server must be running in a separate process + logger.log(Level.INFO, "Application server will be " + + "started on a separate host"); + SlaveRequest sr = new StartApplicationServerRequest( + InetAddress.getLocalHost().getHostName()); + SlaveTest.broadcast(sr); + } else { + Class app = Class.forName( + "com.sun.jini.test.impl.reliability.ApplicationServer"); + server = new Thread((Runnable) app.newInstance()); + logger.log(Level.INFO, "Starting application server " + + "in same process"); + server.start(); + } + + // wait for other server to call startTest method + logger.log(Level.INFO, "Waiting for application server " + + "process to start"); + while (!startTestNotified) { + this.wait(); + } + } + + startTime = System.currentTimeMillis(); + logger.log(Level.INFO, "Test starting"); + + // wait for exception to be reported or first thread to complete + logger.log(Level.INFO, "Waiting " + (testDuration/60000) + + " minutes for test to complete or exception to be thrown"); + + synchronized (lock) { + while (status == null && !finished) { + lock.wait(); + } + } + + if (status != null) { + throw new RuntimeException("TEST FAILED: " + + "juicer server reported an exception", status); + } else { + logger.log(Level.INFO, "TEST PASSED"); + } + } + + // inherit javadoc + public void tearDown() { + long actualDuration = System.currentTimeMillis() - startTime; + logger.log(Level.INFO, "Test finished"); + exporter.unexport(true); + logger.log(Level.INFO, "Test duration was " + + (actualDuration/1000) + " seconds " + + "(" + (actualDuration/60000) + " minutes or " + + (actualDuration/3600000) + " hours)"); + super.tearDown(); + } + +} Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/scalability/DemoScalabilityTest.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/scalability/DemoScalabilityTest.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/scalability/DemoScalabilityTest.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/scalability/DemoScalabilityTest.java Sun Oct 26 13:17:28 2014 @@ -1,67 +1,68 @@ -/* - * 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.scalability; - -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.Test; -import com.sun.jini.qa.harness.TestException; - -import java.rmi.NoSuchObjectException; -import java.util.StringTokenizer; -import java.util.HashMap; - - -/** - * Tests that an Lease Renweal Service properly grants, renews, - * cancels, and/or expires leases. Tests for availably by adding - * leases to the set. - */ -public class DemoScalabilityTest extends QATestEnvironment implements Test { - - public Test construct(QAConfig config) throws Exception { - super.construct(config); - return this; - } - - public void run() throws Exception { - // wait for 'all systems go' - getConfig().suspendRun("Demo test suspended at phase 1" - + "<popup>Resume this test when<br>" - + "all participating services are ready</popup>"); - - // simulate doing some work - getConfig().setTestStatus("Performing test actions for 10 seconds"); - try { - Thread.sleep(10000); - } catch (InterruptedException ignore) { - } - - // simulate phase 2 work - getConfig().suspendRun("Demo test suspended at phase 2" - + "<popup>Resume this test when<br>" - + "all phase 2 activities are setup</popup>"); - - // wait for termination request - getConfig().suspendRun("Demo test suspended at end of run" - + "<popup>Resume this test to terminate</popup>"); - } -} +/* + * 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.scalability; + +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.Test; +import com.sun.jini.qa.harness.TestException; + +import java.rmi.NoSuchObjectException; +import java.util.StringTokenizer; +import java.util.HashMap; + + +/** + * Tests that an Lease Renweal Service properly grants, renews, + * cancels, and/or expires leases. Tests for availably by adding + * leases to the set. + */ +public class DemoScalabilityTest extends QATestEnvironment implements Test { + + public Test construct(QAConfig config) throws Exception { + super.construct(config); + return this; + } + + public void run() throws Exception { + // wait for 'all systems go' + getConfig().suspendRun("Demo test suspended at phase 1" + + "<popup>Resume this test when<br>" + + "all participating services are ready</popup>"); + + // simulate doing some work + getConfig().setTestStatus("Performing test actions for 10 seconds"); + try { + Thread.sleep(10000); + } catch (InterruptedException ignore) { + Thread.currentThread().interrupt(); + } + + // simulate phase 2 work + getConfig().suspendRun("Demo test suspended at phase 2" + + "<popup>Resume this test when<br>" + + "all phase 2 activities are setup</popup>"); + + // wait for termination request + getConfig().suspendRun("Demo test suspended at end of run" + + "<popup>Resume this test to terminate</popup>"); + } +} Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/TerminateSemantics.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/TerminateSemantics.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/TerminateSemantics.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/TerminateSemantics.java Sun Oct 26 13:17:28 2014 @@ -1,229 +1,231 @@ -/* - * 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.servicediscovery; - -import java.util.logging.Level; - -import com.sun.jini.test.spec.servicediscovery.AbstractBaseTest; - -import net.jini.discovery.DiscoveryManagement; -import net.jini.lease.LeaseRenewalManager; -import net.jini.lookup.LookupCache; - -import net.jini.core.lookup.ServiceItem; - -import java.rmi.RemoteException; -import com.sun.jini.qa.harness.QAConfig; -import com.sun.jini.qa.harness.Test; -import com.sun.jini.qa.harness.TestException; - -/** - * With respect to the current implementation of the - * <code>ServiceDiscoveryManager</code> utility, this class verifies - * that - except for the <code>terminate</code> method itself - if any - * of the public methods of that utility are invoked after the service - * discovery manager has been terminated, an <code>IllegalStateException</code> - * results. Any invocation of the <code>terminate</code> method made - * after the initial invocation of that method will result in no - * action being taken, and no exception being thrown. - * - * The environment in which this class expects to operate is as follows: - * <p><ul> - * <li> no lookup services - * <li> one instance of ServiceDiscoveryManager - * <li> after invoking the terminate method on the service discovery - * manager, each version of each public method is invoked - * </ul><p> - * - * If the <code>ServiceDiscoveryManager</code> utility functions as - * intended, then upon invoking any of the public methods on an instance - * of that utility (except the <code>terminate</code> method) after - * that instance has been terminated, an <code>IllegalStateException</code> - * will occur. Upon invoking the <code>terminate</code> method after the - * initial invocation of that method, no action will be taken. - * - * Regression test for Bug ID 4394139, 4480307 - */ -public class TerminateSemantics extends AbstractBaseTest { - - /** Performs actions necessary to prepare for execution of the - * current test. - * - * 1. Creates a service discovery manager using the default input - */ - public Test construct(QAConfig config) throws Exception { - super.construct(config); - testDesc = "verify invocation semantics of public methods after " - +"termination"; - waitForLookupDiscovery = false; - terminateDelay = 0; - return this; - }//end construct - - /** Defines the actual steps of this particular test. - * - * 1. Terminates the service discovery manager created in construct and - * verifies that an invocation of any of that service discovery - * manager's public methods (except the terminate method itself) - * will result in an <code>IllegalStateException</code>. - * 2. Verifies that any additional invocation of that service discovery - * manager's terminate method will result in no further action being - * taken - */ - protected void applyTestDef() throws Exception { - /* Terminate the service discovery manager */ - logger.log(Level.FINE, "terminating the service discovery manager ..."); - srvcDiscoveryMgr.terminate(); - sdmList.clear(); - String methodStr = ""; - String successStr = "IllegalStateException occurred as expected -- "; - String errStr = " no IllegalStateException -- "; - boolean failed = false; - /* Invoke methods on terminated sdm -- getDiscoveryManager */ - methodStr = "getDiscoveryManager()"; - logger.log(Level.FINE, "invoking "+methodStr+" ..."); - try { - DiscoveryManagement dm = srvcDiscoveryMgr.getDiscoveryManager(); - logger.log(Level.FINE, ""+errStr+methodStr); - failed = true; - } catch(IllegalStateException e) { - logger.log(Level.FINE, ""+successStr+methodStr); - } - /* getLeaseRenewalManager */ - methodStr = "getLeaseRenewalManager()"; - logger.log(Level.FINE, "invoking "+methodStr+" ..."); - try { - LeaseRenewalManager lrm - = srvcDiscoveryMgr.getLeaseRenewalManager(); - logger.log(Level.FINE, ""+errStr+methodStr); - failed = true; - } catch(IllegalStateException e) { - logger.log(Level.FINE, ""+successStr+methodStr); - } - /* createLookupCache */ - methodStr = new String("createLookupCache()"); - logger.log(Level.FINE, "invoking "+methodStr+" ..."); - try { - LookupCache cache = srvcDiscoveryMgr.createLookupCache - (template, - firstStageFilter, - null);//listener - logger.log(Level.FINE, errStr+methodStr); - failed = true; - } catch(IllegalStateException e) { - logger.log(Level.FINE, successStr+methodStr); - } catch(RemoteException e) { - e.printStackTrace(); - logger.log(Level.FINE, "RemoteException occurred on " - +"call to "+methodStr); - failed = true; - } - /* lookup(tmpl,filter) */ - methodStr = new String("lookup(tmpl,filter)"); - logger.log(Level.FINE, "invoking "+methodStr+" ..."); - try { - ServiceItem srvcItem = srvcDiscoveryMgr.lookup(template, - firstStageFilter); - logger.log(Level.FINE, ""+errStr+methodStr); - failed = true; - } catch(IllegalStateException e) { - logger.log(Level.FINE, successStr+methodStr); - } - /* lookup(tmpl,filter,waitDur) */ - methodStr = new String("lookup(tmpl,filter,waitDur)"); - logger.log(Level.FINE, "invoking "+methodStr+" ..."); - try { - ServiceItem srvcItem = srvcDiscoveryMgr.lookup(template, - firstStageFilter, - 1000); - logger.log(Level.FINE, errStr+methodStr); - failed = true; - } catch(IllegalStateException e) { - logger.log(Level.FINE, successStr+methodStr); - } catch(InterruptedException e) { - e.printStackTrace(); - logger.log(Level.FINE, "InterruptedException occurred " - +"on call to "+methodStr); - failed = true; - } catch(RemoteException e) { - e.printStackTrace(); - logger.log(Level.FINE, "RemoteException occurred on " - +"call to "+methodStr); - failed = true; - } - /* lookup(tmpl,maxMatches,filter) */ - methodStr = new String("lookup(tmpl,maxMatches,filter)"); - logger.log(Level.FINE, "invoking "+methodStr+" ..."); - try { - ServiceItem[] srvcItems = srvcDiscoveryMgr.lookup - (template, - 1, - firstStageFilter); - logger.log(Level.FINE, ""+errStr+methodStr); - failed = true; - } catch(IllegalStateException e) { - logger.log(Level.FINE, ""+successStr+methodStr); - } - /* lookup(tmpl,maxMatches,minMatches,filter,waitDur) */ - methodStr = new String("lookup(tmpl,maxMatches,minMatches," - +"filter,waitDur)"); - logger.log(Level.FINE, "invoking "+methodStr+" ..."); - try { - ServiceItem[] srvcItems = srvcDiscoveryMgr.lookup - (template, - 1, - 1, - firstStageFilter, - 1000); - logger.log(Level.FINE, errStr+methodStr); - failed = true; - } catch(IllegalStateException e) { - logger.log(Level.FINE, successStr+methodStr); - } catch(InterruptedException e) { - e.printStackTrace(); - logger.log(Level.FINE, "InterruptedException occurred " - +"on call to "+methodStr); - failed = true; - } catch(RemoteException e) { - e.printStackTrace(); - logger.log(Level.FINE, "RemoteException occurred on " - +"call to "+methodStr); - failed = true; - } - /* terminate */ - methodStr = new String("terminate()"); - logger.log(Level.FINE, "invoking "+methodStr+" ..."); - try { - srvcDiscoveryMgr.terminate(); - logger.log(Level.FINE, "OK - on multiple invocations of "+methodStr); - } catch(Exception e) { - e.printStackTrace(); - logger.log(Level.FINE, "exception occurred on second " - +"invocation of "+methodStr); - failed = true; - } - if(failed) { - throw new TestException(" -- no IllegalStateException from at " - + "least one public method"); - } - }//end applyTestDef - -}//end class TerminateSemantics - - +/* + * 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.servicediscovery; + +import java.util.logging.Level; + +import com.sun.jini.test.spec.servicediscovery.AbstractBaseTest; + +import net.jini.discovery.DiscoveryManagement; +import net.jini.lease.LeaseRenewalManager; +import net.jini.lookup.LookupCache; + +import net.jini.core.lookup.ServiceItem; + +import java.rmi.RemoteException; +import com.sun.jini.qa.harness.QAConfig; +import com.sun.jini.qa.harness.Test; +import com.sun.jini.qa.harness.TestException; + +/** + * With respect to the current implementation of the + * <code>ServiceDiscoveryManager</code> utility, this class verifies + * that - except for the <code>terminate</code> method itself - if any + * of the public methods of that utility are invoked after the service + * discovery manager has been terminated, an <code>IllegalStateException</code> + * results. Any invocation of the <code>terminate</code> method made + * after the initial invocation of that method will result in no + * action being taken, and no exception being thrown. + * + * The environment in which this class expects to operate is as follows: + * <p><ul> + * <li> no lookup services + * <li> one instance of ServiceDiscoveryManager + * <li> after invoking the terminate method on the service discovery + * manager, each version of each public method is invoked + * </ul><p> + * + * If the <code>ServiceDiscoveryManager</code> utility functions as + * intended, then upon invoking any of the public methods on an instance + * of that utility (except the <code>terminate</code> method) after + * that instance has been terminated, an <code>IllegalStateException</code> + * will occur. Upon invoking the <code>terminate</code> method after the + * initial invocation of that method, no action will be taken. + * + * Regression test for Bug ID 4394139, 4480307 + */ +public class TerminateSemantics extends AbstractBaseTest { + + /** Performs actions necessary to prepare for execution of the + * current test. + * + * 1. Creates a service discovery manager using the default input + */ + public Test construct(QAConfig config) throws Exception { + super.construct(config); + testDesc = "verify invocation semantics of public methods after " + +"termination"; + waitForLookupDiscovery = false; + terminateDelay = 0; + return this; + }//end construct + + /** Defines the actual steps of this particular test. + * + * 1. Terminates the service discovery manager created in construct and + * verifies that an invocation of any of that service discovery + * manager's public methods (except the terminate method itself) + * will result in an <code>IllegalStateException</code>. + * 2. Verifies that any additional invocation of that service discovery + * manager's terminate method will result in no further action being + * taken + */ + protected void applyTestDef() throws Exception { + /* Terminate the service discovery manager */ + logger.log(Level.FINE, "terminating the service discovery manager ..."); + srvcDiscoveryMgr.terminate(); + sdmList.clear(); + String methodStr = ""; + String successStr = "IllegalStateException occurred as expected -- "; + String errStr = " no IllegalStateException -- "; + boolean failed = false; + /* Invoke methods on terminated sdm -- getDiscoveryManager */ + methodStr = "getDiscoveryManager()"; + logger.log(Level.FINE, "invoking "+methodStr+" ..."); + try { + DiscoveryManagement dm = srvcDiscoveryMgr.getDiscoveryManager(); + logger.log(Level.FINE, ""+errStr+methodStr); + failed = true; + } catch(IllegalStateException e) { + logger.log(Level.FINE, ""+successStr+methodStr); + } + /* getLeaseRenewalManager */ + methodStr = "getLeaseRenewalManager()"; + logger.log(Level.FINE, "invoking "+methodStr+" ..."); + try { + LeaseRenewalManager lrm + = srvcDiscoveryMgr.getLeaseRenewalManager(); + logger.log(Level.FINE, ""+errStr+methodStr); + failed = true; + } catch(IllegalStateException e) { + logger.log(Level.FINE, ""+successStr+methodStr); + } + /* createLookupCache */ + methodStr = new String("createLookupCache()"); + logger.log(Level.FINE, "invoking "+methodStr+" ..."); + try { + LookupCache cache = srvcDiscoveryMgr.createLookupCache + (template, + firstStageFilter, + null);//listener + logger.log(Level.FINE, errStr+methodStr); + failed = true; + } catch(IllegalStateException e) { + logger.log(Level.FINE, successStr+methodStr); + } catch(RemoteException e) { + e.printStackTrace(); + logger.log(Level.FINE, "RemoteException occurred on " + +"call to "+methodStr); + failed = true; + } + /* lookup(tmpl,filter) */ + methodStr = new String("lookup(tmpl,filter)"); + logger.log(Level.FINE, "invoking "+methodStr+" ..."); + try { + ServiceItem srvcItem = srvcDiscoveryMgr.lookup(template, + firstStageFilter); + logger.log(Level.FINE, ""+errStr+methodStr); + failed = true; + } catch(IllegalStateException e) { + logger.log(Level.FINE, successStr+methodStr); + } + /* lookup(tmpl,filter,waitDur) */ + methodStr = new String("lookup(tmpl,filter,waitDur)"); + logger.log(Level.FINE, "invoking "+methodStr+" ..."); + try { + ServiceItem srvcItem = srvcDiscoveryMgr.lookup(template, + firstStageFilter, + 1000); + logger.log(Level.FINE, errStr+methodStr); + failed = true; + } catch(IllegalStateException e) { + logger.log(Level.FINE, successStr+methodStr); + } catch(InterruptedException e) { + Thread.currentThread().interrupt(); + e.printStackTrace(); + logger.log(Level.FINE, "InterruptedException occurred " + +"on call to "+methodStr); + failed = true; + } catch(RemoteException e) { + e.printStackTrace(); + logger.log(Level.FINE, "RemoteException occurred on " + +"call to "+methodStr); + failed = true; + } + /* lookup(tmpl,maxMatches,filter) */ + methodStr = new String("lookup(tmpl,maxMatches,filter)"); + logger.log(Level.FINE, "invoking "+methodStr+" ..."); + try { + ServiceItem[] srvcItems = srvcDiscoveryMgr.lookup + (template, + 1, + firstStageFilter); + logger.log(Level.FINE, ""+errStr+methodStr); + failed = true; + } catch(IllegalStateException e) { + logger.log(Level.FINE, ""+successStr+methodStr); + } + /* lookup(tmpl,maxMatches,minMatches,filter,waitDur) */ + methodStr = new String("lookup(tmpl,maxMatches,minMatches," + +"filter,waitDur)"); + logger.log(Level.FINE, "invoking "+methodStr+" ..."); + try { + ServiceItem[] srvcItems = srvcDiscoveryMgr.lookup + (template, + 1, + 1, + firstStageFilter, + 1000); + logger.log(Level.FINE, errStr+methodStr); + failed = true; + } catch(IllegalStateException e) { + logger.log(Level.FINE, successStr+methodStr); + } catch(InterruptedException e) { + Thread.currentThread().interrupt(); + e.printStackTrace(); + logger.log(Level.FINE, "InterruptedException occurred " + +"on call to "+methodStr); + failed = true; + } catch(RemoteException e) { + e.printStackTrace(); + logger.log(Level.FINE, "RemoteException occurred on " + +"call to "+methodStr); + failed = true; + } + /* terminate */ + methodStr = new String("terminate()"); + logger.log(Level.FINE, "invoking "+methodStr+" ..."); + try { + srvcDiscoveryMgr.terminate(); + logger.log(Level.FINE, "OK - on multiple invocations of "+methodStr); + } catch(Exception e) { + e.printStackTrace(); + logger.log(Level.FINE, "exception occurred on second " + +"invocation of "+methodStr); + failed = true; + } + if(failed) { + throw new TestException(" -- no IllegalStateException from at " + + "least one public method"); + } + }//end applyTestDef + +}//end class TerminateSemantics + + Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/AddListenerEvent.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/AddListenerEvent.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/AddListenerEvent.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/AddListenerEvent.java Sun Oct 26 13:17:28 2014 @@ -54,13 +54,13 @@ import com.sun.jini.test.share.LookupSer */ public class AddListenerEvent extends AbstractBaseTest { - protected LookupCache cache; - protected int testServiceType; + protected volatile LookupCache cache; + protected volatile int testServiceType; - protected int nListeners = 2; - protected int nAddedExpected = 0; + protected final int nListeners = 2; + protected volatile int nAddedExpected = 0; - protected SDMListener[] sdmListener = new SDMListener[nListeners]; + protected final SDMListener[] sdmListener = new SDMListener[nListeners]; public static class SDMListener extends AbstractBaseTest.SrvcListener { final String testName; @@ -131,7 +131,6 @@ public class AddListenerEvent extends Ab cache = srvcDiscoveryMgr.createLookupCache(template, firstStageFilter, sdmListener[0]); - cacheList.add(cache); } catch(RemoteException e) { throw new TestException("RemoteException during lookup cache " +"creation", e); @@ -155,6 +154,9 @@ public class AddListenerEvent extends Ab indx = 1; logger.log(Level.FINE, "adding listener_"+indx+" to cache"); cache.addListener(sdmListener[indx]); + // The next line was added to allow more time for the new task based + // executor program structre in SDM. + DiscoveryServiceUtil.delayMS(nSecsServiceDiscovery*1000); nAdded = sdmListener[indx].getNAdded(); logger.log(Level.FINE, "listener_"+indx +" ---> "+nAdded+" event(s) received, " Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/AddListenerEvent.td URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/AddListenerEvent.td?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/AddListenerEvent.td (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/AddListenerEvent.td Sun Oct 26 13:17:28 2014 @@ -3,6 +3,7 @@ testClass=AddListenerEvent testCategories=servicediscovery,servicediscovery_impl,servicediscoveryevent,implservicediscovery,implservicediscoveryevent net.jini.lookup.nLookupServices=1 net.jini.lookup.nServices=1 +net.jini.lookup.nSecsServiceDiscovery=10 # Not need to run activatable and/or persistent version of # the lookp service. Uncomment the following items when # the harness supports starting the non-activatable Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/DiscardServiceUp.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/DiscardServiceUp.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/DiscardServiceUp.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/DiscardServiceUp.java Sun Oct 26 13:17:28 2014 @@ -235,7 +235,6 @@ public class DiscardServiceUp extends Ab cache = srvcDiscoveryMgr.createLookupCache(template, firstStageFilter, srvcListener); - cacheList.add(cache); } catch(RemoteException e) { throw new TestException(" -- RemoteException during lookup cache " +"creation", e); Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/LookupDropProxyTaskRace.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/LookupDropProxyTaskRace.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/LookupDropProxyTaskRace.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/LookupDropProxyTaskRace.java Sun Oct 26 13:17:28 2014 @@ -172,7 +172,6 @@ public class LookupDropProxyTaskRace ext cache = srvcDiscoveryMgr.createLookupCache(template, firstStageFilter, srvcListener); - cacheList.add(cache); //delay to allow LookupTask to get started before L0 //is removed from proxyRegSet when it is discarded below logger.log(Level.FINE, "cache created ... " Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/LookupTaskRace.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/LookupTaskRace.java?rev=1634322&r1=1634321&r2=1634322&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/LookupTaskRace.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/servicediscovery/event/LookupTaskRace.java Sun Oct 26 13:17:28 2014 @@ -169,7 +169,6 @@ public class LookupTaskRace extends Abst cache = srvcDiscoveryMgr.createLookupCache(template, firstStageFilter, srvcListener); - cacheList.add(cache); } catch(RemoteException e) { throw new TestException(" -- RemoteException during lookup cache " +"creation", e);
