will_hunting will_hunting - 6 months ago 87
Java Question

How can I replace deprecated method Mockit.setUpMock?

I have some code, which is using old version of jmockit library. I find out that setUpMock method of Mockit class is deprecated, but I cann't find on Jmockit API documentation explanation, how can I replace code like below.

public void updateWithBadRownum() throws Exception
Mockit.setUpMock(Tool.class, new MockTool()); //It doesn't support on latest version of jmockit
Mockit.setUpMock(Criteria.class, new MockCriteria());
new TaskInitializer().populateSchemas(cnn, 10);
Map parameters = new HashMap();
parameters.put("ROWNUM", "abc");
Assert.assertTrue(4 == StatusUpdaterImpl.execute(parameters));


Use Mockup

new MockUp<Tool>() {
    @Mock int someMethod(int i) { assertTrue(i > 0); return 123; }