Package redis.client

Source Code of redis.client.Issue20Test

package redis.client;

import com.google.common.util.concurrent.ListenableFuture;
import org.junit.Before;
import org.junit.Test;
import redis.reply.StatusReply;

import java.util.concurrent.Future;

import static junit.framework.Assert.assertEquals;

/**
* https://github.com/spullara/redis-protocol/issues/20
*/
public class Issue20Test {
  private RedisClient client;

  @Before
  public void setUp() throws Exception {
    client = new RedisClient("localhost", 6379);
  }

  @Test
  public void testMultiDiscard() throws Exception {
    StatusReply set = client.set("testitnow", "willdo");
    StatusReply multi = client.multi();
    ListenableFuture<StatusReply> set1 = client.pipeline().set("testitnow", "notok");
    client.discard();
    assertEquals("willdo", new String(client.get("testitnow").data()));
    // Ensure we can run a new tx after discarding previous one
    testMultiExec();
  }

  @Test
  public void testMultiExec() throws Exception {
    StatusReply multi = client.multi();
    ListenableFuture<StatusReply> reply = client.pipeline().set("key", "value");
    Future<Boolean> exec = client.exec();
    assertEquals("OK", reply.get().data());
  }
}
TOP

Related Classes of redis.client.Issue20Test

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.