Implemented AUTH

This commit is contained in:
Jonathan Leibiusky
2010-08-03 23:47:52 -03:00
parent 2131265436
commit b4862828b0
12 changed files with 50 additions and 186 deletions

View File

@@ -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);
}
}

View File

@@ -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();
}
}

View File

@@ -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();

View File

@@ -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() {
}
}

View File

@@ -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");

View File

@@ -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();
}
}

View File

@@ -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");

View File

@@ -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");

View File

@@ -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");

View File

@@ -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");

View File

@@ -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");

View File

@@ -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();