ReflectionOptimizerTestpublic class ReflectionOptimizerTest extends org.hibernate.junit.UnitTestCase
Constructors Summary |
---|
public ReflectionOptimizerTest(String string)
super( string );
|
Methods Summary |
---|
private void | assertEquivalent(java.lang.Object[] checkValues, java.lang.Object[] values)
assertEquals( "Different lengths", checkValues.length, values.length );
for ( int i = 0; i < checkValues.length; i++ ) {
assertEquals( "different values at index [" + i + "]", checkValues[i], values[i] );
}
| public static junit.framework.TestSuite | suite()
return new TestSuite( ReflectionOptimizerTest.class );
| public void | testReflectionOptimization()
BytecodeProviderImpl provider = new BytecodeProviderImpl();
ReflectionOptimizer optimizer = provider.getReflectionOptimizer(
Bean.class,
BeanReflectionHelper.getGetterNames(),
BeanReflectionHelper.getSetterNames(),
BeanReflectionHelper.getTypes()
);
assertNotNull( optimizer );
assertNotNull( optimizer.getInstantiationOptimizer() );
assertNotNull( optimizer.getAccessOptimizer() );
Object instance = optimizer.getInstantiationOptimizer().newInstance();
assertEquals( instance.getClass(), Bean.class );
Bean bean = ( Bean ) instance;
optimizer.getAccessOptimizer().setPropertyValues( bean, BeanReflectionHelper.TEST_VALUES );
assertEquals( bean.getSomeString(), BeanReflectionHelper.TEST_VALUES[0] );
Object[] values = optimizer.getAccessOptimizer().getPropertyValues( bean );
assertEquivalent( values, BeanReflectionHelper.TEST_VALUES );
|
|