Java Doc for LoadTest.java in  » Testing » JUnitPerf » com » clarkware » junitperf » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » JUnitPerf » com.clarkware.junitperf 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.clarkware.junitperf.LoadTest

LoadTest
public class LoadTest implements Test(Code)
The LoadTest is a test decorator that runs a test with a simulated number of concurrent users and iterations.

In its simplest form, a LoadTest is constructed with a test to decorate and the number of concurrent users.

For example, to create a load test of 10 concurrent users with each user running ExampleTest once and all users started simultaneously, use:

 Test loadTest = new LoadTest(new TestSuite(ExampleTest.class), 10);
 
or, to load test a single test method, use:
 Test loadTest = new LoadTest(new ExampleTest("testSomething"), 10);
 

The load can be ramped by specifying a pluggable Timer instance which prescribes the delay between the addition of each concurrent user. A ConstantTimer has a constant delay, with a zero value indicating that all users will be started simultaneously. A RandomTimer has a random delay with a uniformly distributed variation.

For example, to create a load test of 10 concurrent users with each user running ExampleTest.testSomething() once and with a one second delay between the addition of users, use:

 Timer timer = new ConstantTimer(1000);
 Test loadTest = new LoadTest(new ExampleTest("testSomething"), 10, timer);
 

In order to simulate each concurrent user running a test for a specified number of iterations, a LoadTest can be constructed to decorate a RepeatedTest. Alternatively, a LoadTest convenience constructor specifying the number of iterations is provided which creates a RepeatedTest.

For example, to create a load test of 10 concurrent users with each user running ExampleTest.testSomething() for 20 iterations, and with a one second delay between the addition of users, use:

 Timer timer = new ConstantTimer(1000);
 Test repeatedTest = new RepeatedTest(new ExampleTest("testSomething"), 20);
 Test loadTest = new LoadTest(repeatedTest, 10, timer);
 
or, alternatively, use:
 Timer timer = new ConstantTimer(1000);
 Test loadTest = new LoadTest(new ExampleTest("testSomething"), 10, 20, timer);
 
A LoadTest can be decorated as a TimedTest to test the elapsed time of the load test. For example, to decorate the load test constructed above as a timed test with a maximum elapsed time of 2 seconds, use:
 Test timedTest = new TimedTest(loadTest, 2000);
 

By default, a LoadTest does not enforce test atomicity (as defined in transaction processing) if its decorated test spawns threads, either directly or indirectly. In other words, if a decorated test spawns a thread and then returns control without waiting for its spawned thread to complete, then the test is assumed to be transactionally complete.

If threads are integral to the successful completion of a decorated test, meaning that the decorated test should not be treated as complete until all of its threads complete, then setEnforceTestAtomicity(true) should be invoked to enforce test atomicity. This effectively causes the load test to wait for the completion of all threads belonging to the same ThreadGroup as the thread running the decorated test.


author:
   Mike Clark
author:
   Clarkware Consulting, Inc.
author:
   Ervin Varga



Constructor Summary
public  LoadTest(Test test, int users)
     Constructs a LoadTest to decorate the specified test using the specified number of concurrent users starting simultaneously.
public  LoadTest(Test test, int users, int iterations)
     Constructs a LoadTest to decorate the specified test using the specified number of concurrent users starting simultaneously and the number of iterations per user.
public  LoadTest(Test test, int users, int iterations, Timer timer)
     Constructs a LoadTest to decorate the specified test using the specified number of concurrent users, number of iterations per user, and delay timer.
public  LoadTest(Test test, int users, Timer timer)
     Constructs a LoadTest to decorate the specified test using the specified number of concurrent users and delay timer.

Method Summary
protected  voidcleanup()
    
public  intcountTestCases()
     Returns the number of tests in this load test.
protected  longgetDelay()
    
public  voidrun(TestResult result)
     Runs the test.
public  voidsetEnforceTestAtomicity(boolean isAtomic)
     Indicates whether test atomicity should be enforced.

If threads are integral to the successful completion of a decorated test, meaning that the decorated test should not be treated as complete until all of its threads complete, then setEnforceTestAtomicity(true) should be invoked to enforce test atomicity.

protected  voidsleep(long time)
    
public  StringtoString()
    
protected  voidwaitForAllThreadsToComplete()
    
protected  voidwaitForTestCompletion()
    
protected  voidwaitForThreadedTestThreadsToComplete()
    


Constructor Detail
LoadTest
public LoadTest(Test test, int users)(Code)
Constructs a LoadTest to decorate the specified test using the specified number of concurrent users starting simultaneously.
Parameters:
  test - Test to decorate.
Parameters:
  users - Number of concurrent users.



LoadTest
public LoadTest(Test test, int users, int iterations)(Code)
Constructs a LoadTest to decorate the specified test using the specified number of concurrent users starting simultaneously and the number of iterations per user.
Parameters:
  test - Test to decorate.
Parameters:
  users - Number of concurrent users.
Parameters:
  iterations - Number of iterations per user.



LoadTest
public LoadTest(Test test, int users, int iterations, Timer timer)(Code)
Constructs a LoadTest to decorate the specified test using the specified number of concurrent users, number of iterations per user, and delay timer.
Parameters:
  test - Test to decorate.
Parameters:
  users - Number of concurrent users.
Parameters:
  iterations - Number of iterations per user.
Parameters:
  timer - Delay timer.



LoadTest
public LoadTest(Test test, int users, Timer timer)(Code)
Constructs a LoadTest to decorate the specified test using the specified number of concurrent users and delay timer.
Parameters:
  test - Test to decorate.
Parameters:
  users - Number of concurrent users.
Parameters:
  timer - Delay timer.




Method Detail
cleanup
protected void cleanup()(Code)



countTestCases
public int countTestCases()(Code)
Returns the number of tests in this load test. Number of tests.



getDelay
protected long getDelay()(Code)



run
public void run(TestResult result)(Code)
Runs the test.
Parameters:
  result - Test result.



setEnforceTestAtomicity
public void setEnforceTestAtomicity(boolean isAtomic)(Code)
Indicates whether test atomicity should be enforced.

If threads are integral to the successful completion of a decorated test, meaning that the decorated test should not be treated as complete until all of its threads complete, then setEnforceTestAtomicity(true) should be invoked to enforce test atomicity. This effectively causes the load test to wait for the completion of all threads belonging to the same ThreadGroup as the thread running the decorated test.
Parameters:
  isAtomic - true to enforce test atomicity;false otherwise.




sleep
protected void sleep(long time)(Code)



toString
public String toString()(Code)



waitForAllThreadsToComplete
protected void waitForAllThreadsToComplete()(Code)



waitForTestCompletion
protected void waitForTestCompletion()(Code)



waitForThreadedTestThreadsToComplete
protected void waitForThreadedTestThreadsToComplete()(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.