Search in sources :

Example 1 with JdiscBindingsConfig

use of com.yahoo.container.jdisc.JdiscBindingsConfig in project vespa by vespa-engine.

the class MultipleRestApisTest method jersey_bindings_are_included_in_config.

@Test
public void jersey_bindings_are_included_in_config() {
    JdiscBindingsConfig config = root.getConfig(JdiscBindingsConfig.class, CLUSTER_ID);
    assertThat(config.handlers(HANDLER_ID_1).serverBindings(), hasItems(HTTP_BINDING_1, HTTPS_BINDING_1));
    assertThat(config.handlers(HANDLER_ID_2).serverBindings(), hasItems(HTTP_BINDING_2, HTTPS_BINDING_2));
}
Also used : JdiscBindingsConfig(com.yahoo.container.jdisc.JdiscBindingsConfig) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 2 with JdiscBindingsConfig

use of com.yahoo.container.jdisc.JdiscBindingsConfig in project vespa by vespa-engine.

the class RestApiTest method jersey_bindings_are_included_in_config.

@Test
public void jersey_bindings_are_included_in_config() throws Exception {
    setup();
    JdiscBindingsConfig config = root.getConfig(JdiscBindingsConfig.class, ClusterId);
    assertThat(config.handlers(HandlerId).serverBindings(), hasItems(HttpBinding, HttpsBinding));
}
Also used : JdiscBindingsConfig(com.yahoo.container.jdisc.JdiscBindingsConfig) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 3 with JdiscBindingsConfig

use of com.yahoo.container.jdisc.JdiscBindingsConfig in project vespa by vespa-engine.

the class RestApiTest method legacy_syntax_should_produce_valid_model.

@Test
public void legacy_syntax_should_produce_valid_model() throws Exception {
    String legacyXml = "<container version=\"1.0\" >\n" + "  <handler id=\"" + JerseyHandler.CLASS + "\" >\n" + "    <binding>" + HttpBinding + "</binding>\n" + "    <config name=\"jdisc.jersey.jersey-handler\">\n" + "      <jerseyMapping>jersey</jerseyMapping>\n" + "    </config>\n" + "  </handler>\n" + "</container>";
    createModel(root, DomBuilderTest.parse(legacyXml));
    Handler<?> handler = (Handler<?>) getContainerComponent("container", JerseyHandler.CLASS);
    assertThat(handler, not(nullValue()));
    assertThat(handler.getServerBindings(), hasItem(HttpBinding));
    JdiscBindingsConfig bindingsConfig = root.getConfig(JdiscBindingsConfig.class, ClusterId);
    assertThat(bindingsConfig.handlers(JerseyHandler.CLASS).serverBindings(), hasItem(HttpBinding));
}
Also used : Handler(com.yahoo.vespa.model.container.component.Handler) JerseyHandler(com.yahoo.vespa.model.container.jersey.JerseyHandler) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) JdiscBindingsConfig(com.yahoo.container.jdisc.JdiscBindingsConfig) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 4 with JdiscBindingsConfig

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

use of com.yahoo.container.jdisc.JdiscBindingsConfig in project vespa by vespa-engine.

the class ContainerModelBuilderTest method verify_bindings_for_builtin_handlers.

@Test
public void verify_bindings_for_builtin_handlers() throws Exception {
    Element clusterElem = DomBuilderTest.parse("<jdisc id='default' version='1.0' />");
    createModel(root, clusterElem);
    JdiscBindingsConfig config = root.getConfig(JdiscBindingsConfig.class, "default/container.0");
    JdiscBindingsConfig.Handlers defaultRootHandler = config.handlers(BindingsOverviewHandler.class.getName());
    assertThat(defaultRootHandler.serverBindings(), contains("*://*/"));
    JdiscBindingsConfig.Handlers applicationStatusHandler = config.handlers(ApplicationStatusHandler.class.getName());
    assertThat(applicationStatusHandler.serverBindings(), contains("http://*/ApplicationStatus", "https://*/ApplicationStatus"));
    JdiscBindingsConfig.Handlers statisticsRequestHandler = config.handlers(StatisticsRequestHandler.class.getName());
    assertTrue(statisticsRequestHandler.serverBindings(0).startsWith("http://*/statistics"));
    assertTrue(statisticsRequestHandler.serverBindings(1).startsWith("https://*/statistics"));
    JdiscBindingsConfig.Handlers fileRequestHandler = config.handlers(VipStatusHandler.class.getName());
    assertThat(fileRequestHandler.serverBindings(), contains("http://*/status.html", "https://*/status.html"));
}
Also used : Element(org.w3c.dom.Element) BindingsOverviewHandler(com.yahoo.container.usability.BindingsOverviewHandler) VipStatusHandler(com.yahoo.container.handler.VipStatusHandler) ApplicationStatusHandler(com.yahoo.container.handler.observability.ApplicationStatusHandler) JdiscBindingsConfig(com.yahoo.container.jdisc.JdiscBindingsConfig) StatisticsRequestHandler(com.yahoo.container.config.StatisticsRequestHandler) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Test(org.junit.Test)

Aggregations

JdiscBindingsConfig (com.yahoo.container.jdisc.JdiscBindingsConfig)6 Test (org.junit.Test)6 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 ComponentId (com.yahoo.component.ComponentId)2 Handlers (com.yahoo.container.jdisc.JdiscBindingsConfig.Handlers)2 HashMap (java.util.HashMap)2 StatisticsRequestHandler (com.yahoo.container.config.StatisticsRequestHandler)1 VipStatusHandler (com.yahoo.container.handler.VipStatusHandler)1 ApplicationStatusHandler (com.yahoo.container.handler.observability.ApplicationStatusHandler)1 BindingsOverviewHandler (com.yahoo.container.usability.BindingsOverviewHandler)1 RequestHandler (com.yahoo.jdisc.handler.RequestHandler)1 ClientProvider (com.yahoo.jdisc.service.ClientProvider)1 Handler (com.yahoo.vespa.model.container.component.Handler)1 JerseyHandler (com.yahoo.vespa.model.container.jersey.JerseyHandler)1 Element (org.w3c.dom.Element)1