Search in sources :

Example 1 with Handlers

use of com.yahoo.container.jdisc.JdiscBindingsConfig.Handlers 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 2 with Handlers

use of com.yahoo.container.jdisc.JdiscBindingsConfig.Handlers 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)2 JdiscBindingsConfig (com.yahoo.container.jdisc.JdiscBindingsConfig)2 Handlers (com.yahoo.container.jdisc.JdiscBindingsConfig.Handlers)2 HashMap (java.util.HashMap)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Test (org.junit.Test)2 RequestHandler (com.yahoo.jdisc.handler.RequestHandler)1 ClientProvider (com.yahoo.jdisc.service.ClientProvider)1