nl.lxtreme.ols.test
Class Ensure

java.lang.Object
  extended by nl.lxtreme.ols.test.Ensure

public class Ensure
extends Object

Helper class to make sure that steps in a test happen in the correct order. Instantiate this class and subsequently invoke step(nr) with steps starting at 1. You can also have threads wait until you arrive at a certain step.

Taken from Apache Felix Dependency Manager. (C) Copyright 2010-11 Apache Felix Project.


Constructor Summary
Ensure()
          Creates a new Ensure object.
Ensure(boolean aDebug)
          Creates a new Ensure object.
 
Method Summary
static Runnable createRunnableStep(Ensure aEnsure, int aNr)
          Factory method to create a runnable step that steps to the given number.
 void setStream(PrintStream aOutput)
          Sets the output stream for printing the results of steps to.
 void step()
          Mark this point as the next step.
 void step(int aNr)
          Mark this point as step nr.
 void waitForStep(int aNr, int aTimeout)
          Wait until we arrive at least at step nr in the process, or fail if that takes more than timeout milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ensure

public Ensure()
Creates a new Ensure object.


Ensure

public Ensure(boolean aDebug)
Creates a new Ensure object.

Parameters:
aDebug - true to output more information about the steps this class enters/waits for, false otherwise.
Method Detail

createRunnableStep

public static Runnable createRunnableStep(Ensure aEnsure,
                                          int aNr)
Factory method to create a runnable step that steps to the given number.

Parameters:
aEnsure - the ensure class to use for setting the step;
aNr - the number to set upon invoking the returned runnable.
Returns:
a runnable setting the ensured step.

setStream

public void setStream(PrintStream aOutput)
Sets the output stream for printing the results of steps to.

Parameters:
aOutput - the print stream to set, cannot be null.
Throws:
IllegalArgumentException - in case the given stream was null.

step

public void step()
Mark this point as the next step.


step

public void step(int aNr)
Mark this point as step nr.

Parameters:
aNr - the step we are in.

waitForStep

public void waitForStep(int aNr,
                        int aTimeout)
Wait until we arrive at least at step nr in the process, or fail if that takes more than timeout milliseconds. If you invoke wait on a thread, you are effectively assuming some other thread will invoke the step(nr) method.

Parameters:
aNr - the step to wait for
aTimeout - the number of milliseconds to wait
Throws:
IllegalStateException - in case current step isn't the step we expected.


Copyright © 2012 L'Xtreme IT consultancy. All Rights Reserved.