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.FunSpec
|
||||||
import org.scalatest.mock.MockitoSugar
|
import org.scalatest.mock.MockitoSugar
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
|
||||||
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 DummyHandlerSpec extends FunSpec with CheckerBehaviors with UpdaterBehavio
|
|||||||
dh
|
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") {
|
describe("A DummyHandler") {
|
||||||
it should behave like checker(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.FunSpec
|
||||||
import org.scalatest.mock.MockitoSugar
|
import org.scalatest.mock.MockitoSugar
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
|
||||||
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,7 +20,19 @@ class NewsHandlerSpec extends FunSpec with UpdaterBehaviors with MockitoSugar {
|
|||||||
nh
|
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") {
|
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.FunSpec
|
||||||
import org.scalatest.mock.MockitoSugar
|
import org.scalatest.mock.MockitoSugar
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
|
||||||
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 PluginUpdateHandlerSpec extends FunSpec with CheckerBehaviors with Updater
|
|||||||
puh
|
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") {
|
describe("A PluginUpdateHandler") {
|
||||||
it should behave like checker(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.FunSpec
|
||||||
import org.scalatest.mock.MockitoSugar
|
import org.scalatest.mock.MockitoSugar
|
||||||
|
|
||||||
import java.util.TreeSet
|
import java.util.ArrayList
|
||||||
|
|
||||||
import net.i2p.router.RouterContext
|
import net.i2p.router.RouterContext
|
||||||
import net.i2p.update.UpdateMethod
|
import net.i2p.update.UpdateMethod
|
||||||
@ -21,13 +21,13 @@ class UnsignedUpdateHandlerSpec extends FunSpec with CheckerBehaviors with Updat
|
|||||||
}
|
}
|
||||||
|
|
||||||
def validTypes = {
|
def validTypes = {
|
||||||
val vt = new TreeSet<UpdateType>
|
val vt = new ArrayList[UpdateType]
|
||||||
vt.add(UpdateType.ROUTER_UNSIGNED)
|
vt.add(UpdateType.ROUTER_UNSIGNED)
|
||||||
vt
|
vt
|
||||||
}
|
}
|
||||||
|
|
||||||
def validMethods = {
|
def validMethods = {
|
||||||
val vm = new TreeSet<UpdateMethod>
|
val vm = new ArrayList[UpdateMethod]
|
||||||
vm.add(UpdateMethod.HTTP)
|
vm.add(UpdateMethod.HTTP)
|
||||||
vm
|
vm
|
||||||
}
|
}
|
||||||
|
@ -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.ArrayList
|
||||||
|
|
||||||
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,7 +20,19 @@ class UpdateHandlerSpec extends FunSpec with UpdaterBehaviors with MockitoSugar
|
|||||||
uh
|
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") {
|
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 org.scalatest.FunSpec
|
||||||
|
|
||||||
|
import java.net.URI
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import java.util.Set
|
import java.util.List
|
||||||
|
|
||||||
import net.i2p.update.UpdateMethod
|
import net.i2p.update.UpdateMethod
|
||||||
import net.i2p.update.UpdateType
|
import net.i2p.update.UpdateType
|
||||||
@ -13,13 +14,14 @@ import net.i2p.update.Updater
|
|||||||
* @author str4d
|
* @author str4d
|
||||||
*/
|
*/
|
||||||
trait UpdaterBehaviors { this: FunSpec =>
|
trait UpdaterBehaviors { this: FunSpec =>
|
||||||
def updater(newUpdater: => Updater, validTypes: => Set<UpdateType>,
|
def updater(newUpdater: => Updater, validTypes: => List[UpdateType],
|
||||||
validMethods: => Set<UpdateMethod>) {
|
validMethods: => List[UpdateMethod]) {
|
||||||
it("should return null if no updateSources are provided") {
|
it("should return null if no updateSources are provided") {
|
||||||
val updateSources = Collections.emptyList
|
val updateSources = Collections.emptyList[URI]
|
||||||
val updateTask = newUpdater.update(validTypes[0], validMethods[0],
|
val updateTask = newUpdater.update(validTypes.iterator().next(),
|
||||||
|
validMethods.iterator().next(),
|
||||||
updateSources, "", "", 1000)
|
updateSources, "", "", 1000)
|
||||||
updateTask should be (null)
|
assert(updateTask == null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user