Search in sources :

Example 6 with StringConfiguration

use of org.infinispan.commons.configuration.StringConfiguration in project infinispan by infinispan.

the class HotRodAdmin method testCreateDeleteCache.

@Test
public void testCreateDeleteCache() {
    RemoteCacheManager rcm = SERVER_TEST.hotrod().createRemoteCacheManager();
    String cacheName = "testCreateDeleteCache";
    String config = String.format("<infinispan><cache-container><distributed-cache name=\"%s\"/></cache-container></infinispan>", cacheName);
    RemoteCache<String, String> cache = rcm.administration().createCache(cacheName, new StringConfiguration(config));
    cache.put("k", "v");
    assertNotNull(cache.get("k"));
    rcm.administration().removeCache(cacheName);
    assertNull(rcm.getCache(cacheName));
}
Also used : RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) Test(org.junit.Test)

Example 7 with StringConfiguration

use of org.infinispan.commons.configuration.StringConfiguration in project infinispan by infinispan.

the class HotRodAdmin method testCreateDeleteTemplateFragment.

@Test
public void testCreateDeleteTemplateFragment() {
    RemoteCacheManager rcm = SERVER_TEST.hotrod().createRemoteCacheManager();
    String templateName = "templateFragment";
    String template = String.format("<distributed-cache name=\"%s\"/>", templateName);
    rcm.administration().createTemplate(templateName, new StringConfiguration(template));
    RemoteCache<String, String> cache = rcm.administration().createCache("testCreateDeleteTemplateFragment", templateName);
    cache.put("k", "v");
    assertNotNull(cache.get("k"));
    rcm.administration().removeTemplate(templateName);
    Exceptions.expectException(HotRodClientException.class, () -> rcm.administration().createCache("anotherCache", templateName));
}
Also used : RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) Test(org.junit.Test)

Example 8 with StringConfiguration

use of org.infinispan.commons.configuration.StringConfiguration in project infinispan by infinispan.

the class HotRodTransactionalCacheOperations method testTransactionalCache.

@Test
public void testTransactionalCache() throws Exception {
    ConfigurationBuilder config = new ConfigurationBuilder();
    config.remoteCache(SERVER_TEST.getMethodName()).transactionMode(TransactionMode.NON_XA).transactionManagerLookup(RemoteTransactionManagerLookup.getInstance());
    String xml = String.format(TEST_CACHE_XML_CONFIG, SERVER_TEST.getMethodName(), txMode.name());
    RemoteCache<String, String> cache = SERVER_TEST.hotrod().withClientConfiguration(config).withServerConfiguration(new StringConfiguration(xml)).create();
    TransactionManager tm = cache.getTransactionManager();
    tm.begin();
    cache.put("k", "v1");
    assertEquals("v1", cache.get("k"));
    tm.commit();
    assertEquals("v1", cache.get("k"));
    tm.begin();
    cache.put("k", "v2");
    cache.put("k2", "v1");
    assertEquals("v2", cache.get("k"));
    assertEquals("v1", cache.get("k2"));
    tm.rollback();
    assertEquals("v1", cache.get("k"));
    assertNull(cache.get("k2"));
}
Also used : ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) TransactionManager(javax.transaction.TransactionManager) Test(org.junit.Test)

Example 9 with StringConfiguration

use of org.infinispan.commons.configuration.StringConfiguration in project infinispan by infinispan.

the class XSiteHotRodCacheOperations method getTotalMemoryEntries.

private int getTotalMemoryEntries(String lonXML) {
    RestClient restClient = SERVER_TEST.rest(LON).withServerConfiguration(new StringConfiguration(lonXML)).get();
    RestCacheClient client = restClient.cache(SERVER_TEST.getMethodName());
    Json json = Json.read(sync(client.stats()).getBody());
    return json.asJsonMap().get("current_number_of_entries_in_memory").asInteger();
}
Also used : StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) RestClient(org.infinispan.client.rest.RestClient) RestCacheClient(org.infinispan.client.rest.RestCacheClient) Json(org.infinispan.commons.dataconversion.internal.Json)

Example 10 with StringConfiguration

use of org.infinispan.commons.configuration.StringConfiguration in project infinispan by infinispan.

the class XSiteHotRodCacheOperations method testHotRodOperationsWithDifferentCacheName.

@Test
public void testHotRodOperationsWithDifferentCacheName() {
    RemoteCache<String, String> lonCache = SERVER_TEST.hotrod(LON).createRemoteCacheManager().administration().createCache("lon-cache", new StringConfiguration(LON_CACHE_CUSTOM_NAME_XML_CONFIG));
    RemoteCache<String, String> nycCache = SERVER_TEST.hotrod(NYC).createRemoteCacheManager().administration().createCache("nyc-cache", new StringConfiguration(NYC_CACHE_CUSTOM_NAME_XML_CONFIG));
    insertAndVerifyEntries(lonCache, nycCache, true);
}
Also used : StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) Test(org.junit.Test)

Aggregations

StringConfiguration (org.infinispan.commons.configuration.StringConfiguration)18 Test (org.junit.Test)8 RemoteCacheManager (org.infinispan.client.hotrod.RemoteCacheManager)6 BasicConfiguration (org.infinispan.commons.configuration.BasicConfiguration)3 TransactionManager (javax.transaction.TransactionManager)2 ConfigurationBuilder (org.infinispan.client.hotrod.configuration.ConfigurationBuilder)2 RestClient (org.infinispan.client.rest.RestClient)2 Test (org.testng.annotations.Test)2 CacheMeterBinder (io.micrometer.core.instrument.binder.cache.CacheMeterBinder)1 HashMap (java.util.HashMap)1 RemoteCacheManagerAdmin (org.infinispan.client.hotrod.RemoteCacheManagerAdmin)1 RemoteCacheConfiguration (org.infinispan.client.hotrod.configuration.RemoteCacheConfiguration)1 TransactionMode (org.infinispan.client.hotrod.configuration.TransactionMode)1 OperationsFactory (org.infinispan.client.hotrod.impl.operations.OperationsFactory)1 PingResponse (org.infinispan.client.hotrod.impl.operations.PingResponse)1 SingleHotRodServerTest (org.infinispan.client.hotrod.test.SingleHotRodServerTest)1 RestCacheClient (org.infinispan.client.rest.RestCacheClient)1 RestMetricsClient (org.infinispan.client.rest.RestMetricsClient)1 RestResponse (org.infinispan.client.rest.RestResponse)1 Json (org.infinispan.commons.dataconversion.internal.Json)1