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


Java LoggingInterceptor类代码示例

本文整理汇总了Java中ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor的典型用法代码示例。如果您正苦于以下问题:Java LoggingInterceptor类的具体用法?Java LoggingInterceptor怎么用?Java LoggingInterceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LoggingInterceptor类属于ca.uhn.fhir.rest.client.interceptor包,在下文中一共展示了LoggingInterceptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFindConsent

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
/**
 * Test method for
 * {@link org.iexhub.services.JaxRsConsentRestProvider\#find(@IdParam final
 * IdDt id)}.
 */
@Test
public void testFindConsent() {

	try {
		Logger logger = LoggerFactory.getLogger(ConsentDstu3Test.class);
		LoggingInterceptor loggingInterceptor = new LoggingInterceptor();
		loggingInterceptor.setLogRequestSummary(true);
		loggingInterceptor.setLogRequestBody(true);
		loggingInterceptor.setLogger(logger);

		IGenericClient client = ctxt.newRestfulGenericClient(serverBaseUrl);
		client.registerInterceptor(loggingInterceptor); // Required only for
														// logging
		Consent retVal = client.read(Consent.class,
				/*iExHubDomainOid + "." + consentId*/ /*"2.25.1469220780502"*/ "2.25.1471531116858");
		
		assertTrue("Error - unexpected return value for testFindConsent", retVal != null);
	} catch (Exception e) {
		fail(e.getMessage());
	}
}
 
开发者ID:bhits,项目名称:iexhub,代码行数:27,代码来源:ConsentDstu3Test.java

示例2: main

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
public static void main(String[] theArgs) {

		// Create a client
      IGenericClient client = FhirContext.forDstu3().newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3");

      // Register some interceptors
      client.registerInterceptor(new CookieInterceptor("mycookie=Chips Ahoy"));
      client.registerInterceptor(new LoggingInterceptor());

      // Read a Patient
      Patient patient = client.read().resource(Patient.class).withId("example").execute();

		// Change the gender
		patient.setGender(patient.getGender() == AdministrativeGender.MALE ? AdministrativeGender.FEMALE : AdministrativeGender.MALE);

		// Update the patient
		MethodOutcome outcome = client.update().resource(patient).execute();
		
		System.out.println("Now have ID: " + outcome.getId());
	}
 
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:21,代码来源:Example09_Interceptors.java

