Search in sources :

Example 1 with RestClientConfiguration

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

the class RestConnectorTest method testUrlWithoutPort.

@Test
public void testUrlWithoutPort() {
    RestConnector connector = new RestConnector();
    RestConnection connection = (RestConnection) connector.getConnection("http://localhost", null);
    RestClientConfigurationBuilder builder = connection.getBuilder();
    RestClientConfiguration configuration = builder.build();
    assertEquals(80, 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 2 with RestClientConfiguration

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

the class RestConnectorTest method testUrlWithCredentials.

@Test
public void testUrlWithCredentials() {
    RestConnector connector = new RestConnector();
    RestConnection connection = (RestConnection) connector.getConnection("http://user:password@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());
    assertTrue(configuration.security().authentication().enabled());
    assertEquals("user", configuration.security().authentication().username());
    assertArrayEquals("password".toCharArray(), configuration.security().authentication().password());
}
Also used : RestClientConfiguration(org.infinispan.client.rest.configuration.RestClientConfiguration) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) Test(org.junit.Test)

Example 3 with RestClientConfiguration

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

the class RestConnectorTest method testEmptyUrl.

@Test
public void testEmptyUrl() {
    RestConnector connector = new RestConnector();
    RestConnection connection = (RestConnection) connector.getConnection("", null);
    RestClientConfigurationBuilder builder = connection.getBuilder();
    RestClientConfiguration configuration = builder.build();
    assertEquals(11222, configuration.servers().get(0).port());
    assertEquals("localhost", 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)

Example 4 with RestClientConfiguration

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

the class XSiteResourceTest method startServers.

@BeforeClass
public void startServers() {
    sites.forEach(site -> {
        String siteName = site.getSiteName();
        EmbeddedCacheManager cm = site.cacheManagers().iterator().next();
        RestServerHelper restServerHelper = new RestServerHelper(cm);
        restServerHelper.start(TestResourceTracker.getCurrentTestShortName());
        restServerPerSite.put(siteName, restServerHelper);
        RestClientConfiguration clientConfig = new RestClientConfigurationBuilder().addServer().host("127.0.0.1").port(restServerHelper.getPort()).build();
        RestClient client = RestClient.forConfiguration(clientConfig);
        clientPerSite.put(siteName, client);
    });
}
Also used : RestClientConfiguration(org.infinispan.client.rest.configuration.RestClientConfiguration) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) RestClient(org.infinispan.client.rest.RestClient) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) RestServerHelper(org.infinispan.rest.helper.RestServerHelper) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with RestClientConfiguration

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

the class EndpointInteroperabilityTest method setup.

@BeforeClass
protected void setup() throws Exception {
    cacheManager = TestCacheManagerFactory.createServerModeCacheManager();
    cacheManager.defineConfiguration(DEFAULT_CACHE_NAME, getDefaultCacheConfiguration().build());
    cacheManager.defineConfiguration(MARSHALLED_CACHE_NAME, getMarshalledCacheConfiguration().build());
    cacheManager.defineConfiguration(STRING_CACHE_NAME, getStringsCacheConfiguration().build());
    RestServerConfigurationBuilder builder = new RestServerConfigurationBuilder();
    builder.port(findFreePort());
    restServer = new RestServer();
    restServer.setServerManagement(new DummyServerManagement(), true);
    restServer.start(builder.build(), cacheManager);
    RestClientConfigurationBuilder clientBuilder = new RestClientConfigurationBuilder();
    RestClientConfiguration configuration = clientBuilder.addServer().host(restServer.getHost()).port(restServer.getPort()).build();
    restClient = RestClient.forConfiguration(configuration);
    HotRodServerConfigurationBuilder serverBuilder = new HotRodServerConfigurationBuilder();
    serverBuilder.adminOperationsHandler(new EmbeddedServerAdminOperationHandler());
    hotRodServer = startHotRodServer(cacheManager, serverBuilder);
    defaultRemoteCache = createRemoteCacheManager(IdentityMarshaller.INSTANCE).getCache(DEFAULT_CACHE_NAME);
    defaultMarshalledRemoteCache = createRemoteCacheManager(null).getCache(MARSHALLED_CACHE_NAME);
    stringRemoteCache = createRemoteCacheManager(new UTF8StringMarshaller()).getCache(STRING_CACHE_NAME);
}
Also used : RestServer(org.infinispan.rest.RestServer) RestServerConfigurationBuilder(org.infinispan.rest.configuration.RestServerConfigurationBuilder) RestClientConfiguration(org.infinispan.client.rest.configuration.RestClientConfiguration) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) EmbeddedServerAdminOperationHandler(org.infinispan.server.core.admin.embeddedserver.EmbeddedServerAdminOperationHandler) UTF8StringMarshaller(org.infinispan.commons.marshall.UTF8StringMarshaller) DummyServerManagement(org.infinispan.server.core.DummyServerManagement) HotRodServerConfigurationBuilder(org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder) BeforeClass(org.testng.annotations.BeforeClass)

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