Making everything compile and tests pass

This commit is contained in:
Viktor Klang 2012-06-28 15:33:49 +02:00
parent 9ac9e88c31
commit 1a7f29aaec
35 changed files with 101 additions and 59 deletions

View file

@ -157,7 +157,7 @@ object ActorModelSpec {
try {
await(deadline)(stops == dispatcher.stops.get)
} catch {
case e
case e: Throwable
system.eventStream.publish(Error(e, dispatcher.toString, dispatcher.getClass, "actual: stops=" + dispatcher.stops.get +
" required: stops=" + stops))
throw e
@ -214,7 +214,7 @@ object ActorModelSpec {
await(deadline)(stats.msgsProcessed.get() == msgsProcessed)
await(deadline)(stats.restarts.get() == restarts)
} catch {
case e
case e: Throwable
system.eventStream.publish(Error(e,
Option(dispatcher).toString,
(Option(dispatcher) getOrElse this).getClass,

View file

@ -646,7 +646,7 @@ private[akka] class ActorSystemImpl(val name: String, applicationConfig: Config,
instance //Profit!
}
} catch {
case t
case t: Throwable
extensions.remove(ext, inProcessOfRegistration) //In case shit hits the fan, remove the inProcess signal
throw t //Escalate to caller
} finally {

View file

@ -300,7 +300,7 @@ abstract class MessageDispatcher(val prerequisites: DispatcherPrerequisites) ext
try {
executeTask(invocation)
} catch {
case t
case t: Throwable
addInhabitants(-1)
throw t
}
@ -575,7 +575,7 @@ object ForkJoinExecutorConfigurator {
final override def setRawResult(u: Unit): Unit = ()
final override def getRawResult(): Unit = ()
final override def exec(): Boolean = try { mailbox.run; true } catch {
case anything
case anything: Throwable
val t = Thread.currentThread
t.getUncaughtExceptionHandler match {
case null

View file

@ -688,7 +688,7 @@ sealed trait Future[+T] extends Await.Awaitable[T] {
case NonFatal(e)
executor.reportFailure(new LogEventException(Debug("Future", getClass, e.getMessage), e))
p complete Left(e)
case t
case t: Throwable
p complete Left(new ExecutionException(t)); throw t
}
}

View file

@ -25,9 +25,9 @@ class Switch(startAsOn: Boolean = false) {
protected def transcend(from: Boolean, action: Unit): Boolean = synchronized {
if (switch.compareAndSet(from, !from)) {
try action catch {
case e
case t: Throwable
switch.compareAndSet(!from, from) // revert status
throw e
throw t
}
true
} else false

View file

@ -1,5 +1,7 @@
package akka.agent
import language.postfixOps
import akka.dispatch.Await
import akka.util.Duration
import akka.util.duration._

View file

@ -20,7 +20,7 @@ import akka.event.LoggingAdapter;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import static akka.japi.Util.manifest;
import static akka.japi.Util.classTag;
import static akka.actor.SupervisorStrategy.*;
import static akka.pattern.Patterns.ask;
@ -146,7 +146,7 @@ public class FaultHandlingDocSample {
// Send current progress to the initial sender
pipe(ask(counterService, GetCurrentCount, askTimeout)
.mapTo(manifest(CurrentCount.class))
.mapTo(classTag(CurrentCount.class))
.map(new Mapper<CurrentCount, Progress>() {
public Progress apply(CurrentCount c) {
return new Progress(100.0 * c.count / totalCount);

View file

@ -21,7 +21,7 @@ Sockets are always created using the ``akka.zeromq.ZeroMQExtension``, for exampl
.. includecode:: code/docs/zeromq/ZeromqDocTestBase.java#pub-socket
Above examples will create a ZeroMQ Publisher socket that is Bound to the port 1233 on localhost.
Above examples will create a ZeroMQ Publisher socket that is Bound to the port 21231 on localhost.
Similarly you can create a subscription socket, with a listener, that subscribes to all messages from the publisher using:

View file

@ -3,6 +3,8 @@
*/
package docs.actor.mailbox
import language.postfixOps
//#imports
import akka.actor.Props
@ -56,7 +58,7 @@ import akka.util.duration._
class MyMailboxType(systemSettings: ActorSystem.Settings, config: Config)
extends MailboxType {
override def create(owner: Option[ActorRef], system: Option[ActorSystem]): MessageQueue = owner zip system headOption match {
override def create(owner: Option[ActorRef], system: Option[ActorSystem]): MessageQueue = (owner zip system) headOption match {
case Some((o, s: ExtendedActorSystem)) new MyMessageQueue(o, s)
case None throw new IllegalArgumentException(
"requires an owner (i.e. does not work with BalancingDispatcher)")

View file

@ -3,6 +3,8 @@
*/
package docs.actor
import language.postfixOps
//#imports1
import akka.actor.Actor
import akka.actor.Props

View file

@ -3,6 +3,8 @@
*/
package docs.actor
import language.postfixOps
//#test-code
import akka.testkit.AkkaSpec
import akka.actor.Props

View file

@ -3,6 +3,8 @@
*/
package docs.actor
import language.postfixOps
//#all
//#imports
import akka.actor._

View file

@ -3,6 +3,8 @@
*/
package docs.actor
import language.postfixOps
//#testkit
import akka.testkit.{ AkkaSpec, ImplicitSender, EventFilter }
import akka.actor.{ ActorRef, Props, Terminated }

View file

@ -3,6 +3,8 @@
*/
package docs.actor
import language.postfixOps
//#imports1
import akka.actor.Actor
import akka.actor.Props

View file

@ -3,6 +3,8 @@
*/
package docs.actor
import language.postfixOps
//#imports
import akka.dispatch.{ Promise, Future, Await }
import akka.util.duration._

View file

@ -3,6 +3,8 @@
*/
package docs.agent
import language.postfixOps
import akka.agent.Agent
import akka.util.duration._
import akka.util.Timeout

View file

@ -1,7 +1,7 @@
package docs.camel
object Consumers {
{
def foo = {
//#Consumer1
import akka.camel.{ CamelMessage, Consumer }
@ -14,7 +14,7 @@ object Consumers {
}
//#Consumer1
}
{
def bar = {
//#Consumer2
import akka.camel.{ CamelMessage, Consumer }

View file

@ -1,7 +1,7 @@
package docs.camel
object Introduction {
{
def foo = {
//#Consumer-mina
import akka.camel.{ CamelMessage, Consumer }
@ -21,7 +21,7 @@ object Introduction {
val mina = sys.actorOf(Props[MinaClient])
//#Consumer-mina
}
{
def bar = {
//#Consumer
import akka.camel.{ CamelMessage, Consumer }
@ -35,7 +35,7 @@ object Introduction {
}
//#Consumer
}
{
def baz = {
//#Producer
import akka.actor.Actor
import akka.camel.{ Producer, Oneway }

View file

@ -3,6 +3,8 @@
*/
package docs.dispatcher
import language.postfixOps
import org.scalatest.{ BeforeAndAfterAll, WordSpec }
import org.scalatest.matchers.MustMatchers
import akka.testkit.AkkaSpec

View file

@ -3,6 +3,8 @@
*/
package docs.future
import language.postfixOps
import org.scalatest.{ BeforeAndAfterAll, WordSpec }
import org.scalatest.matchers.MustMatchers
import akka.testkit._

View file

@ -3,6 +3,8 @@
*/
package docs.io
import language.postfixOps
//#imports
import akka.actor._
import akka.util.{ ByteString, ByteStringBuilder }

View file

@ -3,6 +3,8 @@
*/
package docs.routing
import language.postfixOps
import akka.routing.{ ScatterGatherFirstCompletedRouter, BroadcastRouter, RandomRouter, RoundRobinRouter }
import annotation.tailrec
import akka.actor.{ Props, Actor }

View file

@ -1,5 +1,8 @@
package docs.testkit
import language.postfixOps
import language.implicitConversions
import org.specs2.Specification
import org.specs2.specification.{ Step, Scope }

View file

@ -1,5 +1,7 @@
package docs.testkit
import language.postfixOps
import org.specs2.mutable.Specification
import org.specs2.specification.Scope
import org.specs2.time.NoTimeConversions

View file

@ -3,6 +3,8 @@
*/
package docs.testkit
import language.postfixOps
//#testkit-usage
import scala.util.Random

View file

@ -3,6 +3,8 @@
*/
package docs.testkit
import language.postfixOps
//#imports-test-probe
import akka.testkit.TestProbe
import akka.util.duration._

View file

@ -4,6 +4,8 @@
package docs.transactor
import language.postfixOps
import akka.actor._
import akka.transactor._
import akka.util.duration._

View file

@ -3,6 +3,8 @@
*/
package docs.zeromq
import language.postfixOps
import akka.actor.Actor
import akka.actor.Props
import akka.util.duration._
@ -30,7 +32,7 @@ object ZeromqDocSpec {
class HealthProbe extends Actor {
val pubSocket = context.system.newSocket(SocketType.Pub, Bind("tcp://127.0.0.1:1235"))
val pubSocket = ZeroMQExtension(context.system).newSocket(SocketType.Pub, Bind("tcp://127.0.0.1:1235"))
val memory = ManagementFactory.getMemoryMXBean
val os = ManagementFactory.getOperatingSystemMXBean
val ser = SerializationExtension(context.system)
@ -64,7 +66,7 @@ object ZeromqDocSpec {
//#logger
class Logger extends Actor with ActorLogging {
context.system.newSocket(SocketType.Sub, Listener(self), Connect("tcp://127.0.0.1:1235"), Subscribe("health"))
ZeroMQExtension(context.system).newSocket(SocketType.Sub, Listener(self), Connect("tcp://127.0.0.1:1235"), Subscribe("health"))
val ser = SerializationExtension(context.system)
val timestampFormat = new SimpleDateFormat("HH:mm:ss.SSS")
@ -90,7 +92,7 @@ object ZeromqDocSpec {
//#alerter
class HeapAlerter extends Actor with ActorLogging {
context.system.newSocket(SocketType.Sub, Listener(self), Connect("tcp://127.0.0.1:1235"), Subscribe("health.heap"))
ZeroMQExtension(context.system).newSocket(SocketType.Sub, Listener(self), Connect("tcp://127.0.0.1:1235"), Subscribe("health.heap"))
val ser = SerializationExtension(context.system)
var count = 0
@ -121,11 +123,6 @@ class ZeromqDocSpec extends AkkaSpec("akka.loglevel=INFO") {
val pubSocket = ZeroMQExtension(system).newSocket(SocketType.Pub, Bind("tcp://127.0.0.1:21231"))
//#pub-socket
//#pub-socket2
import akka.zeromq._
val pubSocket2 = system.newSocket(SocketType.Pub, Bind("tcp://127.0.0.1:21232"))
//#pub-socket2
//#sub-socket
import akka.zeromq._
val listener = system.actorOf(Props(new Actor {
@ -135,11 +132,11 @@ class ZeromqDocSpec extends AkkaSpec("akka.loglevel=INFO") {
case _ //...
}
}))
val subSocket = system.newSocket(SocketType.Sub, Listener(listener), Connect("tcp://127.0.0.1:21231"), SubscribeAll)
val subSocket = ZeroMQExtension(system).newSocket(SocketType.Sub, Listener(listener), Connect("tcp://127.0.0.1:21231"), SubscribeAll)
//#sub-socket
//#sub-topic-socket
val subTopicSocket = system.newSocket(SocketType.Sub, Listener(listener), Connect("tcp://127.0.0.1:21231"), Subscribe("foo.bar"))
val subTopicSocket = ZeroMQExtension(system).newSocket(SocketType.Sub, Listener(listener), Connect("tcp://127.0.0.1:21231"), Subscribe("foo.bar"))
//#sub-topic-socket
//#unsub-topic-socket
@ -155,7 +152,7 @@ class ZeromqDocSpec extends AkkaSpec("akka.loglevel=INFO") {
system.stop(subTopicSocket)
//#high-watermark
val highWatermarkSocket = system.newSocket(
val highWatermarkSocket = ZeroMQExtension(system).newSocket(
SocketType.Router,
Listener(listener),
Bind("tcp://127.0.0.1:21233"),

View file

@ -21,12 +21,8 @@ Sockets are always created using the ``akka.zeromq.ZeroMQExtension``, for exampl
.. includecode:: code/docs/zeromq/ZeromqDocSpec.scala#pub-socket
or by importing the ``akka.zeromq._`` package to make newSocket method available on system, via an implicit conversion.
.. includecode:: code/docs/zeromq/ZeromqDocSpec.scala#pub-socket2
Above examples will create a ZeroMQ Publisher socket that is Bound to the port 1234 on localhost.
Above examples will create a ZeroMQ Publisher socket that is Bound to the port 1233 on localhost.
Similarly you can create a subscription socket, with a listener, that subscribes to all messages from the publisher using:

View file

@ -1,5 +1,7 @@
package akka.actor.mailbox
import language.postfixOps
import org.apache.commons.io.FileUtils
import akka.dispatch.Mailbox

View file

@ -31,7 +31,7 @@ trait NetworkFailureSpec extends DefaultTimeout { self: AkkaSpec ⇒
Thread.sleep(duration.toMillis)
restoreIP
} catch {
case e
case e: Throwable
dead.set(true)
e.printStackTrace
}
@ -46,7 +46,7 @@ trait NetworkFailureSpec extends DefaultTimeout { self: AkkaSpec ⇒
Thread.sleep(duration.toMillis)
restoreIP
} catch {
case e
case e: Throwable
dead.set(true)
e.printStackTrace
}
@ -61,7 +61,7 @@ trait NetworkFailureSpec extends DefaultTimeout { self: AkkaSpec ⇒
Thread.sleep(duration.toMillis)
restoreIP
} catch {
case e
case e: Throwable
dead.set(true)
e.printStackTrace
}

View file

@ -4,6 +4,8 @@
package akka.transactor
import language.postfixOps
import akka.actor.{ Actor, ActorRef }
import scala.concurrent.stm.InTxn

View file

@ -4,18 +4,20 @@
package akka.transactor
import language.postfixOps
import org.scalatest.BeforeAndAfterAll
import akka.actor._
import akka.dispatch.Await
import akka.util.duration._
import akka.util.Timeout
import akka.testkit._
import akka.testkit.TestEvent.Mute
import scala.concurrent.stm._
import scala.util.Random.{ nextInt random }
import java.util.concurrent.CountDownLatch
import akka.pattern.{ AskTimeoutException, ask }
import akka.util.{ NonFatal, Timeout }
object FickleFriends {
case class FriendlyIncrement(friends: Seq[ActorRef], timeout: Timeout, latch: CountDownLatch)
@ -49,7 +51,7 @@ object FickleFriends {
}
}
} catch {
case _ () // swallow exceptions
case NonFatal(_) () // swallow exceptions
}
}
}

View file

@ -4,6 +4,8 @@
package akka.transactor
import language.postfixOps
import akka.actor._
import akka.dispatch.Await
import akka.util.duration._

View file

@ -20,13 +20,15 @@ import Sphinx.{ sphinxDocs, sphinxHtml, sphinxLatex, sphinxPdf, sphinxPygments,
object AkkaBuild extends Build {
System.setProperty("akka.mode", "test") // Is there better place for this?
lazy val desiredScalaVersion = "2.10.0-M4"
lazy val buildSettings = Seq(
organization := "com.typesafe.akka",
version := "2.1-SNAPSHOT",
//scalaVersion := "2.10.0-M4"
scalaVersion := "2.10.0-SNAPSHOT",
scalaVersion in update <<= (scalaVersion) apply {
case "2.10.0-SNAPSHOT" => "2.10.0-M4"
case "2.10.0-SNAPSHOT" => desiredScalaVersion
case x => x
}
)
@ -48,7 +50,7 @@ object AkkaBuild extends Build {
sphinxLatex <<= sphinxLatex in LocalProject(docs.id),
sphinxPdf <<= sphinxPdf in LocalProject(docs.id)
),
aggregate = Seq(actor, testkit, actorTests, remote, remoteTests, camel, cluster, slf4j, agent, transactor, mailboxes, zeroMQ, kernel, akkaSbtPlugin, samples, tutorials, docs)
aggregate = Seq(actor, testkit, actorTests, remote, remoteTests, camel, cluster, slf4j, agent, transactor, mailboxes, zeroMQ, kernel, /*akkaSbtPlugin,*/ samples, tutorials, docs)
)
lazy val actor = Project(
@ -299,6 +301,7 @@ object AkkaBuild extends Build {
override lazy val settings = super.settings ++ buildSettings ++ Seq(
resolvers += "Sonatype Snapshot Repo" at "https://oss.sonatype.org/content/repositories/snapshots/",
resolvers += "Sonatype Releases Repo" at "https://oss.sonatype.org/content/repositories/releases/",
shellPrompt := { s => Project.extract(s).currentProject.id + " > " }
)
@ -446,9 +449,7 @@ object AkkaBuild extends Build {
object Dependencies {
import Dependency._
val actor = Seq(
config
)
val actor = Seq(config)
val testkit = Seq(Test.scalatest, Test.junit)
@ -480,28 +481,31 @@ object Dependencies {
}
object Dependency {
def v(a: String): String = a+"_"+AkkaBuild.desiredScalaVersion
// Compile
val config = "com.typesafe" % "config" % "0.4.1" // ApacheV2
val camelCore = "org.apache.camel" % "camel-core" % "2.8.0" // ApacheV2
val netty = "io.netty" % "netty" % "3.5.0.Final" // ApacheV2
val protobuf = "com.google.protobuf" % "protobuf-java" % "2.4.1" // New BSD
val scalaStm = "org.scala-tools" %% "scala-stm" % "0.5" // Modified BSD (Scala)
val slf4jApi = "org.slf4j" % "slf4j-api" % "1.6.4" // MIT
val zeroMQ = "org.zeromq" %% "zeromq-scala-binding" % "0.0.6" // ApacheV2 //FIXME SWITCH TO OFFICIAL VERSION
val uncommonsMath = "org.uncommons.maths" % "uncommons-maths" % "1.2.2a" // ApacheV2
val config = "com.typesafe" % "config" % "0.4.1" // ApacheV2
val camelCore = "org.apache.camel" % "camel-core" % "2.8.0" // ApacheV2
val netty = "io.netty" % "netty" % "3.5.1.Final" // ApacheV2
val protobuf = "com.google.protobuf" % "protobuf-java" % "2.4.1" // New BSD
val scalaStm = "org.scala-tools" % v("scala-stm") % "0.5" // Modified BSD (Scala)
val slf4jApi = "org.slf4j" % "slf4j-api" % "1.6.4" // MIT
val zeroMQ = "org.zeromq" % v("zeromq-scala-binding") % "0.0.6" // ApacheV2 //FIXME SWITCH TO OFFICIAL VERSION
val uncommonsMath = "org.uncommons.maths" % "uncommons-maths" % "1.2.2a" // ApacheV2
// Test
object Test {
val commonsMath = "org.apache.commons" % "commons-math" % "2.1" % "test" // ApacheV2
val commonsIo = "commons-io" % "commons-io" % "2.0.1" % "test" // ApacheV2
val junit = "junit" % "junit" % "4.10" % "test" // Common Public License 1.0
val logback = "ch.qos.logback" % "logback-classic" % "1.0.4" % "test" // EPL 1.0 / LGPL 2.1
val mockito = "org.mockito" % "mockito-all" % "1.8.1" % "test" // MIT
val scalatest = "org.scalatest" %% "scalatest" % "1.9-2.10.0-M4-B2" % "test" // ApacheV2
val scalacheck = "org.scalacheck" %% "scalacheck" % "1.10.0-b1" % "test" // New BSD
val specs2 = "org.specs2" %% "specs2" % "1.11" % "test" // Modified BSD / ApacheV2
val commonsMath = "org.apache.commons" % "commons-math" % "2.1" % "test" // ApacheV2
val commonsIo = "commons-io" % "commons-io" % "2.0.1" % "test" // ApacheV2
val junit = "junit" % "junit" % "4.10" % "test" // Common Public License 1.0
val logback = "ch.qos.logback" % "logback-classic" % "1.0.4" % "test" // EPL 1.0 / LGPL 2.1
val mockito = "org.mockito" % "mockito-all" % "1.8.1" % "test" // MIT
val scalatest = "org.scalatest" % v("scalatest") % "1.9-2.10.0-M4-B2" % "test" // ApacheV2
val scalacheck = "org.scalacheck" % v("scalacheck") % "1.10.0-b1" % "test" // New BSD
val specs2 = "org.specs2" % "specs2_2.10" % "1.11" % "test" // Modified BSD / ApacheV2
}
}