Started filling out UpdaterBehaviors

This commit is contained in:
str4d
2012-11-05 10:37:18 +00:00
parent 6a91918e6f
commit 3d35984cf5
2 changed files with 30 additions and 3 deletions

View File

@ -3,7 +3,11 @@ package net.i2p.router.update
import org.scalatest.FunSpec import org.scalatest.FunSpec
import org.scalatest.mock.MockitoSugar import org.scalatest.mock.MockitoSugar
import java.util.TreeSet
import net.i2p.router.RouterContext import net.i2p.router.RouterContext
import net.i2p.update.UpdateMethod
import net.i2p.update.UpdateType
/** /**
* @author str4d * @author str4d
@ -16,9 +20,21 @@ class UnsignedUpdateHandlerSpec extends FunSpec with CheckerBehaviors with Updat
uuh uuh
} }
def validTypes = {
val vt = new TreeSet<UpdateType>
vt.add(UpdateType.ROUTER_UNSIGNED)
vt
}
def validMethods = {
val vm = new TreeSet<UpdateMethod>
vm.add(UpdateMethod.HTTP)
vm
}
describe("An UnsignedUpdateHandler") { describe("An UnsignedUpdateHandler") {
it should behave like checker(unsignedUpdateHandler) it should behave like checker(unsignedUpdateHandler)
it should behave like updater(unsignedUpdateHandler) it should behave like updater(unsignedUpdateHandler, validTypes, validMethods)
} }
} }

View File

@ -2,13 +2,24 @@ package net.i2p.router.update
import org.scalatest.FunSpec import org.scalatest.FunSpec
import java.util.Collections
import java.util.Set
import net.i2p.update.UpdateMethod
import net.i2p.update.UpdateType
import net.i2p.update.Updater import net.i2p.update.Updater
/** /**
* @author str4d * @author str4d
*/ */
trait UpdaterBehaviors { this: FunSpec => trait UpdaterBehaviors { this: FunSpec =>
def updater(newUpdater: => Updater) { def updater(newUpdater: => Updater, validTypes: => Set<UpdateType>,
it("should provide a method to perform updates") (pending) validMethods: => Set<UpdateMethod>) {
it("should return null if no updateSources are provided") {
val updateSources = Collections.emptyList
val updateTask = newUpdater.update(validTypes[0], validMethods[0],
updateSources, "", "", 1000)
updateTask should be (null)
}
} }
} }