Use mockito

This commit is contained in:
OHTAKE Tomohiro committed 2011-10-24 23:26:37 +09:00
1 parent 47f70c0f59
commit eca11dfcfc
2 files changed
+11 -15

No files matched your search

+6 -15
View File
@@ -28,29 +28,20 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import static org.mockito.Mockito.*;
public class FunctionsTest {
@Test
@Bug(7725)
public void testGetActionUrl_mailto(){
String mailto = "mailto:nobody@example.com";
String result = Functions.getActionUrl(null, new MockAction(mailto));
String result = Functions.getActionUrl(null, createMockAction(mailto));
assertEquals(mailto, result);
}
private static final class MockAction implements Action {
private String url;
public MockAction(String url) {
this.url = url;
}
public String getIconFileName() {
throw new UnsupportedOperationException("Not supported yet.");
}
public String getDisplayName() {
throw new UnsupportedOperationException("Not supported yet.");
}
public String getUrlName() {
return url;
}
private static Action createMockAction(String uri) {
Action action = mock(Action.class);
when(action.getUrlName()).thenReturn(uri);
return action;
}
}