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));
}
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;
}
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();
}
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);
}
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);
}
Aggregations