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));
}
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));
}
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"));
}
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();
}
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);
}
Aggregations