Anyone used this annotation in grails unit tests? Didnt seem to work for me. Thanks. D
Update: the last line of my test below does throw the expected exception. However the test fails (Stack trace too big for here...). I'm using grails 1.2 and running the test in eclipse's junit runner. Maybe grails is using an earlier version of junit than 4?
/**
* Get the EC by a manager of a different company. Should throw exception
*/
@ExpectedException(ServiceAuthorizationException.class)
void testGetEcByNonOwnerManagerOfDifferentCompany() {
mockDomain(ExpenseClaim , [new ExpenseClaim(id:"1",narrative:"marksClaim", employee:userMark, company:dereksCompany)])
def authControl = mockFor(AuthenticateService)
authControl.demand.userDomain(1..1) {-> otherUserMgr }
authControl.demand.ifAllGranted(1..1) {String arg1 -> return "ROLE_COMPANYMANAGER".equals(arg1) } //returns true
def testService = new ExpenseClaimService()
testService.authenticateService = authControl.createMock()
def thrown = false
testService.getExpenseClaim("1")
}