当前位置: 首页>>代码示例>>Java>>正文


Java InterceptorAdapter类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:23,代码来源:ExceptionTest.java

示例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);
		}
	});

}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:21,代码来源:ResourceProviderInterceptorDstu3Test.java

示例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);
		}
	});

}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:21,代码来源:ResourceProviderInterceptorR4Test.java

示例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);
	}
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:29,代码来源:InterceptorDstu3Test.java

示例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);
		}
	});

}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:35,代码来源:ResourceProviderInterceptorDstu2Test.java


注:本文中的ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。