Skip to content

Commit

Permalink
bump akka version etc
Browse files Browse the repository at this point in the history
  • Loading branch information
casualjim committed Aug 12, 2015
1 parent 4352292 commit 0d670ef
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
16 changes: 9 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,29 @@ version := "0.4.2-SNAPSHOT"

scalaVersion := "2.10.5"

crossScalaVersions := Seq("2.10.5", "2.11.5")
crossScalaVersions := Seq("2.10.5", "2.11.7")

compileOrder := CompileOrder.ScalaThenJava

libraryDependencies ++= Seq(
"io.netty" % "netty" % "3.10.4.Final",
"com.github.nscala-time" %% "nscala-time" % "1.4.0",
"org.json4s" %% "json4s-jackson" % "3.2.10" % "compile",
"com.github.nscala-time" %% "nscala-time" % "1.8.0",
"org.json4s" %% "json4s-jackson" % "3.2.11" % "compile",
"commons-io" % "commons-io" % "2.4",
"com.typesafe.akka" %% "akka-actor" % "2.1.4" % "compile",
"com.typesafe.akka" %% "akka-testkit" % "2.1.4" % "test",
"org.specs2" %% "specs2" % "1.14" % "test",
"com.typesafe.akka" %% "akka-actor" % "2.3.12" % "compile",
"com.typesafe.akka" %% "akka-testkit" % "2.3.12" % "test",
"org.specs2" %% "specs2-core" % "3.6.4" % "test",
"org.specs2" %% "specs2-junit" % "3.6.4" % "test",
"junit" % "junit" % "4.11" % "test",
"joda-time" % "joda-time" % "2.2"
"joda-time" % "joda-time" % "2.8.2"
)

scalacOptions ++= Seq(
"-optimize",
"-deprecation",
"-unchecked",
"-Xcheckinit",
"-Yrangepos",
"-encoding", "utf8")

