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