java - Using AspectJ to replace third party objects with mocks in Unit Tests -
i'm writing web services client using spring-ws , webservicetemplate class. down in bowls of webservicetemplate class, webserviceconnection created. webserviceconnection.send used send message. i'd intercept call webserviceconnection.send , replace logic examines object passed webserviceconnetion.send.
it strikes me place use aspects. however, i'm not sure how can have aspects run when i'm executing unit tests. have different aspects run based on tests i'm executing.
anyone have ideas on how this?
you can use runtime weaving aspectj. don't have compile aspects yout app, enought include them when testing.
since there has meta-inf/aop.xml on classpath when using aspectj, , since have start jvm -agent:mypath/aspectjweaver.jar, have tools @ hand use aspectj when testing.
oh, , if use aspectj compile app, can still use additional aspects when testing if combine runtime weaving , compile time weaving.
Comments
Post a Comment