001: /*
002: * This file is part of the WfMOpen project.
003: * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
004: * All rights reserved.
005: *
006: * This program is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published by
008: * the Free Software Foundation; either version 2 of the License, or
009: * (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * $Id: InteractiveInvoker.java,v 1.2 2006/09/29 12:32:07 drmlipp Exp $
021: *
022: * $Log: InteractiveInvoker.java,v $
023: * Revision 1.2 2006/09/29 12:32:07 drmlipp
024: * Consistently using WfMOpen as projct name now.
025: *
026: * Revision 1.1.1.1 2003/12/19 13:01:45 drmlipp
027: * Updated to 1.1rc1
028: *
029: * Revision 1.3 2003/10/30 16:22:51 weidauer
030: * added cleaning suite
031: *
032: * Revision 1.2 2003/10/22 16:10:06 weidauer
033: * initial version
034: *
035: */
036:
037: package load;
038:
039: import junit.framework.Test;
040: import junit.framework.TestSuite;
041:
042: import com.clarkware.junitperf.LoadTest;
043: import com.clarkware.junitperf.ConstantTimer;
044: import com.clarkware.junitperf.Timer;
045:
046: import javax.security.auth.login.LoginException;
047:
048: import common.STProjectLoginContext;
049: import de.danet.an.util.junit.EJBClientTest;
050:
051: /**
052: * Enables interactive invocation of <code>GenericTest</code>s by using
053: * JUnitPerf´s features. <br>
054: * Using the system properties load.packageID, load.users, load.delay and
055: * load.iterations the process P0 of the defined package (file) can be load
056: * tested for a defined number of users and iterations. Additionally a delay
057: * for starting the users can be defined.<br>
058: * This interactive invocation is supported by the build file in this
059: * directory.<br>
060: * E. g.: ant -DpackageID=A5naaT4par -Dusers=4 -Diterations=20 -Ddelay=5 invoke<br>
061: * Defaults are defined by the build file.
062: *
063: * @author <a href="mailto:weidauer@danet.de">Christian Weidauer</a>
064: * @author <a href="http://www.danet.de">Danet GmbH</a>
065: *
066: */
067:
068: public class InteractiveInvoker {
069:
070: protected static STProjectLoginContext plc = null;
071: static {
072: try {
073: plc = new STProjectLoginContext();
074: plc.login();
075: } catch (LoginException e) {
076: throw new IllegalStateException(e.getMessage());
077: }
078: }
079:
080: /**
081: * Assemble the test suite.
082: * @return the test suite
083: */
084: public static Test suite() {
085:
086: String packageID = System.getProperty("load.packageID");
087: int users = Integer.parseInt(System.getProperty("load.users"));
088: int iterations = Integer.parseInt(System
089: .getProperty("load.iterations"));
090: int delay = Integer.parseInt(System.getProperty("load.delay"));
091:
092: System.out.println("PackageID: " + packageID);
093: System.out.println("Users: " + users);
094: System.out.println("Iterations: " + iterations);
095: System.out.println("Delay: " + delay);
096:
097: // create a test suite
098: TestSuite suite = new TestSuite("LoadTest for " + packageID
099: + " with " + users + " users and " + iterations
100: + " iterations");
101:
102: // prepare the environment for the tests - establish
103: // all resources required to create a process in addition
104: // to once create a process in order to load the required
105: // java classes
106: suite.addTest(new GenericTest("prepareForCreateProcess",
107: packageID));
108: suite.addTest(new GenericTest("createProcess", packageID));
109:
110: Timer timer = new ConstantTimer(delay);
111: suite.addTest(new LoadTest(new GenericTest("createProcess",
112: packageID), users, iterations, timer));
113: suite.addTest(new LoadTest(new GenericTest(
114: "createAndStartProcess", packageID), users, iterations,
115: timer));
116: suite.addTest(GenericTest.cleaningSuite());
117: return new EJBClientTest(plc, suite);
118: }
119:
120: }
|