单元测试--测试HTTP服务

来源:互联网 发布:网络大学专升本 编辑:程序博客网 时间:2024/06/01 15:12

@Rule
public WireMockRule wireMockRule = new WireMockRule(8500);

@Beforepublic void setUp() throws IOException {    wireMockRule.resetMappings();    stubFor(get(urlEqualTo("/service/test_service?source=%E4%BD%A0%E5%A5%BD"))            .willReturn(aResponse().withBody("mock response here")));}@Testpublic void romanize() throws Exception {    RomanizationUtils romanizationUtils = new RomanizationUtils("http://localhost:8500/service/test_service?source=", 3);    assertEquals("mock response here", romanizationUtils.romanize("你好"));}
原创粉丝点击