Skip to content

Commit

Permalink
migrate to scala 2.13
Browse files Browse the repository at this point in the history
  • Loading branch information
htimur committed Nov 24, 2023
1 parent 49b7c04 commit e52ddb0
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 30 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,7 @@ project/plugins/project/
.worksheet

.idea/
project/
project/
.metals
.bsp
.bloop
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.watcherExclude": {
"**/target": true
}
}
10 changes: 5 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name := "scala_nio_server"

version := "1.0"

scalaVersion := "2.11.8"
scalaVersion := "2.13.11"

libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.7"
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.5.0"
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.9.5"

libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.0" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
libraryDependencies += "org.mockito" % "mockito-core" % "1.10.19" % "test"
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.10" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
libraryDependencies += "org.scalatestplus" %% "mockito-4-11" % "3.2.17.0" % "test"
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ object Followermaze extends App {
clientListener.start()

new Thread(EventTransformer.toTypedEvent(eventSourceQueue, transformedQueue), "Transformer thread").start()
new Thread(Router(transformedQueue, clientController, followerController), "Router thread")start()
new Thread(Router(transformedQueue, clientController, followerController), "Router thread").start()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package de.khamrakulov.followermaze.controller

import java.util.concurrent.ConcurrentHashMap

import scala.collection.convert.decorateAsScala._
import scala.jdk.CollectionConverters._

/**
* @author Timur Khamrakulov <[email protected]>.
Expand All @@ -12,7 +12,7 @@ object ClientController {
}

class ClientController {
val clients = new ConcurrentHashMap[Int, Client]().asScala
val clients = new ConcurrentHashMap[Int, Client]().asScala

def get(id: Int) = clients.get(id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package de.khamrakulov.followermaze.controller

import java.util.concurrent.{ConcurrentHashMap, ConcurrentSkipListSet}

import scala.collection.convert.decorateAsScala._
import scala.jdk.CollectionConverters._

/**
* @author Timur Khamrakulov <[email protected]>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package de.khamrakulov.followermaze.controller

import de.khamrakulov.followermaze.nio.NioClientImpl
import org.scalatest.mockito.MockitoSugar
import org.scalatest.{FlatSpec, Matchers}
import org.scalatestplus.mockito.MockitoSugar
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

/**
* @author Timur Khamrakulov <[email protected]>.
*/
class ClientControllerSpec extends FlatSpec with Matchers with MockitoSugar {
class ClientControllerSpec extends AnyFlatSpec with Matchers with MockitoSugar {
"ClientController" should "add and get clients" in {
val controller = ClientController()
val client = mock[NioClientImpl]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package de.khamrakulov.followermaze.controller

import org.scalatest.{FlatSpec, Matchers}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

/**
* @author Timur Khamrakulov <[email protected]>.
*/
class FollowControllerSpec extends FlatSpec with Matchers {
class FollowControllerSpec extends AnyFlatSpec with Matchers {
"FollowController" should "add, get and remove follow relations" in {
val controller = FollowController()
controller.add(1, 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package de.khamrakulov.followermaze.controller

import de.khamrakulov.followermaze.{Broadcast, TypedEvent}
import org.mockito.Mockito
import org.scalatest.mockito.MockitoSugar
import org.scalatest.{FlatSpec, Matchers}
import org.scalatestplus.mockito.MockitoSugar
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers


/**
* @author Timur Khamrakulov <[email protected]>.
*/
class TypedEventSeqControllerSpec extends FlatSpec with Matchers with MockitoSugar {
class TypedEventSeqControllerSpec extends AnyFlatSpec with Matchers with MockitoSugar {
"TypedEventSeqController" should "provide events in correct order" in {
type Handler = TypedEvent => Unit
val handler = mock[Handler]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package de.khamrakulov.followermaze.event

import de.khamrakulov.followermaze._
import org.scalatest._

import org.scalatestplus.mockito.MockitoSugar
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
/**
* @author Timur Khamrakulov <[email protected]>.
*/
class ParserSpec extends FlatSpec with Matchers {
class ParserSpec extends AnyFlatSpec with Matchers {
val followString = "666|F|60|50"
val unfollowString = "666|U|60|50"
val broadcastString = "666|B"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import de.khamrakulov.followermaze._
import de.khamrakulov.followermaze.controller.{ClientController, FollowController}
import de.khamrakulov.followermaze.nio.NioClientImpl
import org.mockito.Mockito
import org.scalatest.mockito.MockitoSugar
import org.scalatest.{FlatSpec, Matchers}
import org.scalatestplus.mockito.MockitoSugar
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

/**
* @author Timur Khamrakulov <[email protected]>.
*/
class RouterSpec extends FlatSpec with Matchers with MockitoSugar {
class RouterSpec extends AnyFlatSpec with Matchers with MockitoSugar {
"Router" should "correctly route events" in {
val service = Executors.newSingleThreadExecutor()
val in = new LinkedBlockingQueue[TypedEvent]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import java.util.concurrent.{LinkedBlockingQueue, TimeUnit, Future => JFuture}
import de.khamrakulov.followermaze.UntypedEvent
import org.mockito.invocation.InvocationOnMock
import org.mockito.stubbing.Answer
import org.mockito.{Mockito, Matchers => M}
import org.scalatest.mockito.MockitoSugar
import org.scalatest.{FlatSpec, Matchers}
import org.mockito.{Mockito, ArgumentMatchers => M}
import org.scalatestplus.mockito.MockitoSugar
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

/**
* @author Timur Khamrakulov <[email protected]>.
*/
class UntypedEventSourceSpec extends FlatSpec with Matchers with MockitoSugar {
class UntypedEventSourceSpec extends AnyFlatSpec with Matchers with MockitoSugar {
def getSocket(output1: String, output2: String) = {
val stringBytes1 = output1.getBytes("utf-8")
val stringBytes2 = output2.getBytes("utf-8")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package de.khamrakulov.followermaze.event.transformer
import java.util.concurrent.{Executors, LinkedBlockingQueue, TimeUnit}

import de.khamrakulov.followermaze._
import org.scalatest.{FlatSpec, Matchers}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

/**
* @author Timur Khamrakulov <[email protected]>.
*/
class ToTypedEventTransformerSpec extends FlatSpec with Matchers {
class ToTypedEventTransformerSpec extends AnyFlatSpec with Matchers {
"ToTypedEventTransformer" should "correctly transform events" in {
val in = new LinkedBlockingQueue[UntypedEvent]()
in.add(UntypedEvent("1|F|2|3"))
Expand Down

0 comments on commit e52ddb0

Please sign in to comment.