本文整理匯總了Java中org.openhim.mediator.engine.messages.ExceptError類的典型用法代碼示例。如果您正苦於以下問題:Java ExceptError類的具體用法?Java ExceptError怎麽用?Java ExceptError使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ExceptError類屬於org.openhim.mediator.engine.messages包,在下文中一共展示了ExceptError類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setupFhirContext
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
private boolean setupFhirContext(ActorRef requestHandler) {
String targetContext = (String)config.getDynamicConfig().get("fhir-context");
if (fhirContext==null || !setupContext.equals(targetContext)) {
log.info("Initializing HAPI FHIR context");
switch (targetContext) {
case "DSTU1":
fhirContext = FhirContext.forDstu1();
break;
case "DSTU2":
fhirContext = FhirContext.forDstu2();
break;
default:
requestHandler.tell(new ExceptError(new RuntimeException("Unsupported option specified for fhir-context")), getSelf());
return false;
}
setupContext = targetContext;
}
return true;
}
示例2: convertBodyForUpstream
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
private Contents convertBodyForUpstream(Contents contents) {
String targetContentType = determineTargetContentType(contents.contentType);
if ("Client".equalsIgnoreCase(upstreamFormat) || isUpstreamAndClientFormatsEqual(contents.contentType)) {
return new Contents(targetContentType, contents.content);
}
log.info("[" + openhimTrxID + "] Converting request body to " + targetContentType);
IParser inParser = newParser(contents.contentType);
IBaseResource resource = inParser.parseResource(contents.content);
if ("JSON".equalsIgnoreCase(upstreamFormat) || "XML".equalsIgnoreCase(upstreamFormat)) {
IParser outParser = newParser(targetContentType);
String converted = outParser.setPrettyPrint(true).encodeResourceToString(resource);
return new Contents(targetContentType, converted);
} else {
requestHandler.tell(new ExceptError(new RuntimeException("Unknown upstream format specified " + upstreamFormat)), getSelf());
return null;
}
}
示例3: testPassthrough_POST
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* If upstream format is 'Client' and validation is disabled, the proxy acts as a pass-through
*/
@Test
public void testPassthrough_POST() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, AcceptJSONCreateFhirServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "Client");
testConfig.getDynamicConfig().put("validation-enabled", false);
try {
MediatorHTTPRequest POST_Request = POSTPatientRequest(Constants.FHIR_MIME_JSON, patientJSON);
fhirProxyHandler.tell(POST_Request, getRef());
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError)result).getError();
}
assertEquals(new Integer(201), ((FinishRequest)result).getResponseStatus());
} finally {
cleanup();
}
}};
}
示例4: testPassthrough_GET
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* If upstream format is 'Client' and validation is disabled, the proxy acts as a pass-through
*/
@Test
public void testPassthrough_GET() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, AcceptJSONGetFhirServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "Client");
testConfig.getDynamicConfig().put("validation-enabled", false);
try {
MediatorHTTPRequest GET_Request = GETPatientRequest(Constants.FHIR_MIME_JSON);
fhirProxyHandler.tell(GET_Request, getRef());
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError)result).getError();
}
assertEquals(new Integer(200), ((FinishRequest)result).getResponseStatus());
assertEquals(Constants.FHIR_MIME_JSON, ((FinishRequest)result).getResponseMimeType());
JSONAssert.assertEquals(patientJSON, ((FinishRequest)result).getResponse(), JSONCompareMode.LENIENT);
} finally {
cleanup();
}
}};
}
示例5: testValidContentShouldForward
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* Should forward valid contents upstream
*/
@Test
public void testValidContentShouldForward() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, AcceptJSONCreateFhirServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "Client");
testConfig.getDynamicConfig().put("validation-enabled", true);
try {
MediatorHTTPRequest POST_Request = POSTPatientRequest(Constants.FHIR_MIME_JSON, patientJSON);
fhirProxyHandler.tell(POST_Request, getRef());
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError)result).getError();
}
assertEquals(new Integer(201), ((FinishRequest)result).getResponseStatus());
} finally {
cleanup();
}
}};
}
示例6: testInvalidContentShouldNotForward
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* Should not forward invalid contents upstream
*/
@Test
public void testInvalidContentShouldNotForward() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, TrapServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "Client");
testConfig.getDynamicConfig().put("validation-enabled", true);
try {
MediatorHTTPRequest POST_Request = POSTPatientRequest(Constants.FHIR_MIME_JSON, patientJSON_invalid);
fhirProxyHandler.tell(POST_Request, getRef());
//should not hit the trap server
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError)result).getError();
}
} finally {
cleanup();
}
}};
}
示例7: testInvalidContentShouldRespondWithBadRequest
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* Should respond with bad request OperationOutcome if content invalid
*/
@Test
public void testInvalidContentShouldRespondWithBadRequest() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, TrapServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "Client");
testConfig.getDynamicConfig().put("validation-enabled", true);
try {
MediatorHTTPRequest POST_Request = POSTPatientRequest(Constants.FHIR_MIME_JSON, patientJSON_invalid);
fhirProxyHandler.tell(POST_Request, getRef());
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError)result).getError();
}
assertEquals(new Integer(400), ((FinishRequest)result).getResponseStatus());
assertEquals(Constants.FHIR_MIME_JSON, ((FinishRequest)result).getResponseMimeType());
JSONAssert.assertEquals("{\"resourceType\": \"OperationOutcome\"}", ((FinishRequest)result).getResponse(), JSONCompareMode.LENIENT);
} finally {
cleanup();
}
}};
}
示例8: testInvalidJSONSyntaxContentShouldRespondWithBadRequest
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* Should respond with bad request OperationOutcome if JSON syntax is invalid
*/
@Test
public void testInvalidJSONSyntaxContentShouldRespondWithBadRequest() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, TrapServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "Client");
testConfig.getDynamicConfig().put("validation-enabled", true);
try {
MediatorHTTPRequest POST_Request = POSTPatientRequest(Constants.FHIR_MIME_JSON, patientJSON_invalidSyntax);
fhirProxyHandler.tell(POST_Request, getRef());
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError)result).getError();
}
assertEquals(new Integer(400), ((FinishRequest)result).getResponseStatus());
assertEquals(Constants.FHIR_MIME_JSON, ((FinishRequest)result).getResponseMimeType());
JSONAssert.assertEquals("{\"resourceType\": \"OperationOutcome\"}", ((FinishRequest)result).getResponse(), JSONCompareMode.LENIENT);
} finally {
cleanup();
}
}};
}
示例9: testPOSTJSONToXML
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* Test POST JSON -> XML conversion
*/
@Test
public void testPOSTJSONToXML() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, AcceptXMLCreateFhirServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "XML");
testConfig.getDynamicConfig().put("validation-enabled", false);
try {
MediatorHTTPRequest POST_Request = POSTPatientRequest(Constants.FHIR_MIME_JSON, patientJSON);
fhirProxyHandler.tell(POST_Request, getRef());
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError)result).getError();
}
assertEquals(new Integer(201), ((FinishRequest)result).getResponseStatus());
} finally {
cleanup();
}
}};
}
示例10: testPOSTJSONToXML_formatParam
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* Test POST JSON -> XML conversion - specified with _format param
*/
@Test
public void testPOSTJSONToXML_formatParam() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, AcceptXMLCreateFhirServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "XML");
testConfig.getDynamicConfig().put("validation-enabled", false);
try {
MediatorHTTPRequest POST_Request = POSTPatientRequest(Constants.FHIR_MIME_JSON, patientJSON);
fhirProxyHandler.tell(POST_Request, getRef());
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError)result).getError();
}
assertEquals(new Integer(201), ((FinishRequest)result).getResponseStatus());
} finally {
cleanup();
}
}};
}
示例11: testPOSTXMLToJSON
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* Test POST XML -> JSON conversion
*/
@Test
public void testPOSTXMLToJSON() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, AcceptJSONCreateFhirServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "JSON");
testConfig.getDynamicConfig().put("validation-enabled", false);
try {
MediatorHTTPRequest POST_Request = POSTPatientRequest(Constants.FHIR_MIME_XML, patientXML);
fhirProxyHandler.tell(POST_Request, getRef());
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError) result).getError();
}
assertEquals(new Integer(201), ((FinishRequest) result).getResponseStatus());
} finally {
cleanup();
}
}};
}
示例12: testPOSTXMLToXML
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* Test POST XML -> XML conversion
*/
@Test
public void testPOSTXMLToXML() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, AcceptXMLCreateFhirServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "XML");
testConfig.getDynamicConfig().put("validation-enabled", false);
try {
MediatorHTTPRequest POST_Request = POSTPatientRequest(Constants.FHIR_MIME_XML, patientXML);
fhirProxyHandler.tell(POST_Request, getRef());
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError) result).getError();
}
assertEquals(new Integer(201), ((FinishRequest) result).getResponseStatus());
} finally {
cleanup();
}
}};
}
示例13: testPOSTJSONToJSON
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* Test POST JSON -> JSON conversion
*/
@Test
public void testPOSTJSONToJSON() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, AcceptJSONCreateFhirServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "JSON");
testConfig.getDynamicConfig().put("validation-enabled", false);
try {
MediatorHTTPRequest POST_Request = POSTPatientRequest(Constants.FHIR_MIME_JSON, patientJSON);
fhirProxyHandler.tell(POST_Request, getRef());
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError) result).getError();
}
assertEquals(new Integer(201), ((FinishRequest) result).getResponseStatus());
} finally {
cleanup();
}
}};
}
示例14: testGETJSONToJSON
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* Test GET JSON -> JSON conversion
*/
@Test
public void testGETJSONToJSON() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, AcceptJSONGetFhirServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "JSON");
testConfig.getDynamicConfig().put("validation-enabled", false);
try {
MediatorHTTPRequest GET_Request = GETPatientRequest(Constants.FHIR_MIME_JSON);
fhirProxyHandler.tell(GET_Request, getRef());
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError) result).getError();
}
assertEquals(new Integer(200), ((FinishRequest) result).getResponseStatus());
assertEquals(Constants.FHIR_MIME_JSON, ((FinishRequest)result).getResponseMimeType());
JSONAssert.assertEquals(patientJSON, ((FinishRequest)result).getResponse(), JSONCompareMode.LENIENT);
} finally {
cleanup();
}
}};
}
示例15: testGETJSONToJSON_formatParam
import org.openhim.mediator.engine.messages.ExceptError; //導入依賴的package包/類
/**
* Test GET JSON -> JSON conversion - specified with _format param
*/
@Test
public void testGETJSONToJSON_formatParam() throws Throwable {
new FhirProxyTestKit(system, DSTU2FhirContext.class, AcceptJSONGetFhirServer.class) {{
testConfig.getDynamicConfig().put("upstream-format", "JSON");
testConfig.getDynamicConfig().put("validation-enabled", false);
try {
MediatorHTTPRequest GET_Request = GETPatientRequest_formatParam(Constants.FHIR_MIME_JSON);
fhirProxyHandler.tell(GET_Request, getRef());
Object result = expectMsgAnyClassOf(Duration.create(5, TimeUnit.SECONDS), FinishRequest.class, ExceptError.class);
if (result instanceof ExceptError) {
throw ((ExceptError) result).getError();
}
assertEquals(new Integer(200), ((FinishRequest) result).getResponseStatus());
assertEquals(Constants.FHIR_MIME_JSON, ((FinishRequest)result).getResponseMimeType());
JSONAssert.assertEquals(patientJSON, ((FinishRequest)result).getResponse(), JSONCompareMode.LENIENT);
} finally {
cleanup();
}
}};
}