I do not have any interface (I can not change it), I want it to be
Fake mockedClass = Fake (ObjectExample.class, "returnObject", new class [] {java.lang.Integer, java.lang.Integer}, new object [] (1,9001)); This object has been junked successfully, and on debugging I can see that the parameters are being set up successfully, my question is how can I use this said object; for example, after the code I Sub in How to return the object returnOnject to the person, and to neutralize the call on this object Edit: I will send the JMP to CGLIB I'm experimenting with
If I were you, I would not use jMock outside of a unit test A proxy framework such as seaglib or javaistist can directly create a proxy for ObjectExample , which is basically a subclass of this mocked class Represents. Then you can use this subclass object in the form of the ObjectExample . Here is an example of how you can create a proxy with cglib:
@Test public invalid testMethodInterceptor () throws an exception {Enhancer enhancer = new Enhancer (); Enhancer.setSuperclass (ObjectExample.class); Enhancer.setCallback (new method interceptor) throws thrrowable {override public object blocker (object obj, method method, object [args, methodProxy proxy] (if (method.getName (.) Equals ("returnObject")) / Add your proxy logic here.} Else {Proxy in Vocusuper (Oz, Args);}}}); ObjectExample Proxy = (ObjectExample) enhancer.create (); }
No comments:
Post a Comment