Search in sources :

Example 1 with CatalogConsulClient

use of com.ecwid.consul.v1.catalog.CatalogConsulClient in project spring-cloud-consul by spring-cloud.

the class ConsulAutoConfigurationTests method tlsConfigured.

@Test
public void tlsConfigured() {
    appContextRunner.withPropertyValues("spring.cloud.consul.tls.key-store-instance-type=JKS", "spring.cloud.consul.tls.key-store-path=src/test/resources/server.jks", "spring.cloud.consul.tls.key-store-password=letmein", "spring.cloud.consul.tls.certificate-path=src/test/resources/trustStore.jks", "spring.cloud.consul.tls.certificate-password=change_me").run(context -> {
        assertThat(context).hasNotFailed().hasSingleBean(ConsulClient.class);
        ConsulClient consulClient = context.getBean(ConsulClient.class);
        CatalogConsulClient client = (CatalogConsulClient) ReflectionTestUtils.getField(consulClient, "catalogClient");
        ConsulRawClient rawClient = (ConsulRawClient) ReflectionTestUtils.getField(client, "rawClient");
        HttpTransport httpTransport = (HttpTransport) ReflectionTestUtils.getField(rawClient, "httpTransport");
        assertThat(httpTransport).isInstanceOf(DefaultHttpsTransport.class);
    });
}
Also used : HttpTransport(com.ecwid.consul.transport.HttpTransport) ConsulClient(com.ecwid.consul.v1.ConsulClient) CatalogConsulClient(com.ecwid.consul.v1.catalog.CatalogConsulClient) ConsulRawClient(com.ecwid.consul.v1.ConsulRawClient) CatalogConsulClient(com.ecwid.consul.v1.catalog.CatalogConsulClient) Test(org.junit.Test)

Example 2 with CatalogConsulClient

use of com.ecwid.consul.v1.catalog.CatalogConsulClient in project spring-cloud-consul by spring-cloud.

the class ConsulAutoConfigurationTests method customPathConfigured.

@Test
public void customPathConfigured() {
    appContextRunner.withPropertyValues("spring.cloud.consul.path=/consul/proxy/").run(context -> {
        assertThat(context).hasNotFailed().hasSingleBean(ConsulClient.class);
        ConsulClient consulClient = context.getBean(ConsulClient.class);
        CatalogConsulClient client = (CatalogConsulClient) ReflectionTestUtils.getField(consulClient, "catalogClient");
        ConsulRawClient rawClient = (ConsulRawClient) ReflectionTestUtils.getField(client, "rawClient");
        String agentAddress = (String) ReflectionTestUtils.getField(rawClient, "agentAddress");
        assertThat(agentAddress).isNotNull();
        assertThat(new URL(agentAddress).getPath()).isEqualTo("/consul/proxy");
    });
}
Also used : ConsulClient(com.ecwid.consul.v1.ConsulClient) CatalogConsulClient(com.ecwid.consul.v1.catalog.CatalogConsulClient) ConsulRawClient(com.ecwid.consul.v1.ConsulRawClient) CatalogConsulClient(com.ecwid.consul.v1.catalog.CatalogConsulClient) URL(java.net.URL) Test(org.junit.Test)

Aggregations

ConsulClient (com.ecwid.consul.v1.ConsulClient)2 ConsulRawClient (com.ecwid.consul.v1.ConsulRawClient)2 CatalogConsulClient (com.ecwid.consul.v1.catalog.CatalogConsulClient)2 Test (org.junit.Test)2 HttpTransport (com.ecwid.consul.transport.HttpTransport)1 URL (java.net.URL)1