Skip to content

Commit

Permalink
Fix user issue by adding AuditService as @component
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeams committed Nov 23, 2011
1 parent fb6e5af commit ad27d43
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

public class AuditAspectTests extends BaseTestClass
{
@Autowired
private IAuditRepository auditRepository;

@Autowired
private AuditService service;

@Test
public void testAudit()
{
AuditService service = new AuditService();
// make sure call IS NOT audited
service.unAuditedCall();
assertThat(auditRepository.count(), CoreMatchers.is(0L));
Expand All @@ -26,6 +29,9 @@ public void testAudit()
assertThat(auditRepository.count(), CoreMatchers.is(1L));
}

}

@Component
class AuditService
{
@Auditable(actionCode = "auditedCall", auditMessage = "value returned was %r%")
Expand All @@ -39,4 +45,3 @@ public String unAuditedCall()
return "current time is " + new Date();
}
}
}

0 comments on commit ad27d43

Please sign in to comment.