提交 eca11dfc 编写于 作者: O OHTAKE Tomohiro

Use mockito

上级 47f70c0f
......@@ -425,6 +425,11 @@ THE SOFTWARE.
<artifactId>junit-dep</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency><!-- needed by Jelly -->
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
......
......@@ -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;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册