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


Java MockLauncher类代码示例

本文整理汇总了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));
}
 
开发者ID:jembi,项目名称:openhim-mediator-fhir-proxy,代码行数:11,代码来源:FhirProxyHandlerTest.java

示例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);
}
 
开发者ID:jembi,项目名称:openhim-mediator-xds,代码行数:10,代码来源:PIXRequestActorTest.java

示例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);
}
 
开发者ID:jembi,项目名称:openhim-mediator-xds,代码行数:15,代码来源:RegistryActorTest.java

示例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());
    }};
}
 
开发者ID:jembi,项目名称:openhim-mediator-engine-java,代码行数:45,代码来源:MediatorRequestHandlerTest.java


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