org.apache.jackrabbit.oak.performance
Class AbstractTest

java.lang.Object
  extended by org.apache.jackrabbit.oak.performance.AbstractTest
Direct Known Subclasses:
ConcurrentReadTest, CreateManyChildNodesTest, DescendantSearchTest, LoginLogoutTest, LoginTest, ReadPropertyTest, SetPropertyTest, SimpleSearchTest, SmallFileReadTest, SmallFileWriteTest, TransientManyChildNodesTest, UpdateManyChildNodesTest

public abstract class AbstractTest
extends Object

Abstract base class for individual performance benchmarks.


Constructor Summary
AbstractTest()
           
 
Method Summary
protected  void addBackgroundJob(Runnable job)
          Adds a background thread that repeatedly executes the given job until all the iterations of this test have been executed.
protected  void afterSuite()
          Run after all iterations of this test have been executed.
protected  void afterTest()
           
protected  void beforeSuite()
          Run before any iterations of this test get executed.
protected  void beforeTest()
           
 long execute()
          Executes a single iteration of this test.
protected  void failOnRepositoryVersions(String... versions)
           
protected  javax.jcr.Credentials getCredentials()
           
protected  javax.jcr.Repository getRepository()
           
protected static int getScale(int def)
           
protected  javax.jcr.Session loginReader()
          Returns a new reader session that will be automatically closed once all the iterations of this test have been executed.
protected  javax.jcr.Session loginWriter()
          Returns a new writer session that will be automatically closed once all the iterations of this test have been executed.
protected abstract  void runTest()
           
 void setUp(javax.jcr.Repository repository, javax.jcr.Credentials credentials)
          Prepares this performance benchmark.
 void tearDown()
          Cleans up after this performance benchmark.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractTest

public AbstractTest()
Method Detail

getScale

protected static int getScale(int def)

setUp

public void setUp(javax.jcr.Repository repository,
                  javax.jcr.Credentials credentials)
           throws Exception
Prepares this performance benchmark.

Parameters:
repository - the repository to use
credentials - credentials of a user with write access
Throws:
Exception - if the benchmark can not be prepared

execute

public long execute()
             throws Exception
Executes a single iteration of this test.

Returns:
number of milliseconds spent in this iteration
Throws:
Exception - if an error occurs

tearDown

public void tearDown()
              throws Exception
Cleans up after this performance benchmark.

Throws:
Exception - if the benchmark can not be cleaned up

beforeSuite

protected void beforeSuite()
                    throws Exception
Run before any iterations of this test get executed. Subclasses can override this method to set up static test content.

Throws:
Exception - if an error occurs

beforeTest

protected void beforeTest()
                   throws Exception
Throws:
Exception

runTest

protected abstract void runTest()
                         throws Exception
Throws:
Exception

afterTest

protected void afterTest()
                  throws Exception
Throws:
Exception

afterSuite

protected void afterSuite()
                   throws Exception
Run after all iterations of this test have been executed. Subclasses can override this method to clean up static test content.

Throws:
Exception - if an error occurs

failOnRepositoryVersions

protected void failOnRepositoryVersions(String... versions)
                                 throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

getRepository

protected javax.jcr.Repository getRepository()

getCredentials

protected javax.jcr.Credentials getCredentials()

loginReader

protected javax.jcr.Session loginReader()
Returns a new reader session that will be automatically closed once all the iterations of this test have been executed.

Returns:
reader session

loginWriter

protected javax.jcr.Session loginWriter()
Returns a new writer session that will be automatically closed once all the iterations of this test have been executed.

Returns:
writer session

addBackgroundJob

protected void addBackgroundJob(Runnable job)
Adds a background thread that repeatedly executes the given job until all the iterations of this test have been executed.

Parameters:
job - background job

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.