java - Reflection for testNG -
i have method uses restrict access via spring security. following method :
@preauthorize("isauthenticated() , haspermission(#request, 'create_requisition')") @requestmapping(method = requestmethod.post, value = "/trade/createrequisition") public @responsebody void createrequisition(@requestbody createrequisitionro[] request, @requestheader("validateonly") boolean validateonly) { logger.debug("starting createrequisition()..."); (int = 0; < request.length; i++) { createrequisitionro requisitionrequest = request[i]; // fixme has removed/moved requisitionrequest.setfundmanager(requisitionrequest.getuserid()); // fixme might have search using param level systemdefault sysdefault = dbfuncs.references.systemdefault .findbycompanyanddivisionandportfolio( usercontext.getcompany(), usercontext.getdivision(), requisitionrequest.getportfolio()); requisitionrequest.setcustodiann(sysdefault.getcustodiann()); gatekeeper.route(requisitionrequest); } }
now want use java reflection @ run time test whether method working fine unit testing.
i have tried write testng above not working due project architecture have , hence decided use reflection test [though not way of doing , later find solution this]
.
my question how create java reflection class method , call above method , send url /trade/createrequisition
server whether accessible logged in user.
how this.
if want check if security annotation added on method in unit test case using java reflection api can that.
find method using reflection , on check method.getannotation(preauthorize.class)
but should test integration/functional testing.
Comments
Post a Comment