From 3d35984cf5de68c5477a0d31362b897fab878ce6 Mon Sep 17 00:00:00 2001 From: str4d Date: Mon, 5 Nov 2012 10:37:18 +0000 Subject: [PATCH] Started filling out UpdaterBehaviors --- .../update/UnsignedUpdateHandlerSpec.scala | 18 +++++++++++++++++- .../i2p/router/update/UpdaterBehaviors.scala | 15 +++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/apps/routerconsole/java/test/scalatest/net/i2p/router/update/UnsignedUpdateHandlerSpec.scala b/apps/routerconsole/java/test/scalatest/net/i2p/router/update/UnsignedUpdateHandlerSpec.scala index 802ade31c..14a766d93 100644 --- a/apps/routerconsole/java/test/scalatest/net/i2p/router/update/UnsignedUpdateHandlerSpec.scala +++ b/apps/routerconsole/java/test/scalatest/net/i2p/router/update/UnsignedUpdateHandlerSpec.scala @@ -3,7 +3,11 @@ package net.i2p.router.update import org.scalatest.FunSpec import org.scalatest.mock.MockitoSugar +import java.util.TreeSet + import net.i2p.router.RouterContext +import net.i2p.update.UpdateMethod +import net.i2p.update.UpdateType /** * @author str4d @@ -16,9 +20,21 @@ class UnsignedUpdateHandlerSpec extends FunSpec with CheckerBehaviors with Updat uuh } + def validTypes = { + val vt = new TreeSet + vt.add(UpdateType.ROUTER_UNSIGNED) + vt + } + + def validMethods = { + val vm = new TreeSet + vm.add(UpdateMethod.HTTP) + vm + } + describe("An UnsignedUpdateHandler") { it should behave like checker(unsignedUpdateHandler) - it should behave like updater(unsignedUpdateHandler) + it should behave like updater(unsignedUpdateHandler, validTypes, validMethods) } } diff --git a/apps/routerconsole/java/test/scalatest/net/i2p/router/update/UpdaterBehaviors.scala b/apps/routerconsole/java/test/scalatest/net/i2p/router/update/UpdaterBehaviors.scala index 558983497..b68299dcc 100644 --- a/apps/routerconsole/java/test/scalatest/net/i2p/router/update/UpdaterBehaviors.scala +++ b/apps/routerconsole/java/test/scalatest/net/i2p/router/update/UpdaterBehaviors.scala @@ -2,13 +2,24 @@ package net.i2p.router.update 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 /** * @author str4d */ trait UpdaterBehaviors { this: FunSpec => - def updater(newUpdater: => Updater) { - it("should provide a method to perform updates") (pending) + def updater(newUpdater: => Updater, validTypes: => Set, + validMethods: => Set) { + 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) + } } }