From b1c04c0074c67c46a2b82e5031b0ea3189eb3e32 Mon Sep 17 00:00:00 2001 From: Alex Popiel Date: Tue, 15 May 2012 11:29:04 -0700 Subject: [PATCH 1/3] Add maven repo for com.twitter classes --- project/ScalaRedisProject.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project/ScalaRedisProject.scala b/project/ScalaRedisProject.scala index e59e661e..42a138c7 100644 --- a/project/ScalaRedisProject.scala +++ b/project/ScalaRedisProject.scala @@ -15,6 +15,8 @@ object ScalaRedisProject extends Build lazy val coreSettings = commonSettings ++ template ++ Seq( name := "RedisClient", + resolvers += "twitter.com releases" at "http://maven.twttr.com/", + libraryDependencies ++= Seq("commons-pool" % "commons-pool" % "1.5.6", "org.slf4j" % "slf4j-api" % "1.6.1", "org.slf4j" % "slf4j-log4j12" % "1.6.1" % "provided", From 876f739cdd89b5833d8bb4bf0b613b5993e5c34f Mon Sep 17 00:00:00 2001 From: Alex Popiel Date: Tue, 15 May 2012 11:29:44 -0700 Subject: [PATCH 2/3] Fix protocol signature for info command (BulkReply) --- src/main/scala/com/redis/NodeOperations.scala | 4 ++-- src/main/scala/com/redis/cluster/RedisCluster.scala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/redis/NodeOperations.scala b/src/main/scala/com/redis/NodeOperations.scala index 35ed28c6..cbb20c01 100644 --- a/src/main/scala/com/redis/NodeOperations.scala +++ b/src/main/scala/com/redis/NodeOperations.scala @@ -30,8 +30,8 @@ trait NodeOperations { self: Redis => // INFO // the info command returns different information and statistics about the server. - def info = - send("INFO")(asString) + def info(implicit parse: Parse[String]): Option[String] = + send("INFO")(asBulk[String]) // MONITOR // is a debugging command that outputs the whole sequence of commands received by the Redis server. diff --git a/src/main/scala/com/redis/cluster/RedisCluster.scala b/src/main/scala/com/redis/cluster/RedisCluster.scala index d2e82d59..06f2200a 100644 --- a/src/main/scala/com/redis/cluster/RedisCluster.scala +++ b/src/main/scala/com/redis/cluster/RedisCluster.scala @@ -124,7 +124,7 @@ abstract class RedisCluster(hosts: String*) extends RedisClient { override def lastsave = throw new UnsupportedOperationException("not supported on a cluster") override def monitor = throw new UnsupportedOperationException("not supported on a cluster") - override def info = throw new UnsupportedOperationException("not supported on a cluster") + override def info(implicit parse: Parse[String]): Option[String] = throw new UnsupportedOperationException("not supported on a cluster") override def slaveof(options: Any) = throw new UnsupportedOperationException("not supported on a cluster") override def move(key: Any, db: Int)(implicit format: Format) = throw new UnsupportedOperationException("not supported on a cluster") override def auth(secret: Any)(implicit format: Format) = throw new UnsupportedOperationException("not supported on a cluster") From ffc744a949f8ea5d06b197d76f89dc58a13350ad Mon Sep 17 00:00:00 2001 From: Alex Popiel Date: Tue, 15 May 2012 11:45:54 -0700 Subject: [PATCH 3/3] Add a unit test for the info command --- .../scala/com/redis/NodeOperationsSpec.scala | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/test/scala/com/redis/NodeOperationsSpec.scala diff --git a/src/test/scala/com/redis/NodeOperationsSpec.scala b/src/test/scala/com/redis/NodeOperationsSpec.scala new file mode 100644 index 00000000..2f345c94 --- /dev/null +++ b/src/test/scala/com/redis/NodeOperationsSpec.scala @@ -0,0 +1,38 @@ +package com.redis + +import org.scalatest.Spec +import org.scalatest.BeforeAndAfterEach +import org.scalatest.BeforeAndAfterAll +import org.scalatest.matchers.ShouldMatchers +import org.scalatest.junit.JUnitRunner +import org.junit.runner.RunWith + + +@RunWith(classOf[JUnitRunner]) +class NodeOperationsSpec extends Spec + with ShouldMatchers + with BeforeAndAfterEach + with BeforeAndAfterAll { + + val r = new RedisClient("localhost", 6379) + + override def beforeEach = { + } + + override def afterEach = { + r.flushdb + } + + override def afterAll = { + r.disconnect + } + + describe("info") { + it("should return a string containing multiple lines") { + r.info.get.split("\n").length should be > (3) + } + it("should include the redis version") { + r.info.get should include ("redis_version") + } + } +}