use of com.yahoo.application.container.MockClient in project vespa by vespa-engine.
the class ApplicationTest method client.
@Test
public void client() throws Exception {
try (ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().documentType("test", IOUtils.toString(this.getClass().getResourceAsStream("/test.sd"))).container("default", new Application.Builder.Container().client("mbus://*/*", MockClient.class).documentProcessor(MockDispatchDocproc.class))))) {
Map<String, DocumentType> typeMap = app.application().getJDisc("jdisc").documentProcessing().getDocumentTypes();
assertNotNull(typeMap);
DocumentType docType = typeMap.get("test");
Document doc = new Document(docType, "id:foo:test::bar");
doc.setFieldValue("title", "hello");
assertEquals(DocumentProcessor.Progress.DONE, app.process(new DocumentPut(doc)));
MockClient client = (MockClient) app.getClientById(MockClient.class.getName());
assertNotNull(client);
assertEquals(1, client.getCounter());
MockDispatchDocproc docproc = (MockDispatchDocproc) app.getComponentById(MockDispatchDocproc.class.getName() + "@default");
assertNotNull(docproc);
assertEquals(1, docproc.getResponses().size());
assertEquals(200, docproc.getResponses().get(0).getStatus());
}
}
Aggregations