Search in sources :

Example 1 with StringConfiguration

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

the class RemoteCacheAdminStandaloneTest method testCreateClusteredCacheStandAloneServer.

@Test(expectedExceptions = HotRodClientException.class, expectedExceptionsMessageRegExp = ".*ISPN005034.*")
public void testCreateClusteredCacheStandAloneServer() {
    String xml = String.format("<infinispan><cache-container><distributed-cache name=\"%s\"></distributed-cache></cache-container></infinispan>", "cache");
    RemoteCache<?, ?> cache = remoteCacheManager.administration().createCache("cache", new StringConfiguration(xml));
    assertEquals(0, cache.size());
}
Also used : StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) Test(org.testng.annotations.Test) SingleHotRodServerTest(org.infinispan.client.hotrod.test.SingleHotRodServerTest)

Example 2 with StringConfiguration

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

the class RemoteCacheAdminTest method cacheCreateWithXMLConfigurationAndGetCache.

private void cacheCreateWithXMLConfigurationAndGetCache(String cacheName, String xml) {
    client(0).administration().withFlags(CacheContainerAdmin.AdminFlag.VOLATILE).createCache(cacheName, new StringConfiguration(xml));
    final RemoteCache<Object, Object> cache = client(0).getCache(cacheName);
    assertNotNull(cache);
}
Also used : StringConfiguration(org.infinispan.commons.configuration.StringConfiguration)

Example 3 with StringConfiguration

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

the class RemoteCacheAdminTest method templateCreateRemoveTest.

public void templateCreateRemoveTest(Method m) {
    String templateName = m.getName();
    String xml = String.format("<infinispan><cache-container><distributed-cache name=\"%s\"/></cache-container></infinispan>", templateName);
    BasicConfiguration template = new StringConfiguration(xml);
    client(0).administration().withFlags(CacheContainerAdmin.AdminFlag.VOLATILE).createTemplate(templateName, template);
    assertTrue(manager(0).getCacheConfigurationNames().contains(templateName));
    assertTrue(manager(0).getCacheConfigurationNames().contains(templateName));
    client(1).administration().removeTemplate(templateName);
    assertFalse(manager(0).getCacheConfigurationNames().contains(templateName));
    assertFalse(manager(0).getCacheConfigurationNames().contains(templateName));
}
Also used : StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) BasicConfiguration(org.infinispan.commons.configuration.BasicConfiguration)

Example 4 with StringConfiguration

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

the class RemoteCacheAdminTest method cacheCreateWithStringConfiguration.

private void cacheCreateWithStringConfiguration(String cacheName, String xml) {
    client(0).administration().withFlags(CacheContainerAdmin.AdminFlag.VOLATILE).getOrCreateCache(cacheName, new StringConfiguration(xml));
    Configuration configuration = manager(0).getCache(cacheName).getCacheConfiguration();
    assertEquals(10000, configuration.expiration().wakeUpInterval());
    assertEquals(10, configuration.expiration().lifespan());
    assertEquals(10, configuration.expiration().maxIdle());
    assertEquals(MediaType.TEXT_PLAIN, configuration.encoding().keyDataType().mediaType());
    assertEquals(MediaType.APPLICATION_JSON, configuration.encoding().valueDataType().mediaType());
}
Also used : StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) BasicConfiguration(org.infinispan.commons.configuration.BasicConfiguration) StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) HotRodTestingUtil.hotRodCacheConfiguration(org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration) Configuration(org.infinispan.configuration.cache.Configuration)

Example 5 with StringConfiguration

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

the class IndexedCacheNonIndexedEntityTest method shouldPreventNonIndexedEntities.

@Test(expectedExceptions = HotRodClientException.class, expectedExceptionsMessageRegExp = ".*The configured indexed-entity type 'Entity' must be indexed.*")
public void shouldPreventNonIndexedEntities() {
    String config = "<infinispan>" + "  <cache-container>" + "     <local-cache name=\"" + CACHE_NAME + "\">\n" + "        <encoding media-type=\"application/x-protostream\"/>\n" + "        <indexing storage=\"local-heap\">\n" + "           <indexed-entities>\n" + "              <indexed-entity>Entity</indexed-entity>\n" + "              <indexed-entity>EvilTwin</indexed-entity>\n" + "           </indexed-entities>\n" + "          </indexing>" + "       </local-cache>" + "  </cache-container>" + "</infinispan>";
    remoteCacheManager.administration().withFlags(VOLATILE).createCache(CACHE_NAME, new StringConfiguration(config));
    // The SearchMapping is started lazily for protobuf caches, so the exception only happens after first usage
    RemoteCache<Object, Object> cache = remoteCacheManager.getCache(CACHE_NAME);
    cache.put("1", new Entity("name"));
}
Also used : StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) SingleCacheManagerTest(org.infinispan.test.SingleCacheManagerTest) Test(org.testng.annotations.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