Skip to content

Commit

Permalink
support scala3 in mqtt-streaming (#161)
Browse files Browse the repository at this point in the history
Update MqttFlowSpec.scala

Update MqttFlowSpec.scala

Update MqttFlowSpec.scala

Update MqttFlowSpec.scala

remove val declarations
  • Loading branch information
pjfanning committed Aug 17, 2023
1 parent 88655fb commit 3a8be3e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ object ControlPacketType {
val DISCONNECT = ControlPacketType(14)
val Reserved2 = ControlPacketType(15)
}
final case class ControlPacketType private (underlying: Int) extends AnyVal
@InternalApi
final case class ControlPacketType(underlying: Int) extends AnyVal

/**
* 2.2.2 Flags
Expand All @@ -75,7 +76,8 @@ object ControlPacketFlags {
val RETAIN = ControlPacketFlags(1)
}

final case class ControlPacketFlags private (underlying: Int) extends AnyVal {
@InternalApi
final case class ControlPacketFlags(underlying: Int) extends AnyVal {

/**
* Convenience bitwise OR
Expand Down Expand Up @@ -110,7 +112,8 @@ case object Reserved2 extends ControlPacket(ControlPacketType.Reserved2, Control
* 2.3.1 Packet Identifier
* http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html
*/
final case class PacketId private (underlying: Int) extends AnyVal
@InternalApi
final case class PacketId(underlying: Int) extends AnyVal

object ConnectFlags {
val None = ConnectFlags(0)
Expand All @@ -127,7 +130,7 @@ object ConnectFlags {
* 3.1.2.3 Connect Flags
* http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html
*/
final case class ConnectFlags private (underlying: Int) extends AnyVal {
final case class ConnectFlags private[streaming] (underlying: Int) extends AnyVal {

/**
* Convenience bitwise OR
Expand Down Expand Up @@ -223,7 +226,7 @@ object ConnAckFlags {
* 3.2.2.1 Connect Acknowledge Flags
* http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html
*/
final case class ConnAckFlags private (underlying: Int) extends AnyVal
final case class ConnAckFlags private[streaming] (underlying: Int) extends AnyVal

object ConnAckReturnCode {
val ConnectionAccepted = ConnAckReturnCode(0)
Expand All @@ -238,7 +241,7 @@ object ConnAckReturnCode {
* 3.2.2.3 Connect Return code
* http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html
*/
final case class ConnAckReturnCode private (underlying: Int) extends AnyVal {
final case class ConnAckReturnCode private[streaming] (underlying: Int) extends AnyVal {

/**
* Convenience bitwise OR
Expand Down Expand Up @@ -286,7 +289,8 @@ object Publish {
* 3.3 PUBLISH – Publish message
* http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html
*/
final case class Publish @InternalApi private[streaming] (override val flags: ControlPacketFlags,
@InternalApi
final case class Publish(override val flags: ControlPacketFlags,
topicName: String,
packetId: Option[PacketId],
payload: ByteString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ final class ActorMqttClientSession(settings: MqttSessionSettings)(implicit syste
import MqttSession._
import system.dispatcher

private implicit val loggingAdapter: LoggingAdapter = Logging(system, this.getClass)
private implicit val loggingAdapter: LoggingAdapter = Logging(system, classOf[ActorMqttClientSession])

override def ![A](cp: Command[A]): Unit = cp match {
case Command(cp: Publish, _, carry) =>
Expand Down Expand Up @@ -504,7 +504,7 @@ final class ActorMqttServerSession(settings: MqttSessionSettings)(implicit syste
import MqttSession._
import system.dispatcher

private implicit val loggingAdapter: LoggingAdapter = Logging(system, this.getClass)
private implicit val loggingAdapter: LoggingAdapter = Logging(system, classOf[ActorMqttClientSession])

override def ![A](cp: Command[A]): Unit = cp match {
case Command(cp: Publish, _, carry) =>
Expand Down
17 changes: 8 additions & 9 deletions mqtt-streaming/src/test/scala/docs/scaladsl/MqttFlowSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,26 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpecLike

class UntypedMqttFlowSpec
extends ParametrizedTestKit("untyped-flow-spec/flow",
extends MqttFlowSpecBase("untyped-flow-spec/flow",
"untyped-flow-spec/topic1",
ActorSystem("UntypedMqttFlowSpec"))
with MqttFlowSpec

class TypedMqttFlowSpec
extends ParametrizedTestKit("typed-flow-spec/flow",
extends MqttFlowSpecBase("typed-flow-spec/flow",
"typed-flow-spec/topic1",
org.apache.pekko.actor.typed.ActorSystem(Behaviors.ignore, "TypedMqttFlowSpec").toClassic)
with MqttFlowSpec

class ParametrizedTestKit(val clientId: String, val topic: String, system: ActorSystem) extends TestKit(system)
pekko.actor.typed.ActorSystem(Behaviors.ignore, "TypedMqttFlowSpec").toClassic)

trait MqttFlowSpec extends AnyWordSpecLike with Matchers with BeforeAndAfterAll with ScalaFutures with LogCapturing {
self: ParametrizedTestKit =>
abstract class MqttFlowSpecBase(clientId: String, topic: String, system: ActorSystem) extends TestKit(system)
with AnyWordSpecLike with Matchers with BeforeAndAfterAll with ScalaFutures with LogCapturing {

override def sourceActorSytem = Some(system.name)

private implicit val defaultPatience: PatienceConfig = PatienceConfig(timeout = 5.seconds, interval = 100.millis)

private implicit val dispatcherExecutionContext: ExecutionContext = system.dispatcher

private implicit val implicitSystem: ActorSystem = system

implicit val logAdapter: LoggingAdapter = Logging(system, this.getClass.getName)

override def afterAll(): Unit =
Expand Down
1 change: 0 additions & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ object Dependencies {
"org.eclipse.paho" % "org.eclipse.paho.client.mqttv3" % "1.2.5"))

val MqttStreaming = Seq(
crossScalaVersions -= Scala3,
libraryDependencies ++= Seq(
"org.apache.pekko" %% "pekko-actor-typed" % PekkoVersion,
"org.apache.pekko" %% "pekko-actor-testkit-typed" % PekkoVersion % Test,
Expand Down

0 comments on commit 3a8be3e

Please sign in to comment.