=pro #3759 Changed to using non-deprecated ScalaTest Matchers

This commit is contained in:
Björn Antonsson 2013-12-17 14:25:56 +01:00
parent b8c7d7badd
commit 003609c9c5
246 changed files with 2822 additions and 2822 deletions

View file

@ -81,7 +81,7 @@ class TcpConnectionSpec extends AkkaSpec("""
run {
val connectionActor = createConnectionActor(options = Vector(Inet.SO.ReuseAddress(true)))
val clientChannel = connectionActor.underlyingActor.channel
clientChannel.socket.getReuseAddress must be(true)
clientChannel.socket.getReuseAddress should be(true)
}
}
@ -90,10 +90,10 @@ class TcpConnectionSpec extends AkkaSpec("""
// Workaround for systems where SO_KEEPALIVE is true by default
val connectionActor = createConnectionActor(options = Vector(SO.KeepAlive(false)))
val clientChannel = connectionActor.underlyingActor.channel
clientChannel.socket.getKeepAlive must be(true) // only set after connection is established
clientChannel.socket.getKeepAlive should be(true) // only set after connection is established
EventFilter.warning(pattern = "registration timeout", occurrences = 1) intercept {
selector.send(connectionActor, ChannelConnectable)
clientChannel.socket.getKeepAlive must be(false)
clientChannel.socket.getKeepAlive should be(false)
}
}
}
@ -123,14 +123,14 @@ class TcpConnectionSpec extends AkkaSpec("""
serverSideChannel.socket.setSendBufferSize(150000)
val wrote = serverSideChannel.write(buffer)
wrote must be(DataSize)
wrote should be(DataSize)
expectNoMsg(1000.millis) // data should have been transferred fully by now
selector.send(connectionActor, ChannelReadable)
connectionHandler.expectMsgType[Received].data.length must be(bufferSize)
connectionHandler.expectMsgType[Received].data.length must be(1500)
connectionHandler.expectMsgType[Received].data.length should be(bufferSize)
connectionHandler.expectMsgType[Received].data.length should be(1500)
}
}
@ -146,7 +146,7 @@ class TcpConnectionSpec extends AkkaSpec("""
userHandler.expectMsg(Connected(serverAddress, clientSideChannel.socket.getLocalSocketAddress.asInstanceOf[InetSocketAddress]))
userHandler.send(connectionActor, Register(userHandler.ref))
userHandler.expectMsgType[Received].data.decodeString("ASCII") must be("immediatedata")
userHandler.expectMsgType[Received].data.decodeString("ASCII") should be("immediatedata")
interestCallReceiver.expectMsg(OP_READ)
}
}
@ -158,22 +158,22 @@ class TcpConnectionSpec extends AkkaSpec("""
// reply to write commander with Ack
val ackedWrite = Write(ByteString("testdata"), Ack)
val buffer = ByteBuffer.allocate(100)
serverSideChannel.read(buffer) must be(0)
serverSideChannel.read(buffer) should be(0)
writer.send(connectionActor, ackedWrite)
writer.expectMsg(Ack)
pullFromServerSide(remaining = 8, into = buffer)
buffer.flip()
buffer.limit must be(8)
buffer.limit should be(8)
// not reply to write commander for writes without Ack
val unackedWrite = Write(ByteString("morestuff!"))
buffer.clear()
serverSideChannel.read(buffer) must be(0)
serverSideChannel.read(buffer) should be(0)
writer.send(connectionActor, unackedWrite)
writer.expectNoMsg(500.millis)
pullFromServerSide(remaining = 10, into = buffer)
buffer.flip()
ByteString(buffer).utf8String must be("morestuff!")
ByteString(buffer).utf8String should be("morestuff!")
}
}
@ -189,13 +189,13 @@ class TcpConnectionSpec extends AkkaSpec("""
val write = Write(testData, Ack)
val buffer = ByteBuffer.allocate(bufferSize)
serverSideChannel.read(buffer) must be(0)
serverSideChannel.read(buffer) should be(0)
writer.send(connectionActor, write)
pullFromServerSide(remaining = bufferSize, into = buffer)
buffer.flip()
buffer.limit must be(bufferSize)
buffer.limit should be(bufferSize)
ByteString(buffer) must be(testData)
ByteString(buffer) should be(testData)
}
}
@ -258,12 +258,12 @@ class TcpConnectionSpec extends AkkaSpec("""
// reply to write commander with Ack
val buffer = ByteBuffer.allocate(100)
serverSideChannel.read(buffer) must be(0)
serverSideChannel.read(buffer) should be(0)
writer.send(connectionActor, compoundWrite)
pullFromServerSide(remaining = 15, into = buffer)
buffer.flip()
ByteString(buffer).utf8String must be("test1test2test4")
ByteString(buffer).utf8String should be("test1test2test4")
writer.expectMsg(Ack(1))
writer.expectMsg(Ack(3))
writer.expectMsg(Ack(4))
@ -375,10 +375,10 @@ class TcpConnectionSpec extends AkkaSpec("""
closeCommander.expectMsg(Closed)
assertThisConnectionActorTerminated()
serverSelectionKey must be(selectedAs(OP_READ, 2.seconds))
serverSelectionKey should be(selectedAs(OP_READ, 2.seconds))
val buffer = ByteBuffer.allocate(1)
serverSideChannel.read(buffer) must be(-1)
serverSideChannel.read(buffer) should be(-1)
}
}
@ -400,8 +400,8 @@ class TcpConnectionSpec extends AkkaSpec("""
assertThisConnectionActorTerminated()
val buffer = ByteBuffer.allocate(1)
val thrown = evaluating { serverSideChannel.read(buffer) } must produce[IOException]
thrown.getMessage must be(ConnectionResetByPeerMessage)
val thrown = evaluating { serverSideChannel.read(buffer) } should produce[IOException]
thrown.getMessage should be(ConnectionResetByPeerMessage)
}
}
@ -436,8 +436,8 @@ class TcpConnectionSpec extends AkkaSpec("""
selector.send(connectionActor, ChannelReadable)
val buffer = ByteBuffer.allocate(1)
serverSelectionKey must be(selectedAs(OP_READ, 2.seconds))
serverSideChannel.read(buffer) must be(-1)
serverSelectionKey should be(selectedAs(OP_READ, 2.seconds))
serverSideChannel.read(buffer) should be(-1)
closeServerSideAndWaitForClientReadable()
@ -471,8 +471,8 @@ class TcpConnectionSpec extends AkkaSpec("""
connectionHandler.expectNoMsg(100.millis) // not yet
val buffer = ByteBuffer.allocate(1)
serverSelectionKey must be(selectedAs(SelectionKey.OP_READ, 2.seconds))
serverSideChannel.read(buffer) must be(-1)
serverSelectionKey should be(selectedAs(SelectionKey.OP_READ, 2.seconds))
serverSideChannel.read(buffer) should be(-1)
closeServerSideAndWaitForClientReadable()
@ -535,7 +535,7 @@ class TcpConnectionSpec extends AkkaSpec("""
abortClose(serverSideChannel)
selector.send(connectionActor, ChannelReadable)
val err = connectionHandler.expectMsgType[ErrorClosed]
err.cause must be(ConnectionResetByPeerMessage)
err.cause should be(ConnectionResetByPeerMessage)
// wait a while
connectionHandler.expectNoMsg(200.millis)
@ -570,7 +570,7 @@ class TcpConnectionSpec extends AkkaSpec("""
// This timeout should be large enough to work on Windows
sel.select(3000)
key.isConnectable must be(true)
key.isConnectable should be(true)
val forceThisLazyVal = connectionActor.toString
Thread.sleep(300)
selector.send(connectionActor, ChannelConnectable)
@ -595,7 +595,7 @@ class TcpConnectionSpec extends AkkaSpec("""
new UnacceptedConnectionTest() {
override lazy val connectionActor = createConnectionActor(serverAddress = UnboundAddress, timeout = Option(100.millis))
run {
connectionActor.toString must not be ("")
connectionActor.toString should not be ("")
userHandler.expectMsg(CommandFailed(Connect(UnboundAddress, timeout = Option(100.millis))))
verifyActorTermination(connectionActor)
}
@ -629,7 +629,7 @@ class TcpConnectionSpec extends AkkaSpec("""
EventFilter[DeathPactException](occurrences = 1) intercept {
system.stop(connectionHandler.ref)
val deaths = Set(expectMsgType[Terminated].actor, expectMsgType[Terminated].actor)
deaths must be(Set(connectionHandler.ref, connectionActor))
deaths should be(Set(connectionHandler.ref, connectionActor))
}
}
}
@ -649,7 +649,7 @@ class TcpConnectionSpec extends AkkaSpec("""
writer.receiveWhile(1.second) {
case CommandFailed(write) written -= 1
}
writer.msgAvailable must be(false)
writer.msgAvailable should be(false)
// writes must fail now
writer.send(connectionActor, write)
@ -723,7 +723,7 @@ class TcpConnectionSpec extends AkkaSpec("""
writer.receiveWhile(1.second) {
case CommandFailed(write) written -= 1
}
writer.msgAvailable must be(false)
writer.msgAvailable should be(false)
// writes must fail now
writer.send(connectionActor, write)
@ -830,14 +830,14 @@ class TcpConnectionSpec extends AkkaSpec("""
}
abstract class UnacceptedConnectionTest extends LocalServerTest {
// lazy init since potential exceptions must not be triggered in the constructor but during execution of `run`
// lazy init since potential exceptions should not be triggered in the constructor but during execution of `run`
private[io] lazy val connectionActor = createConnectionActor(serverAddress)
// calling .underlyingActor ensures that the actor is actually created at this point
lazy val clientSideChannel = connectionActor.underlyingActor.channel
override def run(body: Unit): Unit = super.run {
registerCallReceiver.expectMsg(Registration(clientSideChannel, 0))
registerCallReceiver.sender must be(connectionActor)
registerCallReceiver.sender should be(connectionActor)
body
}
}
@ -845,7 +845,7 @@ class TcpConnectionSpec extends AkkaSpec("""
abstract class EstablishedConnectionTest(keepOpenOnPeerClosed: Boolean = false, useResumeWriting: Boolean = true)
extends UnacceptedConnectionTest {
// lazy init since potential exceptions must not be triggered in the constructor but during execution of `run`
// lazy init since potential exceptions should not be triggered in the constructor but during execution of `run`
lazy val serverSideChannel = acceptServerSideConnection(localServerChannel)
lazy val connectionHandler = TestProbe()
lazy val nioSelector = SelectorProvider.provider().openSelector()
@ -856,7 +856,7 @@ class TcpConnectionSpec extends AkkaSpec("""
override def run(body: Unit): Unit = super.run {
try {
serverSideChannel.configureBlocking(false)
serverSideChannel must not be (null)
serverSideChannel should not be (null)
interestCallReceiver.expectMsg(OP_CONNECT)
selector.send(connectionActor, ChannelConnectable)
@ -881,7 +881,7 @@ class TcpConnectionSpec extends AkkaSpec("""
def closeServerSideAndWaitForClientReadable(fullClose: Boolean = true): Unit = {
if (fullClose) serverSideChannel.close() else serverSideChannel.socket.shutdownOutput()
checkFor(clientSelectionKey, OP_READ, 3.seconds.toMillis.toInt) must be(true)
checkFor(clientSelectionKey, OP_READ, 3.seconds.toMillis.toInt) should be(true)
}
def registerChannel(channel: SocketChannel, name: String): SelectionKey = {
@ -943,20 +943,20 @@ class TcpConnectionSpec extends AkkaSpec("""
}
@tailrec final def expectReceivedString(data: String): Unit = {
data.length must be > 0
data.length should be > 0
selector.send(connectionActor, ChannelReadable)
val gotReceived = connectionHandler.expectMsgType[Received]
val receivedString = gotReceived.data.decodeString("ASCII")
data.startsWith(receivedString) must be(true)
data.startsWith(receivedString) should be(true)
if (receivedString.length < data.length)
expectReceivedString(data.drop(receivedString.length))
}
def assertThisConnectionActorTerminated(): Unit = {
verifyActorTermination(connectionActor)
clientSideChannel must not be ('open)
clientSideChannel should not be ('open)
}
def selectedAs(interest: Int, duration: Duration): BeMatcher[SelectionKey] =