com.google.testing.threadtester
Class Instrumentation<T>

java.lang.Object
  extended by com.google.testing.threadtester.Instrumentation<T>
Type Parameters:
T - the class being instrumented

public class Instrumentation<T>
extends Object

Factory for obtaining instrumented classes and objects. In order for instrumentation to be enabled, the classes must have been loaded via a special classloader, so that the necessary data can be added to the class' bytecode. The easiest way to do this is to run all tests via a threaded test runner.

Author:
alasdair.mackintosh@gmail.com (Alasdair Mackintosh)
See Also:
ClassInstrumentation, ObjectInstrumentation, BaseThreadedTestRunner, TestInstrumenter, InstrumentedClassLoader

Method Summary
static
<T> ClassInstrumentation
getClassInstrumentation(Class<T> clss)
          Returns the ClassInstrumentation corresponding to a given class.
static
<T> ClassInstrumentation
getClassInstrumentationForObject(T underlyingObject)
          Returns the ClassInstrumentation corresponding to the class of the given object.
static
<T> ClassInstrumentation
getNamedClassInstrumentation(String classname)
          Returns the ClassInstrumentation corresponding to a given classname.
static
<T> ObjectInstrumentation<T>
getObjectInstrumentation(T underlyingObject)
          Returns the ObjectInstrumentation corresponding to a given object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getObjectInstrumentation

public static <T> ObjectInstrumentation<T> getObjectInstrumentation(T underlyingObject)
Returns the ObjectInstrumentation corresponding to a given object. Note that this method always returns the same result for a given object - i.e. there is a one-to-one mapping from ObjectInstrumentation to underlying object.

Throws:
IllegalArgumentException - if the object's class has not been instrumented.

getClassInstrumentation

public static <T> ClassInstrumentation getClassInstrumentation(Class<T> clss)
Returns the ClassInstrumentation corresponding to a given class. Note that this method always returns the same result for a given class - i.e. there is a one-to-one mapping from a ClassInstrumentation to a class.

Throws:
IllegalArgumentException - if the class has not been instrumented.

getNamedClassInstrumentation

public static <T> ClassInstrumentation getNamedClassInstrumentation(String classname)
Returns the ClassInstrumentation corresponding to a given classname. Note that this method always returns the same result for a given class - i.e. there is a one-to-one mapping from ClassInstrumentation to class.

Throws:
IllegalArgumentException - if the class has not been instrumented.

getClassInstrumentationForObject

public static <T> ClassInstrumentation getClassInstrumentationForObject(T underlyingObject)
Returns the ClassInstrumentation corresponding to the class of the given object. Note that this method always returns the same result for a given class - i.e. there is a one-to-one mapping from ClassInstrumentation to class.

Throws:
IllegalArgumentException - if the class has not been instrumented.


Copyright © 2013. All Rights Reserved.