use of org.jaffa.rules.jbossaop.interceptors.InitializeInterceptor in project jaffa-framework by jaffa-projects.
the class FieldInitializerTest method testInterceptor.
/**
* Tests the interceptor based initializer
*/
@Test
public void testInterceptor() throws Throwable {
TestModel testModel = new TestModel();
AbstractRuleInterceptor interceptor = new InitializeInterceptor();
interceptor.setTargetClassName(testModel.getClass().getName());
// this has to be a valid method, in production code it would be the constructor
Method method = TestModel.class.getMethod("validate");
MethodInvocation invocation = new MethodInvocation(new Interceptor[0], 0, method, method, null);
invocation.setTargetObject(testModel);
assertNull(testModel.getField1());
interceptor.invoke(invocation);
assertEquals(FIELD1_INIT_VALUE, testModel.getField1());
}
Aggregations