Updating to ScalaTest 3.0.0 and ScalaCheck 1.13.2

This commit is contained in:
Endre Sándor Varga 2016-08-03 14:06:57 +02:00
parent 0ed4a2aae9
commit 5e830323f6
27 changed files with 213 additions and 201 deletions

View file

@ -11,6 +11,7 @@ import java.util.ArrayList;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import akka.testkit.TestActors; import akka.testkit.TestActors;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import akka.japi.Creator; import akka.japi.Creator;
@ -209,7 +210,7 @@ public class ActorCreationTest extends JUnitSuite {
public void testWrongAnonymousClassStaticCreator() { public void testWrongAnonymousClassStaticCreator() {
try { try {
Props.create(new C() {}); // has implicit reference to outer class Props.create(new C() {}); // has implicit reference to outer class
fail("Should have detected this is not a real static class, and thrown"); org.junit.Assert.fail("Should have detected this is not a real static class, and thrown");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
assertEquals("cannot use non-static local Creator to create actors; make it static (e.g. local to a static method) or top-level", e.getMessage()); assertEquals("cannot use non-static local Creator to create actors; make it static (e.g. local to a static method) or top-level", e.getMessage());
} }
@ -278,7 +279,7 @@ public class ActorCreationTest extends JUnitSuite {
// captures enclosing class // captures enclosing class
}; };
Props.create(anonymousCreatorFromStaticMethod); Props.create(anonymousCreatorFromStaticMethod);
fail("Should have detected this is not a real static class, and thrown"); org.junit.Assert.fail("Should have detected this is not a real static class, and thrown");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
assertEquals("cannot use non-static local Creator to create actors; make it static (e.g. local to a static method) or top-level", e.getMessage()); assertEquals("cannot use non-static local Creator to create actors; make it static (e.g. local to a static method) or top-level", e.getMessage());
} }
@ -296,7 +297,7 @@ public class ActorCreationTest extends JUnitSuite {
assertEquals(TestActor.class, p.actorClass()); assertEquals(TestActor.class, p.actorClass());
try { try {
TestActor.propsUsingLamdaWithoutClass(17); TestActor.propsUsingLamdaWithoutClass(17);
fail("Should have detected lambda erasure, and thrown"); org.junit.Assert.fail("Should have detected lambda erasure, and thrown");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
assertEquals("erased Creator types are unsupported, use Props.create(actorClass, creator) instead", assertEquals("erased Creator types are unsupported, use Props.create(actorClass, creator) instead",
e.getMessage()); e.getMessage());

View file

@ -41,14 +41,14 @@ public class JavaAPITestBase extends JUnitSuite {
String s : Option.some("abc")) { String s : Option.some("abc")) {
return; return;
} }
fail("for-loop not entered"); org.junit.Assert.fail("for-loop not entered");
} }
@Test @Test
public void shouldNotEnterForLoop() { public void shouldNotEnterForLoop() {
for (@SuppressWarnings("unused") for (@SuppressWarnings("unused")
Object o : Option.none()) { Object o : Option.none()) {
fail("for-loop entered"); org.junit.Assert.fail("for-loop entered");
} }
} }

View file

@ -719,7 +719,14 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa
Await.result(p.future, timeout.duration) should ===(message) Await.result(p.future, timeout.duration) should ===(message)
} }
} }
"always cast successfully using mapTo" in { f((future, message) (evaluating { Await.result(future.mapTo[java.lang.Thread], timeout.duration) } should produce[java.lang.Exception]).getMessage should ===(message)) } "always cast successfully using mapTo" in {
f((future, message) {
val exception = the[java.lang.Exception] thrownBy {
Await.result(future.mapTo[java.lang.Thread], timeout.duration)
}
exception.getMessage should ===(message)
})
}
} }
implicit def arbFuture: Arbitrary[Future[Int]] = Arbitrary(for (n arbitrary[Int]) yield Future(n)) implicit def arbFuture: Arbitrary[Future[Int]] = Arbitrary(for (n arbitrary[Int]) yield Future(n))

View file

