Implemented AUTH
This commit is contained in:
@@ -417,4 +417,8 @@ public class Client extends Connection {
|
||||
public void brpop(String[] args) throws JedisException {
|
||||
sendCommand("BRPOP", args);
|
||||
}
|
||||
|
||||
public void auth(String password) throws JedisException {
|
||||
sendCommand("AUTH", password);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,4 +542,9 @@ public class Jedis {
|
||||
client.brpop(args.toArray(new String[args.size()]));
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public String auth(String password) throws JedisException {
|
||||
client.auth(password);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
}
|
||||
@@ -3,30 +3,11 @@ package redis.clients.jedis.tests.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class AllKindOfValuesCommandsTest extends Assert {
|
||||
private Jedis jedis;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jedis = new Jedis("localhost");
|
||||
jedis.connect();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
jedis.flushDB();
|
||||
jedis.disconnect();
|
||||
}
|
||||
|
||||
public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void ping() throws JedisException {
|
||||
String status = jedis.ping();
|
||||
|
||||
@@ -1,38 +1,12 @@
|
||||
package redis.clients.jedis.tests.commands;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class ConnectionHandlingCommandsTest extends Assert {
|
||||
private Jedis jedis;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jedis = new Jedis("localhost");
|
||||
jedis.connect();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
jedis.flushDB();
|
||||
jedis.disconnect();
|
||||
}
|
||||
|
||||
public class ConnectionHandlingCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void quit() throws JedisException {
|
||||
jedis.quit();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore(value = "Need to implement!")
|
||||
public void auth() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,30 +6,11 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class HashesCommandsTest extends Assert {
|
||||
private Jedis jedis;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jedis = new Jedis("localhost");
|
||||
jedis.connect();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
jedis.flushDB();
|
||||
jedis.disconnect();
|
||||
}
|
||||
|
||||
public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void hset() throws JedisException {
|
||||
int status = jedis.hset("foo", "bar", "car");
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package redis.clients.jedis.tests.commands;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
public class JedisCommandTestBase extends Assert {
|
||||
|
||||
protected Jedis jedis;
|
||||
|
||||
public JedisCommandTestBase() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jedis = new Jedis("localhost");
|
||||
jedis.connect();
|
||||
jedis.auth("foobared");
|
||||
jedis.flushDB();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
jedis.disconnect();
|
||||
}
|
||||
}
|
||||
@@ -3,30 +3,12 @@ package redis.clients.jedis.tests.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class ListCommandsTest extends Assert {
|
||||
private Jedis jedis;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jedis = new Jedis("localhost");
|
||||
jedis.connect();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
jedis.flushDB();
|
||||
jedis.disconnect();
|
||||
}
|
||||
|
||||
public class ListCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void rpush() throws JedisException {
|
||||
int size = jedis.rpush("foo", "bar");
|
||||
|
||||
@@ -3,30 +3,11 @@ package redis.clients.jedis.tests.commands;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class SetCommandsTest extends Assert {
|
||||
private Jedis jedis;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jedis = new Jedis("localhost");
|
||||
jedis.connect();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
jedis.flushDB();
|
||||
jedis.disconnect();
|
||||
}
|
||||
|
||||
public class SetCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void sadd() throws JedisException {
|
||||
int status = jedis.sadd("foo", "a");
|
||||
|
||||
@@ -3,31 +3,12 @@ package redis.clients.jedis.tests.commands;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
import redis.clients.jedis.Tuple;
|
||||
|
||||
public class SortedSetCommandsTest extends Assert {
|
||||
private Jedis jedis;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jedis = new Jedis("localhost");
|
||||
jedis.connect();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
jedis.flushDB();
|
||||
jedis.disconnect();
|
||||
}
|
||||
|
||||
public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void zadd() throws JedisException {
|
||||
int status = jedis.zadd("foo", 1d, "a");
|
||||
|
||||
@@ -3,32 +3,12 @@ package redis.clients.jedis.tests.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
import redis.clients.jedis.SortingParams;
|
||||
|
||||
public class SortingCommandsTest extends Assert {
|
||||
private Jedis jedis;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jedis = new Jedis("localhost");
|
||||
jedis.connect();
|
||||
jedis.flushDB();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
jedis.flushDB();
|
||||
jedis.disconnect();
|
||||
}
|
||||
|
||||
public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void sort() throws JedisException {
|
||||
jedis.lpush("foo", "3");
|
||||
|
||||
@@ -3,30 +3,11 @@ package redis.clients.jedis.tests.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class StringValuesCommandsTest extends Assert {
|
||||
private Jedis jedis;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jedis = new Jedis("localhost");
|
||||
jedis.connect();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
jedis.flushDB();
|
||||
jedis.disconnect();
|
||||
}
|
||||
|
||||
public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void setAndGet() throws JedisException {
|
||||
String status = jedis.set("foo", "bar");
|
||||
|
||||
@@ -5,10 +5,6 @@ import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
@@ -16,21 +12,7 @@ import redis.clients.jedis.JedisException;
|
||||
import redis.clients.jedis.Transaction;
|
||||
import redis.clients.jedis.TransactionBlock;
|
||||
|
||||
public class TransactionCommandsTest extends Assert {
|
||||
private Jedis jedis;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jedis = new Jedis("localhost");
|
||||
jedis.connect();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
jedis.flushDB();
|
||||
jedis.disconnect();
|
||||
}
|
||||
|
||||
public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void multi() throws JedisException {
|
||||
Transaction trans = jedis.multi();
|
||||
@@ -85,6 +67,7 @@ public class TransactionCommandsTest extends Assert {
|
||||
|
||||
Jedis nj = new Jedis("localhost");
|
||||
nj.connect();
|
||||
nj.auth("foobared");
|
||||
nj.set("mykey", "bar");
|
||||
nj.disconnect();
|
||||
|
||||
@@ -105,6 +88,7 @@ public class TransactionCommandsTest extends Assert {
|
||||
|
||||
Jedis nj = new Jedis("localhost");
|
||||
nj.connect();
|
||||
nj.auth("foobared");
|
||||
nj.set("mykey", "bar");
|
||||
nj.disconnect();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user