Search in sources :

Example 1 with MockDispatchDocproc

use of com.yahoo.application.container.docprocs.MockDispatchDocproc 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());
    }
}
Also used : DocumentPut(com.yahoo.document.DocumentPut) DocumentType(com.yahoo.document.DocumentType) MockDispatchDocproc(com.yahoo.application.container.docprocs.MockDispatchDocproc) Document(com.yahoo.document.Document) MockClient(com.yahoo.application.container.MockClient) Test(org.junit.Test)

Aggregations

MockClient (com.yahoo.application.container.MockClient)1 MockDispatchDocproc (com.yahoo.application.container.docprocs.MockDispatchDocproc)1 Document (com.yahoo.document.Document)1 DocumentPut (com.yahoo.document.DocumentPut)1 DocumentType (com.yahoo.document.DocumentType)1 Test (org.junit.Test)1