audit4j / audit4j-core

An open source auditing framework.
http://audit4j.org
Apache License 2.0
126 stars 76 forks source link

I've done several test cases and found incorrect behavior in annotation's work #17

Closed msamichev closed 8 years ago

msamichev commented 8 years ago

Hi

I've done several test cases and found incorrect behavior in annotation work:

Description: I have one interface UserService and one implementation UserServiceImpl

Test1 - Set @Audit on interface level. Result1 - not works at all.

Test2 - Set @Audit on class level. Result2 - works correct.

Test3 - Set @Audit on class level and @IgnorAudit on special method. Result3 - works incorrect, all methods are audited.

Test4 Set @Audit on method level in the class. Result4 - not works at all.

Test5 Set @Audit on method level in interface. Result5 - not works at all.

Test6 Set @Audit on method level in interface and class in the same time. Result6 - works correct.

janithb commented 8 years ago

Hi @msamichev

I will check on this and let you know by tomorrow.

janithb commented 8 years ago

Fixed the issue. There wasn't an error in annotation processing logic. There was an issue in spring aspect which returns the wrong class and method.

Use annotations only for the implementation.

Issue is fixed in audit4j-spring-2.4.0-alpha4 and which is available maven central. please upgrade.

msamichev commented 8 years ago

Works fine, thanks.

Are you planning to make possibility to use @audit annotation in interface?

janithb commented 8 years ago

I would encourage to use annotations in implementations since if there are more than one implementation for particular interface, annotations are applied for all the implementations.

Is there any use case to use annotations in interface?

msamichev commented 8 years ago

Maybe you are right, but for example you can have common interface for all services with CRUD methods and easiest way to switch on audit it put @Audit into interface.