forked from I2P_Developers/i2p.i2p
More changes to finish first test in UpdateBehaviors
This commit is contained in:
@ -3,7 +3,11 @@ package net.i2p.router.update
|
||||
import org.scalatest.FunSpec
|
||||
import org.scalatest.mock.MockitoSugar
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
import net.i2p.router.RouterContext
|
||||
import net.i2p.update.UpdateMethod
|
||||
import net.i2p.update.UpdateType
|
||||
|
||||
/**
|
||||
* @author str4d
|
||||
@ -16,9 +20,21 @@ class DummyHandlerSpec extends FunSpec with CheckerBehaviors with UpdaterBehavio
|
||||
dh
|
||||
}
|
||||
|
||||
def validTypes = {
|
||||
val vt = new ArrayList[UpdateType]
|
||||
vt.add(UpdateType.ROUTER_UNSIGNED)
|
||||
vt
|
||||
}
|
||||
|
||||
def validMethods = {
|
||||
val vm = new ArrayList[UpdateMethod]
|
||||
vm.add(UpdateMethod.HTTP)
|
||||
vm
|
||||
}
|
||||
|
||||
describe("A DummyHandler") {
|
||||
it should behave like checker(dummyHandler)
|
||||
|
||||
it should behave like updater(dummyHandler)
|
||||
it should behave like updater(dummyHandler, validTypes, validMethods)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,11 @@ package net.i2p.router.update
|
||||
import org.scalatest.FunSpec
|
||||
import org.scalatest.mock.MockitoSugar
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
import net.i2p.router.RouterContext
|
||||
import net.i2p.update.UpdateMethod
|
||||
import net.i2p.update.UpdateType
|
||||
|
||||
/**
|
||||
* @author str4d
|
||||
@ -16,7 +20,19 @@ class NewsHandlerSpec extends FunSpec with UpdaterBehaviors with MockitoSugar {
|
||||
nh
|
||||
}
|
||||
|
||||
def validTypes = {
|
||||
val vt = new ArrayList[UpdateType]
|
||||
vt.add(UpdateType.ROUTER_UNSIGNED)
|
||||
vt
|
||||
}
|
||||
|
||||
def validMethods = {
|
||||
val vm = new ArrayList[UpdateMethod]
|
||||
vm.add(UpdateMethod.HTTP)
|
||||
vm
|
||||
}
|
||||
|
||||
describe("A NewsHandler") {
|
||||
it should behave like updater(newsHandler)
|
||||
it should behave like updater(newsHandler, validTypes, validMethods)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,11 @@ package net.i2p.router.update
|
||||
import org.scalatest.FunSpec
|
||||
import org.scalatest.mock.MockitoSugar
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
import net.i2p.router.RouterContext
|
||||
import net.i2p.update.UpdateMethod
|
||||
import net.i2p.update.UpdateType
|
||||
|
||||
/**
|
||||
* @author str4d
|
||||
@ -16,9 +20,21 @@ class PluginUpdateHandlerSpec extends FunSpec with CheckerBehaviors with Updater
|
||||
puh
|
||||
}
|
||||
|
||||
def validTypes = {
|
||||
val vt = new ArrayList[UpdateType]
|
||||
vt.add(UpdateType.ROUTER_UNSIGNED)
|
||||
vt
|
||||
}
|
||||
|
||||
def validMethods = {
|
||||
val vm = new ArrayList[UpdateMethod]
|
||||
vm.add(UpdateMethod.HTTP)
|
||||
vm
|
||||
}
|
||||
|
||||
describe("A PluginUpdateHandler") {
|
||||
it should behave like checker(pluginUpdateHandler)
|
||||
|
||||
it should behave like updater(pluginUpdateHandler)
|
||||
it should behave like updater(pluginUpdateHandler, validTypes, validMethods)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package net.i2p.router.update
|
||||
import org.scalatest.FunSpec
|
||||
import org.scalatest.mock.MockitoSugar
|
||||
|
||||
import java.util.TreeSet
|
||||
import java.util.ArrayList
|
||||
|
||||
import net.i2p.router.RouterContext
|
||||
import net.i2p.update.UpdateMethod
|
||||
@ -21,13 +21,13 @@ class UnsignedUpdateHandlerSpec extends FunSpec with CheckerBehaviors with Updat
|
||||
}
|
||||
|
||||
def validTypes = {
|
||||
val vt = new TreeSet<UpdateType>
|
||||
val vt = new ArrayList[UpdateType]
|
||||
vt.add(UpdateType.ROUTER_UNSIGNED)
|
||||
vt
|
||||
}
|
||||
|
||||
def validMethods = {
|
||||
val vm = new TreeSet<UpdateMethod>
|
||||
val vm = new ArrayList[UpdateMethod]
|
||||
vm.add(UpdateMethod.HTTP)
|
||||
vm
|
||||
}
|
||||
|
@ -3,7 +3,11 @@ package net.i2p.router.update
|
||||
import org.scalatest.FunSpec
|
||||
import org.scalatest.mock.MockitoSugar
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
import net.i2p.router.RouterContext
|
||||
import net.i2p.update.UpdateMethod
|
||||
import net.i2p.update.UpdateType
|
||||
|
||||
/**
|
||||
* @author str4d
|
||||
@ -16,7 +20,19 @@ class UpdateHandlerSpec extends FunSpec with UpdaterBehaviors with MockitoSugar
|
||||
uh
|
||||
}
|
||||
|
||||
def validTypes = {
|
||||
val vt = new ArrayList[UpdateType]
|
||||
vt.add(UpdateType.ROUTER_UNSIGNED)
|
||||
vt
|
||||
}
|
||||
|
||||
def validMethods = {
|
||||
val vm = new ArrayList[UpdateMethod]
|
||||
vm.add(UpdateMethod.HTTP)
|
||||
vm
|
||||
}
|
||||
|
||||
describe("An UpdateHandler") {
|
||||
it should behave like updater(updateHandler)
|
||||
it should behave like updater(updateHandler, validTypes, validMethods)
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,9 @@ package net.i2p.router.update
|
||||
|
||||
import org.scalatest.FunSpec
|
||||
|
||||
import java.net.URI
|
||||
import java.util.Collections
|
||||
import java.util.Set
|
||||
import java.util.List
|
||||
|
||||
import net.i2p.update.UpdateMethod
|
||||
import net.i2p.update.UpdateType
|
||||
@ -13,13 +14,14 @@ import net.i2p.update.Updater
|
||||
* @author str4d
|
||||
*/
|
||||
trait UpdaterBehaviors { this: FunSpec =>
|
||||
def updater(newUpdater: => Updater, validTypes: => Set<UpdateType>,
|
||||
validMethods: => Set<UpdateMethod>) {
|
||||
def updater(newUpdater: => Updater, validTypes: => List[UpdateType],
|
||||
validMethods: => List[UpdateMethod]) {
|
||||
it("should return null if no updateSources are provided") {
|
||||
val updateSources = Collections.emptyList
|
||||
val updateTask = newUpdater.update(validTypes[0], validMethods[0],
|
||||
val updateSources = Collections.emptyList[URI]
|
||||
val updateTask = newUpdater.update(validTypes.iterator().next(),
|
||||
validMethods.iterator().next(),
|
||||
updateSources, "", "", 1000)
|
||||
updateTask should be (null)
|
||||
assert(updateTask == null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user