:
Java 1.7 Java 1.6, TestNG jMockit 1.5 1.16, in-method MockUp <... > .
:
public class MyCache extends AbstractLazyCache<ExchangeObject> {...}
:
public abstract class AbstractLazyCache<CachedObject> extends AbstractCache {
protected void putCachedObject(String tenantId, String objectId, CachedObject o, Date expiryDate) {...}
}
:
new MockUp<MyCache>() {
@Mock(invocations = 2)
public void putCachedObject(Invocation inv, String tenantId, String objectId,
RangeExchange o, Date expiryDate) {
inv.proceed(tenantId, objectId, o, new Date(System.currentTimeMillis() + waitTimeMillis));
}
};
. , , , :
new MockUp<MyCache>() {
@Mock(invocations = 2)
public <RangeExchange> void putCachedObject(Invocation inv, String tenantId, String objectId,
RangeExchange o, Date expiryDate) {
inv.proceed(tenantId, objectId, o, new Date(System.currentTimeMillis() + waitTimeMillis));
}
};