Search in sources :

Example 41 with ComponentId

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

the class FilterBindingsProviderTest method requireThatEmptyInputGivesEmptyOutput.

@Test
public void requireThatEmptyInputGivesEmptyOutput() {
    final FilterChainRepository filterChainRepository = new FilterChainRepository(new ChainsConfig(new ChainsConfig.Builder()), new ComponentRegistry<>(), new ComponentRegistry<>(), new ComponentRegistry<>(), new ComponentRegistry<>());
    final FilterBindingsProvider provider = new FilterBindingsProvider(new ComponentId("foo"), new ServerConfig(configBuilder), filterChainRepository, new ComponentRegistry<>());
    final FilterBindings filterBindings = provider.get();
    assertThat(filterBindings, is(not(nullValue())));
    assertThat(filterBindings.getRequestFilters().iterator().hasNext(), is(false));
    assertThat(filterBindings.getResponseFilters().iterator().hasNext(), is(false));
}
Also used : ServerConfig(com.yahoo.jdisc.http.ServerConfig) ChainsConfig(com.yahoo.container.core.ChainsConfig) FilterBindings(com.yahoo.jdisc.http.server.FilterBindings) FilterChainRepository(com.yahoo.container.http.filter.FilterChainRepository) ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test)

Example 42 with ComponentId

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

the class FilterBindingsProviderTest method requireThatInstanceCanNotBeBothRequestAndResponseFilter.

@Test
public void requireThatInstanceCanNotBeBothRequestAndResponseFilter() {
    final String filterId = "filter";
    // Set up config.
    configBuilder.filter(new ServerConfig.Filter.Builder().id(filterId).binding("http://*/*"));
    // Set up registry.
    final DualRoleFilter filterInstance = mock(DualRoleFilter.class);
    final ComponentRegistry<RequestFilter> availableRequestFilters = new ComponentRegistry<>();
    availableRequestFilters.register(ComponentId.fromString(filterId), filterInstance);
    final FilterChainRepository filterChainRepository = new FilterChainRepository(new ChainsConfig(new ChainsConfig.Builder()), availableRequestFilters, new ComponentRegistry<>(), new ComponentRegistry<>(), new ComponentRegistry<>());
    try {
        new FilterBindingsProvider(new ComponentId("foo"), new ServerConfig(configBuilder), filterChainRepository, new ComponentRegistry<>());
        fail("Dual-role filter should not be accepted");
    } catch (RuntimeException e) {
        assertThat(e.getMessage(), containsString("Invalid config"));
    }
}
Also used : ChainsConfig(com.yahoo.container.core.ChainsConfig) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ServerConfig(com.yahoo.jdisc.http.ServerConfig) RequestFilter(com.yahoo.jdisc.http.filter.RequestFilter) SecurityRequestFilter(com.yahoo.jdisc.http.filter.SecurityRequestFilter) ResponseFilter(com.yahoo.jdisc.http.filter.ResponseFilter) SecurityResponseFilter(com.yahoo.jdisc.http.filter.SecurityResponseFilter) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) FilterChainRepository(com.yahoo.container.http.filter.FilterChainRepository) ComponentId(com.yahoo.component.ComponentId) RequestFilter(com.yahoo.jdisc.http.filter.RequestFilter) SecurityRequestFilter(com.yahoo.jdisc.http.filter.SecurityRequestFilter) Test(org.junit.Test)

Example 43 with ComponentId

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

the class ApplicationStatusHandler method renderObjectComponents.

static JSONArray renderObjectComponents(Map<ComponentId, ?> componentsById) {
    JSONArray ret = new JSONArray();
    for (Map.Entry<ComponentId, ?> componentEntry : componentsById.entrySet()) {
        JSONObject jc = renderComponent(componentEntry.getValue(), componentEntry.getKey());
        ret.put(jc);
    }
    return ret;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Map(java.util.Map) ComponentId(com.yahoo.component.ComponentId)

Example 44 with ComponentId

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

the class ApplicationStatusHandlerTest method object_components_are_rendered.

@Test
public void object_components_are_rendered() throws Exception {
    HashMap<ComponentId, Object> id2object = new HashMap<>();
    id2object.put(new ComponentId("myComponent"), new Object());
    String json = ApplicationStatusHandler.renderObjectComponents(id2object).toString();
    assertThat(json, containsString("myComponent"));
}
Also used : HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test)

Example 45 with ComponentId

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

the class ApplicationStatusHandlerTest method request_handlers_are_rendered.

@Test
public void request_handlers_are_rendered() throws Exception {
    final String id = "myHandler";
    final String serverBinding1 = "http://*/serverBinding";
    final String serverBinding2 = "http://*/anotherServerBinding";
    final String clientBinding = "http://*/clientBinding";
    HashMap<ComponentId, RequestHandler> handlersById = new HashMap<>();
    handlersById.put(new ComponentId(id), Mockito.mock(RequestHandler.class));
    JdiscBindingsConfig bindingsConfig = new JdiscBindingsConfig(new JdiscBindingsConfig.Builder().handlers(id, new Handlers.Builder().serverBindings(serverBinding1).serverBindings(serverBinding2).clientBindings(clientBinding)));
    String json = ApplicationStatusHandler.renderRequestHandlers(bindingsConfig, handlersById).toString();
    assertThat(json, containsString("\"" + id + "\""));
    assertThat(json, containsString(serverBinding1));
    assertThat(json, containsString(serverBinding2));
    assertThat(json, containsString(clientBinding));
}
Also used : Handlers(com.yahoo.container.jdisc.JdiscBindingsConfig.Handlers) RequestHandler(com.yahoo.jdisc.handler.RequestHandler) 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)

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