Skip to content

Commit

Permalink
Merge branch 'github_master' into release-2.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Zuercher committed Sep 21, 2012
2 parents 3e1c887 + f34342f commit 38d71d0
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 34 deletions.
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ externalResolvers <<= (resolvers) map identity
addSbtPlugin("com.twitter" %% "sbt-package-dist" % "1.0.5")

addSbtPlugin("com.twitter" %% "sbt11-scrooge" % "1.0.0")

2 changes: 1 addition & 1 deletion src/scripts/load/leaky-reader
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
DIST_HOME="$(dirname $(readlink $0 || echo $0))/../.."
TEST_JAR=$DIST_HOME/kestrel-tests-@[email protected]
TEST_JAR=$DIST_HOME/@DIST_NAME@-@VERSION@-test.jar
java -server -classpath @DIST_CLASSPATH@:$TEST_JAR net.lag.kestrel.load.LeakyThriftReader "$@"
2 changes: 1 addition & 1 deletion src/scripts/load/many-clients
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
DIST_HOME="$(dirname $(readlink $0 || echo $0))/../.."
TEST_JAR=$DIST_HOME/kestrel-tests-@[email protected]
TEST_JAR=$DIST_HOME/@DIST_NAME@-@VERSION@-test.jar
java -server -classpath @DIST_CLASSPATH@:$TEST_JAR net.lag.kestrel.load.ManyClients "$@"
2 changes: 1 addition & 1 deletion src/scripts/load/packing
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
DIST_HOME="$(dirname $(readlink $0 || echo $0))/../.."
TEST_JAR=$DIST_HOME/kestrel-tests-@[email protected]
TEST_JAR=$DIST_HOME/@DIST_NAME@-@VERSION@-test.jar
java -server -classpath @DIST_CLASSPATH@:$TEST_JAR net.lag.kestrel.load.JournalPacking "$@"
2 changes: 1 addition & 1 deletion src/scripts/load/put-many
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
DIST_HOME="$(dirname $(readlink $0 || echo $0))/../.."
TEST_JAR=$DIST_HOME/kestrel-tests-@[email protected]
TEST_JAR=$DIST_HOME/@DIST_NAME@-@VERSION@-test.jar
java -server -classpath @DIST_CLASSPATH@:$TEST_JAR net.lag.kestrel.load.PutMany "$@"
75 changes: 75 additions & 0 deletions src/test/scala/net/lag/kestrel/ItemIdListSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package net.lag.kestrel

import org.specs.Specification

class ItemIdListSpec extends Specification {
"ItemIdList" should {
val iil = new ItemIdList()

"add an Integer to the list" in {
iil.add(3)
iil.size mustEqual 1
}

"add a sequence of Integers to the list" in {
iil.add(Seq(1, 2, 3, 4))
iil.size mustEqual 4
}

"pop one item at a time" in {
iil.add(Seq(90, 99))
iil.pop() mustEqual Some(90)
iil.pop() mustEqual Some(99)
}

"pop None when there's nothing to pop" in {
iil.pop() mustEqual None
}

"pop all items from an index upward" in {
iil.add(Seq(1, 2, 3, 4))
val expected = Seq(1, 2)
val actual = iil.pop(2)
expected mustEqual actual
}

"pop all items from the list" in {
val seq = Seq(12, 13, 14)
iil.add(seq)
iil.popAll() mustEqual seq
}

"return empty seq when pop's count is invalid" in {
iil.pop(1) mustEqual Seq()
}

"remove a set of items from the list" in {
iil.add(Seq(19, 7, 20, 22))
val expected = Set(7, 20, 22)
iil.remove(expected) mustEqual expected
}

"add and pop" in {
iil.add(Seq(5, 4))
iil.size mustEqual 2
iil.pop() mustEqual Some(5)
iil.pop() mustEqual Some(4)
iil.pop() mustEqual None
}

"remove from the middle" in {
iil.add(Seq(7, 6, 5, 4, 3, 2))
iil.pop() mustEqual Some(7)
iil.remove(Set(5, 4, 2)) mustEqual Set(5, 4, 2)
iil.popAll() mustEqual Seq(6, 3)
}

"remove and pop combined" in {
iil.add(Seq(7, 6, 5, 4, 3, 2))
iil.remove(Set(6)) mustEqual Set(6)
iil.pop() mustEqual Some(7)
iil.pop() mustEqual Some(5)
iil.popAll() mustEqual Seq(4, 3, 2)
}
}
}
30 changes: 0 additions & 30 deletions src/test/scala/net/lag/kestrel/KestrelHandlerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,6 @@ import config._
class FakeKestrelHandler(queues: QueueCollection, maxOpenTransactions: Int)
extends KestrelHandler(queues, maxOpenTransactions, () => "none", 0) with SimplePendingReads

class ItemIdListSpec extends Specification with TestLogging {
"ItemIdList" should {
"add and pop" in {
val x = new ItemIdList()
x.add(Seq(5, 4))
x.size mustEqual 2
x.pop() mustEqual Some(5)
x.pop() mustEqual Some(4)
x.pop() mustEqual None
}

"remove from the middle" in {
val x = new ItemIdList()
x.add(Seq(7, 6, 5, 4, 3, 2))
x.pop() mustEqual Some(7)
x.remove(Set(5, 4, 2)) mustEqual Set(5, 4, 2)
x.popAll() mustEqual Seq(6, 3)
}

"remove and pop combined" in {
val x = new ItemIdList()
x.add(Seq(7, 6, 5, 4, 3, 2))
x.remove(Set(6)) mustEqual Set(6)
x.pop() mustEqual Some(7)
x.pop() mustEqual Some(5)
x.popAll() mustEqual Seq(4, 3, 2)
}
}
}

class KestrelHandlerSpec extends Specification with TempFolder with TestLogging {
val config = new QueueBuilder().apply()

Expand Down

0 comments on commit 38d71d0

Please sign in to comment.