Search in sources :

Example 11 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class ApplicationStatusHandlerTest method client_providers_are_rendered.

@Test
public void client_providers_are_rendered() throws Exception {
    final String id = "myClient";
    final String clientBinding = "http://*/clientBinding";
    final String clientBinding2 = "http://*/anotherClientBinding";
    final String serverBinding = "http://*/serverBinding";
    HashMap<ComponentId, ClientProvider> clientsById = new HashMap<>();
    clientsById.put(new ComponentId(id), Mockito.mock(ClientProvider.class));
    JdiscBindingsConfig bindingsConfig = new JdiscBindingsConfig(new JdiscBindingsConfig.Builder().handlers(id, new Handlers.Builder().clientBindings(clientBinding).clientBindings(clientBinding2).serverBindings(serverBinding)));
    String json = ApplicationStatusHandler.renderRequestHandlers(bindingsConfig, clientsById).toString();
    System.out.println(json);
    assertThat(json, containsString("\"" + id + "\""));
    assertThat(json, containsString(clientBinding));
    assertThat(json, containsString(clientBinding2));
    assertThat(json, containsString(serverBinding));
}
Also used : Handlers(com.yahoo.container.jdisc.JdiscBindingsConfig.Handlers) ClientProvider(com.yahoo.jdisc.service.ClientProvider) HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ComponentId(com.yahoo.component.ComponentId) JdiscBindingsConfig(com.yahoo.container.jdisc.JdiscBindingsConfig) Test(org.junit.Test)

Example 12 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class PageTemplateSearcherTestCase method createPageTemplateRegistry.

private PageTemplateRegistry createPageTemplateRegistry() {
    PageTemplateRegistry registry = new PageTemplateRegistry();
    PageTemplate twoSources = new PageTemplate(new ComponentId("default"));
    twoSources.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source1"));
    twoSources.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source2"));
    registry.register(twoSources);
    PageTemplate oneSource = new PageTemplate(new ComponentId("oneSource"));
    oneSource.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source1"));
    registry.register(oneSource);
    PageTemplate threeSources = new PageTemplate(new ComponentId("threeSources"));
    threeSources.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source1"));
    threeSources.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source2"));
    threeSources.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source3"));
    registry.register(threeSources);
    PageTemplate twoSourcesAndAny = new PageTemplate(new ComponentId("twoSourcesAndAny"));
    twoSourcesAndAny.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source1"));
    twoSourcesAndAny.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source2"));
    twoSourcesAndAny.getSection().elements().add(com.yahoo.search.pagetemplates.model.Source.any);
    registry.register(twoSourcesAndAny);
    PageTemplate anySource = new PageTemplate(new ComponentId("anySource"));
    anySource.getSection().elements().add(com.yahoo.search.pagetemplates.model.Source.any);
    registry.register(anySource);
    PageTemplate choiceOfSources = new PageTemplate(new ComponentId("choiceOfSources"));
    List<PageElement> alternatives = new ArrayList<>();
    alternatives.add(new com.yahoo.search.pagetemplates.model.Source("source1"));
    alternatives.add(new com.yahoo.search.pagetemplates.model.Source("source2"));
    choiceOfSources.getSection().elements().add(Choice.createSingletons(alternatives));
    registry.register(choiceOfSources);
    registry.freeze();
    return registry;
}
Also used : PageTemplate(com.yahoo.search.pagetemplates.PageTemplate) PageTemplateRegistry(com.yahoo.search.pagetemplates.PageTemplateRegistry) com.yahoo.search.intent.model(com.yahoo.search.intent.model) PageElement(com.yahoo.search.pagetemplates.model.PageElement) ComponentId(com.yahoo.component.ComponentId)

Example 13 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class HttpPostTestCase method testPostingSearcher.

@Test
public void testPostingSearcher() throws Exception {
    StupidSingleThreadedHttpServer server = new StupidSingleThreadedHttpServer();
    server.start();
    TestPostSearcher searcher = new TestPostSearcher(new ComponentId("foo:1"), Arrays.asList(new Connection("localhost", server.getServerPort())), "/");
    Query q = new Query("");
    q.setTimeout(10000000L);
    Execution e = new Execution(searcher, Execution.Context.createContextStub());
    searcher.search(q, e);
    assertThat(server.getRequest(), containsString("My POST body"));
    server.stop();
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) StupidSingleThreadedHttpServer(com.yahoo.search.StupidSingleThreadedHttpServer) Connection(com.yahoo.search.federation.http.Connection) ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test)

Example 14 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class JuniperSearcherTestCase method createSearchChain.

/**
 * Creates a search chain which always returns a result with one hit containing information given in this
 *
 * @param sdName the search definition type of the returned hit
 * @param content the content of the "dynteaser" field of the returned hit
 */
private Chain<Searcher> createSearchChain(String sdName, String content) {
    JuniperSearcher searcher = new JuniperSearcher(new ComponentId("test"), new QrSearchersConfig(new QrSearchersConfig.Builder()));
    DocumentSourceSearcher docsource = new DocumentSourceSearcher();
    addResult(new Query("?query=12"), sdName, content, docsource);
    addResult(new Query("?query=12&bolding=false"), sdName, content, docsource);
    return new Chain<Searcher>(searcher, docsource);
}
Also used : Chain(com.yahoo.component.chain.Chain) Query(com.yahoo.search.Query) QrSearchersConfig(com.yahoo.container.QrSearchersConfig) JuniperSearcher(com.yahoo.prelude.searcher.JuniperSearcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) ComponentId(com.yahoo.component.ComponentId)

Example 15 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class FederationTester method addSearchChain.

void addSearchChain(String id, FederationOptions federationOptions, Searcher... searchers) {
    ComponentId searchChainId = ComponentId.fromString(id);
    builder.addSearchChain(searchChainId, federationOptions, Collections.<String>emptyList());
    Chain<Searcher> chain = new Chain<>(searchChainId, searchers);
    registry.register(chain);
}
Also used : Chain(com.yahoo.component.chain.Chain) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Searcher(com.yahoo.search.Searcher) ComponentId(com.yahoo.component.ComponentId)

Aggregations

ComponentId (com.yahoo.component.ComponentId)68 Test (org.junit.Test)25 Result (com.yahoo.search.Result)14 Query (com.yahoo.search.Query)13 Execution (com.yahoo.search.searchchain.Execution)13 ArrayList (java.util.ArrayList)10 Chain (com.yahoo.component.chain.Chain)8 Searcher (com.yahoo.search.Searcher)8 ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)7 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)7 FederationSearcher (com.yahoo.search.federation.FederationSearcher)6 Hit (com.yahoo.search.result.Hit)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)4 ChainsConfig (com.yahoo.container.core.ChainsConfig)4 FilterChainRepository (com.yahoo.container.http.filter.FilterChainRepository)4 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)4 QueryProfileTypeRegistry (com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)4 Component (com.yahoo.vespa.model.container.component.Component)4 HashMap (java.util.HashMap)4