本文整理匯總了Java中org.openhim.mediator.engine.testing.MockLauncher類的典型用法代碼示例。如果您正苦於以下問題:Java MockLauncher類的具體用法?Java MockLauncher怎麽用?Java MockLauncher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MockLauncher類屬於org.openhim.mediator.engine.testing包,在下文中一共展示了MockLauncher類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: FhirProxyTestKit
import org.openhim.mediator.engine.testing.MockLauncher; //導入依賴的package包/類
public FhirProxyTestKit(ActorSystem actorSystem, Class<? extends Actor> context, Class<? extends MockHTTPConnector> upstreamMock) {
super(actorSystem);
List<MockLauncher.ActorToLaunch> testActors = new ArrayList<>();
testActors.add(new MockLauncher.ActorToLaunch("fhir-context", context));
testActors.add(new MockLauncher.ActorToLaunch("http-connector", upstreamMock));
TestingUtils.launchActors(system, testConfig.getName(), testActors);
expectNoMsg((FiniteDuration) dilated(Duration.create(20, TimeUnit.MILLISECONDS))); //delay a bit - the actors sometimes need a moment
fhirProxyHandler = system.actorOf(Props.create(FhirProxyHandler.class, testConfig));
}
示例2: sendTestRequest
import org.openhim.mediator.engine.testing.MockLauncher; //導入依賴的package包/類
private void sendTestRequest(ActorRef ref, Class<? extends UntypedActor> handler) {
TestingUtils.launchActors(system, testConfig.getName(), Collections.singletonList(new MockLauncher.ActorToLaunch("mllp-connector", handler)));
TestActorRef<PIXRequestActor> actor = TestActorRef.create(system, Props.create(PIXRequestActor.class, testConfig));
Identifier fromId = new Identifier("1234", new AssigningAuthority("test-auth", "1.2.3", "ISO"));
AssigningAuthority targetDomain = new AssigningAuthority("ECID", "ECID", "ECID");
actor.tell(new ResolvePatientIdentifier(ref, ref, fromId, targetDomain), ref);
}
示例3: before
import org.openhim.mediator.engine.testing.MockLauncher; //導入依賴的package包/類
@Before
public void before() throws Exception {
system = ActorSystem.create();
testConfig = new MediatorConfig();
testConfig.setName("registry-tests");
testConfig.setProperties("mediator-unit-test.properties");
List<MockLauncher.ActorToLaunch> toLaunch = new LinkedList<>();
toLaunch.add(new MockLauncher.ActorToLaunch("http-connector", MockRegistry.class));
toLaunch.add(new MockLauncher.ActorToLaunch("parse-registry-stored-query", ParseRegistryStoredQueryActor.class));
toLaunch.add(new MockLauncher.ActorToLaunch("enrich-registry-stored-query", EnrichRegistryStoredQueryActor.class));
TestingUtils.launchActors(system, testConfig.getName(), toLaunch);
}
示例4: testMessage_AsyncRouting
import org.openhim.mediator.engine.testing.MockLauncher; //導入依賴的package包/類
@Test
public void testMessage_AsyncRouting() throws Exception {
new JavaTestKit(system) {{
//mock core api
MockLauncher.ActorToLaunch mockCoreAPI = new MockLauncher.ActorToLaunch("core-api-connector", MockCoreAPI.class);
TestingUtils.launchActors(system, testConfig.getName(), Collections.singletonList(mockCoreAPI));
//route to mock receiver
RoutingTable table = new RoutingTable();
table.addRoute("/test", AsyncRoutingMock.class);
testConfig.setRoutingTable(table);
//route request
TestActorRef<MediatorRequestHandler> actor = TestActorRef.create(system, Props.create(MediatorRequestHandler.class, testConfig));
assertFalse(actor.underlyingActor().async);
MediatorHTTPRequest testSession = new MediatorHTTPRequest(
actor, getRef(), "/test", "GET", "http", "localhost", 1234, "/test", null, Collections.singletonMap("X-OpenHIM-TransactionID", "test-async"), null
);
actor.tell(testSession, getRef());
//get response
MediatorHTTPResponse response = expectMsgClass(Duration.create(1, TimeUnit.SECONDS), MediatorHTTPResponse.class);
assertTrue("Async should be enabled", actor.underlyingActor().async);
assertEquals("Core transaction ID should be set", "test-async", actor.underlyingActor().coreTransactionID);
//request handler should respond with 202 Accepted
String body = response.getBody();
assertTrue(body.contains("\"status\":202"));
CoreResponse coreResponse = actor.underlyingActor().response;
assertNotNull(actor.underlyingActor().response);
//delay a bit waiting for the async update
expectNoMsg(Duration.create(1, TimeUnit.SECONDS));
//response token should be updated with final result
assertNotNull(coreResponse.getResponse());
assertEquals(new Integer(200), coreResponse.getResponse().getStatus());
assertEquals("async-routing", coreResponse.getResponse().getBody());
TestingUtils.clearRootContext(system, testConfig.getName());
}};
}