diff --git a/core/pom.xml b/core/pom.xml index 1629e4c5aa2e46ed23372eb0349cec342b2f7d81..afffdfa3f043ac744fe411961965ec88d22bd9cf 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -425,6 +425,11 @@ THE SOFTWARE. junit-dep test + + org.mockito + mockito-core + test + javax.servlet jstl diff --git a/core/src/test/java/hudson/FunctionsTest.java b/core/src/test/java/hudson/FunctionsTest.java index 42c57bca81add9675efeb37e9bc77e38792190d4..b3c6fb4e78952d37960482c3b538543d95d73234 100644 --- a/core/src/test/java/hudson/FunctionsTest.java +++ b/core/src/test/java/hudson/FunctionsTest.java @@ -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; } }