@ -3,9 +3,9 @@ package akka.io
import java.net.InetAddress import java.net.InetAddress
import java.util.concurrent.atomic.AtomicLong import java.util.concurrent.atomic.AtomicLong
import org.scalatest.{ ShouldMatchers, WordSpec } import org.scalatest.{ Matchers, WordSpec }
class SimpleDnsCacheSpec extends WordSpec with ShouldMatchers { class SimpleDnsCacheSpec extends WordSpec with Matchers {
"Cache" should { "Cache" should {
"not reply with expired but not yet swept out entries" in { "not reply with expired but not yet swept out entries" in {
val localClock = new AtomicLong(0) val localClock = new AtomicLong(0)
@ -15,11 +15,11 @@ class SimpleDnsCacheSpec extends WordSpec with ShouldMatchers {
val cacheEntry = Dns.Resolved("test.local", Seq(InetAddress.getByName("127.0.0.1"))) val cacheEntry = Dns.Resolved("test.local", Seq(InetAddress.getByName("127.0.0.1")))
cache.put(cacheEntry, 5000) cache.put(cacheEntry, 5000)
cache.cached("test.local") should equal(Some(cacheEntry)) cache.cached("test.local") should ===(Some(cacheEntry))
localClock.set(4999) localClock.set(4999)
cache.cached("test.local") should equal(Some(cacheEntry)) cache.cached("test.local") should ===(Some(cacheEntry))
localClock.set(5000) localClock.set(5000)
cache.cached("test.local") should equal(None) cache.cached("test.local") should ===(None)
} }
"sweep out expired entries on cleanup()" in { "sweep out expired entries on cleanup()" in {
@ -30,16 +30,16 @@ class SimpleDnsCacheSpec extends WordSpec with ShouldMatchers {
val cacheEntry = Dns.Resolved("test.local", Seq(InetAddress.getByName("127.0.0.1"))) val cacheEntry = Dns.Resolved("test.local", Seq(InetAddress.getByName("127.0.0.1")))
cache.put(cacheEntry, 5000) cache.put(cacheEntry, 5000)
cache.cached("test.local") should equal(Some(cacheEntry)) cache.cached("test.local") should ===(Some(cacheEntry))
localClock.set(5000) localClock.set(5000)
cache.cached("test.local") should equal(None) cache.cached("test.local") should ===(None)
localClock.set(0) localClock.set(0)
cache.cached("test.local") should equal(Some(cacheEntry)) cache.cached("test.local") should ===(Some(cacheEntry))
localClock.set(5000) localClock.set(5000)
cache.cleanup() cache.cleanup()
cache.cached("test.local") should equal(None) cache.cached("test.local") should ===(None)
localClock.set(0) localClock.set(0)
cache.cached("test.local") should equal(None) cache.cached("test.local") should ===(None)
} }
} }
} }

View file

@ -449,10 +449,10 @@ class TcpConnectionSpec extends AkkaSpec("""
assertThisConnectionActorTerminated() assertThisConnectionActorTerminated()
val buffer = ByteBuffer.allocate(1) val buffer = ByteBuffer.allocate(1)
val thrown = evaluating { val thrown = the[IOException] thrownBy {
windowsWorkaroundToDetectAbort() windowsWorkaroundToDetectAbort()
serverSideChannel.read(buffer) serverSideChannel.read(buffer)
} should produce[IOException] }
thrown.getMessage should ===(ConnectionResetByPeerMessage) thrown.getMessage should ===(ConnectionResetByPeerMessage)
} }
} }

View file

@ -326,7 +326,7 @@ class PersistentReceivePipelineSpec(config: Config) extends AkkaSpec(config) wit
totaller ! 6 totaller ! 6
totaller ! "get" totaller ! "get"
expectMsg(6) expectMsg(6)
probe.expectMsg(99) probe.expectMsg(99L)
} }
} }
} }

View file

@ -18,6 +18,7 @@ import akka.http.javadsl.testkit.JUnitRouteTest;
import akka.stream.Materializer; import akka.stream.Materializer;
import akka.stream.javadsl.Flow; import akka.stream.javadsl.Flow;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@ -67,8 +68,8 @@ public class CustomHttpMethodExamplesTest extends JUnitRouteTest {
CompletionStage<HttpResponse> response = http.singleRequest(request, materializer); CompletionStage<HttpResponse> response = http.singleRequest(request, materializer);
//#customHttpMethod //#customHttpMethod
assertResult(StatusCodes.OK, response.toCompletableFuture().get().status()); assertEquals(StatusCodes.OK, response.toCompletableFuture().get().status());
assertResult( assertEquals(
"This is a BOLT request.", "This is a BOLT request.",
response.toCompletableFuture().get().entity().toStrict(3000, materializer).toCompletableFuture().get().getData().utf8String() response.toCompletableFuture().get().entity().toStrict(3000, materializer).toCompletableFuture().get().getData().utf8String()
); );

View file

@ -19,6 +19,7 @@ import akka.util.ByteString;
import com.typesafe.config.Config; import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory; import com.typesafe.config.ConfigFactory;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -68,16 +69,16 @@ public class RangeDirectivesExamplesTest extends JUnitRouteTest {
try { try {
final List<Multipart.ByteRanges.BodyPart> bodyParts = final List<Multipart.ByteRanges.BodyPart> bodyParts =
completionStage.toCompletableFuture().get(3, TimeUnit.SECONDS); completionStage.toCompletableFuture().get(3, TimeUnit.SECONDS);
assertResult(2, bodyParts.toArray().length); assertEquals(2, bodyParts.toArray().length);
final Multipart.ByteRanges.BodyPart part1 = bodyParts.get(0); final Multipart.ByteRanges.BodyPart part1 = bodyParts.get(0);
assertResult(bytes028Range, part1.getContentRange()); assertEquals(bytes028Range, part1.getContentRange());
assertResult(ByteString.fromString("ABC"), assertEquals(ByteString.fromString("ABC"),
part1.toStrict(1000, materializer).toCompletableFuture().get().getEntity().getData()); part1.toStrict(1000, materializer).toCompletableFuture().get().getEntity().getData());
final Multipart.ByteRanges.BodyPart part2 = bodyParts.get(1); final Multipart.ByteRanges.BodyPart part2 = bodyParts.get(1);
assertResult(bytes678Range, part2.getContentRange()); assertEquals(bytes678Range, part2.getContentRange());
assertResult(ByteString.fromString("GH"), assertEquals(ByteString.fromString("GH"),
part2.toStrict(1000, materializer).toCompletableFuture().get().getEntity().getData()); part2.toStrict(1000, materializer).toCompletableFuture().get().getEntity().getData());
} catch (Exception e) { } catch (Exception e) {

View file

@ -98,7 +98,7 @@ public class GraphDSLDocTest extends AbstractJavaTest {
); );
// unconnected zip.out (!) => "The inlets [] and outlets [] must correspond to the inlets [] and outlets [ZipWith2.out]" // unconnected zip.out (!) => "The inlets [] and outlets [] must correspond to the inlets [] and outlets [ZipWith2.out]"
//#simple-graph //#simple-graph
fail("expected IllegalArgumentException"); org.junit.Assert.fail("expected IllegalArgumentException");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
assertTrue(e != null && e.getMessage() != null && e.getMessage().contains("must correspond to")); assertTrue(e != null && e.getMessage() != null && e.getMessage().contains("must correspond to"));
} }

View file

@ -16,7 +16,7 @@ import akka.testkit.AkkaSpec
import akka.http.scaladsl.{ Http, TestUtils } import akka.http.scaladsl.{ Http, TestUtils }
import akka.http.scaladsl.model._ import akka.http.scaladsl.model._
import akka.stream.testkit.Utils import akka.stream.testkit.Utils
import org.scalatest.concurrent.ScalaFutures import org.scalatest.concurrent.PatienceConfiguration.Timeout
class HighLevelOutgoingConnectionSpec extends AkkaSpec { class HighLevelOutgoingConnectionSpec extends AkkaSpec {
implicit val materializer = ActorMaterializer(ActorMaterializerSettings(system).withFuzzing(true)) implicit val materializer = ActorMaterializer(ActorMaterializerSettings(system).withFuzzing(true))
@ -38,8 +38,7 @@ class HighLevelOutgoingConnectionSpec extends AkkaSpec {
.mapAsync(4)(_.entity.toStrict(1.second)) .mapAsync(4)(_.entity.toStrict(1.second))
.map { r val s = r.data.utf8String; log.debug(s); s.toInt } .map { r val s = r.data.utf8String; log.debug(s); s.toInt }
.runFold(0)(_ + _) .runFold(0)(_ + _)
result.futureValue(Timeout(10.seconds)) should ===(N * (N + 1) / 2)
result.futureValue(PatienceConfig(10.seconds)) shouldEqual N * (N + 1) / 2
binding.futureValue.unbind() binding.futureValue.unbind()
} }
@ -73,7 +72,7 @@ class HighLevelOutgoingConnectionSpec extends AkkaSpec {
.map { r val s = r.data.utf8String; log.debug(s); s.toInt } .map { r val s = r.data.utf8String; log.debug(s); s.toInt }
.runFold(0)(_ + _) .runFold(0)(_ + _)
result.futureValue(PatienceConfig(10.seconds)) shouldEqual C * N * (N + 1) / 2 result.futureValue(Timeout(10.seconds)) should ===(C * N * (N + 1) / 2)
binding.futureValue.unbind() binding.futureValue.unbind()
} }

View file

@ -6,6 +6,7 @@ package akka.http.scaladsl.server.directives
import akka.http.scaladsl.model.StatusCodes import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server._ import akka.http.scaladsl.server._
import org.scalactic.source.Position
import org.scalatest.Inside import org.scalatest.Inside
class PathDirectivesSpec extends RoutingSpec with Inside { class PathDirectivesSpec extends RoutingSpec with Inside {
@ -15,83 +16,83 @@ class PathDirectivesSpec extends RoutingSpec with Inside {
"""path("foo")""" should { """path("foo")""" should {
val test = testFor(path("foo") { echoUnmatchedPath }) val test = testFor(path("foo") { echoUnmatchedPath })
"reject [/bar]" in test() "reject [/bar]" inThe test()
"reject [/foobar]" in test() "reject [/foobar]" inThe test()
"reject [/foo/bar]" in test() "reject [/foo/bar]" inThe test()
"accept [/foo] and clear the unmatchedPath" in test("") "accept [/foo] and clear the unmatchedPath" inThe test("")
"reject [/foo/]" in test() "reject [/foo/]" inThe test()
} }
"""pathPrefix("")""" should { """pathPrefix("")""" should {
val test = testFor(pathPrefix("") { echoUnmatchedPath }) val test = testFor(pathPrefix("") { echoUnmatchedPath })
// Should match everything because pathPrefix is used and "" is a neutral element. // Should match everything because pathPrefix is used and "" is a neutral element.
"accept [/] and clear the unmatchedPath=" in test("") "accept [/] and clear the unmatchedPath=" inThe test("")
"accept [/foo] and clear the unmatchedPath" in test("foo") "accept [/foo] and clear the unmatchedPath" inThe test("foo")
"accept [/foo/] and clear the unmatchedPath" in test("foo/") "accept [/foo/] and clear the unmatchedPath" inThe test("foo/")
"accept [/bar/] and clear the unmatchedPath" in test("bar/") "accept [/bar/] and clear the unmatchedPath" inThe test("bar/")
} }
"""path("" | "foo")""" should { """path("" | "foo")""" should {
val test = testFor(path("" | "foo") { echoUnmatchedPath }) val test = testFor(path("" | "foo") { echoUnmatchedPath })
// Should not match anything apart of "/", because path requires whole path being matched. // Should not match anything apart of "/", because path requires whole path being matched.
"accept [/] and clear the unmatchedPath=" in test("") "accept [/] and clear the unmatchedPath=" inThe test("")
"reject [/foo]" in test() "reject [/foo]" inThe test()
"reject [/foo/]" in test() "reject [/foo/]" inThe test()
"reject [/bar/]" in test() "reject [/bar/]" inThe test()
} }
"""path("") ~ path("foo")""" should { """path("") ~ path("foo")""" should {
val test = testFor(path("")(echoUnmatchedPath) ~ path("foo")(echoUnmatchedPath)) val test = testFor(path("")(echoUnmatchedPath) ~ path("foo")(echoUnmatchedPath))
// Should match both because ~ operator is used for two exclusive routes. // Should match both because ~ operator is used for two exclusive routes.
"accept [/] and clear the unmatchedPath=" in test("") "accept [/] and clear the unmatchedPath=" inThe test("")
"accept [/foo] and clear the unmatchedPath=" in test("") "accept [/foo] and clear the unmatchedPath=" inThe test("")
} }
"""path("foo" /)""" should { """path("foo" /)""" should {
val test = testFor(path("foo" /) { echoUnmatchedPath }) val test = testFor(path("foo" /) { echoUnmatchedPath })
"reject [/foo]" in test() "reject [/foo]" inThe test()
"accept [/foo/] and clear the unmatchedPath" in test("") "accept [/foo/] and clear the unmatchedPath" inThe test("")
} }
"""path("")""" should { """path("")""" should {
val test = testFor(path("") { echoUnmatchedPath }) val test = testFor(path("") { echoUnmatchedPath })
"reject [/foo]" in test() "reject [/foo]" inThe test()
"accept [/] and clear the unmatchedPath" in test("") "accept [/] and clear the unmatchedPath" in test("")
} }
"""pathPrefix("foo")""" should { """pathPrefix("foo")""" should {
val test = testFor(pathPrefix("foo") { echoUnmatchedPath }) val test = testFor(pathPrefix("foo") { echoUnmatchedPath })
"reject [/bar]" in test() "reject [/bar]" inThe test()
"accept [/foobar]" in test("bar") "accept [/foobar]" inThe test("bar")
"accept [/foo/bar]" in test("/bar") "accept [/foo/bar]" inThe test("/bar")
"accept [/foo] and clear the unmatchedPath" in test("") "accept [/foo] and clear the unmatchedPath" inThe test("")
"accept [/foo/] and clear the unmatchedPath" in test("/") "accept [/foo/] and clear the unmatchedPath" inThe test("/")
} }
"""pathPrefix("foo" / "bar")""" should { """pathPrefix("foo" / "bar")""" should {
val test = testFor(pathPrefix("foo" / "bar") { echoUnmatchedPath }) val test = testFor(pathPrefix("foo" / "bar") { echoUnmatchedPath })
"reject [/bar]" in test() "reject [/bar]" inThe test()
"accept [/foo/bar]" in test("") "accept [/foo/bar]" inThe test("")
"accept [/foo/bar/baz]" in test("/baz") "accept [/foo/bar/baz]" inThe test("/baz")
} }
"""pathPrefix("ab[cd]+".r)""" should { """pathPrefix("ab[cd]+".r)""" should {
val test = testFor(pathPrefix("ab[cd]+".r) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefix("ab[cd]+".r) { echoCaptureAndUnmatchedPath })
"reject [/bar]" in test() "reject [/bar]" inThe test()
"reject [/ab/cd]" in test() "reject [/ab/cd]" inThe test()
"accept [/abcdef]" in test("abcd:ef") "accept [/abcdef]" inThe test("abcd:ef")
"accept [/abcdd/ef]" in test("abcdd:/ef") "accept [/abcdd/ef]" inThe test("abcdd:/ef")
} }
"""pathPrefix("ab(cd)".r)""" should { """pathPrefix("ab(cd)".r)""" should {
val test = testFor(pathPrefix("ab(cd)+".r) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefix("ab(cd)+".r) { echoCaptureAndUnmatchedPath })
"reject [/bar]" in test() "reject [/bar]" inThe test()
"reject [/ab/cd]" in test() "reject [/ab/cd]" inThe test()
"accept [/abcdef]" in test("cd:ef") "accept [/abcdef]" inThe test("cd:ef")
"accept [/abcde/fg]" in test("cd:e/fg") "accept [/abcde/fg]" inThe test("cd:e/fg")
} }
"pathPrefix(regex)" should { "pathPrefix(regex)" should {
@ -102,11 +103,11 @@ class PathDirectivesSpec extends RoutingSpec with Inside {
"pathPrefix(IntNumber)" should { "pathPrefix(IntNumber)" should {
val test = testFor(pathPrefix(IntNumber) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefix(IntNumber) { echoCaptureAndUnmatchedPath })
"accept [/23]" in test("23:") "accept [/23]" inThe test("23:")
"accept [/12345yes]" in test("12345:yes") "accept [/12345yes]" inThe test("12345:yes")
"reject [/]" in test() "reject [/]" inThe test()
"reject [/abc]" in test() "reject [/abc]" inThe test()
"reject [/2147483648]" in test() // > Int.MaxValue "reject [/2147483648]" inThe test() // > Int.MaxValue
} }
"pathPrefix(CustomShortNumber)" should { "pathPrefix(CustomShortNumber)" should {
@ -115,200 +116,200 @@ class PathDirectivesSpec extends RoutingSpec with Inside {
} }
val test = testFor(pathPrefix(CustomShortNumber) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefix(CustomShortNumber) { echoCaptureAndUnmatchedPath })
"accept [/23]" in test("23:") "accept [/23]" inThe test("23:")
"accept [/12345yes]" in test("12345:yes") "accept [/12345yes]" inThe test("12345:yes")
"reject [/]" in test() "reject [/]" inThe test()
"reject [/abc]" in test() "reject [/abc]" inThe test()
"reject [/33000]" in test() // > Short.MaxValue "reject [/33000]" inThe test() // > Short.MaxValue
} }
"pathPrefix(JavaUUID)" should { "pathPrefix(JavaUUID)" should {
val test = testFor(pathPrefix(JavaUUID) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefix(JavaUUID) { echoCaptureAndUnmatchedPath })
"accept [/bdea8652-f26c-40ca-8157-0b96a2a8389d]" in test("bdea8652-f26c-40ca-8157-0b96a2a8389d:") "accept [/bdea8652-f26c-40ca-8157-0b96a2a8389d]" inThe test("bdea8652-f26c-40ca-8157-0b96a2a8389d:")
"accept [/bdea8652-f26c-40ca-8157-0b96a2a8389dyes]" in test("bdea8652-f26c-40ca-8157-0b96a2a8389d:yes") "accept [/bdea8652-f26c-40ca-8157-0b96a2a8389dyes]" inThe test("bdea8652-f26c-40ca-8157-0b96a2a8389d:yes")
"reject [/]" in test() "reject [/]" inThe test()
"reject [/abc]" in test() "reject [/abc]" inThe test()
} }
"pathPrefix(Map(\"red\" -> 1, \"green\" -> 2, \"blue\" -> 3))" should { "pathPrefix(Map(\"red\" -> 1, \"green\" -> 2, \"blue\" -> 3))" should {
val test = testFor(pathPrefix(Map("red" 1, "green" 2, "blue" 3)) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefix(Map("red" 1, "green" 2, "blue" 3)) { echoCaptureAndUnmatchedPath })
"accept [/green]" in test("2:") "accept [/green]" inThe test("2:")
"accept [/redsea]" in test("1:sea") "accept [/redsea]" inThe test("1:sea")
"reject [/black]" in test() "reject [/black]" inThe test()
} }
"pathPrefix(Map.empty)" should { "pathPrefix(Map.empty)" should {
val test = testFor(pathPrefix(Map[String, Int]()) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefix(Map[String, Int]()) { echoCaptureAndUnmatchedPath })
"reject [/black]" in test() "reject [/black]" inThe test()
} }
"pathPrefix(Segment)" should { "pathPrefix(Segment)" should {
val test = testFor(pathPrefix(Segment) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefix(Segment) { echoCaptureAndUnmatchedPath })
"accept [/abc]" in test("abc:") "accept [/abc]" inThe test("abc:")
"accept [/abc/]" in test("abc:/") "accept [/abc/]" inThe test("abc:/")
"accept [/abc/def]" in test("abc:/def") "accept [/abc/def]" inThe test("abc:/def")
"reject [/]" in test() "reject [/]" inThe test()
} }
"pathPrefix(Segments)" should { "pathPrefix(Segments)" should {
val test = testFor(pathPrefix(Segments) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefix(Segments) { echoCaptureAndUnmatchedPath })
"accept [/]" in test("List():") "accept [/]" inThe test("List():")
"accept [/a/b/c]" in test("List(a, b, c):") "accept [/a/b/c]" inThe test("List(a, b, c):")
"accept [/a/b/c/]" in test("List(a, b, c):/") "accept [/a/b/c/]" inThe test("List(a, b, c):/")
} }
"""pathPrefix(separateOnSlashes("a/b"))""" should { """pathPrefix(separateOnSlashes("a/b"))""" should {
val test = testFor(pathPrefix(separateOnSlashes("a/b")) { echoUnmatchedPath }) val test = testFor(pathPrefix(separateOnSlashes("a/b")) { echoUnmatchedPath })
"accept [/a/b]" in test("") "accept [/a/b]" inThe test("")
"accept [/a/b/]" in test("/") "accept [/a/b/]" inThe test("/")
"reject [/a/c]" in test() "reject [/a/c]" inThe test()
} }
"""pathPrefix(separateOnSlashes("abc"))""" should { """pathPrefix(separateOnSlashes("abc"))""" should {
val test = testFor(pathPrefix(separateOnSlashes("abc")) { echoUnmatchedPath }) val test = testFor(pathPrefix(separateOnSlashes("abc")) { echoUnmatchedPath })
"accept [/abc]" in test("") "accept [/abc]" inThe test("")
"accept [/abcdef]" in test("def") "accept [/abcdef]" inThe test("def")
"reject [/ab]" in test() "reject [/ab]" inThe test()
} }
"""pathPrefixTest("a" / Segment ~ Slash)""" should { """pathPrefixTest("a" / Segment ~ Slash)""" should {
val test = testFor(pathPrefixTest("a" / Segment ~ Slash) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefixTest("a" / Segment ~ Slash) { echoCaptureAndUnmatchedPath })
"accept [/a/bc/]" in test("bc:/a/bc/") "accept [/a/bc/]" inThe test("bc:/a/bc/")
"reject [/a/bc]" in test() "reject [/a/bc]" inThe test()
"reject [/a/]" in test() "reject [/a/]" inThe test()
} }
"""pathSuffix("edit" / Segment)""" should { """pathSuffix("edit" / Segment)""" should {
val test = testFor(pathSuffix("edit" / Segment) { echoCaptureAndUnmatchedPath }) val test = testFor(pathSuffix("edit" / Segment) { echoCaptureAndUnmatchedPath })
"accept [/orders/123/edit]" in test("123:/orders/") "accept [/orders/123/edit]" inThe test("123:/orders/")
"reject [/orders/123/ed]" in test() "reject [/orders/123/ed]" inThe test()
"reject [/edit]" in test() "reject [/edit]" inThe test()
} }
"""pathSuffix("foo" / "bar" ~ "baz")""" should { """pathSuffix("foo" / "bar" ~ "baz")""" should {
val test = testFor(pathSuffix("foo" / "bar" ~ "baz") { echoUnmatchedPath }) val test = testFor(pathSuffix("foo" / "bar" ~ "baz") { echoUnmatchedPath })
"accept [/orders/barbaz/foo]" in test("/orders/") "accept [/orders/barbaz/foo]" inThe test("/orders/")
"reject [/orders/bazbar/foo]" in test() "reject [/orders/bazbar/foo]" inThe test()
} }
"pathSuffixTest(Slash)" should { "pathSuffixTest(Slash)" should {
val test = testFor(pathSuffixTest(Slash) { echoUnmatchedPath }) val test = testFor(pathSuffixTest(Slash) { echoUnmatchedPath })
"accept [/]" in test("/") "accept [/]" inThe test("/")
"accept [/foo/]" in test("/foo/") "accept [/foo/]" inThe test("/foo/")
"reject [/foo]" in test() "reject [/foo]" inThe test()
} }
"""pathPrefix("foo" | "bar")""" should { """pathPrefix("foo" | "bar")""" should {
val test = testFor(pathPrefix("foo" | "bar") { echoUnmatchedPath }) val test = testFor(pathPrefix("foo" | "bar") { echoUnmatchedPath })
"accept [/foo]" in test("") "accept [/foo]" inThe test("")
"accept [/foops]" in test("ps") "accept [/foops]" inThe test("ps")
"accept [/bar]" in test("") "accept [/bar]" inThe test("")
"reject [/baz]" in test() "reject [/baz]" inThe test()
} }
"""pathSuffix(!"foo")""" should { """pathSuffix(!"foo")""" should {
val test = testFor(pathSuffix(!"foo") { echoUnmatchedPath }) val test = testFor(pathSuffix(!"foo") { echoUnmatchedPath })
"accept [/bar]" in test("/bar") "accept [/bar]" inThe test("/bar")
"reject [/foo]" in test() "reject [/foo]" inThe test()
} }
"pathPrefix(IntNumber?)" should { "pathPrefix(IntNumber?)" should {
val test = testFor(pathPrefix(IntNumber?) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefix(IntNumber?) { echoCaptureAndUnmatchedPath })
"accept [/12]" in test("Some(12):") "accept [/12]" inThe test("Some(12):")
"accept [/12a]" in test("Some(12):a") "accept [/12a]" inThe test("Some(12):a")
"accept [/foo]" in test("None:foo") "accept [/foo]" inThe test("None:foo")
} }
"""pathPrefix("foo"?)""" should { """pathPrefix("foo"?)""" should {
val test = testFor(pathPrefix("foo"?) { echoUnmatchedPath }) val test = testFor(pathPrefix("foo"?) { echoUnmatchedPath })
"accept [/foo]" in test("") "accept [/foo]" inThe test("")
"accept [/fool]" in test("l") "accept [/fool]" inThe test("l")
"accept [/bar]" in test("bar") "accept [/bar]" inThe test("bar")
} }
"""pathPrefix("foo") & pathEnd""" should { """pathPrefix("foo") & pathEnd""" should {
val test = testFor((pathPrefix("foo") & pathEnd) { echoUnmatchedPath }) val test = testFor((pathPrefix("foo") & pathEnd) { echoUnmatchedPath })
"reject [/foobar]" in test() "reject [/foobar]" inThe test()
"reject [/foo/bar]" in test() "reject [/foo/bar]" inThe test()
"accept [/foo] and clear the unmatchedPath" in test("") "accept [/foo] and clear the unmatchedPath" inThe test("")
"reject [/foo/]" in test() "reject [/foo/]" inThe test()
} }
"""pathPrefix("foo") & pathEndOrSingleSlash""" should { """pathPrefix("foo") & pathEndOrSingleSlash""" should {
val test = testFor((pathPrefix("foo") & pathEndOrSingleSlash) { echoUnmatchedPath }) val test = testFor((pathPrefix("foo") & pathEndOrSingleSlash) { echoUnmatchedPath })
"reject [/foobar]" in test() "reject [/foobar]" inThe test()
"reject [/foo/bar]" in test() "reject [/foo/bar]" inThe test()
"accept [/foo] and clear the unmatchedPath" in test("") "accept [/foo] and clear the unmatchedPath" inThe test("")
"accept [/foo/] and clear the unmatchedPath" in test("") "accept [/foo/] and clear the unmatchedPath" inThe test("")
} }
"""pathPrefix(IntNumber.repeat(separator = "."))""" should { """pathPrefix(IntNumber.repeat(separator = "."))""" should {
{ {
val test = testFor(pathPrefix(IntNumber.repeat(min = 2, max = 5, separator = ".")) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefix(IntNumber.repeat(min = 2, max = 5, separator = ".")) { echoCaptureAndUnmatchedPath })
"reject [/foo]" in test() "reject [/foo]" inThe test()
"reject [/1foo]" in test() "reject [/1foo]" inThe test()
"reject [/1.foo]" in test() "reject [/1.foo]" inThe test()
"accept [/1.2foo]" in test("List(1, 2):foo") "accept [/1.2foo]" inThe test("List(1, 2):foo")
"accept [/1.2.foo]" in test("List(1, 2):.foo") "accept [/1.2.foo]" inThe test("List(1, 2):.foo")
"accept [/1.2.3foo]" in test("List(1, 2, 3):foo") "accept [/1.2.3foo]" inThe test("List(1, 2, 3):foo")
"accept [/1.2.3.foo]" in test("List(1, 2, 3):.foo") "accept [/1.2.3.foo]" inThe test("List(1, 2, 3):.foo")
"accept [/1.2.3.4foo]" in test("List(1, 2, 3, 4):foo") "accept [/1.2.3.4foo]" inThe test("List(1, 2, 3, 4):foo")
"accept [/1.2.3.4.foo]" in test("List(1, 2, 3, 4):.foo") "accept [/1.2.3.4.foo]" inThe test("List(1, 2, 3, 4):.foo")
"accept [/1.2.3.4.5foo]" in test("List(1, 2, 3, 4, 5):foo") "accept [/1.2.3.4.5foo]" inThe test("List(1, 2, 3, 4, 5):foo")
"accept [/1.2.3.4.5.foo]" in test("List(1, 2, 3, 4, 5):.foo") "accept [/1.2.3.4.5.foo]" inThe test("List(1, 2, 3, 4, 5):.foo")
"accept [/1.2.3.4.5.6foo]" in test("List(1, 2, 3, 4, 5):.6foo") "accept [/1.2.3.4.5.6foo]" inThe test("List(1, 2, 3, 4, 5):.6foo")
"accept [/1.2.3.]" in test("List(1, 2, 3):.") "accept [/1.2.3.]" inThe test("List(1, 2, 3):.")
"accept [/1.2.3/]" in test("List(1, 2, 3):/") "accept [/1.2.3/]" inThe test("List(1, 2, 3):/")
"accept [/1.2.3./]" in test("List(1, 2, 3):./") "accept [/1.2.3./]" inThe test("List(1, 2, 3):./")
} }
{ {
val test = testFor(pathPrefix(IntNumber.repeat(2, ".")) { echoCaptureAndUnmatchedPath }) val test = testFor(pathPrefix(IntNumber.repeat(2, ".")) { echoCaptureAndUnmatchedPath })
"reject [/bar]" in test() "reject [/bar]" inThe test()
"reject [/1bar]" in test() "reject [/1bar]" inThe test()
"reject [/1.bar]" in test() "reject [/1.bar]" inThe test()
"accept [/1.2bar]" in test("List(1, 2):bar") "accept [/1.2bar]" inThe test("List(1, 2):bar")
"accept [/1.2.bar]" in test("List(1, 2):.bar") "accept [/1.2.bar]" inThe test("List(1, 2):.bar")
"accept [/1.2.3bar]" in test("List(1, 2):.3bar") "accept [/1.2.3bar]" inThe test("List(1, 2):.3bar")
} }
} }
"""rawPathPrefix(Slash ~ "a" / Segment ~ Slash)""" should { """rawPathPrefix(Slash ~ "a" / Segment ~ Slash)""" should {
val test = testFor(rawPathPrefix(Slash ~ "a" / Segment ~ Slash) { echoCaptureAndUnmatchedPath }) val test = testFor(rawPathPrefix(Slash ~ "a" / Segment ~ Slash) { echoCaptureAndUnmatchedPath })
"accept [/a/bc/]" in test("bc:") "accept [/a/bc/]" inThe test("bc:")
"reject [/a/bc]" in test() "reject [/a/bc]" inThe test()
"reject [/ab/]" in test() "reject [/ab/]" inThe test()
} }
"""rawPathPrefixTest(Slash ~ "a" / Segment ~ Slash)""" should { """rawPathPrefixTest(Slash ~ "a" / Segment ~ Slash)""" should {
val test = testFor(rawPathPrefixTest(Slash ~ "a" / Segment ~ Slash) { echoCaptureAndUnmatchedPath }) val test = testFor(rawPathPrefixTest(Slash ~ "a" / Segment ~ Slash) { echoCaptureAndUnmatchedPath })
"accept [/a/bc/]" in test("bc:/a/bc/") "accept [/a/bc/]" inThe test("bc:/a/bc/")
"reject [/a/bc]" in test() "reject [/a/bc]" inThe test()
"reject [/ab/]" in test() "reject [/ab/]" inThe test()
} }
"PathMatchers" should { "PathMatchers" should {
{ {
val test = testFor(path(Remaining.tmap { case Tuple1(s) Tuple1(s.split('-').toList) }) { echoComplete }) val test = testFor(path(Remaining.tmap { case Tuple1(s) Tuple1(s.split('-').toList) }) { echoComplete })
"support the hmap modifier in accept [/yes-no]" in test("List(yes, no)") "support the hmap modifier in accept [/yes-no]" inThe test("List(yes, no)")
} }
{ {
val test = testFor(path(Remaining.map(_.split('-').toList)) { echoComplete }) val test = testFor(path(Remaining.map(_.split('-').toList)) { echoComplete })
"support the map modifier in accept [/yes-no]" in test("List(yes, no)") "support the map modifier in accept [/yes-no]" inThe test("List(yes, no)")
} }
{ {
val test = testFor(path(Remaining.tflatMap { case Tuple1(s) Some(s).filter("yes" ==).map(x Tuple1(x)) }) { echoComplete }) val test = testFor(path(Remaining.tflatMap { case Tuple1(s) Some(s).filter("yes" ==).map(x Tuple1(x)) }) { echoComplete })
"support the hflatMap modifier in accept [/yes]" in test("yes") "support the hflatMap modifier in accept [/yes]" inThe test("yes")
"support the hflatMap modifier in reject [/blub]" in test() "support the hflatMap modifier in reject [/blub]" inThe test()
} }
{ {
val test = testFor(path(Remaining.flatMap(s Some(s).filter("yes" ==))) { echoComplete }) val test = testFor(path(Remaining.flatMap(s Some(s).filter("yes" ==))) { echoComplete })
"support the flatMap modifier in accept [/yes]" in test("yes") "support the flatMap modifier in accept [/yes]" inThe test("yes")
"support the flatMap modifier reject [/blub]" in test() "support the flatMap modifier reject [/blub]" inThe test()
} }
} }
implicit class WithIn(str: String) { implicit class WithIn(str: String) {
def in(f: String Unit) = convertToWordSpecStringWrapper(str) in f(str) def inThe(f: String Unit) = convertToWordSpecStringWrapper(str) in f(str)
def in(body: Unit) = convertToWordSpecStringWrapper(str) in body def inThe(body: Unit) = convertToWordSpecStringWrapper(str) in body
} }
case class testFor(route: Route) { case class testFor(route: Route) {

View file

@ -6,6 +6,7 @@ package akka.persistence.japi.journal
import akka.persistence.CapabilityFlag import akka.persistence.CapabilityFlag
import akka.persistence.journal.JournalPerfSpec import akka.persistence.journal.JournalPerfSpec
import com.typesafe.config.Config import com.typesafe.config.Config
import org.scalactic.source.Position
import org.scalatest.Informer import org.scalatest.Informer
/** /**
@ -43,7 +44,8 @@ import org.scalatest.Informer
*/ */
class JavaJournalPerfSpec(config: Config) extends JournalPerfSpec(config) { class JavaJournalPerfSpec(config: Config) extends JournalPerfSpec(config) {
override protected def info: Informer = new Informer { override protected def info: Informer = new Informer {
override def apply(message: String, payload: Option[Any]): Unit = System.out.println(message) override def apply(message: String, payload: Option[Any])(implicit pos: Position): Unit =
System.out.println(message)
} }
override protected def supportsRejectingNonSerializableObjects: CapabilityFlag = CapabilityFlag.on override protected def supportsRejectingNonSerializableObjects: CapabilityFlag = CapabilityFlag.on

View file

@ -3,6 +3,7 @@
*/ */
package akka.persistence.scalatest package akka.persistence.scalatest
import org.scalactic.source.Position
import org.scalatest.exceptions.TestCanceledException import org.scalatest.exceptions.TestCanceledException
import org.scalatest.words.StringVerbBlockRegistration import org.scalatest.words.StringVerbBlockRegistration
@ -37,8 +38,8 @@ trait MayVerb {
* *
* @see <a href="https://www.rfc-editor.org/rfc/rfc2119.txt">RFC 2119</a> * @see <a href="https://www.rfc-editor.org/rfc/rfc2119.txt">RFC 2119</a>
*/ */
def may(right: Unit)(implicit fun: StringVerbBlockRegistration) { def may(right: Unit)(implicit fun: StringVerbBlockRegistration, pos: Position) {
fun(leftSideString, "may", right _) fun(leftSideString, "may", pos, right _)
} }
} }

View file

@ -166,7 +166,7 @@ abstract class PersistentActorStashingSpec(config: Config) extends PersistenceSp
cmds foreach (persistentActor ! _) cmds foreach (persistentActor ! _)
persistentActor ! GetState persistentActor ! GetState
expectMsg(evts) expectMsg(evts.toList)
} }
} }

View file

@ -8,7 +8,8 @@ import org.scalatest.tools.StandardOutReporter
import org.scalatest.events._ import org.scalatest.events._
import java.lang.Boolean.getBoolean import java.lang.Boolean.getBoolean
class QuietReporter(inColor: Boolean, withDurations: Boolean = false) extends StandardOutReporter(withDurations, inColor, false, true, false, false, false, false, false) { class QuietReporter(inColor: Boolean, withDurations: Boolean = false)
extends StandardOutReporter(withDurations, inColor, false, true, false, false, false, false, false, false) {
def this() = this(!getBoolean("akka.test.nocolor"), !getBoolean("akka.test.nodurations")) def this() = this(!getBoolean("akka.test.nocolor"), !getBoolean("akka.test.nodurations"))

View file

@ -188,7 +188,7 @@ class AccrualFailureDetectorSpec extends AkkaSpec("akka.loglevel = INFO") {
fd.heartbeat() //2000 fd.heartbeat() //2000
fd.heartbeat() //2500 fd.heartbeat() //2500
val phi2 = fd.phi //3000 val phi2 = fd.phi //3000
phi2 should ===(phi1.plusOrMinus(0.001)) phi2 should ===(phi1 +- (0.001))
} }
} }

View file

@ -458,8 +458,7 @@ class RemotingSpec extends AkkaSpec(RemotingSpec.cfg) with ImplicitSender with D
"be able to use multiple transports and use the appropriate one (TCP)" in { "be able to use multiple transports and use the appropriate one (TCP)" in {
val r = system.actorOf(Props[Echo1], "gonk") val r = system.actorOf(Props[Echo1], "gonk")
r.path.toString should be === r.path.toString should ===(s"akka.tcp://remote-sys@localhost:${port(remoteSystem, "tcp")}/remote/akka.tcp/RemotingSpec@localhost:${port(system, "tcp")}/user/gonk")
s"akka.tcp://remote-sys@localhost:${port(remoteSystem, "tcp")}/remote/akka.tcp/RemotingSpec@localhost:${port(system, "tcp")}/user/gonk"
r ! 42 r ! 42
expectMsg(42) expectMsg(42)
EventFilter[Exception]("crash", occurrences = 1).intercept { EventFilter[Exception]("crash", occurrences = 1).intercept {
@ -474,8 +473,7 @@ class RemotingSpec extends AkkaSpec(RemotingSpec.cfg) with ImplicitSender with D
"be able to use multiple transports and use the appropriate one (UDP)" in { "be able to use multiple transports and use the appropriate one (UDP)" in {
val r = system.actorOf(Props[Echo1], "zagzag") val r = system.actorOf(Props[Echo1], "zagzag")
r.path.toString should be === r.path.toString should ===(s"akka.udp://remote-sys@localhost:${port(remoteSystem, "udp")}/remote/akka.udp/RemotingSpec@localhost:${port(system, "udp")}/user/zagzag")
s"akka.udp://remote-sys@localhost:${port(remoteSystem, "udp")}/remote/akka.udp/RemotingSpec@localhost:${port(system, "udp")}/user/zagzag"
r ! 42 r ! 42
expectMsg(10.seconds, 42) expectMsg(10.seconds, 42)
EventFilter[Exception]("crash", occurrences = 1).intercept { EventFilter[Exception]("crash", occurrences = 1).intercept {
@ -490,8 +488,7 @@ class RemotingSpec extends AkkaSpec(RemotingSpec.cfg) with ImplicitSender with D
"be able to use multiple transports and use the appropriate one (SSL)" in { "be able to use multiple transports and use the appropriate one (SSL)" in {
val r = system.actorOf(Props[Echo1], "roghtaar") val r = system.actorOf(Props[Echo1], "roghtaar")
r.path.toString should be === r.path.toString should ===(s"akka.ssl.tcp://remote-sys@localhost:${port(remoteSystem, "ssl.tcp")}/remote/akka.ssl.tcp/RemotingSpec@localhost:${port(system, "ssl.tcp")}/user/roghtaar")
s"akka.ssl.tcp://remote-sys@localhost:${port(remoteSystem, "ssl.tcp")}/remote/akka.ssl.tcp/RemotingSpec@localhost:${port(system, "ssl.tcp")}/user/roghtaar"
r ! 42 r ! 42
expectMsg(10.seconds, 42) expectMsg(10.seconds, 42)
EventFilter[Exception]("crash", occurrences = 1).intercept { EventFilter[Exception]("crash", occurrences = 1).intercept {

View file

@ -804,7 +804,7 @@ public class FlowTest extends StreamTest {
try { try {
Source.<Integer> maybe().via(Flow.of(Integer.class).initialTimeout(Duration.create(1, "second"))) Source.<Integer> maybe().via(Flow.of(Integer.class).initialTimeout(Duration.create(1, "second")))
.runWith(Sink.<Integer> head(), materializer).toCompletableFuture().get(3, TimeUnit.SECONDS); .runWith(Sink.<Integer> head(), materializer).toCompletableFuture().get(3, TimeUnit.SECONDS);
fail("A TimeoutException was expected"); org.junit.Assert.fail("A TimeoutException was expected");
} catch (ExecutionException e) { } catch (ExecutionException e) {
throw e.getCause(); throw e.getCause();
} }
@ -820,7 +820,7 @@ public class FlowTest extends StreamTest {
try { try {
Source.<Integer> maybe().via(Flow.of(Integer.class).completionTimeout(Duration.create(1, "second"))) Source.<Integer> maybe().via(Flow.of(Integer.class).completionTimeout(Duration.create(1, "second")))
.runWith(Sink.<Integer> head(), materializer).toCompletableFuture().get(3, TimeUnit.SECONDS); .runWith(Sink.<Integer> head(), materializer).toCompletableFuture().get(3, TimeUnit.SECONDS);
fail("A TimeoutException was expected"); org.junit.Assert.fail("A TimeoutException was expected");
} catch (ExecutionException e) { } catch (ExecutionException e) {
throw e.getCause(); throw e.getCause();
} }
@ -835,7 +835,7 @@ public class FlowTest extends StreamTest {
try { try {
Source.<Integer> maybe().via(Flow.of(Integer.class).idleTimeout(Duration.create(1, "second"))) Source.<Integer> maybe().via(Flow.of(Integer.class).idleTimeout(Duration.create(1, "second")))
.runWith(Sink.<Integer> head(), materializer).toCompletableFuture().get(3, TimeUnit.SECONDS); .runWith(Sink.<Integer> head(), materializer).toCompletableFuture().get(3, TimeUnit.SECONDS);
fail("A TimeoutException was expected"); org.junit.Assert.fail("A TimeoutException was expected");
} catch (ExecutionException e) { } catch (ExecutionException e) {
throw e.getCause(); throw e.getCause();
} }

View file

@ -767,7 +767,7 @@ public class SourceTest extends StreamTest {
try { try {
Source.maybe().initialTimeout(Duration.create(1, "second")).runWith(Sink.head(), materializer) Source.maybe().initialTimeout(Duration.create(1, "second")).runWith(Sink.head(), materializer)
.toCompletableFuture().get(3, TimeUnit.SECONDS); .toCompletableFuture().get(3, TimeUnit.SECONDS);
fail("A TimeoutException was expected"); org.junit.Assert.fail("A TimeoutException was expected");
} catch (ExecutionException e) { } catch (ExecutionException e) {
throw e.getCause(); throw e.getCause();
} }
@ -782,7 +782,7 @@ public class SourceTest extends StreamTest {
try { try {
Source.maybe().completionTimeout(Duration.create(1, "second")).runWith(Sink.head(), materializer) Source.maybe().completionTimeout(Duration.create(1, "second")).runWith(Sink.head(), materializer)
.toCompletableFuture().get(3, TimeUnit.SECONDS); .toCompletableFuture().get(3, TimeUnit.SECONDS);
fail("A TimeoutException was expected"); org.junit.Assert.fail("A TimeoutException was expected");
} catch (ExecutionException e) { } catch (ExecutionException e) {
throw e.getCause(); throw e.getCause();
} }
@ -797,7 +797,7 @@ public class SourceTest extends StreamTest {
try { try {
Source.maybe().idleTimeout(Duration.create(1, "second")).runWith(Sink.head(), materializer) Source.maybe().idleTimeout(Duration.create(1, "second")).runWith(Sink.head(), materializer)
.toCompletableFuture().get(3, TimeUnit.SECONDS); .toCompletableFuture().get(3, TimeUnit.SECONDS);
fail("A TimeoutException was expected"); org.junit.Assert.fail("A TimeoutException was expected");
} catch (ExecutionException e) { } catch (ExecutionException e) {
throw e.getCause(); throw e.getCause();
} }

View file

@ -4,10 +4,10 @@
package akka.stream.impl package akka.stream.impl
import scala.util.Random import scala.util.Random
import org.scalatest.{ ShouldMatchers, WordSpec } import org.scalatest.{ Matchers, WordSpec }
import akka.stream.impl.ResizableMultiReaderRingBuffer._ import akka.stream.impl.ResizableMultiReaderRingBuffer._
class ResizableMultiReaderRingBufferSpec extends WordSpec with ShouldMatchers { class ResizableMultiReaderRingBufferSpec extends WordSpec with Matchers {
"A ResizableMultiReaderRingBuffer" should { "A ResizableMultiReaderRingBuffer" should {

View file

@ -7,6 +7,7 @@ import akka.stream._
import akka.stream.scaladsl._ import akka.stream.scaladsl._
import akka.stream.testkit.StreamSpec import akka.stream.testkit.StreamSpec
import org.reactivestreams.{ Publisher, Subscriber, Subscription } import org.reactivestreams.{ Publisher, Subscriber, Subscription }
import org.scalatest.concurrent.PatienceConfiguration.Timeout
import scala.concurrent.duration._ import scala.concurrent.duration._
@ -126,7 +127,7 @@ class StreamLayoutSpec extends StreamSpec {
} }
// Seen tests run in 9-10 seconds, these test cases are heavy on the GC // Seen tests run in 9-10 seconds, these test cases are heavy on the GC
val veryPatient = PatienceConfig(20.seconds) val veryPatient = Timeout(20.seconds)
"not fail materialization when building a large graph with simple computation" when { "not fail materialization when building a large graph with simple computation" when {

View file

@ -7,6 +7,7 @@ import scala.concurrent.Await
import scala.concurrent.Future import scala.concurrent.Future
import scala.concurrent.duration._ import scala.concurrent.duration._
import java.util.concurrent.ThreadLocalRandom import java.util.concurrent.ThreadLocalRandom
import scala.util.control.NoStackTrace import scala.util.control.NoStackTrace
import akka.stream.ActorMaterializer import akka.stream.ActorMaterializer
import akka.stream.testkit._ import akka.stream.testkit._
@ -16,11 +17,14 @@ import akka.testkit.TestProbe
import akka.stream.ActorAttributes.supervisionStrategy import akka.stream.ActorAttributes.supervisionStrategy
import akka.stream.Supervision.resumingDecider import akka.stream.Supervision.resumingDecider
import akka.stream.impl.ReactiveStreamsCompliance import akka.stream.impl.ReactiveStreamsCompliance
import scala.annotation.tailrec import scala.annotation.tailrec
import scala.concurrent.Promise import scala.concurrent.Promise
import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicInteger
import java.util.concurrent.LinkedBlockingQueue import java.util.concurrent.LinkedBlockingQueue
import org.scalatest.concurrent.PatienceConfiguration.Timeout
class FlowMapAsyncSpec extends StreamSpec { class FlowMapAsyncSpec extends StreamSpec {
implicit val materializer = ActorMaterializer() implicit val materializer = ActorMaterializer()
@ -245,7 +249,7 @@ class FlowMapAsyncSpec extends StreamSpec {
Source(1 to N) Source(1 to N)
.mapAsync(parallelism)(i deferred()) .mapAsync(parallelism)(i deferred())
.runFold(0)((c, _) c + 1) .runFold(0)((c, _) c + 1)
.futureValue(PatienceConfig(3.seconds)) should ===(N) .futureValue(Timeout(3.seconds)) should ===(N)
} finally { } finally {
timer.interrupt() timer.interrupt()
} }

View file

@ -7,7 +7,7 @@ import scala.concurrent.Await
import scala.concurrent.Future import scala.concurrent.Future
import scala.concurrent.duration._ import scala.concurrent.duration._
import scala.util.control.NoStackTrace import scala.util.control.NoStackTrace
import akka.stream.{ ActorMaterializer } import akka.stream.ActorMaterializer
import akka.stream.testkit._ import akka.stream.testkit._
import akka.stream.testkit.scaladsl._ import akka.stream.testkit.scaladsl._
import akka.stream.testkit.Utils._ import akka.stream.testkit.Utils._
@ -17,8 +17,11 @@ import akka.stream.ActorAttributes.supervisionStrategy
import akka.stream.Supervision.resumingDecider import akka.stream.Supervision.resumingDecider
import akka.stream.impl.ReactiveStreamsCompliance import akka.stream.impl.ReactiveStreamsCompliance
import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicInteger
import scala.concurrent.Promise import scala.concurrent.Promise
import java.util.concurrent.LinkedBlockingQueue import java.util.concurrent.LinkedBlockingQueue
import org.scalatest.concurrent.PatienceConfiguration.Timeout
import scala.annotation.tailrec import scala.annotation.tailrec
class FlowMapAsyncUnorderedSpec extends StreamSpec { class FlowMapAsyncUnorderedSpec extends StreamSpec {
@ -236,7 +239,7 @@ class FlowMapAsyncUnorderedSpec extends StreamSpec {
Source(1 to N) Source(1 to N)
.mapAsyncUnordered(parallelism)(i deferred()) .mapAsyncUnordered(parallelism)(i deferred())
.runFold(0)((c, _) c + 1) .runFold(0)((c, _) c + 1)
.futureValue(PatienceConfig(3.seconds)) should ===(N) .futureValue(Timeout(3.seconds)) should ===(N)
} finally { } finally {
timer.interrupt() timer.interrupt()
} }

View file

@ -2,7 +2,6 @@ package akka.typed
import scala.concurrent.duration._ import scala.concurrent.duration._
import scala.concurrent.Future import scala.concurrent.Future
import org.scalautils.ConversionCheckedTripleEquals
import com.typesafe.config.ConfigFactory import com.typesafe.config.ConfigFactory
import akka.actor.DeadLetterSuppression import akka.actor.DeadLetterSuppression

View file

@ -3,8 +3,6 @@
*/ */
package akka.typed package akka.typed
import org.scalautils.ConversionCheckedTripleEquals
class BehaviorSpec extends TypedSpec { class BehaviorSpec extends TypedSpec {
sealed trait Command { sealed trait Command {

View file

@ -19,15 +19,11 @@ object Dependencies {
crossScalaVersions := Seq("2.11.8"), // "2.12.0-M4" crossScalaVersions := Seq("2.11.8"), // "2.12.0-M4"
scalaVersion := crossScalaVersions.value.head, scalaVersion := crossScalaVersions.value.head,
scalaStmVersion := sys.props.get("akka.build.scalaStmVersion").getOrElse("0.7"), scalaStmVersion := sys.props.get("akka.build.scalaStmVersion").getOrElse("0.7"),
scalaCheckVersion := sys.props.get("akka.build.scalaCheckVersion").getOrElse("1.11.6"), scalaCheckVersion := sys.props.get("akka.build.scalaCheckVersion").getOrElse("1.13.2"),
scalaTestVersion := { scalaTestVersion := {
scalaVersion.value match { scalaVersion.value match {
case "2.12.0-M1" => "2.2.5-M1" case "2.12.0-M5" => "3.0.0"
case "2.12.0-M2" => "2.2.5-M2" case _ => "3.0.0"
case "2.12.0-M3" => "2.2.5-M3"
case "2.12.0-M4" => "2.2.6"
case "2.12.0-M5" => "3.0.0-RC4"
case _ => "2.2.4"
} }
}, },
java8CompatVersion := { java8CompatVersion := {