Thursday, May 16, 2013
Mocking a Static Method
import the following:
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
Add the following annotations to the class:
@RunWith(PowerMockRunner.class)
@PrepareForTest(Static_Class.class)
public class ClassNameTest
And mock the class with the following Code.
PowerMock.mockStatic(Static_Class.class);
expect(
StaticClass.Static_Method(params)
.andReturn(mockObject);
PowerMock.expectLastCall().atLeastOnce();
PowerMock.replayAll();
Wednesday, May 8, 2013
Use of @Override annotation JDK 1.5 vs JDK 1.6
The JDK version 1.5 doesn't require the Implementing class for an Interface to use @Override annotation for the implemented methods.
Usually when eclipse has the settings to run on JDK 1.6, it adds @Override annotation, as JDK 1.6 allows the use of @Override annotation even for implemented methods from an interface.
Its documented well here.
http://stackoverflow.com/questions/2335655/why-is-javac-failing-on-override-annotation
Subscribe to:
Posts (Atom)