Search in sources :

Example 11 with MemcachedClient

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

the class GemcachedDevelopmentJUnitTest method testExpiration.

// GEODE-1140: time sensitive, thread sleep
@Category(FlakyTest.class)
@Test
public void testExpiration() throws Exception {
    MemcachedClient client = bootstrapClient();
    // we add with expiration 10 seconds
    Thread.sleep(15 * 1000);
    assertNull(client.get("key"));
}
Also used : MemcachedClient(net.spy.memcached.MemcachedClient) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 12 with MemcachedClient

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

the class GemcachedDevelopmentJUnitTest method testPrepend.

@Test
public void testPrepend() throws Exception {
    MemcachedClient client = bootstrapClient();
    Future<Boolean> b = client.prepend(0, "key", "prepended");
    assertTrue(b.get());
    assertEquals("prependedmyStringValue", client.get("key"));
    b = client.prepend(0, "prependkey", "val");
    assertFalse(b.get());
    assertNull(client.get("prependkey"));
}
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 13 with MemcachedClient

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

the class GemcachedDevelopmentJUnitTest method testIncr.

@Test
public void testIncr() throws Exception {
    MemcachedClient client = bootstrapClient();
    client.add("incrkey", 10, 99).get();
    assertEquals(104, client.incr("incrkey", 5));
    assertEquals(105, client.incr("incrkey", 1));
    assertEquals(-1, client.incr("inckey1", 10));
}
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 14 with MemcachedClient

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

the class GemcachedDevelopmentJUnitTest method testCas.

@Test
public void testCas() throws Exception {
    MemcachedClient client = bootstrapClient();
    client.add("caskey", 10, "casValue").get();
    CASValue<Object> val = client.gets("caskey");
    assertEquals("casValue", val.getValue());
    CASResponse r = client.cas("caskey", val.getCas(), "newValue");
    assertEquals(CASResponse.OK, r);
    r = client.cas("caskey", val.getCas(), "newValue2");
    assertEquals(CASResponse.EXISTS, r);
}
Also used : MemcachedClient(net.spy.memcached.MemcachedClient) CASResponse(net.spy.memcached.CASResponse) Test(org.junit.Test) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 15 with MemcachedClient

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

the class GemcachedDevelopmentJUnitTest method testDelete.

@Test
public void testDelete() throws Exception {
    MemcachedClient client = bootstrapClient();
    Future<Boolean> b = client.delete("key");
    assertTrue(b.get());
    b = client.delete("nonExistentkey");
    assertFalse(b.get());
}
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)

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