Search in sources :

Example 36 with MemcachedClient

use of net.spy.memcached.MemcachedClient in project geode by apache.

the class GemcachedDevelopmentJUnitTest method testAppend.

@Test
public void testAppend() throws Exception {
    MemcachedClient client = bootstrapClient();
    Future<Boolean> b = client.append(0, "key", "WithAddition");
    assertTrue(b.get());
    assertEquals("myStringValueWithAddition", client.get("key"));
    b = client.append(0, "appendkey", "val");
    assertFalse(b.get());
    assertNull(client.get("appendkey"));
}
Also used : MemcachedClient(net.spy.memcached.MemcachedClient) Test(org.junit.Test) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 37 with MemcachedClient

use of net.spy.memcached.MemcachedClient in project geode by apache.

the class GemcachedDevelopmentJUnitTest method testDecr.

@Test
public void testDecr() throws Exception {
    MemcachedClient client = bootstrapClient();
    client.add("decrkey", 10, 99).get();
    assertEquals(95, client.decr("decrkey", 4));
    assertEquals(94, client.decr("decrkey", 1));
    assertEquals(-1, client.decr("decrkey1", 77));
}
Also used : MemcachedClient(net.spy.memcached.MemcachedClient) Test(org.junit.Test) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 38 with MemcachedClient

use of net.spy.memcached.MemcachedClient in project geode by apache.

the class GemcachedDevelopmentJUnitTest method testGets.

@Test
public void testGets() throws Exception {
    MemcachedClient client = bootstrapClient();
    client.add("getskey", 10, "casValue").get();
    CASValue<Object> val = client.gets("getskey");
    long oldCas = val.getCas();
    assertEquals("casValue", val.getValue());
    client.replace("getskey", 10, "myNewVal").get();
    val = client.gets("getskey");
    assertEquals(oldCas + 1, val.getCas());
    assertEquals("myNewVal", val.getValue());
}
Also used : MemcachedClient(net.spy.memcached.MemcachedClient) Test(org.junit.Test) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 39 with MemcachedClient

use of net.spy.memcached.MemcachedClient in project geode by apache.

the class GemcachedDevelopmentJUnitTest method testLongExpiration.

@Test
public void testLongExpiration() throws Exception {
    MemcachedClient client = bootstrapClient();
    client.add("newKey", (int) System.currentTimeMillis() - 60 * 1000, "newValue");
    Thread.sleep(15 * 1000);
    assertEquals("newValue", client.get("newKey"));
}
Also used : MemcachedClient(net.spy.memcached.MemcachedClient) Test(org.junit.Test) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 40 with MemcachedClient

use of net.spy.memcached.MemcachedClient in project geode by apache.

the class GemcachedDevelopmentJUnitTest method bootstrapClient.

private MemcachedClient bootstrapClient() throws IOException, UnknownHostException, InterruptedException, ExecutionException {
    MemcachedClient client = createMemcachedClient();
    Future<Boolean> f = client.add("key", 10, "myStringValue");
    f.get();
    Future<Boolean> f1 = client.add("key1", 10, "myStringValue1");
    f1.get();
    return client;
}
Also used : MemcachedClient(net.spy.memcached.MemcachedClient)

Aggregations

MemcachedClient (net.spy.memcached.MemcachedClient)52 Test (org.junit.Test)22 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)20 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)17 InetSocketAddress (java.net.InetSocketAddress)11 ExecutionException (java.util.concurrent.ExecutionException)9 ConnectionFactoryBuilder (net.spy.memcached.ConnectionFactoryBuilder)8 ConnectionFactory (net.spy.memcached.ConnectionFactory)7 IOException (java.io.IOException)6 TimeoutException (java.util.concurrent.TimeoutException)6 Map (java.util.Map)5 HashMap (java.util.HashMap)4 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 BinaryConnectionFactory (net.spy.memcached.BinaryConnectionFactory)3 Predicate (com.google.common.base.Predicate)2 Supplier (com.google.common.base.Supplier)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Config (com.hazelcast.config.Config)2