本文整理汇总了Java中org.jboss.resteasy.mock.MockHttpResponse类的典型用法代码示例。如果您正苦于以下问题:Java MockHttpResponse类的具体用法?Java MockHttpResponse怎么用?Java MockHttpResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockHttpResponse类属于org.jboss.resteasy.mock包,在下文中一共展示了MockHttpResponse类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetOdmOpenEpic
import org.jboss.resteasy.mock.MockHttpResponse; //导入依赖的package包/类
@Test
public void testGetOdmOpenEpic() {
MockHttpRequest request = null;
try {
request = MockHttpRequest.get(
"/fhir/patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB/odm?project_id=29&instrument=usciit_prep_flu_study&group_id=2&encounter_start=2016-04-18&encounter_end=2016-04-20");
} catch (URISyntaxException e) {
fail(e.getMessage());
}
MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
assertTrue(response.getContentAsString().contains("Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB"));
}
示例2: testGetPatientHapi
import org.jboss.resteasy.mock.MockHttpResponse; //导入依赖的package包/类
@Test
public void testGetPatientHapi() {
MockHttpRequest request = null;
try {
request = MockHttpRequest.get("/fhir/patient/fhirTest?group_id=4");
//http://fhirtest.uhn.ca/baseDstu2/Patient?_id=fhirTest
} catch (URISyntaxException e) {
fail(e.getMessage());
}
MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
assertTrue(response.getContentAsString().contains("fhirTest"));
}
示例3: testGetPatientOpenEpic
import org.jboss.resteasy.mock.MockHttpResponse; //导入依赖的package包/类
@Test
public void testGetPatientOpenEpic() {
MockHttpRequest request = null;
try {
request = MockHttpRequest.get("/fhir/patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB?group_id=2");
//https://open-ic.epic.com/FHIR/api/FHIR/DSTU2/Patient?_id=Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB
} catch (URISyntaxException e) {
fail(e.getMessage());
}
MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
assertTrue(response.getContentAsString().contains("Argonaut, Jason"));
}
示例4: testGetOdmHapi
import org.jboss.resteasy.mock.MockHttpResponse; //导入依赖的package包/类
@Test
public void testGetOdmHapi() {
MockHttpRequest request = null;
try {
request = MockHttpRequest.get(
"/fhir/patient/fhirTest/odm?project_id=29&instrument=usciit_prep_flu_study&group_id=4&encounter_start=2016-05-29T09:00:00&encounter_end=2016-06-20");
} catch (URISyntaxException e) {
fail(e.getMessage());
}
MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
assertTrue(response.getContentAsString().contains("fhirTest"));
}
示例5: testSendingHttpRequest
import org.jboss.resteasy.mock.MockHttpResponse; //导入依赖的package包/类
@Test
public void testSendingHttpRequest() throws Exception {
MockHttpRequest request = MockHttpRequest.post("/rest").contentType(MediaType.APPLICATION_XML_TYPE);
MockHttpResponse response = new MockHttpResponse();
Person person = new Person();
person.setAge(25);
StringWriter writer = new StringWriter();
context.createMarshaller().marshal(person, writer);
request.content(writer.toString().getBytes());
dispatcher.invoke(request, response);
assertThat(response.getStatus(), is(Response.Status.OK.getStatusCode()));
assertThat(response.getContentAsString(), is("true"));
}
示例6: get
import org.jboss.resteasy.mock.MockHttpResponse; //导入依赖的package包/类
private ContentTypeHelper get(String uri, String acceptHeader) throws Exception {
MockHttpRequest req = MockHttpRequest.get(uri);
MockHttpResponse res = new MockHttpResponse();
RequestImpl restReq = new RequestImpl(req, res);
if (acceptHeader != null) {
req = req.header(HttpHeaders.ACCEPT, acceptHeader);
}
return new ContentTypeHelper(req, restReq, req.getUri());
}
示例7: invoke
import org.jboss.resteasy.mock.MockHttpResponse; //导入依赖的package包/类
@Override
public ClientResponse invoke(ClientInvocation request) {
MockHttpRequest mockRequest = createRequest(request);
MockHttpResponse mockResponse = new MockHttpResponse();
dispatcher.invoke(mockRequest, mockResponse);
return createResponse(request, mockResponse);
}
示例8: createResponse
import org.jboss.resteasy.mock.MockHttpResponse; //导入依赖的package包/类
private ClientResponse createResponse(
final ClientInvocation request, final MockHttpResponse mockResponse) {
ClientResponse response =
new ClientResponse(request.getClientConfiguration()) {
private InputStream inputStream;
@Override
protected InputStream getInputStream() {
if (inputStream == null) {
inputStream = new ByteArrayInputStream(mockResponse.getOutput());
}
return inputStream;
}
@Override
protected void setInputStream(InputStream is) {
inputStream = is;
}
@Override
public void releaseConnection() throws IOException {
// no-op
}
};
response.setStatus(mockResponse.getStatus());
response.setHeaders(
transformHeaders(mockResponse.getOutputHeaders(), mockResponse.getNewCookies()));
return response;
}
示例9: invoke
import org.jboss.resteasy.mock.MockHttpResponse; //导入依赖的package包/类
public HttpResponse invoke(HttpRequest request) {
MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(request, response);
return response;
}
示例10: executeRequest
import org.jboss.resteasy.mock.MockHttpResponse; //导入依赖的package包/类
private JaxrsResponse executeRequest(MockHttpRequest request) {
MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(request, response);
return new RestEasyResponse(response);
}
示例11: RestEasyResponse
import org.jboss.resteasy.mock.MockHttpResponse; //导入依赖的package包/类
RestEasyResponse(MockHttpResponse mockResponse) {
this.mockResponse = mockResponse;
}