Skip to content

Commit

Permalink
Fix error configuration syntax in Scala 2.10.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonnie Pryor committed May 24, 2015
1 parent 57ab46d commit f376b1f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,13 @@ val loggingRetryPolicy = retryForever monitorWith {
Logger.getLogger("log") onRetrying logDebug onRetryingWith [RuntimeException] logInfo orOnRetryingWhere {
case Failure(e: Error) => logWarning
}
}

// NOTE: In Scala 2.10 the `onXxxWith[Throwable]` methods require chaining method invocations with `.`, `(` and `)`.
val sameLoggingRetryPolicy = retryForever monitorWith {
Logger.getLogger("log").onRetrying(logDebug).onRetryingWith[RuntimeException](logInfo).orOnRetryingWhere {
case Failure(e: Error) => logWarning
}
}
```

Expand Down
28 changes: 14 additions & 14 deletions src/test/scala/atmos/dsl/EventMonitorConfigSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class EventMonitorConfigSpec extends FlatSpec with Matchers with MockFactory {
new TestCase[Slf4jLogger, LogEventsWithSlf4j, LogAction[Slf4jLevel]] {
override def expect(action: LogAction[Slf4jLevel]) = action match {
case LogAction.LogAt(Slf4jLevel.Info) => (target.info(_: String, _: Throwable)).expects(*, *) once
case LogAction.LogAt(Slf4jLevel.Warn) => (target.warn(_: String, _: Throwable))expects(*, *) once
case LogAction.LogAt(Slf4jLevel.Warn) => (target.warn(_: String, _: Throwable)) expects (*, *) once
case _ =>
}
} run (target, LogAction.LogNothing, LogAction.LogAt(Slf4jLevel.Info), LogAction.LogAt(Slf4jLevel.Warn))
Expand All @@ -109,15 +109,15 @@ class EventMonitorConfigSpec extends FlatSpec with Matchers with MockFactory {

/** A utility for testing the various events handled by monitor DSL methods. */
trait TestCase[T, Monitor <: EventMonitor, MonitorAction] {

val name = None: Option[String]
val attempt = 1
val backoff = 1 second
val silent = false

/** Sets an expectation for this test case. */
def expect(action: MonitorAction): Unit

/** Runs this test case. */
def run(
target: T,
Expand All @@ -132,9 +132,9 @@ class EventMonitorConfigSpec extends FlatSpec with Matchers with MockFactory {
val monitor: Monitor = target
locally {
val test = (monitor
onRetrying onSuccess
onRetryingWith[Exception] onException
orOnRetryingWith[Error] onError)
.onRetrying(onSuccess)
.onRetryingWith[Exception](onException)
.orOnRetryingWith[Error](onError))
expect(onSuccess)
test.retrying(name, success, attempt, backoff, silent)
expect(onException)
Expand All @@ -144,9 +144,9 @@ class EventMonitorConfigSpec extends FlatSpec with Matchers with MockFactory {
}
locally {
val test = (monitor
onInterrupted onSuccess
onInterruptedWith[Exception] onException
orOnInterruptedWith[Error] onError)
.onInterrupted(onSuccess)
.onInterruptedWith[Exception](onException)
.orOnInterruptedWith[Error](onError))
expect(onSuccess)
test.interrupted(name, success, attempt)
expect(onException)
Expand All @@ -156,9 +156,9 @@ class EventMonitorConfigSpec extends FlatSpec with Matchers with MockFactory {
}
locally {
val test = (monitor
onAborted onSuccess
onAbortedWith[Exception] onException
orOnAbortedWith[Error] onError)
.onAborted(onSuccess)
.onAbortedWith[Exception](onException)
.orOnAbortedWith[Error](onError))
expect(onSuccess)
test.aborted(name, success, attempt)
expect(onException)
Expand All @@ -167,7 +167,7 @@ class EventMonitorConfigSpec extends FlatSpec with Matchers with MockFactory {
test.aborted(name, error, attempt)
}
}

}

/** A trait that presents a narrow view of Akka loggers to help ScalaMock resolve the correct overloaded method. */
Expand Down

0 comments on commit f376b1f

Please sign in to comment.