org.jvnet.hudson.test
Class RunLoadCounter

java.lang.Object
  extended by org.jvnet.hudson.test.RunLoadCounter

public final class RunLoadCounter
extends Object

Utility to determine when a build record is loaded.

Since:
1.517

Nested Class Summary
static class RunLoadCounter.Marker
          Used internally.
static class RunLoadCounter.MarkerAdder
          Used internally.
 
Method Summary
static
<T> T
assertMaxLoads(hudson.model.AbstractProject<?,?> project, int max, Callable<T> thunk)
          Asserts that at most a certain number of build records are loaded as a result of some task.
static int countLoads(hudson.model.AbstractProject<?,?> project, Runnable thunk)
          Counts how many build records are loaded as a result of some task.
static void prepare(hudson.model.AbstractProject<?,?> project)
          Prepares a new project to be measured.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

prepare

public static void prepare(hudson.model.AbstractProject<?,?> project)
                    throws IOException
Prepares a new project to be measured. Usually called before starting builds, but may also be called retroactively.

Parameters:
project - a project of any kind
Throws:
IOException - if preparations fail

countLoads

public static int countLoads(hudson.model.AbstractProject<?,?> project,
                             Runnable thunk)
Counts how many build records are loaded as a result of some task.

Parameters:
project - a project on which prepare(hudson.model.AbstractProject) was called prior to creating builds
thunk - a task which is expected to load some build records
Returns:
how many build records were actually loaded as a result

assertMaxLoads

public static <T> T assertMaxLoads(hudson.model.AbstractProject<?,?> project,
                                   int max,
                                   Callable<T> thunk)
                        throws Exception
Asserts that at most a certain number of build records are loaded as a result of some task.

Type Parameters:
T - the return value type
Parameters:
project - a project on which prepare(hudson.model.AbstractProject) was called prior to creating builds
max - the maximum number of build records we expect to load
thunk - a task which is expected to load some build records
Returns:
the result of the task, if any
Throws:
Exception - if the task failed
AssertionError - if one more than max build record is loaded


Copyright © 2004-2014. All Rights Reserved.