Skip to content

Commit

Permalink
test: Add nowarn annotation to test
Browse files Browse the repository at this point in the history
Because it is a test of deprecated API
  • Loading branch information
tksugimoto committed Jul 15, 2021
1 parent a5968fe commit 4ceaaa8
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import akka.remote.testconductor.RoleName
import akka.remote.testkit.MultiNodeConfig
import com.typesafe.config.ConfigFactory

import scala.annotation.nowarn

object ConsistencyTestBase {

object ConsistencyTestBaseConfig extends MultiNodeConfig {
Expand Down Expand Up @@ -71,6 +73,7 @@ object ConsistencyTestBase {
}
}

@nowarn // for deprecated ReplicationActor
class ConsistencyTestReplicationActor() extends ReplicationActor[Int] {

import ConsistencyTestReplicationActor._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package lerna.akka.entityreplication

import java.util.concurrent.atomic.AtomicInteger

import akka.actor.{ ActorRef, Props }
import akka.remote.testkit.MultiNodeSpec
import lerna.akka.entityreplication.ConsistencyTestBase.{ ConsistencyTestBaseConfig, ConsistencyTestReplicationActor }
import org.scalatest.Inside

import scala.annotation.nowarn
import scala.concurrent.duration._

class ConsistencyTestNormalMultiJvmNode1 extends ConsistencyTestNormal
Expand All @@ -14,6 +15,7 @@ class ConsistencyTestNormalMultiJvmNode3 extends ConsistencyTestNormal
class ConsistencyTestNormalMultiJvmNode4 extends ConsistencyTestNormal
class ConsistencyTestNormalMultiJvmNode5 extends ConsistencyTestNormal

@nowarn // for deprecated ClusterReplication(system).start
class ConsistencyTestNormal extends MultiNodeSpec(ConsistencyTestBaseConfig) with STMultiNodeSpec with Inside {

import ConsistencyTestBaseConfig._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import lerna.akka.entityreplication.RaftActorCompactionSpec.DummyReplicationActo
import lerna.akka.entityreplication.raft.protocol.SnapshotOffer

import java.util.concurrent.atomic.AtomicInteger
import scala.annotation.nowarn
import scala.concurrent.duration._

object RaftActorCompactionSpecConfig extends MultiNodeConfig {
Expand Down Expand Up @@ -79,6 +80,7 @@ object RaftActorCompactionSpec {

import DummyReplicationActor._

@nowarn // for deprecated ReplicationActor
class DummyReplicationActor extends ReplicationActor[State] {

private[this] var state: State = State(0)
Expand Down Expand Up @@ -207,6 +209,7 @@ class RaftActorCompactionSpec extends MultiNodeSpec(RaftActorCompactionSpecConfi
}
}

@nowarn // for deprecated ClusterReplication(system).start
def createReplication(typeName: String): ActorRef =
planAutoKill {
ClusterReplication(system).start(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.typesafe.config.ConfigFactory
import lerna.akka.entityreplication.raft.protocol.SnapshotOffer

import java.util.concurrent.atomic.AtomicInteger
import scala.annotation.nowarn

object RaftEventSourcedSpecConfig extends MultiNodeConfig {
val node1: RoleName = role("node1")
Expand Down Expand Up @@ -91,6 +92,7 @@ object RaftEventSourcedSpec {

import DummyReplicationActor._

@nowarn // for deprecated ReplicationActor
class DummyReplicationActor extends ReplicationActor[State] {

private[this] var state: State = State(count = 0, knownRequestId = Set.empty)
Expand Down Expand Up @@ -150,6 +152,7 @@ object RaftEventSourcedSpec {
}
}

@nowarn // for deprecated ClusterReplication(system).start
class RaftEventSourcedSpec extends MultiNodeSpec(RaftEventSourcedSpecConfig) with STMultiNodeSpec {

import RaftEventSourcedSpec._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package lerna.akka.entityreplication

import java.util.concurrent.atomic.AtomicInteger

import akka.{ Done, NotUsed }
import akka.actor.{ ActorRef, PoisonPill, Props }
import akka.cluster.Cluster
Expand All @@ -13,6 +12,7 @@ import com.typesafe.config.ConfigFactory
import lerna.akka.entityreplication.raft.protocol.SnapshotOffer
import lerna.akka.entityreplication.raft.routing.MemberIndex

import scala.annotation.nowarn
import scala.concurrent.duration._
import scala.collection.Set

Expand Down Expand Up @@ -71,6 +71,7 @@ object ReplicationActorMultiNodeSpec {
}
}

@nowarn // for deprecated ReplicationActor
class PingPongReplicationActor extends ReplicationActor[Int] {

import PingPongReplicationActor._
Expand Down Expand Up @@ -124,6 +125,7 @@ object ReplicationActorMultiNodeSpec {
}
}

@nowarn // for deprecated ReplicationActor
class LockReplicationActor extends ReplicationActor[NotUsed] {
import LockReplicationActor._

Expand Down Expand Up @@ -183,6 +185,7 @@ object ReplicationActorMultiNodeSpec {
}
}

@nowarn // for deprecated ReplicationActor
class EphemeralReplicationActor extends ReplicationActor[Int] {

import EphemeralReplicationActor._
Expand Down Expand Up @@ -220,6 +223,7 @@ class ReplicationActorMultiNodeSpecMultiJvmNode1 extends ReplicationActorMultiNo
class ReplicationActorMultiNodeSpecMultiJvmNode2 extends ReplicationActorMultiNodeSpec
class ReplicationActorMultiNodeSpecMultiJvmNode3 extends ReplicationActorMultiNodeSpec

@nowarn // for deprecated ClusterReplication(system).start
class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecConfig) with STMultiNodeSpec {
import ReplicationActorMultiNodeSpec._
import ReplicationActorSpecConfig._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import lerna.akka.entityreplication.raft.RaftProtocol.Command
import lerna.akka.entityreplication.raft.protocol.SnapshotOffer
import lerna.akka.entityreplication.raft.routing.MemberIndex

import scala.annotation.nowarn
import scala.concurrent.Future
import scala.jdk.CollectionConverters._
import scala.concurrent.duration._
Expand Down Expand Up @@ -47,6 +48,7 @@ object ReplicationRegionSpec {
}
}

@nowarn // for deprecated ReplicationActor
class DummyReplicationActor(probe: TestProbe) extends DiagnosticActorLogging with ReplicationActor[Int] {

import DummyReplicationActor._
Expand Down Expand Up @@ -176,6 +178,7 @@ class ReplicationRegionSpec extends MultiNodeSpec(ReplicationRegionSpecConfig) w

val raftActorProbe = TestProbe("RaftActor")

@nowarn // for deprecated ClusterReplication(system).start
def createReplication(typeName: String): ActorRef =
planAutoKill {
ClusterReplication(system).start(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import lerna.akka.entityreplication.ReplicationActorSpec.{ config, ExampleReplic
import lerna.akka.entityreplication.model.EntityInstanceId
import lerna.akka.entityreplication.raft.model.{ EntityEvent, LogEntry, LogEntryIndex, Term }
import lerna.akka.entityreplication.raft.{ ActorSpec, RaftProtocol }

import java.util.concurrent.atomic.AtomicInteger
import scala.annotation.nowarn

object ReplicationActorSpec {

Expand All @@ -29,6 +31,7 @@ object ReplicationActorSpec {
case class Counted() extends Event
}

@nowarn // for deprecated ReplicationActor
class ExampleReplicationActor extends ReplicationActor[Int] {
import ExampleReplicationActor._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import lerna.akka.entityreplication.{ ReplicationActor, ReplicationRegion }
import lerna.akka.entityreplication.testkit.TestReplicationActorPropsSpec.WordCountReplicationActor
import org.scalatest.{ Matchers, WordSpecLike }

import scala.annotation.nowarn

object TestReplicationActorPropsSpec {

object WordCountReplicationActor {
Expand All @@ -22,6 +24,7 @@ object TestReplicationActorPropsSpec {
final case class Counted(wordCount: Int) extends DomainEvent
}

@nowarn // for deprecated ReplicationActor
class WordCountReplicationActor extends ReplicationActor[Int] {
import WordCountReplicationActor._

Expand Down Expand Up @@ -60,19 +63,22 @@ class TestReplicationActorPropsSpec extends TestKit(ActorSystem()) with WordSpec
"TestReplicationActorProps" should {

"take in only ReplicationActor Props" in {
@nowarn // for deprecated TestReplicationActorProps
val ex = intercept[IllegalArgumentException] {
TestReplicationActorProps(Props.default)
}
ex.getMessage should be(s"The Props for [${Props.default.actorClass()}] doesn't provide ReplicationActor")
}

"forward commands to ReplicationActor" in {
@nowarn // for deprecated TestReplicationActorProps
val actor = system.actorOf(TestReplicationActorProps(WordCountReplicationActor.props))
actor ! CountWord("hello")
expectMsg(Counted(wordCount = "hello".length))
}

"allow that ReplicationActor process ensureConsistency" in {
@nowarn // for deprecated TestReplicationActorProps
val actor = system.actorOf(TestReplicationActorProps(WordCountReplicationActor.props))
actor ! CountWord("hello")
expectMsgType[Counted]
Expand All @@ -81,6 +87,7 @@ class TestReplicationActorPropsSpec extends TestKit(ActorSystem()) with WordSpec
}

"allow to check ReplicationActor passivation" in {
@nowarn // for deprecated TestReplicationActorProps
val actor = watch(system.actorOf(TestReplicationActorProps(WordCountReplicationActor.props)))
actor ! Stop() // Passivate

Expand Down

0 comments on commit 4ceaaa8

Please sign in to comment.