FileDocCategorySizeDatePackage
AbstractTransformingClassLoaderInstrumentTestCase.javaAPI DocHibernate 3.2.54037Tue Dec 12 16:22:26 GMT 2006org.hibernate.test.instrument.runtime

AbstractTransformingClassLoaderInstrumentTestCase

public abstract class AbstractTransformingClassLoaderInstrumentTestCase extends org.hibernate.junit.AbstractClassLoaderIsolatedTestCase
author
Steve Ebersole

Fields Summary
private static final Class[]
SIG
private static final Object[]
ARGS
Constructors Summary
public AbstractTransformingClassLoaderInstrumentTestCase(String string)

		super( string );
	
Methods Summary
protected abstract org.hibernate.bytecode.BytecodeProviderbuildBytecodeProvider()

protected java.lang.ClassLoaderbuildIsolatedClassLoader(java.lang.ClassLoader parent)

		BytecodeProvider provider = buildBytecodeProvider();
		return new InstrumentedClassLoader(
				parent,
				provider.getTransformer(
						new BasicClassFilter( new String[] { "org.hibernate.test.instrument" }, null ),
						new FieldFilter() {
							public boolean shouldInstrumentField(String className, String fieldName) {
								return className.startsWith( "org.hibernate.test.instrument.domain" );
							}
							public boolean shouldTransformFieldAccess(String transformingClassName, String fieldOwnerClassName, String fieldName) {
								return fieldOwnerClassName.startsWith( "org.hibernate.test.instrument.domain" )
										&& transformingClassName.equals( fieldOwnerClassName );
							}
						}
				)
		);

	
public voidexecuteExecutable(java.lang.String name)


	    
		Class execClass = null;
		Object executable = null;
		try {
			execClass = Thread.currentThread().getContextClassLoader().loadClass( name );
			executable = execClass.newInstance();
		}
		catch( Throwable t ) {
			throw new HibernateException( "could not load executable", t );
		}
		try {
			execClass.getMethod( "prepare", SIG ).invoke( executable, ARGS );
			execClass.getMethod( "execute", SIG ).invoke( executable, ARGS );
		}
		catch ( NoSuchMethodException e ) {
			throw new HibernateException( "could not exeucte executable", e );
		}
		catch ( IllegalAccessException e ) {
			throw new HibernateException( "could not exeucte executable", e );
		}
		catch ( InvocationTargetException e ) {
			throw new HibernateException( "could not exeucte executable", e.getTargetException() );
		}
		finally {
			try {
				execClass.getMethod( "complete", SIG ).invoke( executable, ARGS );
			}
			catch ( Throwable ignore ) {
			}
		}
	
protected voidreleaseIsolatedClassLoader(java.lang.ClassLoader isolatedLoader)

	
public voidtestDirtyCheck()

		executeExecutable( "org.hibernate.test.instrument.cases.TestDirtyCheckExecutable" );
	
public voidtestFetchAll()

		executeExecutable( "org.hibernate.test.instrument.cases.TestFetchAllExecutable" );
	
public voidtestLazy()

		executeExecutable( "org.hibernate.test.instrument.cases.TestLazyExecutable" );
	
public voidtestLazyManyToOne()

		executeExecutable( "org.hibernate.test.instrument.cases.TestLazyManyToOneExecutable" );
	
public voidtestLazyPropertyCustomType()

		executeExecutable( "org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable" );
	
public voidtestManyToOneProxy()

		executeExecutable( "org.hibernate.test.instrument.cases.TestManyToOneProxyExecutable" );
	
public voidtestPropertyInitialized()

		executeExecutable( "org.hibernate.test.instrument.cases.TestIsPropertyInitializedExecutable" );
	
public voidtestSetFieldInterceptor()

		executeExecutable( "org.hibernate.test.instrument.cases.TestInjectFieldInterceptorExecutable" );