Search in sources :

Example 1 with MemcachedServerConfigurationBuilder

use of org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder in project infinispan by infinispan.

the class MemcachedServerTest method testNoDefaultConfigurationLocal.

public void testNoDefaultConfigurationLocal() {
    GlobalConfigurationBuilder global = new GlobalConfigurationBuilder();
    Stoppable.useCacheManager(new DefaultCacheManager(global.build()), cm -> Stoppable.useServer(new MemcachedServer(), ms -> {
        ms.start(new MemcachedServerConfigurationBuilder().build(), cm);
        assertEquals(CacheMode.LOCAL, ms.getCache().getCacheConfiguration().clustering().cacheMode());
    }));
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) CacheMode(org.infinispan.configuration.cache.CacheMode) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) AbstractInfinispanTest(org.infinispan.test.AbstractInfinispanTest) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Stoppable(org.infinispan.server.core.test.Stoppable) CacheConfigurationException(org.infinispan.commons.CacheConfigurationException) TestCacheManagerFactory(org.infinispan.test.fwk.TestCacheManagerFactory) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) Test(org.testng.annotations.Test) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) AssertJUnit.fail(org.testng.AssertJUnit.fail) MemcachedServerConfigurationBuilder(org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) MemcachedServerConfigurationBuilder(org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder)

Example 2 with MemcachedServerConfigurationBuilder

use of org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder in project infinispan by infinispan.

the class MemcachedServerTest method testValidateInvalidExpiration.

@Test(expectedExceptions = CacheConfigurationException.class)
public void testValidateInvalidExpiration() {
    ConfigurationBuilder config = new ConfigurationBuilder();
    config.expiration().lifespan(10);
    Stoppable.useCacheManager(TestCacheManagerFactory.createCacheManager(config), cm -> Stoppable.useServer(new MemcachedServer(), ms -> {
        ms.start(new MemcachedServerConfigurationBuilder().defaultCacheName(cm.getCacheManagerConfiguration().defaultCacheName().get()).build(), cm);
        fail("Server should not start when expiration is enabled");
    }));
}
Also used : CacheMode(org.infinispan.configuration.cache.CacheMode) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) AbstractInfinispanTest(org.infinispan.test.AbstractInfinispanTest) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Stoppable(org.infinispan.server.core.test.Stoppable) CacheConfigurationException(org.infinispan.commons.CacheConfigurationException) TestCacheManagerFactory(org.infinispan.test.fwk.TestCacheManagerFactory) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) Test(org.testng.annotations.Test) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) AssertJUnit.fail(org.testng.AssertJUnit.fail) MemcachedServerConfigurationBuilder(org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) MemcachedServerConfigurationBuilder(org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder) MemcachedServerConfigurationBuilder(org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder) AbstractInfinispanTest(org.infinispan.test.AbstractInfinispanTest) Test(org.testng.annotations.Test)

Example 3 with MemcachedServerConfigurationBuilder

use of org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder in project infinispan by infinispan.

the class MemcachedTestingUtil method startMemcachedTextServer.

public static MemcachedServer startMemcachedTextServer(EmbeddedCacheManager cacheManager, int port, MediaType valueMediaType) {
    MemcachedServer server = new MemcachedServer();
    String serverName = TestResourceTracker.getCurrentTestShortName();
    server.start(new MemcachedServerConfigurationBuilder().name(serverName).host(host).port(port).clientEncoding(valueMediaType).build(), cacheManager);
    return server;
}
Also used : MemcachedServerConfigurationBuilder(org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder) MemcachedServer(org.infinispan.server.memcached.MemcachedServer)

Example 4 with MemcachedServerConfigurationBuilder

use of org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder in project infinispan by infinispan.

the class NoReplyListener method testStoreAsBinaryOverride.

public void testStoreAsBinaryOverride() {
    ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false);
    builder.memory().storageType(StorageType.BINARY);
    EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(builder);
    Configuration cfg = builder.build();
    cm.defineConfiguration(new MemcachedServerConfigurationBuilder().build().defaultCacheName(), cfg);
    assertEquals(StorageType.BINARY, cfg.memory().storageType());
    MemcachedServer testServer = startMemcachedTextServer(cm, server.getPort() + 33);
    try {
        Cache memcachedCache = cm.getCache(testServer.getConfiguration().defaultCacheName());
        assertEquals(StorageType.BINARY, memcachedCache.getCacheConfiguration().memory().storageType());
    } finally {
        cm.stop();
        testServer.stop();
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) MemcachedServerConfigurationBuilder(org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) MemcachedServerConfigurationBuilder(org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) Cache(org.infinispan.Cache)

Example 5 with MemcachedServerConfigurationBuilder

use of org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder in project infinispan by infinispan.

the class MemcachedServerTest method testNoDefaultConfigurationClustered.

public void testNoDefaultConfigurationClustered() {
    GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
    Stoppable.useCacheManager(new DefaultCacheManager(global.build()), cm -> Stoppable.useServer(new MemcachedServer(), ms -> {
        ms.start(new MemcachedServerConfigurationBuilder().build(), cm);
        assertEquals(CacheMode.REPL_SYNC, ms.getCache().getCacheConfiguration().clustering().cacheMode());
    }));
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) CacheMode(org.infinispan.configuration.cache.CacheMode) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) AbstractInfinispanTest(org.infinispan.test.AbstractInfinispanTest) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Stoppable(org.infinispan.server.core.test.Stoppable) CacheConfigurationException(org.infinispan.commons.CacheConfigurationException) TestCacheManagerFactory(org.infinispan.test.fwk.TestCacheManagerFactory) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) Test(org.testng.annotations.Test) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) AssertJUnit.fail(org.testng.AssertJUnit.fail) MemcachedServerConfigurationBuilder(org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) MemcachedServerConfigurationBuilder(org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder)

Aggregations

MemcachedServerConfigurationBuilder (org.infinispan.server.memcached.configuration.MemcachedServerConfigurationBuilder)6 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)4 CacheConfigurationException (org.infinispan.commons.CacheConfigurationException)3 CacheMode (org.infinispan.configuration.cache.CacheMode)3 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)3 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)3 Stoppable (org.infinispan.server.core.test.Stoppable)3 AbstractInfinispanTest (org.infinispan.test.AbstractInfinispanTest)3 TestCacheManagerFactory (org.infinispan.test.fwk.TestCacheManagerFactory)3 AssertJUnit.assertEquals (org.testng.AssertJUnit.assertEquals)3 AssertJUnit.fail (org.testng.AssertJUnit.fail)3 Test (org.testng.annotations.Test)3 MemcachedServer (org.infinispan.server.memcached.MemcachedServer)2 Cache (org.infinispan.Cache)1 Configuration (org.infinispan.configuration.cache.Configuration)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 MemcachedDecoder (org.infinispan.server.memcached.MemcachedDecoder)1