Search in sources :

Example 6 with RestClientConfiguration

use of org.infinispan.client.rest.configuration.RestClientConfiguration in project infinispan by infinispan.

the class RestConnectorTest method testUrlWithoutCredentials.

@Test
public void testUrlWithoutCredentials() {
    RestConnector connector = new RestConnector();
    RestConnection connection = (RestConnection) connector.getConnection("http://localhost:11222", null);
    RestClientConfigurationBuilder builder = connection.getBuilder();
    RestClientConfiguration configuration = builder.build();
    assertEquals(11222, configuration.servers().get(0).port());
    assertEquals("localhost", configuration.servers().get(0).host());
    assertFalse(configuration.security().authentication().enabled());
}
Also used : RestClientConfiguration(org.infinispan.client.rest.configuration.RestClientConfiguration) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) Test(org.junit.Test)

Example 7 with RestClientConfiguration

use of org.infinispan.client.rest.configuration.RestClientConfiguration in project infinispan by infinispan.

the class RestConnectorTest method testUrlWithSSL.

@Test
public void testUrlWithSSL() throws NoSuchAlgorithmException {
    RestConnector connector = new RestConnector();
    RestConnection connection = (RestConnection) connector.getConnection("https://localhost", null);
    RestClientConfigurationBuilder builder = connection.getBuilder();
    builder.security().ssl().sslContext(SSLContext.getDefault()).trustManagers(new TrustManager[] { new ZeroSecurityTrustManager() });
    RestClientConfiguration configuration = builder.build();
    assertEquals(443, configuration.servers().get(0).port());
    assertEquals("localhost", configuration.servers().get(0).host());
    assertFalse(configuration.security().authentication().enabled());
    assertTrue(configuration.security().ssl().enabled());
}
Also used : RestClientConfiguration(org.infinispan.client.rest.configuration.RestClientConfiguration) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) ZeroSecurityTrustManager(org.infinispan.cli.util.ZeroSecurityTrustManager) Test(org.junit.Test)

Example 8 with RestClientConfiguration

use of org.infinispan.client.rest.configuration.RestClientConfiguration in project infinispan by infinispan.

the class RestConnectorTest method testPlainHostPort.

@Test
public void testPlainHostPort() {
    RestConnector connector = new RestConnector();
    RestConnection connection = (RestConnection) connector.getConnection("my.host.com:12345", null);
    RestClientConfigurationBuilder builder = connection.getBuilder();
    RestClientConfiguration configuration = builder.build();
    assertEquals(12345, configuration.servers().get(0).port());
    assertEquals("my.host.com", configuration.servers().get(0).host());
}
Also used : RestClientConfiguration(org.infinispan.client.rest.configuration.RestClientConfiguration) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) Test(org.junit.Test)

Aggregations

RestClientConfiguration (org.infinispan.client.rest.configuration.RestClientConfiguration)8 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)8 Test (org.junit.Test)6 BeforeClass (org.testng.annotations.BeforeClass)2 ZeroSecurityTrustManager (org.infinispan.cli.util.ZeroSecurityTrustManager)1 RestClient (org.infinispan.client.rest.RestClient)1 UTF8StringMarshaller (org.infinispan.commons.marshall.UTF8StringMarshaller)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 RestServer (org.infinispan.rest.RestServer)1 RestServerConfigurationBuilder (org.infinispan.rest.configuration.RestServerConfigurationBuilder)1 RestServerHelper (org.infinispan.rest.helper.RestServerHelper)1 DummyServerManagement (org.infinispan.server.core.DummyServerManagement)1 EmbeddedServerAdminOperationHandler (org.infinispan.server.core.admin.embeddedserver.EmbeddedServerAdminOperationHandler)1 HotRodServerConfigurationBuilder (org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder)1