本文整理汇总了Java中ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter类的典型用法代码示例。如果您正苦于以下问题:Java InterceptorAdapter类的具体用法?Java InterceptorAdapter怎么用?Java InterceptorAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InterceptorAdapter类属于ca.uhn.fhir.rest.server.interceptor包,在下文中一共展示了InterceptorAdapter类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAuthorizationFailureInPreProcessInterceptor
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter; //导入依赖的package包/类
@Test
public void testAuthorizationFailureInPreProcessInterceptor() throws Exception {
IServerInterceptor interceptor = new InterceptorAdapter() {
@Override
public boolean incomingRequestPreProcessed(HttpServletRequest theRequest, HttpServletResponse theResponse) {
throw new AuthenticationException();
}
};
servlet.registerInterceptor(interceptor);
try {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?throwInternalError=aaa");
HttpResponse status = ourClient.execute(httpGet);
String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
ourLog.info(responseContent);
assertEquals(AuthenticationException.STATUS_CODE, status.getStatusLine().getStatusCode());
assertThat(responseContent, StringContains.containsString("Client unauthorized"));
} finally {
servlet.unregisterInterceptor(interceptor);
}
}
示例2: before
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter; //导入依赖的package包/类
@Override
public void before() throws Exception {
super.before();
myServerInterceptor = mock(IServerInterceptor.class, withSettings().verboseLogging());
myDaoInterceptor = mock(IServerInterceptor.class, withSettings().verboseLogging());
resetServerInterceptor();
myDaoConfig.getInterceptors().add(myDaoInterceptor);
ourRestServer.registerInterceptor(myServerInterceptor);
ourRestServer.registerInterceptor(new InterceptorAdapter() {
@Override
public void incomingRequestPreHandled(RestOperationTypeEnum theOperation, ActionRequestDetails theProcessedRequest) {
super.incomingRequestPreHandled(theOperation, theProcessedRequest);
}
});
}
示例3: before
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter; //导入依赖的package包/类
@Override
public void before() throws Exception {
super.before();
myServerInterceptor = mock(IServerInterceptor.class);
myDaoInterceptor = mock(IServerInterceptor.class);
resetServerInterceptor();
myDaoConfig.getInterceptors().add(myDaoInterceptor);
ourRestServer.registerInterceptor(myServerInterceptor);
ourRestServer.registerInterceptor(new InterceptorAdapter() {
@Override
public void incomingRequestPreHandled(RestOperationTypeEnum theOperation, ActionRequestDetails theProcessedRequest) {
super.incomingRequestPreHandled(theOperation, theProcessedRequest);
}
});
}
示例4: testModifyResponse
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter; //导入依赖的package包/类
@Test
public void testModifyResponse() throws IOException {
InterceptorAdapter interceptor = new InterceptorAdapter() {
@Override
public boolean outgoingResponse(RequestDetails theRequestDetails, ResponseDetails theResponseDetails, HttpServletRequest theServletRequest, HttpServletResponse theServletResponse) throws AuthenticationException {
Patient retVal = new Patient();
retVal.setId(theResponseDetails.getResponseResource().getIdElement());
retVal.addName().setFamily("NAME1");
theResponseDetails.setResponseResource(retVal);
theResponseDetails.setResponseCode(202);
return true;
}
};
ourServlet.registerInterceptor(interceptor);
try {
HttpGet get = new HttpGet("http://localhost:" + ourPort + "/Patient/1");
try (CloseableHttpResponse status = ourClient.execute(get)) {
String response = IOUtils.toString(status.getEntity().getContent(), Constants.CHARSET_UTF8);
assertThat(response, containsString("NAME1"));
assertEquals(202, status.getStatusLine().getStatusCode());
assertEquals("Accepted", status.getStatusLine().getReasonPhrase());
}
} finally {
ourServlet.unregisterInterceptor(interceptor);
}
}
示例5: before
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter; //导入依赖的package包/类
@Override
public void before() throws Exception {
super.before();
myServerInterceptor = mock(IServerInterceptor.class);
myDaoInterceptor = mock(IServerInterceptor.class);
myJpaServerInterceptor = mock(IServerOperationInterceptor.class);
when(myServerInterceptor.handleException(any(RequestDetails.class), any(BaseServerResponseException.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myServerInterceptor.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myServerInterceptor.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myServerInterceptor.outgoingResponse(any(RequestDetails.class), any(IBaseResource.class))).thenReturn(true);
when(myServerInterceptor.outgoingResponse(any(RequestDetails.class), any(IBaseResource.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myServerInterceptor.outgoingResponse(any(RequestDetails.class), any(ResponseDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myJpaServerInterceptor.handleException(any(RequestDetails.class), any(BaseServerResponseException.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myJpaServerInterceptor.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myJpaServerInterceptor.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myJpaServerInterceptor.outgoingResponse(any(RequestDetails.class), any(IBaseResource.class))).thenReturn(true);
when(myJpaServerInterceptor.outgoingResponse(any(RequestDetails.class), any(IBaseResource.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myJpaServerInterceptor.outgoingResponse(any(RequestDetails.class), any(ResponseDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
myDaoConfig.getInterceptors().add(myDaoInterceptor);
ourRestServer.registerInterceptor(myServerInterceptor);
ourRestServer.registerInterceptor(myJpaServerInterceptor);
ourRestServer.registerInterceptor(new InterceptorAdapter() {
@Override
public void incomingRequestPreHandled(RestOperationTypeEnum theOperation, ActionRequestDetails theProcessedRequest) {
super.incomingRequestPreHandled(theOperation, theProcessedRequest);
}
});
}