示例3: operationHttpGet

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
@SuppressWarnings("unused")
private static void operationHttpGet() {
   // START SNIPPET: operationHttpGet
   // Create a client to talk to the HeathIntersections server
   FhirContext ctx = FhirContext.forDstu2();
   IGenericClient client = ctx.newRestfulGenericClient("http://fhir-dev.healthintersections.com.au/open");
   client.registerInterceptor(new LoggingInterceptor(true));
   
   // Create the input parameters to pass to the server
   Parameters inParams = new Parameters();
   inParams.addParameter().setName("start").setValue(new DateDt("2001-01-01"));
   inParams.addParameter().setName("end").setValue(new DateDt("2015-03-01"));
   
   // Invoke $everything on "Patient/1"
   Parameters outParams = client
      .operation()
      .onInstance(new IdDt("Patient", "1"))
      .named("$everything")
      .withParameters(inParams)
      .useHttpGet() // Use HTTP GET instead of POST
      .execute();
   // END SNIPPET: operationHttpGet
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:24,代码来源:GenericClientExample.java

示例4: operation

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
@SuppressWarnings("unused")
private static void operation() {
   // START SNIPPET: operation
   // Create a client to talk to the HeathIntersections server
   FhirContext ctx = FhirContext.forDstu2();
   IGenericClient client = ctx.newRestfulGenericClient("http://fhir-dev.healthintersections.com.au/open");
   client.registerInterceptor(new LoggingInterceptor(true));
   
   // Create the input parameters to pass to the server
   Parameters inParams = new Parameters();
   inParams.addParameter().setName("start").setValue(new DateDt("2001-01-01"));
   inParams.addParameter().setName("end").setValue(new DateDt("2015-03-01"));
   
   // Invoke $everything on "Patient/1"
   Parameters outParams = client
      .operation()
      .onInstance(new IdDt("Patient", "1"))
      .named("$everything")
      .withParameters(inParams)
      .execute();
   // END SNIPPET: operation
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:23,代码来源:GenericClientExample.java

示例5: operationNoIn

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
@SuppressWarnings("unused")
private static void operationNoIn() {
   // START SNIPPET: operationNoIn
   // Create a client to talk to the HeathIntersections server
   FhirContext ctx = FhirContext.forDstu2();
   IGenericClient client = ctx.newRestfulGenericClient("http://fhir-dev.healthintersections.com.au/open");
   client.registerInterceptor(new LoggingInterceptor(true));
   
   // Invoke $everything on "Patient/1"
   Parameters outParams = client
      .operation()
      .onInstance(new IdDt("Patient", "1"))
      .named("$everything")
      .withNoParameters(Parameters.class) // No input parameters
      .execute();
   // END SNIPPET: operationNoIn
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:18,代码来源:GenericClientExample.java

示例6: testNonRepeatableParam

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
@Test
public void testNonRepeatableParam() throws Exception {
	MyServerBaseProvider patientProvider = new MyServerBaseProvider();
	myServlet.setResourceProviders(patientProvider);

	myServer.start();

	FhirContext ctx = new FhirContext();
	IGenericClient client = ctx.newRestfulGenericClient("http://localhost:" + myPort + "/");
	client.registerInterceptor(new LoggingInterceptor(true));

	try {
		client.search().forResource("Patient").where(new StringClientParam("singleParam").matches().values(Arrays.asList("AA", "BB"))).execute();
		fail();
	} catch (InvalidRequestException e) {
		assertThat(
				e.getMessage(),
				StringContains
						.containsString("HTTP 400 Bad Request: Multiple values detected for non-repeatable parameter 'singleParam'. This server is not configured to allow multiple (AND/OR) values for this param."));
	}
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:22,代码来源:ServerExtraParametersTest.java

示例7: main

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
public static void main(String[] theArgs) {

		// Create a client
		FhirContext ctx = new FhirContext();
		String serverBaseUrl = "http://fhirtest.uhn.ca/base";
		IGenericClient client = ctx.newRestfulGenericClient(serverBaseUrl);

		// Log requests and responses
		client.registerInterceptor(new LoggingInterceptor(true));
		
		// Build a search and execute it
		Bundle response = client.search()
			.forResource(Patient.class)
			.where(Patient.NAME.matches().value("Test"))
			.and(Patient.BIRTHDATE.before().day("2014-01-01"))
			.limitTo(100)
			.execute();
		
		// How many resources did we find?
		System.out.println("Responses: " + response.size());
		
		// Print the ID of the first one
		IdDt firstResponseId = response.getEntries().get(0).getResource().getId();
		System.out.println(firstResponseId);
		
	}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:27,代码来源:Example06_ClientReadAndUpdate.java

示例8: beforeClass

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
	ourPort = PortUtil.findFreePort();
	ourServer = new Server(ourPort);

	PatientProvider patientProvider = new PatientProvider();

	ServletHandler proxyHandler = new ServletHandler();
	RestfulServer servlet = new RestfulServer(ourCtx);
	servlet.setResourceProviders(patientProvider);
	ServletHolder servletHolder = new ServletHolder(servlet);
	proxyHandler.addServletWithMapping(servletHolder, "/*");
	ourServer.setHandler(proxyHandler);
	ourServer.start();

	PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
	HttpClientBuilder builder = HttpClientBuilder.create();
	builder.setConnectionManager(connectionManager);
	ourClient = builder.build();

	ourCtx.getRestfulClientFactory().setSocketTimeout(500 * 1000);
	ourHapiClient = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/");
	ourHapiClient.registerInterceptor(new LoggingInterceptor());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:25,代码来源:DeleteConditionalDstu3Test.java

示例9: testConformance

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
@Test
	public void testConformance() throws Exception {
		LoggingInterceptor loggingInterceptor = new LoggingInterceptor();
		loggingInterceptor.setLogResponseBody(true);
		myFhirClient.registerInterceptor(loggingInterceptor);

		CapabilityStatement p = myFhirClient.fetchConformance().ofType(CapabilityStatement.class).prettyPrint().execute();
		ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(p));
		
		List<CapabilityStatementRestOperationComponent> ops = p.getRest().get(0).getOperation();
		assertThat(ops.size(), greaterThan(1));

		List<String> opNames = toOpNames(ops);
		assertThat(opNames, containsInRelativeOrder("OP_TYPE"));
		
//		OperationDefinition def = (OperationDefinition) ops.get(opNames.indexOf("OP_TYPE")).getDefinition().getResource();
		OperationDefinition def = myFhirClient.read().resource(OperationDefinition.class).withId(ops.get(opNames.indexOf("OP_TYPE")).getDefinition().getReferenceElement()).execute();
		assertEquals("OP_TYPE", def.getCode());
	}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:20,代码来源:OperationServerDstu3Test.java

示例10: testConformance

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
@Test
	public void testConformance() throws Exception {
		LoggingInterceptor loggingInterceptor = new LoggingInterceptor();
		loggingInterceptor.setLogResponseBody(true);
		myFhirClient.registerInterceptor(loggingInterceptor);

		Conformance p = myFhirClient.fetchConformance().ofType(Conformance.class).prettyPrint().execute();
		ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(p));
		
		List<ConformanceRestOperationComponent> ops = p.getRest().get(0).getOperation();
		assertThat(ops.size(), greaterThan(1));

		List<String> opNames = toOpNames(ops);
		assertThat(opNames, containsInRelativeOrder("OP_TYPE"));
		
//		OperationDefinition def = (OperationDefinition) ops.get(opNames.indexOf("OP_TYPE")).getDefinition().getResource();
		OperationDefinition def = myFhirClient.read().resource(OperationDefinition.class).withId(ops.get(opNames.indexOf("OP_TYPE")).getDefinition().getReferenceElement()).execute();
		assertEquals("OP_TYPE", def.getCode());
	}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:20,代码来源:OperationServerDstu2_1Test.java

示例11: testNonRepeatableParam

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
@Test
public void testNonRepeatableParam() throws Exception {
	MyServerBaseProvider patientProvider = new MyServerBaseProvider();
	myServlet.setResourceProviders(patientProvider);

	myServer.start();

	FhirContext ctx = ourCtx;
	IGenericClient client = ctx.newRestfulGenericClient("http://localhost:" + myPort + "/");
	client.registerInterceptor(new LoggingInterceptor(true));

	try {
		client.search().forResource("Patient").where(new StringClientParam("singleParam").matches().values(Arrays.asList("AA", "BB"))).execute();
		fail();
	} catch (InvalidRequestException e) {
		assertThat(
				e.getMessage(),
				StringContains
						.containsString("HTTP 400 Bad Request: Multiple values detected for non-repeatable parameter 'singleParam'. This server is not configured to allow multiple (AND/OR) values for this param."));
	}
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:22,代码来源:ServerExtraParametersTest.java

示例12: testLoggerNonVerbose

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
@Test
public void testLoggerNonVerbose() throws Exception {
	System.out.println("Starting testLogger");
	IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort);
	ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);

	LoggingInterceptor interceptor = new LoggingInterceptor(false);
	client.registerInterceptor(interceptor);
	Patient patient = client.read(Patient.class, "1");
	assertFalse(patient.getIdentifierFirstRep().isEmpty());

	verify(myMockAppender, times(2)).doAppend(argThat(new ArgumentMatcher<ILoggingEvent>() {
		@Override
		public boolean matches(final Object argument) {
			String formattedMessage = ((LoggingEvent) argument).getFormattedMessage();
			System.out.flush();
			System.out.println("** Got Message: " + formattedMessage);
			System.out.flush();
			return
				formattedMessage.contains("Client request: GET http://localhost:" + ourPort + "/Patient/1 HTTP/1.1") ||
				formattedMessage.contains("Client response: HTTP 200 OK (Patient/1/_history/1)");
		}
	}));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:25,代码来源:LoggingInterceptorTest.java

示例13: beforeClass

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {

	URL conf = LoggingInterceptor.class.getResource("/logback-test-dstuforce.xml");
	assertNotNull(conf);
	LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
	JoranConfigurator configurator = new JoranConfigurator();
	configurator.setContext(context);
	context.reset();
	configurator.doConfigure(conf);

	ourPort = PortUtil.findFreePort();
	ourServer = new Server(ourPort);

	DummyProvider patientProvider = new DummyProvider();

	ServletHandler proxyHandler = new ServletHandler();
	RestfulServer servlet = new RestfulServer(ourCtx);
	servlet.setResourceProviders(patientProvider);
	ServletHolder servletHolder = new ServletHolder(servlet);
	proxyHandler.addServletWithMapping(servletHolder, "/*");
	ourServer.setHandler(proxyHandler);
	ourServer.start();

	ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:27,代码来源:LoggingInterceptorTest.java

示例14: testConformance

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
@Test
	public void testConformance() throws Exception {
		LoggingInterceptor loggingInterceptor = new LoggingInterceptor();
		loggingInterceptor.setLogResponseBody(true);
		myFhirClient.registerInterceptor(loggingInterceptor);

		CapabilityStatement p = myFhirClient.fetchConformance().ofType(CapabilityStatement.class).prettyPrint().execute();
		ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(p));

		List<CapabilityStatement.CapabilityStatementRestResourceOperationComponent> ops = p.getRest().get(0).getOperation();
		assertThat(ops.size(), greaterThan(1));

		List<String> opNames = toOpNames(ops);
		assertThat(opNames, containsInRelativeOrder("OP_TYPE"));
		
//		OperationDefinition def = (OperationDefinition) ops.get(opNames.indexOf("OP_TYPE")).getDefinition().getResource();
		OperationDefinition def = myFhirClient.read().resource(OperationDefinition.class).withId(ops.get(opNames.indexOf("OP_TYPE")).getDefinition().getReferenceElement()).execute();
		assertEquals("OP_TYPE", def.getCode());
	}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:20,代码来源:OperationServerR4Test.java

示例15: testExtendedOperations

import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; //导入依赖的package包/类
/** Extended Operations */
// Create a client to talk to the HeathIntersections server
@Test
public void testExtendedOperations() {
	client.registerInterceptor(new LoggingInterceptor(true));

	// Create the input parameters to pass to the server
	Parameters inParams = new Parameters();
	inParams.addParameter().setName("start").setValue(new DateDt("2001-01-01"));
	inParams.addParameter().setName("end").setValue(new DateDt("2015-03-01"));
	inParams.addParameter().setName("dummy").setValue(new StringDt("myAwesomeDummyValue"));

	// Invoke $everything on "Patient/1"
	Parameters outParams = client
			.operation()
			.onInstance(new IdDt("Patient", "1"))
			.named("$firstVersion")
			.withParameters(inParams)
			// .useHttpGet() // Use HTTP GET instead of POST
			.execute();
	String resultValue = outParams.getParameter().get(0).getValue().toString();
	System.out.println(resultValue);
	assertEquals("expected but found : " + resultValue, resultValue.contains("myAwesomeDummyValue"), true);
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:25,代码来源:JaxRsPatientProviderTest.java


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