Package load

Source Code of load.InteractiveInvoker

/*
* This file is part of the WfMOpen project.
* Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
* $Id: InteractiveInvoker.java 2550 2007-10-22 14:00:54Z  $
*
* $Log$
* Revision 1.1.1.1  2003/12/19 13:01:45  drmlipp
* Updated to 1.1rc1
*
* Revision 1.3  2003/10/30 16:22:51  weidauer
* added cleaning suite
*
* Revision 1.2  2003/10/22 16:10:06  weidauer
* initial version
*
*/

package load;

import junit.framework.Test;
import junit.framework.TestSuite;

import com.clarkware.junitperf.LoadTest;
import com.clarkware.junitperf.ConstantTimer;
import com.clarkware.junitperf.Timer;

import javax.security.auth.login.LoginException;

import common.STProjectLoginContext;
import de.danet.an.util.junit.EJBClientTest;


/**
* Enables interactive invocation of <code>GenericTest</code>s by using
* JUnitPerf�s features. <br>
* Using the system properties load.packageID, load.users, load.delay and
* load.iterations the process P0 of the defined package (file) can be load
* tested for a defined number of users and iterations. Additionally a delay
* for starting the users can be defined.<br>
* This interactive invocation is supported by the build file in this
* directory.<br>
* E. g.: ant -DpackageID=A5naaT4par -Dusers=4 -Diterations=20 -Ddelay=5 invoke<br>
* Defaults are defined by the build file. 
*
* @author <a href="mailto:weidauer@danet.de">Christian Weidauer</a>
* @author <a href="http://www.danet.de">Danet GmbH</a>
*
*/

public class InteractiveInvoker {
   
    protected static STProjectLoginContext plc = null;
    static {
  try {
      plc = new STProjectLoginContext();
      plc.login();
  } catch (LoginException e) {
      throw new IllegalStateException (e.getMessage ());
  }
    }

    /**
     * Assemble the test suite.
     * @return the test suite
     */
    public static Test suite() {

  String packageID = System.getProperty("load.packageID");
  int users = Integer.parseInt(System.getProperty("load.users"));
  int iterations
      = Integer.parseInt(System.getProperty("load.iterations"));
  int delay = Integer.parseInt(System.getProperty("load.delay"));
  
  System.out.println("PackageID: " + packageID);
  System.out.println("Users: " + users);
  System.out.println("Iterations: " + iterations);
  System.out.println("Delay: " + delay);

  // create a test suite
  TestSuite suite = new TestSuite("LoadTest for " + packageID + " with "
          + users + " users and " + iterations
          + " iterations");

  // prepare the environment for the tests - establish
  // all resources required to create a process in addition
  // to once create a process in order to load the required
  // java classes
  suite.addTest(new GenericTest("prepareForCreateProcess",
              packageID));
  suite.addTest(new GenericTest("createProcess", packageID));

  Timer timer = new ConstantTimer(delay);
  suite.addTest(new LoadTest(new GenericTest("createProcess",
               packageID),
           users, iterations, timer));
  suite.addTest(new LoadTest(new GenericTest("createAndStartProcess",
               packageID),
           users, iterations, timer));
  suite.addTest(GenericTest.cleaningSuite());
  return new EJBClientTest (plc, suite);
    }

}
TOP

Related Classes of load.InteractiveInvoker

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.