parallelExecution in Test := false
Expand Down
1 change: 0 additions & 1 deletion src/main/scala/io/backchat/hookup/http/Message.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import org.jboss.netty.handler.codec.http.{HttpMessage, HttpHeaders, HttpMethod,
HttpVersion}
import org.jboss.netty.handler.codec.http.cookie.Cookie
import scala.collection.JavaConversions._
import scala.reflect.BeanProperty
import org.joda.time.DateTime
import scala.concurrent.duration.Duration

Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/io/backchat/hookup/server.scala
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,9 @@ object HookupServer {
* @param timeout a [[org.jboss.netty.util.Timeout]]
*/
private class WebSocketCancellable(timeout: NettyTimeout) extends Cancellable {
def cancel() {
def cancel(): Boolean = {
timeout.cancel()
true
}

def isCancelled = timeout.isCancelled
Expand Down
27 changes: 15 additions & 12 deletions src/test/scala/io/backchat/hookup/tests/FileBufferSpec.scala
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package io.backchat.hookup
package tests

import org.specs2.specification.AfterAll
import org.specs2.time.NoTimeConversions
import org.specs2.Specification
import java.io.File
import org.apache.commons.io.{FilenameUtils, FileUtils}
import org.json4s._
import scala.io.Source
import collection.JavaConverters._
import org.specs2.specification.{Fragments, Step}
import org.specs2.specification.core.{Fragments}
import java.util.concurrent.{Executors, ConcurrentLinkedQueue}
import scala.concurrent.{Await, Future, ExecutionContext}
import scala.concurrent.duration._
import akka.actor.ActorSystem
import collection.mutable.{ArrayBuffer, Buffer, SynchronizedBuffer, ListBuffer}
import java.util.concurrent.atomic.AtomicInteger

class FileBufferSpec extends Specification with NoTimeConversions { def is =
class FileBufferSpec extends Specification with AfterAll { def is =
"A FileBuffer should" ^
"create the path to the file if it doesn't exist" ! createsPath ^
"write to a file while the buffer is open" ! writesToFile ^
Expand All @@ -27,7 +28,9 @@ class FileBufferSpec extends Specification with NoTimeConversions { def is =

implicit val wireFormat: WireFormat = new JsonProtocolWireFormat()(DefaultFormats)
implicit val executionContext = ExecutionContext.fromExecutorService(Executors.newCachedThreadPool())
override def map(fs: => Fragments) = super.map(fs) ^ Step(executionContext.shutdown())


override def afterAll(): Unit = executionContext.shutdown()

def createsPath = {
val logPath = new File("./test-work/testing/and/such/buffer.log")
Expand All @@ -45,21 +48,21 @@ class FileBufferSpec extends Specification with NoTimeConversions { def is =
FileUtils.deleteQuietly(new File("./test-work2"))
val logPath = new File("./test-work2/buffer.log")
val buff = new FileBuffer(logPath)
val exp1 = TextMessage("the first message")
val exp2 = TextMessage("the second message")
val exp1: OutboundMessage = TextMessage("the first message")
val exp2: OutboundMessage = TextMessage("the second message")
buff.open()
buff.write(exp1)
buff.write(exp2)
buff.close()
val lines = Source.fromFile(logPath).getLines().toList map wireFormat.parseOutMessage
FileUtils.deleteQuietly(new File("./test-work2"))
lines must haveTheSameElementsAs(List(exp1, exp2))
lines must contain(eachOf(exp1, exp2))
}

def writesToMemory = {
val logPath = new File("./test-work3/buffer.log")
val exp1 = TextMessage("the first message")
val exp2 = TextMessage("the second message")
val exp1: OutboundMessage = TextMessage("the first message")
val exp2: OutboundMessage = TextMessage("the second message")
val queue = new ConcurrentLinkedQueue[String]()
val buff = new FileBuffer(logPath, false, queue)
buff.open()
Expand All @@ -68,14 +71,14 @@ class FileBufferSpec extends Specification with NoTimeConversions { def is =
val lst = queue.asScala.toList
buff.close()
FileUtils.deleteDirectory(new File("./test-work3"))
lst must haveTheSameElementsAs(List(wireFormat.render(exp1), wireFormat.render(exp2)))
lst must contain(eachOf(wireFormat.render(exp1), wireFormat.render(exp2)))
}

def drainsBuffers = {
val logPath = new File("./test-work4/buffer.log")
val buff = new FileBuffer(logPath)
val exp1 = TextMessage("the first message")
val exp2 = TextMessage("the second message")
val exp1: OutboundMessage = TextMessage("the first message")
val exp2: OutboundMessage = TextMessage("the second message")
buff.open()
buff.write(exp1)
buff.write(exp2)
Expand All @@ -88,7 +91,7 @@ class FileBufferSpec extends Specification with NoTimeConversions { def is =
}, 5 seconds)
buff.close()
FileUtils.deleteQuietly(new File("./test-work4"))
lines must haveTheSameElementsAs(List(exp1, exp2))
lines must contain(eachOf(exp1, exp2))
}

def handlesConcurrentLoads = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.backchat.hookup
package tests

import org.specs2.Specification
import org.specs2.specification.{Around, AfterAll}
import org.specs2.time.NoTimeConversions
import org.json4s._
import org.specs2.execute.Result
Expand All @@ -10,7 +11,7 @@ import java.net.{ServerSocket, URI}
import akka.testkit._
import akka.actor.ActorSystem
import scala.concurrent.duration._
import org.specs2.specification.{Around, Step, Fragments}
import org.specs2.specification.core.Fragments
import scala.concurrent.{ExecutionContext, Await}
import scala.concurrent.forkjoin.ForkJoinPool
import java.lang.Thread.UncaughtExceptionHandler
Expand Down Expand Up @@ -88,7 +89,7 @@ trait HookupClientSpecification {

}

class HookupClientSpec extends Specification with NoTimeConversions { def is =
class HookupClientSpec extends Specification with AfterAll { def is =
"A WebSocketClient should" ^
"when configured with jsonProtocol" ^
"connect to a server" ! specify("jsonProtocol").connectsToServer ^
Expand All @@ -106,12 +107,12 @@ class HookupClientSpec extends Specification with NoTimeConversions { def is =

implicit val system: ActorSystem = ActorSystem("HookupClientSpec")

def stopActorSystem = {
def stopActorSystem() = {
system.shutdown()
system.awaitTermination(5 seconds)
}

override def map(fs: => Fragments) = super.map(fs) ^ Step(stopActorSystem)
def afterAll() { stopActorSystem() }

def specify(proto: String) = new ClientSpecContext(proto)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package io.backchat.hookup
package tests

import org.specs2.Specification
import org.specs2.specification.{Step, Fragments, After}
import org.specs2.specification.{AfterAll, After}
import org.specs2.specification.core.Fragments
import scala.concurrent.duration._
import scala.concurrent.{Await, ExecutionContext, Promise}
import org.specs2.time.NoTimeConversions
Expand All @@ -17,7 +18,7 @@ import java.util.concurrent._
import examples.NoopWireformat
import scala.util.Success

class HookupServerSpec extends Specification with NoTimeConversions { def is = sequential ^
class HookupServerSpec extends Specification with AfterAll { def is = sequential ^
"A HookupServer should" ^
"fails connecting when none of the protocols match" ! hookupServerContext(protos:_*).failsWithWrongSubProtocols ^ bt^
"accept connections" ^ t ^
Expand All @@ -40,7 +41,7 @@ class HookupServerSpec extends Specification with NoTimeConversions { def is = s

implicit val executionContext = ExecutionContext.fromExecutorService(Executors.newCachedThreadPool())

override def map(fs: => Fragments) = super.map(fs) ^ Step(executionContext.shutdown())
def afterAll() { executionContext.shutdown() }


case class hookupServerContext(protocols: WireFormat*) extends After {
Expand Down

0 comments on commit 0d670ef

Please sign in to comment.