assertNotNull( reader.getAnnotation( OrderBy.class ) );
assertEquals( "maxSpeed", reader.getAnnotation( OrderBy.class ).value() );
}
public void testEntityListeners() throws Exception {
XMLContext context = buildContext( "org/hibernate/test/annotations/reflection/orm.xml" );
Method method = Administration.class.getDeclaredMethod( "calculate" );
JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader( method, context );
assertTrue( reader.isAnnotationPresent( PrePersist.class ) );
reader = new JPAOverridenAnnotationReader( Administration.class, context );
assertTrue( reader.isAnnotationPresent( EntityListeners.class ) );
assertEquals( 1, reader.getAnnotation( EntityListeners.class ).value().length );
assertEquals( LogListener.class, reader.getAnnotation( EntityListeners.class ).value()[0] );
method = LogListener.class.getDeclaredMethod( "noLog", Object.class );
reader = new JPAOverridenAnnotationReader( method, context );
assertTrue( reader.isAnnotationPresent( PostLoad.class ) );
method = LogListener.class.getDeclaredMethod( "log", Object.class );
reader = new JPAOverridenAnnotationReader( method, context );
assertTrue( reader.isAnnotationPresent( PrePersist.class ) );
assertFalse( reader.isAnnotationPresent( PostPersist.class ) );
assertEquals( 1, context.getDefaultEntityListeners().size() );
assertEquals( OtherLogListener.class.getName(), context.getDefaultEntityListeners().get( 0 ) );
}