/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. * See the copyright.txt in the distribution for a * full listing of individual contributors. * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU Lesser General Public License, v. 2.1. * This program is distributed in the hope that it will be useful, but WITHOUT A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License, * v.2.1 along with this distribution; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * (C) 2005-2006, * @author JBoss Inc. */ package org.jboss.jbossts.qa.ArjunaCore.AbstractRecord.client; import org.jboss.jbossts.qa.ArjunaCore.Utils.BaseTestClient; public class WorkerClient001 extends BaseTestClient { public static void main(String[] args) { WorkerClient001 test = new WorkerClient001(args); } private WorkerClient001(String[] args) { super(args); } public void Test() { try { setNumberOfCalls(3); setNumberOfResources(2); setNumberOfWorkers(1); Worker001[] mWorkers = new Worker001[mNumberOfWorkers]; for (int i = 0; i < mNumberOfWorkers; i++) { mWorkers[i] = new Worker001(mMaxIteration, mNumberOfResources, i); mWorkers[i].start(); } try { //wait for threads to complete for (int i = 0; i < mNumberOfWorkers; i++) { mWorkers[i].join(); //check for any exceptions if (!mWorkers[i].isCorrect()) { Debug("worker " + i + " has encountered an exception"); mCorrect = false; } } } catch (Exception e) { mCorrect = false; Debug("exception in worker thread ", e); } for (int i = 0; i < mNumberOfWorkers; i++) { if (!mWorkers[i].isCorrect()) { mCorrect = false; Debug("worker " + i + " has encountered a problem"); break; } } qaAssert(mCorrect); } catch (Exception e) { Fail("Error in WorkerClient001.test() :", e); } } }