use of net.spy.memcached.MemcachedClient in project geode by apache.
the class GemcachedBinaryClientJUnitTest method testCacheLoaderException.
@SuppressWarnings("unchecked")
public void testCacheLoaderException() throws Exception {
MemcachedClient client = createMemcachedClient();
assertTrue(client.set("key", 0, "value").get());
GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
Region region = cache.getRegion(GemFireMemcachedServer.REGION_NAME);
region.getAttributesMutator().setCacheLoader(new CacheLoader() {
@Override
public void close() {
}
@Override
public Object load(LoaderHelper helper) throws CacheLoaderException {
if (helper.getKey().equals(KeyWrapper.getWrappedKey("exceptionkey".getBytes()))) {
throw new RuntimeException("ExpectedStrings: Cache loader exception");
}
return null;
}
});
long start = System.nanoTime();
try {
client.get("exceptionkey");
throw new RuntimeException("expected exception not thrown");
} catch (Exception e) {
// expected
}
assertEquals("value", client.get("key"));
}
use of net.spy.memcached.MemcachedClient in project geode by apache.
the class GemcachedDevelopmentJUnitTest method testFlushDelay.
@Test
public void testFlushDelay() throws Exception {
MemcachedClient client = bootstrapClient();
Future<Boolean> b = client.flush(5);
assertTrue(b.get());
assertNotNull(client.get("key"));
assertNotNull(client.get("key1"));
Thread.sleep(8 * 1000);
assertNull(client.get("key"));
assertNull(client.get("key1"));
}
use of net.spy.memcached.MemcachedClient in project geode by apache.
the class GemcachedDevelopmentJUnitTest method testPutGet.
@Test
public void testPutGet() throws Exception {
MemcachedClient client = createMemcachedClient();
Future<Boolean> f = client.add("key", 10, "myStringValue");
assertTrue(f.get());
Future<Boolean> f1 = client.add("key1", 10, "myStringValue1");
assertTrue(f1.get());
assertEquals("myStringValue", client.get("key"));
assertEquals("myStringValue1", client.get("key1"));
assertNull(client.get("nonExistentkey"));
// zero exp
f = client.add("Hello", 0, "World");
Thread.sleep(1100);
assertEquals("World", client.get("Hello"));
}
use of net.spy.memcached.MemcachedClient in project geode by apache.
the class GemcachedDevelopmentJUnitTest method testReplace.
@Test
public void testReplace() throws Exception {
MemcachedClient client = bootstrapClient();
Future<Boolean> b = client.replace("key", 10, "newVal");
assertTrue(b.get());
b = client.replace("nonExistentkey", 10, "val");
assertFalse(b.get());
b = client.replace("key", 10, "myStringValue");
assertTrue(b.get());
}
use of net.spy.memcached.MemcachedClient in project geode by apache.
the class GemcachedDevelopmentJUnitTest method testFlush.
@Test
public void testFlush() throws Exception {
MemcachedClient client = bootstrapClient();
Future<Boolean> b = client.flush();
assertTrue(b.get());
assertNull(client.get("key"));
assertNull(client.get("key1"));
}
Aggregations