我有一个平针织网络服务。我想为它编写测试用例。 我的服务是
@Path(value = "/mock")
@Component
public class MockService
{
private static Log log = LogFactory.getLog(MockService.class);
@POST
@Path(value = "/{mockrequest:ABCD}")
@Produces(MediaType.JSON)
public Response mockOKResponse(@Context ContainerRequestContext request, @PathParam("mockrequest") EnumMockService mockService)
{
return Response.ok().build();
}
@GET
@Path(value = "/{mockrequest}")
@Produces("application/pdf")
public Response mockProducesPDF(@Context ContainerRequestContext request, @PathParam("mockrequest") EnumMockService mockService)
{
MockAccountTable testccount = jdbcTestAcountDao.getTestAccountResponseBlob(mockService.toString());
byte[] responseBlob = testccount != null ? testccount.getResponseBlob() : null;
return Response.ok(responseBlob).build();
}
}
我打算为此编写测试用例。它根据特定的reuest调用特定的方法。
@RunWith(MockitoJUnitRunner.class)
public class TestMockService
extends TestCaseSrs
{
private MockService mockService = new MockService();
@Override
@Before
public void prepare()
throws Exception
{
MockitoAnnotations.initMocks(this);
}
@Test
public void testGetIncreasedHardwares()
{
//dynamically call method based on request
}
}
我不知道如何在此处设置请求类型以相应地调用方法,而不是直接调用方法。
如果有人可以帮我解决这个问题,那将会很棒。