diff --git a/.jvmopts b/.jvmopts index 0c9757c0a..208585c76 100644 --- a/.jvmopts +++ b/.jvmopts @@ -22,7 +22,6 @@ -XX:+UseCompressedClassPointers -XX:ReservedCodeCacheSize=256M -XX:+TieredCompilation --XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:+HeapDumpOnOutOfMemoryError diff --git a/Dockerfile b/Dockerfile index 0cf32a45c..1065de9bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,9 @@ RUN curl -sL https://deb.nodesource.com/setup_0.12 | bash - && \ npm install -g bower # for Apache Spark demos -ENV APACHE_SPARK_VERSION 3.0.3 +ENV APACHE_SPARK_VERSION 3.3.1 \ +HADOOP_VERSION=3 \ +SCALA_VERSION=2.13 RUN apt-get -y update && \ apt-get -y install software-properties-common @@ -46,11 +48,11 @@ RUN echo "===> install Java" && \ update-java-alternatives -s java-8-oracle RUN cd /tmp && \ - wget -q http://apache.claz.org/spark/spark-${APACHE_SPARK_VERSION}/spark-${APACHE_SPARK_VERSION}-bin-hadoop2.7.tgz && \ - tar xzf spark-${APACHE_SPARK_VERSION}-bin-hadoop2.7.tgz -C /usr/local && \ - rm spark-${APACHE_SPARK_VERSION}-bin-hadoop2.7.tgz + wget -q https://archive.apache.org/dist/spark/spark-${APACHE_SPARK_VERSION}/spark-${APACHE_SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}-scala${SCALA_VERSION}.tgz && \ + tar xzf spark-${APACHE_SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}-scala${SCALA_VERSION}.tgz -C /usr/local && \ + rm spark-${APACHE_SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}-scala${SCALA_VERSION}.tgz -RUN cd /usr/local && ln -s spark-${APACHE_SPARK_VERSION}-bin-hadoop2.7 spark +RUN cd /usr/local && ln -s spark-${APACHE_SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}-scala${SCALA_VERSION} spark # R support RUN apt-get update && \ diff --git a/Dockerfile.toree-dev b/Dockerfile.toree-dev index 16778a1e3..386ef677f 100644 --- a/Dockerfile.toree-dev +++ b/Dockerfile.toree-dev @@ -23,25 +23,27 @@ FROM jupyter/all-spark-notebook USER root # Spark dependencies -ENV APACHE_SPARK_VERSION 3.0.3 +ENV APACHE_SPARK_VERSION 3.3.1 \ +HADOOP_VERSION=3 \ +SCALA_VERSION=2.13 RUN apt-get -y update && \ - apt-get install -y --no-install-recommends openjdk-8-jdk ca-certificates-java && \ + apt-get install -y --no-install-recommends openjdk-11-jdk ca-certificates-java && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ update-ca-certificates -f && \ - update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java + update-alternatives --set java /usr/lib/jvm/java-11-openjdk-amd64/jre/bin/java # Installing Spark3 RUN cd /tmp && \ - wget -q https://archive.apache.org/dist/spark/spark-${APACHE_SPARK_VERSION}/spark-${APACHE_SPARK_VERSION}-bin-hadoop2.7.tgz && \ - tar xzf spark-${APACHE_SPARK_VERSION}-bin-hadoop2.7.tgz -C /usr/local && \ - rm spark-${APACHE_SPARK_VERSION}-bin-hadoop2.7.tgz + wget -q https://archive.apache.org/dist/spark/spark-${APACHE_SPARK_VERSION}/spark-${APACHE_SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}-scala${SCALA_VERSION}.tgz && \ + tar xzf spark-${APACHE_SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}-scala${SCALA_VERSION}.tgz -C /usr/local && \ + rm spark-${APACHE_SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}-scala${SCALA_VERSION}.tgz # Overwrite symlink RUN cd /usr/local && \ rm spark && \ - ln -s spark-${APACHE_SPARK_VERSION}-bin-hadoop2.7 spark + ln -s spark-${APACHE_SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}-scala${SCALA_VERSION} spark # Remove other scala kernels RUN cd /opt/conda/share/jupyter/kernels/ && \ diff --git a/Makefile b/Makefile index ad67676b8..04c2ba241 100644 --- a/Makefile +++ b/Makefile @@ -30,8 +30,8 @@ IS_SNAPSHOT?=true SNAPSHOT:=-SNAPSHOT endif -APACHE_SPARK_VERSION?=3.0.3 -SCALA_VERSION?=2.12 +APACHE_SPARK_VERSION?=3.3.1 +SCALA_VERSION?=2.13 IMAGE?=jupyter/all-spark-notebook:latest EXAMPLE_IMAGE?=apache/toree-examples TOREE_DEV_IMAGE?=apache/toree-dev diff --git a/build.sbt b/build.sbt index d41889c25..99bc1f5d4 100644 --- a/build.sbt +++ b/build.sbt @@ -22,11 +22,11 @@ ThisBuild / version := Properties.envOrElse("VERSION", "0.0.0-dev") + (if ((ThisBuild / isSnapshot ).value) "-SNAPSHOT" else "") ThisBuild / isSnapshot := Properties.envOrElse("IS_SNAPSHOT","true").toBoolean ThisBuild / organization := "org.apache.toree.kernel" -ThisBuild / crossScalaVersions := Seq("2.12.15") // https://github.com/scala/bug/issues/12475, for Spark 3.2.0 -ThisBuild / scalaVersion := (ThisBuild / crossScalaVersions ).value.head +ThisBuild / crossScalaVersions := Seq("2.13.10") +ThisBuild / scalaVersion := "2.13.10" ThisBuild / Dependencies.sparkVersion := { val envVar = "APACHE_SPARK_VERSION" - val defaultVersion = "3.0.0" + val defaultVersion = "3.3.1" Properties.envOrNone(envVar) match { case None => @@ -65,7 +65,6 @@ ThisBuild / javacOptions ++= Seq( ThisBuild / javaOptions ++= Seq( "-Xms1024M", "-Xmx4096M", "-Xss2m", "-XX:MaxPermSize=1024M", "-XX:ReservedCodeCacheSize=256M", "-XX:+TieredCompilation", - "-XX:+CMSClassUnloadingEnabled", "-XX:+UseConcMarkSweepGC", "-XX:+HeapDumpOnOutOfMemoryError" ) // Add additional test option to show time taken per test diff --git a/client/build.sbt b/client/build.sbt index 1ee62a719..ba647bb95 100644 --- a/client/build.sbt +++ b/client/build.sbt @@ -21,5 +21,9 @@ scalacOptions += "-language:reflectiveCalls" libraryDependencies ++= Seq( Dependencies.akkaActor, Dependencies.akkaSlf4j, - Dependencies.akkaTestkit % "test" + Dependencies.scalaTest % "test", + Dependencies.akkaTestkit % "test", + Dependencies.mockitoSugar % "test", + Dependencies.mockitoScala % "test", + Dependencies.mockitoScalaScalaTest % "test" ) diff --git a/client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/Utilities.scala b/client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/Utilities.scala index 2d63d5ee2..184d78ead 100644 --- a/client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/Utilities.scala +++ b/client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/Utilities.scala @@ -64,7 +64,7 @@ object Utilities extends LogLike { val header = Json.parse(message.frames(delimiterIndex + 2)).as[Header] val parentHeader = Json.parse(message.frames(delimiterIndex + 3)).validate[ParentHeader].fold[ParentHeader]( // TODO: Investigate better solution than setting parentHeader to null for {} - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => null, //HeaderBuilder.empty, + (invalid: collection.Seq[(JsPath, collection.Seq[JsonValidationError])]) => null, //HeaderBuilder.empty, (valid: ParentHeader) => valid ) val metadata = Json.parse(message.frames(delimiterIndex + 4)).as[Metadata] @@ -78,20 +78,20 @@ object Utilities extends LogLike { } implicit def KernelMessageToZMQMessage(kernelMessage : KernelMessage) : ZMQMessage = { - val frames: scala.collection.mutable.ListBuffer[ByteString] = scala.collection.mutable.ListBuffer() - kernelMessage.ids.map((id : Array[Byte]) => frames += ByteString.apply(id) ) - frames += "" - frames += kernelMessage.signature - frames += Json.toJson(kernelMessage.header).toString() - frames += Json.toJson(kernelMessage.parentHeader).toString() - frames += Json.toJson(kernelMessage.metadata).toString - frames += kernelMessage.contentString + var frames: Seq[ByteString] = Seq() + kernelMessage.ids.map((id : Array[Byte]) => frames = frames :+ ByteString.apply(id) ) + frames = frames :+ "" + frames = frames :+ kernelMessage.signature + frames = frames :+ Json.toJson(kernelMessage.header).toString() + frames = frames :+ Json.toJson(kernelMessage.parentHeader).toString() + frames = frames :+ Json.toJson(kernelMessage.metadata).toString + frames = frames :+ kernelMessage.contentString ZMQMessage(frames : _*) } def parseAndHandle[T](json: String, reads: Reads[T], handler: T => Unit) : Unit = { Json.parse(json).validate[T](reads).fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => + (invalid: collection.Seq[(JsPath, collection.Seq[JsonValidationError])]) => logger.error(s"Could not parse JSON, ${json}"), (content: T) => handler(content) ) diff --git a/client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/socket/HeartbeatClient.scala b/client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/socket/HeartbeatClient.scala index fd4c074ed..e92a64f04 100644 --- a/client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/socket/HeartbeatClient.scala +++ b/client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/socket/HeartbeatClient.scala @@ -60,7 +60,7 @@ class HeartbeatClient( case HeartbeatMessage => import scala.concurrent.ExecutionContext.Implicits.global val id = java.util.UUID.randomUUID().toString - futureMap += (id -> sender) + futureMap += (id -> sender()) logger.info(s"Heartbeat client send: $id") val future = socket ? ZMQMessage(ByteString(id.getBytes)) future.onComplete { diff --git a/client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/socket/IOPubClient.scala b/client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/socket/IOPubClient.scala index 02f17946b..ae3043098 100644 --- a/client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/socket/IOPubClient.scala +++ b/client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/socket/IOPubClient.scala @@ -76,7 +76,7 @@ class IOPubClient( } else { logger.warn("Received message with null parent header.") logger.debug(s"Kernel message is: $kernelMessage") - sender.forward(Failure(new RuntimeException(PARENT_HEADER_NULL_MESSAGE))) + sender().forward(Failure(new RuntimeException(PARENT_HEADER_NULL_MESSAGE))) } } diff --git a/client/src/test/scala/integration/unused.integration.socket/ClientToHeartbeatSpecForIntegration.scala b/client/src/test/scala/integration/unused.integration.socket/ClientToHeartbeatSpecForIntegration.scala index 7f1baa1f8..62b9ba5fb 100644 --- a/client/src/test/scala/integration/unused.integration.socket/ClientToHeartbeatSpecForIntegration.scala +++ b/client/src/test/scala/integration/unused.integration.socket/ClientToHeartbeatSpecForIntegration.scala @@ -31,7 +31,7 @@ import org.apache.toree.kernel.protocol.v5.SocketType import org.apache.toree.kernel.protocol.v5.socket._ import org.apache.toree.kernel.protocol.v5.socket.SocketConfig import com.typesafe.config.ConfigFactory -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar import org.scalatest.{FunSpecLike, Matchers} diff --git a/client/src/test/scala/integration/unused.integration.socket/ClientToIOPubSpecForIntegration.scala b/client/src/test/scala/integration/unused.integration.socket/ClientToIOPubSpecForIntegration.scala index 3934142aa..4c29447f9 100644 --- a/client/src/test/scala/integration/unused.integration.socket/ClientToIOPubSpecForIntegration.scala +++ b/client/src/test/scala/integration/unused.integration.socket/ClientToIOPubSpecForIntegration.scala @@ -27,7 +27,7 @@ import akka.testkit.{ImplicitSender, TestKit, TestProbe} import org.apache.toree.kernel.protocol.v5._ import org.apache.toree.kernel.protocol.v5.content.ExecuteResult import org.apache.toree.kernel.protocol.v5.socket._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar import org.scalatest.{FunSpecLike, Matchers} diff --git a/client/src/test/scala/integration/unused.integration.socket/ClientToShellSpecForIntegration.scala b/client/src/test/scala/integration/unused.integration.socket/ClientToShellSpecForIntegration.scala index 1b1033b82..e1370b4e1 100644 --- a/client/src/test/scala/integration/unused.integration.socket/ClientToShellSpecForIntegration.scala +++ b/client/src/test/scala/integration/unused.integration.socket/ClientToShellSpecForIntegration.scala @@ -28,7 +28,7 @@ import akka.zeromq._ import org.apache.toree.kernel.protocol.v5._ import org.apache.toree.kernel.protocol.v5.content.ExecuteRequest import org.apache.toree.kernel.protocol.v5.socket._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar import org.scalatest.{FunSpecLike, Matchers} diff --git a/client/src/test/scala/org/apache/toree/comm/ClientCommManagerSpec.scala b/client/src/test/scala/org/apache/toree/comm/ClientCommManagerSpec.scala index f784d8bac..564c21062 100644 --- a/client/src/test/scala/org/apache/toree/comm/ClientCommManagerSpec.scala +++ b/client/src/test/scala/org/apache/toree/comm/ClientCommManagerSpec.scala @@ -23,10 +23,12 @@ import org.apache.toree.kernel.protocol.v5.client.ActorLoader import org.apache.toree.kernel.protocol.v5.content.CommContent import org.scalatestplus.mockito.MockitoSugar import org.mockito.Mockito._ -import org.mockito.Matchers._ -import org.scalatest.{BeforeAndAfter, FunSpec, Matchers} +import org.mockito.ArgumentMatchers._ +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class ClientCommManagerSpec extends FunSpec with Matchers with BeforeAndAfter +class ClientCommManagerSpec extends AnyFunSpec with Matchers with BeforeAndAfterEach with MockitoSugar { private val TestTargetName = "some target" @@ -38,7 +40,7 @@ class ClientCommManagerSpec extends FunSpec with Matchers with BeforeAndAfter private var generatedCommWriter: CommWriter = _ - before { + override def beforeEach(): Unit = { mockActorLoader = mock[ActorLoader] mockKMBuilder = mock[KMBuilder] mockCommRegistrar = mock[CommRegistrar] diff --git a/client/src/test/scala/org/apache/toree/comm/ClientCommWriterSpec.scala b/client/src/test/scala/org/apache/toree/comm/ClientCommWriterSpec.scala index 4018b19d3..9bec92738 100644 --- a/client/src/test/scala/org/apache/toree/comm/ClientCommWriterSpec.scala +++ b/client/src/test/scala/org/apache/toree/comm/ClientCommWriterSpec.scala @@ -25,10 +25,12 @@ import org.apache.toree.kernel.protocol.v5._ import org.apache.toree.kernel.protocol.v5.client.ActorLoader import org.apache.toree.kernel.protocol.v5.content._ import com.typesafe.config.ConfigFactory -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpecLike +import org.scalatest.matchers.should.Matchers import play.api.libs.json.Json import scala.concurrent.duration._ @@ -43,7 +45,7 @@ object ClientCommWriterSpec { class ClientCommWriterSpec extends TestKit( ActorSystem("ClientCommWriterSpec", ConfigFactory.parseString(ClientCommWriterSpec.config)) -) with FunSpecLike with Matchers with BeforeAndAfter with MockitoSugar +) with AnyFunSpecLike with Matchers with BeforeAndAfterEach with MockitoSugar { private val commId = UUID.randomUUID().toString @@ -84,7 +86,7 @@ class ClientCommWriterSpec extends TestKit( Json.parse(receivedMessage.contentString).as[T] } - before { + override def beforeEach(): Unit = { kernelMessageBuilder = spy(KMBuilder()) // Construct path for kernel message relay diff --git a/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/SparkKernelClientSpec.scala b/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/SparkKernelClientSpec.scala index f5330184c..1830e5a9a 100644 --- a/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/SparkKernelClientSpec.scala +++ b/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/SparkKernelClientSpec.scala @@ -25,13 +25,16 @@ import org.apache.toree.kernel.protocol.v5._ import org.apache.toree.kernel.protocol.v5.client.execution.ExecuteRequestTuple import scala.concurrent.duration._ import org.mockito.Mockito._ -import org.mockito.Matchers.{eq => mockEq, _} +import org.mockito.ArgumentMatchers.{eq => mockEq, _} +import org.scalatest.BeforeAndAfterEach import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpecLike +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfter class SparkKernelClientSpec extends TestKit(ActorSystem("SparkKernelClientActorSystem")) - with Matchers with MockitoSugar with FunSpecLike with BeforeAndAfter + with Matchers with MockitoSugar with AnyFunSpecLike with BeforeAndAfterEach { private val TestTargetName = "some target" @@ -41,7 +44,7 @@ class SparkKernelClientSpec private var executeRequestProbe: TestProbe = _ private var shellClientProbe: TestProbe = _ - before { + override def beforeEach(): Unit = { mockActorLoader = mock[ActorLoader] mockCommRegistrar = mock[CommRegistrar] diff --git a/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/execution/DeferredExecutionTest.scala b/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/execution/DeferredExecutionTest.scala index 40e216848..1f6499e83 100644 --- a/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/execution/DeferredExecutionTest.scala +++ b/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/execution/DeferredExecutionTest.scala @@ -20,7 +20,8 @@ package org.apache.toree.kernel.protocol.v5.client.execution import org.apache.toree.kernel.protocol.v5.content.{StreamContent, ExecuteResult} import org.apache.toree.kernel.protocol.v5.content._ import org.apache.toree.kernel.protocol.v5._ -import org.scalatest.{Matchers, FunSpec} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.scalatest.concurrent.ScalaFutures import scala.concurrent.Promise @@ -64,7 +65,7 @@ object DeferredExecutionTest { class ExecuteResultPromise {} class ExecuteReplyPromise {} -class DeferredExecutionTest extends FunSpec with ScalaFutures with Matchers { +class DeferredExecutionTest extends AnyFunSpec with ScalaFutures with Matchers { import DeferredExecutionTest._ describe("DeferredExecution") { describe("onResult( callback )"){ diff --git a/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/HeartbeatClientSpec.scala b/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/HeartbeatClientSpec.scala index 0e5d8047e..25857f49a 100644 --- a/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/HeartbeatClientSpec.scala +++ b/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/HeartbeatClientSpec.scala @@ -22,12 +22,13 @@ import akka.testkit.{TestProbe, ImplicitSender, TestKit} import org.apache.toree.communication.ZMQMessage import org.apache.toree.kernel.protocol.v5.client.ActorLoader import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{Matchers, FunSpecLike} -import org.mockito.Matchers._ +import org.scalatest.funspec.AnyFunSpecLike +import org.scalatest.matchers.should.Matchers +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ class HeartbeatClientSpec extends TestKit(ActorSystem("HeartbeatActorSpec")) - with ImplicitSender with FunSpecLike with Matchers with MockitoSugar { + with ImplicitSender with AnyFunSpecLike with Matchers with MockitoSugar { describe("HeartbeatClientActor") { val socketFactory = mock[SocketFactory] diff --git a/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/IOPubClientSpec.scala b/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/IOPubClientSpec.scala index 36aacfaa7..1a375bae8 100644 --- a/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/IOPubClientSpec.scala +++ b/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/IOPubClientSpec.scala @@ -32,12 +32,14 @@ import org.apache.toree.kernel.protocol.v5.client.execution.{DeferredExecution, import org.apache.toree.kernel.protocol.v5.client.{ActorLoader, Utilities} import org.apache.toree.kernel.protocol.v5.content.{CommClose, CommMsg, CommOpen, StreamContent} import com.typesafe.config.ConfigFactory -import org.mockito.Matchers.{eq => mockEq, _} +import org.mockito.ArgumentMatchers.{eq => mockEq, _} import org.mockito.Mockito._ import org.scalatest.concurrent.{Eventually, ScalaFutures} import org.scalatestplus.mockito.MockitoSugar import org.scalatest.time.{Milliseconds, Span} -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpecLike +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfterEach import play.api.libs.json.Json import scala.concurrent.duration._ @@ -53,8 +55,8 @@ object IOPubClientSpec { class IOPubClientSpec extends TestKit(ActorSystem( "IOPubClientSpecSystem", ConfigFactory.parseString(IOPubClientSpec.config) -)) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar - with ScalaFutures with BeforeAndAfter with Eventually +)) with ImplicitSender with AnyFunSpecLike with Matchers with MockitoSugar + with ScalaFutures with BeforeAndAfterEach with Eventually { private val TestTimeout = Timeout(10.seconds) implicit override val patienceConfig = PatienceConfig( @@ -77,7 +79,7 @@ class IOPubClientSpec extends TestKit(ActorSystem( private val TestTargetName = "some target" private val TestCommId = UUID.randomUUID().toString - before { + override def beforeEach(): Unit = { kmBuilder = KMBuilder() mockCommCallbacks = mock[CommCallbacks] mockCommRegistrar = mock[CommRegistrar] @@ -89,7 +91,7 @@ class IOPubClientSpec extends TestKit(ActorSystem( mockClientSocketFactory = mock[SocketFactory] // Stub the return value for the socket factory - when(mockClientSocketFactory.IOPubClient(anyObject(), any[ActorRef])) + when(mockClientSocketFactory.IOPubClient(any, any[ActorRef])) .thenReturn(clientSocketProbe.ref) // Construct the object we will test against diff --git a/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/ShellClientSpec.scala b/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/ShellClientSpec.scala index f8a5a5c0f..b004584cc 100644 --- a/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/ShellClientSpec.scala +++ b/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/ShellClientSpec.scala @@ -27,13 +27,14 @@ import org.apache.toree.kernel.protocol.v5._ import org.apache.toree.kernel.protocol.v5.client.ActorLoader import org.apache.toree.kernel.protocol.v5.content.ExecuteRequest import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{Matchers, FunSpecLike} +import org.scalatest.funspec.AnyFunSpecLike +import org.scalatest.matchers.should.Matchers import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import play.api.libs.json.Json class ShellClientSpec extends TestKit(ActorSystem("ShellActorSpec")) - with ImplicitSender with FunSpecLike with Matchers with MockitoSugar { + with ImplicitSender with AnyFunSpecLike with Matchers with MockitoSugar { private val SignatureEnabled = true describe("ShellClientActor") { diff --git a/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/StdinClientSpec.scala b/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/StdinClientSpec.scala index 2c97fc6d4..8df968e2f 100644 --- a/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/StdinClientSpec.scala +++ b/client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/StdinClientSpec.scala @@ -26,17 +26,19 @@ import org.apache.toree.kernel.protocol.v5.client.ActorLoader import org.apache.toree.kernel.protocol.v5.client.socket.StdinClient.{ResponseFunctionMessage, ResponseFunction} import org.apache.toree.kernel.protocol.v5.content.{InputReply, InputRequest, ClearOutput, ExecuteRequest} import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpecLike +import org.scalatest.matchers.should.Matchers import org.apache.toree.kernel.protocol.v5.client.Utilities._ import play.api.libs.json.Json import scala.concurrent.duration._ import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ class StdinClientSpec extends TestKit(ActorSystem("StdinActorSpec")) - with ImplicitSender with FunSpecLike with Matchers with MockitoSugar - with BeforeAndAfter + with ImplicitSender with AnyFunSpecLike with Matchers with MockitoSugar + with BeforeAndAfterEach { private val SignatureEnabled = true private val TestReplyString = "some value" @@ -48,7 +50,7 @@ class StdinClientSpec extends TestKit(ActorSystem("StdinActorSpec")) private var socketProbe: TestProbe = _ private var stdinClient: ActorRef = _ - before { + override def beforeEach(): Unit = { socketProbe = TestProbe() signatureManagerProbe = TestProbe() mockSocketFactory = mock[SocketFactory] diff --git a/client/src/test/scala/system/ClientCommSpecForSystem.scala b/client/src/test/scala/system/ClientCommSpecForSystem.scala index cf7c27e9a..310325ac4 100644 --- a/client/src/test/scala/system/ClientCommSpecForSystem.scala +++ b/client/src/test/scala/system/ClientCommSpecForSystem.scala @@ -26,10 +26,16 @@ import org.apache.toree.kernel.protocol.v5.{KMBuilder, KernelMessage, SocketType import org.scalatest.concurrent.Eventually import org.scalatest.exceptions.TestFailedDueToTimeoutException import org.scalatest.time.{Milliseconds, Seconds, Span} -import org.scalatest.{BeforeAndAfterAll, FunSpecLike, Matchers} +import org.scalatest.BeforeAndAfterAll +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.Json import test.utils.SparkClientDeployer +import org.mockito.ArgumentMatchers.{anyString, eq => mockEq, _} +import org.mockito.Mockito._ +import org.scalatestplus.mockito.MockitoSugar + import scala.concurrent.duration._ /** @@ -39,10 +45,13 @@ import scala.concurrent.duration._ * kernel instance (to avoid death by slowness) and it is not guaranteed * that previous tests will do proper cleanup! */ +trait TestKitLike extends TestKit { + def actorSystem = SparkClientDeployer.getClientActorSystem +} + class ClientCommSpecForSystem - extends TestKit(SparkClientDeployer.getClientActorSystem) - with FunSpecLike with Matchers with BeforeAndAfterAll with Eventually -{ + extends AnyFunSpec with Matchers with BeforeAndAfterAll with Eventually with TestKitLike { + private val MaxFishTime = 2.seconds implicit override val patienceConfig = PatienceConfig( timeout = scaled(Span(2, Seconds)), diff --git a/communication/build.sbt b/communication/build.sbt index 92db41858..07f7be888 100644 --- a/communication/build.sbt +++ b/communication/build.sbt @@ -19,5 +19,8 @@ libraryDependencies ++= Seq( Dependencies.jeroMq, Dependencies.akkaActor, Dependencies.akkaSlf4j, - Dependencies.akkaTestkit % "test" + Dependencies.akkaTestkit % "test", + Dependencies.mockitoSugar % "test", + Dependencies.mockitoScala % "test", + Dependencies.mockitoScalaScalaTest % "test" ) diff --git a/communication/src/main/scala/org/apache/toree/communication/SocketManager.scala b/communication/src/main/scala/org/apache/toree/communication/SocketManager.scala index 0422334a2..762ba04d1 100644 --- a/communication/src/main/scala/org/apache/toree/communication/SocketManager.scala +++ b/communication/src/main/scala/org/apache/toree/communication/SocketManager.scala @@ -21,7 +21,7 @@ import java.util.concurrent.ConcurrentHashMap import org.apache.toree.communication.socket._ import org.zeromq.ZMQ -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ /** * Represents the factory for sockets that also manages ZMQ contexts and diff --git a/communication/src/main/scala/org/apache/toree/communication/security/SignatureCheckerActor.scala b/communication/src/main/scala/org/apache/toree/communication/security/SignatureCheckerActor.scala index fe36b6cc8..f4d4a0990 100644 --- a/communication/src/main/scala/org/apache/toree/communication/security/SignatureCheckerActor.scala +++ b/communication/src/main/scala/org/apache/toree/communication/security/SignatureCheckerActor.scala @@ -35,7 +35,7 @@ class SignatureCheckerActor( val isValidSignature = hmacString == signature logger.trace(s"Signature ${signature} validity checked against " + s"hmac ${hmacString} with outcome ${isValidSignature}") - sender ! isValidSignature + sender() ! isValidSignature } } diff --git a/communication/src/main/scala/org/apache/toree/communication/security/SignatureProducerActor.scala b/communication/src/main/scala/org/apache/toree/communication/security/SignatureProducerActor.scala index 32383a78e..54df4cad0 100644 --- a/communication/src/main/scala/org/apache/toree/communication/security/SignatureProducerActor.scala +++ b/communication/src/main/scala/org/apache/toree/communication/security/SignatureProducerActor.scala @@ -38,7 +38,7 @@ class SignatureProducerActor( Json.stringify(Json.toJson(message.metadata)), message.contentString ) - sender ! signature + sender() ! signature } } diff --git a/communication/src/main/scala/org/apache/toree/communication/socket/ZeroMQSocketRunnable.scala b/communication/src/main/scala/org/apache/toree/communication/socket/ZeroMQSocketRunnable.scala index 0464d5742..13b79ab6a 100644 --- a/communication/src/main/scala/org/apache/toree/communication/socket/ZeroMQSocketRunnable.scala +++ b/communication/src/main/scala/org/apache/toree/communication/socket/ZeroMQSocketRunnable.scala @@ -20,7 +20,7 @@ import org.apache.toree.utils.LogLike import org.zeromq.{ZMsg, ZMQ} import org.zeromq.ZMQ.Context -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.util.Try /** @@ -170,7 +170,7 @@ class ZeroMQSocketRunnable( socket.close() } catch { case ex: Exception => - logger.error("Failed to close socket!", _: Throwable) + logger.error("Failed to close socket!", ex: Throwable) } } } diff --git a/communication/src/main/scala/org/apache/toree/communication/utils/OrderedSupport.scala b/communication/src/main/scala/org/apache/toree/communication/utils/OrderedSupport.scala index 03c33afa7..f6a1420c9 100644 --- a/communication/src/main/scala/org/apache/toree/communication/utils/OrderedSupport.scala +++ b/communication/src/main/scala/org/apache/toree/communication/utils/OrderedSupport.scala @@ -52,7 +52,7 @@ trait OrderedSupport extends Actor with Stash with LogLike { */ def startProcessing(): Unit = { logger.debug("Actor is in processing state and will stash messages of " + - s"types: ${orderedTypes.mkString(" ")}") + s"types: ${orderedTypes().mkString(" ")}") context.become(waiting, discardOld = false) } diff --git a/communication/src/test/scala/integration/JeroMQSocketIntegrationSpec.scala b/communication/src/test/scala/integration/JeroMQSocketIntegrationSpec.scala index 2cd5b0b95..9198c4c06 100644 --- a/communication/src/test/scala/integration/JeroMQSocketIntegrationSpec.scala +++ b/communication/src/test/scala/integration/JeroMQSocketIntegrationSpec.scala @@ -22,11 +22,13 @@ import java.util.concurrent.ConcurrentLinkedDeque import org.apache.toree.communication.SocketManager import org.scalatest.concurrent.Eventually import org.scalatest.time.{Milliseconds, Span} -import org.scalatest.{Matchers, OneInstancePerTest, FunSpec} +import org.scalatest.OneInstancePerTest +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.zeromq.ZMQ.Context import org.zeromq.{ZMsg, ZMQ} -class JeroMQSocketIntegrationSpec extends FunSpec +class JeroMQSocketIntegrationSpec extends AnyFunSpec with OneInstancePerTest with Matchers with Eventually { implicit override val patienceConfig = PatienceConfig( timeout = scaled(Span(800, Milliseconds)), diff --git a/communication/src/test/scala/integration/security/SignatureCheckerActorSpecForIntegration.scala b/communication/src/test/scala/integration/security/SignatureCheckerActorSpecForIntegration.scala index 689b315d0..715d99f3a 100644 --- a/communication/src/test/scala/integration/security/SignatureCheckerActorSpecForIntegration.scala +++ b/communication/src/test/scala/integration/security/SignatureCheckerActorSpecForIntegration.scala @@ -22,7 +22,10 @@ import akka.testkit.{ImplicitSender, TestKit} import org.apache.toree.kernel.protocol.v5._ import org.apache.toree.communication.security.{Hmac, SignatureCheckerActor} import com.typesafe.config.ConfigFactory -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpecLike +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfterEach import play.api.libs.json.Json object SignatureCheckerActorSpecForIntegration { @@ -37,7 +40,7 @@ class SignatureCheckerActorSpecForIntegration extends TestKit( "SignatureCheckerActorSpec", ConfigFactory.parseString(SignatureCheckerActorSpecForIntegration.config) ) -) with ImplicitSender with FunSpecLike with Matchers with BeforeAndAfter +) with ImplicitSender with AnyFunSpecLike with Matchers with BeforeAndAfterEach { private val sigKey = "12345" @@ -62,13 +65,13 @@ class SignatureCheckerActorSpecForIntegration extends TestKit( private var signatureChecker: ActorRef = _ - before { + override def beforeEach(): Unit = { val hmac = Hmac(sigKey) signatureChecker = system.actorOf(Props(classOf[SignatureCheckerActor], hmac)) } - after { + override def afterEach(): Unit = { signatureChecker = null } diff --git a/communication/src/test/scala/integration/security/SignatureManagerActorSpecForIntegration.scala b/communication/src/test/scala/integration/security/SignatureManagerActorSpecForIntegration.scala index 5e937bade..a3380e34b 100644 --- a/communication/src/test/scala/integration/security/SignatureManagerActorSpecForIntegration.scala +++ b/communication/src/test/scala/integration/security/SignatureManagerActorSpecForIntegration.scala @@ -22,7 +22,9 @@ import akka.testkit.{ImplicitSender, TestKit} import org.apache.toree.communication.security.SignatureManagerActor import org.apache.toree.kernel.protocol.v5.{KernelMessage, _} import com.typesafe.config.ConfigFactory -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpecLike +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfterEach import play.api.libs.json.Json import scala.concurrent.duration._ @@ -39,7 +41,7 @@ class SignatureManagerActorSpecForIntegration extends TestKit( "SignatureManagerActorSpec", ConfigFactory.parseString(SignatureManagerActorSpecForIntegration.config) ) -) with ImplicitSender with FunSpecLike with Matchers with BeforeAndAfter +) with ImplicitSender with AnyFunSpecLike with Matchers with BeforeAndAfterEach { private val IncomingMessageType = "d" // Needed for valid signature @@ -66,7 +68,7 @@ class SignatureManagerActorSpecForIntegration extends TestKit( private var signatureManager: ActorRef = _ private var signatureManagerWithNoIncoming: ActorRef = _ - before { + override def beforeEach(): Unit = { signatureManager = system.actorOf(Props( classOf[SignatureManagerActor], sigKey @@ -78,7 +80,7 @@ class SignatureManagerActorSpecForIntegration extends TestKit( )) } - after { + override def afterEach(): Unit = { signatureManager = null } diff --git a/communication/src/test/scala/integration/security/SignatureProducerActorSpecForIntegration.scala b/communication/src/test/scala/integration/security/SignatureProducerActorSpecForIntegration.scala index 6ff5343ef..0150a5b0c 100644 --- a/communication/src/test/scala/integration/security/SignatureProducerActorSpecForIntegration.scala +++ b/communication/src/test/scala/integration/security/SignatureProducerActorSpecForIntegration.scala @@ -22,7 +22,9 @@ import akka.testkit.{ImplicitSender, TestKit} import org.apache.toree.kernel.protocol.v5._ import org.apache.toree.communication.security.{Hmac, SignatureProducerActor} import com.typesafe.config.ConfigFactory -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpecLike +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfterEach object SignatureProducerActorSpecForIntegration { val config = """ @@ -36,21 +38,21 @@ class SignatureProducerActorSpecForIntegration extends TestKit( "SignatureProducerActorSpec", ConfigFactory.parseString(SignatureProducerActorSpecForIntegration.config) ) -) with ImplicitSender with FunSpecLike with Matchers with BeforeAndAfter +) with ImplicitSender with AnyFunSpecLike with Matchers with BeforeAndAfterEach { private val sigKey = "12345" private var signatureProducer: ActorRef = _ - before { + override def beforeEach(): Unit = { val hmac = Hmac(sigKey) signatureProducer = system.actorOf(Props(classOf[SignatureProducerActor], hmac)) } - after { + override def afterEach(): Unit = { signatureProducer = null } diff --git a/communication/src/test/scala/org/apache/toree/communication/security/HmacSpec.scala b/communication/src/test/scala/org/apache/toree/communication/security/HmacSpec.scala index 97b2f5f51..24d71a804 100644 --- a/communication/src/test/scala/org/apache/toree/communication/security/HmacSpec.scala +++ b/communication/src/test/scala/org/apache/toree/communication/security/HmacSpec.scala @@ -19,9 +19,10 @@ package org.apache.toree.communication.security import java.security.NoSuchAlgorithmException -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class HmacSpec extends FunSpec with Matchers { +class HmacSpec extends AnyFunSpec with Matchers { describe("Hmac Object") { describe("#apply") { it("should fail if the algorithm is not available") { diff --git a/communication/src/test/scala/org/apache/toree/communication/socket/JeroMQSocketSpec.scala b/communication/src/test/scala/org/apache/toree/communication/socket/JeroMQSocketSpec.scala index fa9d19bf4..e9c8fa73b 100644 --- a/communication/src/test/scala/org/apache/toree/communication/socket/JeroMQSocketSpec.scala +++ b/communication/src/test/scala/org/apache/toree/communication/socket/JeroMQSocketSpec.scala @@ -18,13 +18,17 @@ package org.apache.toree.communication.socket import org.mockito.invocation.InvocationOnMock import org.mockito.stubbing.Answer -import org.scalatest.{Matchers, BeforeAndAfter, OneInstancePerTest, FunSpec} +import org.scalatest.OneInstancePerTest +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers + import org.scalatestplus.mockito.MockitoSugar import org.mockito.Mockito._ import org.zeromq.ZMsg -class JeroMQSocketSpec extends FunSpec with MockitoSugar - with OneInstancePerTest with BeforeAndAfter with Matchers +class JeroMQSocketSpec extends AnyFunSpec with MockitoSugar + with OneInstancePerTest with BeforeAndAfterEach with Matchers { private val runnable = mock[ZeroMQSocketRunnable] @volatile private var running = true @@ -43,7 +47,7 @@ class JeroMQSocketSpec extends FunSpec with MockitoSugar private val socket: JeroMQSocket = new JeroMQSocket(runnable) - after { + override def afterEach(): Unit = { running = false } diff --git a/communication/src/test/scala/org/apache/toree/communication/socket/ZeroMQSocketRunnableSpec.scala b/communication/src/test/scala/org/apache/toree/communication/socket/ZeroMQSocketRunnableSpec.scala index 605fa296c..126cdaa05 100644 --- a/communication/src/test/scala/org/apache/toree/communication/socket/ZeroMQSocketRunnableSpec.scala +++ b/communication/src/test/scala/org/apache/toree/communication/socket/ZeroMQSocketRunnableSpec.scala @@ -19,14 +19,16 @@ package org.apache.toree.communication.socket import org.scalatest.concurrent.Eventually import org.scalatestplus.mockito.MockitoSugar import org.scalatest.time.{Milliseconds, Seconds, Span} -import org.scalatest.{BeforeAndAfter, FunSpec, Matchers} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.zeromq.ZMQ import org.zeromq.ZMQ.{Socket, Context} import scala.util.Try -class ZeroMQSocketRunnableSpec extends FunSpec with Matchers - with MockitoSugar with Eventually with BeforeAndAfter { +class ZeroMQSocketRunnableSpec extends AnyFunSpec with Matchers + with MockitoSugar with Eventually with BeforeAndAfterEach { implicit override val patienceConfig = PatienceConfig( timeout = scaled(Span(3, Seconds)), @@ -53,13 +55,13 @@ class ZeroMQSocketRunnableSpec extends FunSpec with Matchers override protected def newZmqSocket(zmqContext: Context, socketType: Int): Socket = socket } - before { + override def beforeEach(): Unit = { mockSocketType = mock[SocketType] zmqContext = ZMQ.context(1) pubSocket = zmqContext.socket(PubSocket.`type`) } - after { + override def afterEach(): Unit = { Try(zmqContext.close()) } diff --git a/communication/src/test/scala/org/apache/toree/communication/utils/OrderedSupportSpec.scala b/communication/src/test/scala/org/apache/toree/communication/utils/OrderedSupportSpec.scala index 20e8f2244..3b09f893b 100644 --- a/communication/src/test/scala/org/apache/toree/communication/utils/OrderedSupportSpec.scala +++ b/communication/src/test/scala/org/apache/toree/communication/utils/OrderedSupportSpec.scala @@ -20,7 +20,8 @@ package org.apache.toree.communication.utils import akka.actor._ import akka.testkit.{ImplicitSender, TestKit} import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpecLike +import org.scalatest.matchers.should.Matchers case class OrderedType() case class NotOrderedType() @@ -35,17 +36,17 @@ class TestOrderedSupport extends OrderedSupport { case OrderedType() => startProcessing() receivedCounter = receivedCounter + 1 - sender ! ReceiveMessageCount(receivedCounter) + sender() ! ReceiveMessageCount(receivedCounter) case NotOrderedType() => receivedCounter = receivedCounter + 1 - sender ! ReceiveMessageCount(receivedCounter) + sender() ! ReceiveMessageCount(receivedCounter) case FinishProcessingMessage() => finishedProcessing() } } class OrderedSupportSpec extends TestKit(ActorSystem("OrderedSupportSystem")) - with ImplicitSender with Matchers with FunSpecLike + with ImplicitSender with Matchers with AnyFunSpecLike with MockitoSugar { describe("OrderedSupport"){ @@ -55,9 +56,9 @@ class OrderedSupportSpec extends TestKit(ActorSystem("OrderedSupportSystem")) // Send a message having a type in orderedTypes // Starts processing and is handled with receive() - testOrderedSupport ! new OrderedType + testOrderedSupport ! new OrderedType() // This message should be handled with waiting() - testOrderedSupport ! new OrderedType + testOrderedSupport ! new OrderedType() // Verify receive was not called for the second OrderedType expectMsg(ReceiveMessageCount(1)) @@ -68,10 +69,10 @@ class OrderedSupportSpec extends TestKit(ActorSystem("OrderedSupportSystem")) val testOrderedSupport = system.actorOf(Props[TestOrderedSupport]) // Send a message that starts the processing - testOrderedSupport ! new OrderedType + testOrderedSupport ! new OrderedType() // Send a message having a type not in orderedTypes - testOrderedSupport ! new NotOrderedType + testOrderedSupport ! new NotOrderedType() // Verify receive did get called for NotOrderedType expectMsg(ReceiveMessageCount(1)) @@ -83,13 +84,13 @@ class OrderedSupportSpec extends TestKit(ActorSystem("OrderedSupportSystem")) val testOrderedSupport = system.actorOf(Props[TestOrderedSupport]) // Switch actor to waiting mode - testOrderedSupport ! new OrderedType + testOrderedSupport ! new OrderedType() // Call finishedProcessing - testOrderedSupport ! new FinishProcessingMessage + testOrderedSupport ! new FinishProcessingMessage() // Sending something that would match in receive, and is in orderedTypes - testOrderedSupport ! new OrderedType + testOrderedSupport ! new OrderedType() expectMsg(ReceiveMessageCount(1)) expectMsg(ReceiveMessageCount(2)) diff --git a/kernel-api/build.sbt b/kernel-api/build.sbt index 68be75203..d5a42893c 100644 --- a/kernel-api/build.sbt +++ b/kernel-api/build.sbt @@ -32,7 +32,12 @@ ivyConfigurations += Configurations.ScalaTool libraryDependencies ++= Seq( Dependencies.scalaLibrary.value, Dependencies.scalaCompiler.value % "scala-tool", - Dependencies.scalaReflect.value + Dependencies.scalaReflect.value, + Dependencies.scalaTest % "test", + Dependencies.akkaTestkit % "test", + Dependencies.mockitoSugar % "test", + Dependencies.mockitoScala % "test", + Dependencies.mockitoScalaScalaTest % "test" ) // diff --git a/kernel-api/project/build.properties b/kernel-api/project/build.properties new file mode 100644 index 000000000..46e43a97e --- /dev/null +++ b/kernel-api/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.8.2 diff --git a/kernel-api/src/main/scala/org/apache/toree/dependencies/CoursierDependencyDownloader.scala b/kernel-api/src/main/scala/org/apache/toree/dependencies/CoursierDependencyDownloader.scala index c3d9d1d89..82f9728e2 100644 --- a/kernel-api/src/main/scala/org/apache/toree/dependencies/CoursierDependencyDownloader.scala +++ b/kernel-api/src/main/scala/org/apache/toree/dependencies/CoursierDependencyDownloader.scala @@ -21,16 +21,17 @@ import java.net.{URI, URL} import java.util.Properties import java.util.concurrent.ConcurrentHashMap import coursier.core.Authentication -import coursier.Cache.Logger +import coursier._ +import coursier.util.{Gather, Task} +import coursier.cache.{ArtifactError, Cache} import coursier.Dependency import coursier.core.Repository import coursier.core.Resolution.ModuleVersion import coursier.ivy.{IvyRepository, IvyXml} import coursier.maven.MavenRepository import org.springframework.core.io.support.PathMatchingResourcePatternResolver +import scala.concurrent.ExecutionContext.Implicits.global import scala.util.Try -import scalaz.\/ -import scalaz.concurrent.Task /** * Represents a dependency downloader for jars that uses Coursier underneath. @@ -71,34 +72,27 @@ class CoursierDependencyDownloader extends DependencyDownloader { transitive: Boolean, excludeBaseDependencies: Boolean, ignoreResolutionErrors: Boolean, - extraRepositories: Seq[(URL, Option[Credentials])] = Nil, + extraRepositories: collection.Seq[(URL, Option[Credentials])] = Nil, verbose: Boolean, trace: Boolean, configuration: Option[String] = None, artifactType: Option[String] = None, artifactClassifier: Option[String] = None, - excludes: Set[(String,String)] = Set.empty - ): Seq[URI] = { + excludes: collection.Set[(String,String)] = collection.Set.empty + ): collection.Seq[URI] = { assert(localDirectory != null) import coursier._ // Grab exclusions using base dependencies (always exclude scala lang) - val exclusions: Set[(String, String)] = (if (excludeBaseDependencies) { - getBaseDependencies.map(_.module).map(m => (m.organization, m.name)) - } else Nil).toSet ++ Set(("org.scala-lang", "*"), ("org.scala-lang.modules", "*")) ++ excludes + val exclusions: collection.Set[(String, String)] = (if (excludeBaseDependencies) { + getBaseDependencies.map(_.module).map(m => (m.organization.toString, m.name.toString)) + } else Nil).toSet ++ collection.Set(("org.scala-lang".toString, "*".toString), ("org.scala-lang.modules".toString, "*".toString)) ++ excludes // Mark dependency that we want to download - val start = Resolution(Set( + val start = Resolution(Seq( Dependency( - module = Module(organization = groupId, name = artifactId), - version = version, - transitive = transitive, - exclusions = exclusions, // NOTE: Source/Javadoc not downloaded by default - configuration = configuration.getOrElse("default"), - attributes = Attributes( - artifactType.getOrElse(""), - artifactClassifier.getOrElse("") - ) + module = Module(organization = Organization(groupId), name = ModuleName(artifactId)), + version = version ) )) @@ -112,9 +106,9 @@ class CoursierDependencyDownloader extends DependencyDownloader { // Build list of locations to fetch dependencies val fetchLocations = Seq(ivy2Cache(localDirectory)) ++ allRepositories - val fetch = Fetch.from( + val fetch = ResolutionProcess.fetch( fetchLocations, - Cache.fetch(downloadLocations, logger = Some(new DownloadLogger(verbose, trace))) + Cache.default.fetch ) val fetchUris = localDirectory +: repositoriesToURIs(allRepositories) @@ -123,12 +117,12 @@ class CoursierDependencyDownloader extends DependencyDownloader { printStream.println(s"-> ${fetchUris.mkString("\n-> ")}") } // Verify locations where we will download dependencies - val resolution = start.process.run(fetch).unsafePerformSync + val resolution = start.process.run(fetch).unsafeRun() // Report any resolution errors - val errors: Seq[(ModuleVersion, Seq[String])] = resolution.metadataErrors - errors.foreach { case (dep, e) => - printStream.println(s"-> Failed to resolve ${dep._1.toString()}:${dep._2}") + val errors: collection.Seq[((Module, String), Seq[String])] = resolution.errors + errors.foreach { case ((dep, msg), e) => + printStream.println(s"-> Failed to resolve ${dep.toString()}:${msg}") e.foreach(s => printStream.println(s" -> $s")) } @@ -136,12 +130,9 @@ class CoursierDependencyDownloader extends DependencyDownloader { if (errors.nonEmpty && !ignoreResolutionErrors) return Nil // Perform task of downloading dependencies - val localArtifacts: Seq[FileError \/ File] = Task.gatherUnordered( - resolution.artifacts.map(a => Cache.file( - artifact = a, - cache = downloadLocations, - logger = Some(new DownloadLogger(verbose, trace)) - ).run)).unsafePerformSync + val localArtifacts: collection.Seq[Either[ArtifactError, File]] = Gather[Task].gather( + resolution.artifacts().map(Cache.default.file(_).run) + ).unsafeRun() // Print any errors in retrieving dependencies localArtifacts.flatMap(_.swap.toOption).map(_.message) @@ -192,7 +183,7 @@ class CoursierDependencyDownloader extends DependencyDownloader { * * @return The list of repositories as URIs */ - def getRepositories: Seq[URI] = repositoriesToURIs(repositories) + def getRepositories: collection.Seq[URI] = repositoriesToURIs(repositories) /** * Returns the current directory where dependencies will be downloaded. @@ -220,79 +211,12 @@ class CoursierDependencyDownloader extends DependencyDownloader { true } - private class DownloadLogger( - private val verbose: Boolean, - private val trace: Boolean - ) extends Logger { - import scala.collection.JavaConverters._ - private val downloadId = new ConcurrentHashMap[String, String]().asScala - private val downloadFile = new ConcurrentHashMap[String, File]().asScala - private val downloadAmount = new ConcurrentHashMap[String, Long]().asScala - private val downloadTotal = new ConcurrentHashMap[String, Long]().asScala - - override def foundLocally(url: String, file: File): Unit = { - val id = downloadId.getOrElse(url, url) - val f = s"(${downloadFile.get(url).map(_.getName).getOrElse("")})" - if (verbose) printStream.println(s"=> $id: Found at ${file.getAbsolutePath}") - } - - override def downloadingArtifact(url: String, file: File): Unit = { - downloadId.put(url, nextId()) - val id = downloadId.getOrElse(url, url) - val f = s"(${downloadFile.get(url).map(_.getName).getOrElse("")})" - - if (verbose) printStream.println(s"=> $id $f: Downloading $url") - - downloadFile.put(url, file) - } - - override def downloadLength(url: String, length: Long): Unit = { - val id = downloadId.getOrElse(url, url) - val f = s"(${downloadFile.get(url).map(_.getName).getOrElse("")})" - if (trace) printStream.println(s"===> $id $f: Is $length total bytes") - downloadTotal.put(url, length) - } - - override def downloadProgress(url: String, downloaded: Long): Unit = { - downloadAmount.put(url, downloaded) - - val ratio = downloadAmount(url).toDouble / downloadTotal.getOrElse[Long](url, 1).toDouble - val percent = ratio * 100.0 - - if (trace) printStream.printf( - "===> %s %s: Downloaded %d bytes (%.2f%%)\n", - downloadId.getOrElse(url, url), - s"(${downloadFile.get(url).map(_.getName).getOrElse("")})", - java.lang.Long.valueOf(downloaded), - java.lang.Double.valueOf(percent) - ) - } - - override def downloadedArtifact(url: String, success: Boolean): Unit = { - if (verbose) { - val id = downloadId.getOrElse(url, url) - val f = s"(${downloadFile.get(url).map(_.getName).getOrElse("")})" - if (success) printStream.println(s"=> $id $f: Finished downloading") - else printStream.println(s"=> $id: An error occurred while downloading") - } - } - - private val nextId: () => String = (() => { - var counter: Long = 0 - - () => { - counter += 1 - counter.toString - } - })() - } - /** * Retrieves base dependencies used when building Toree modules. * * @return The collection of dependencies */ - private def getBaseDependencies: Seq[Dependency] = { + private def getBaseDependencies: collection.Seq[Dependency] = { import coursier.core.compatibility.xmlParse // Find all of the *ivy.xml files on the classpath. @@ -307,7 +231,7 @@ class CoursierDependencyDownloader extends DependencyDownloader { nodes.flatMap(_.left.toOption).foreach(s => printStream.println(s"Error: $s")) // Grab Ivy XML projects - val projects = nodes.flatMap(_.right.toOption).map(IvyXml.project) + val projects = nodes.flatMap(_.toOption).map(IvyXml.project) // Report any errors parsing Ivy XML projects.flatMap(_.swap.toOption).foreach(s => printStream.println(s"Error: $s")) @@ -325,7 +249,7 @@ class CoursierDependencyDownloader extends DependencyDownloader { * @param repositories The repositories to convert * @return The resulting URIs */ - private def repositoriesToURIs(repositories: Seq[Repository]) = + private def repositoriesToURIs(repositories: collection.Seq[Repository]) = repositories.map { case ivy: IvyRepository => ivy.pattern.string case maven: MavenRepository => maven.root @@ -344,7 +268,7 @@ class CoursierDependencyDownloader extends DependencyDownloader { "(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[organisation]/[module]/" + "[type]s/[artifact]-[revision](-[classifier]).[ext]", metadataPatternOpt = Some( - ivy2HomeUri + "cache/" + + ivy2HomeUri.toString + "cache/" + "(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[organisation]/[module]/" + "[type]-[revision](-[classifier]).[ext]" ), @@ -374,11 +298,11 @@ object Credentials { p } - private def findKey(keys: Seq[String]) = keys + private def findKey(keys: collection.Seq[String]) = keys .iterator .map(props.getProperty) .filter(_ != null) - .toStream + .to(LazyList) .headOption .getOrElse { throw new NoSuchElementException(s"${keys.head} key in $file") diff --git a/kernel-api/src/main/scala/org/apache/toree/dependencies/DependencyDownloader.scala b/kernel-api/src/main/scala/org/apache/toree/dependencies/DependencyDownloader.scala index 36f8b50c0..666055fc8 100644 --- a/kernel-api/src/main/scala/org/apache/toree/dependencies/DependencyDownloader.scala +++ b/kernel-api/src/main/scala/org/apache/toree/dependencies/DependencyDownloader.scala @@ -54,14 +54,14 @@ abstract class DependencyDownloader { transitive: Boolean = true, excludeBaseDependencies: Boolean = true, ignoreResolutionErrors: Boolean = true, - extraRepositories: Seq[(URL, Option[Credentials])] = Nil, + extraRepositories: collection.Seq[(URL, Option[Credentials])] = Nil, verbose: Boolean = false, trace: Boolean = false, configuration: Option[String] = None, artifactType: Option[String] = None, artifactClassifier: Option[String] = None, - excludes: Set[(String,String)] = Set.empty - ): Seq[URI] + excludes: collection.Set[(String,String)] = collection.Set.empty + ): collection.Seq[URI] /** * Sets the printstream to log to. @@ -89,7 +89,7 @@ abstract class DependencyDownloader { * * @return The list of repositories as URIs */ - def getRepositories: Seq[URI] + def getRepositories: collection.Seq[URI] /** * Sets the directory where all downloaded jars will be stored. diff --git a/kernel-api/src/main/scala/org/apache/toree/dependencies/IvyDependencyDownloader.scala b/kernel-api/src/main/scala/org/apache/toree/dependencies/IvyDependencyDownloader.scala index 47e6da9a8..fb53fdf06 100644 --- a/kernel-api/src/main/scala/org/apache/toree/dependencies/IvyDependencyDownloader.scala +++ b/kernel-api/src/main/scala/org/apache/toree/dependencies/IvyDependencyDownloader.scala @@ -89,14 +89,14 @@ class IvyDependencyDownloader( transitive: Boolean = true, excludeBaseDependencies: Boolean, ignoreResolutionErrors: Boolean, - extraRepositories: Seq[(URL, Option[Credentials])] = Nil, + extraRepositories: collection.Seq[(URL, Option[Credentials])] = Nil, verbose: Boolean, trace: Boolean, configuration: Option[String] = None, artifactType: Option[String] = None, artifactClassifier: Option[String] = None, - excludes: Set[(String,String)] = Set.empty - ): Seq[URI] = { + excludes: collection.Set[(String,String)] = collection.Set.empty + ): collection.Seq[URI] = { // Start building the ivy.xml file val ivyFile = File.createTempFile("ivy-custom", ".xml") ivyFile.deleteOnExit() diff --git a/kernel-api/src/main/scala/org/apache/toree/interpreter/Interpreter.scala b/kernel-api/src/main/scala/org/apache/toree/interpreter/Interpreter.scala index 5a02f9d40..97deabfa1 100644 --- a/kernel-api/src/main/scala/org/apache/toree/interpreter/Interpreter.scala +++ b/kernel-api/src/main/scala/org/apache/toree/interpreter/Interpreter.scala @@ -20,8 +20,7 @@ package org.apache.toree.interpreter import java.net.URL import org.apache.toree.kernel.api.KernelLike - -import scala.tools.nsc.interpreter._ +import java.io.{InputStream, OutputStream} case class LanguageInfo( name: String, @@ -90,7 +89,7 @@ trait Interpreter { * @param value The value of the variable binding * @param modifiers Any annotation, scoping modifiers, etc on the variable */ - def bind(variableName: String, typeName: String, value: Any, modifiers: List[String]) + def bind(variableName: String, typeName: String, value: Any, modifiers: List[String]): Unit /** * Retrieves the contents of the variable with the provided name from the @@ -109,7 +108,7 @@ trait Interpreter { * @param out The new output stream * @param err The new error stream */ - def updatePrintStreams(in: InputStream, out: OutputStream, err: OutputStream) + def updatePrintStreams(in: InputStream, out: OutputStream, err: OutputStream): Unit /** * Attempts to perform code completion via the command. diff --git a/kernel-api/src/main/scala/org/apache/toree/interpreter/broker/BrokerProcess.scala b/kernel-api/src/main/scala/org/apache/toree/interpreter/broker/BrokerProcess.scala index 46af0e3f4..917d18d39 100644 --- a/kernel-api/src/main/scala/org/apache/toree/interpreter/broker/BrokerProcess.scala +++ b/kernel-api/src/main/scala/org/apache/toree/interpreter/broker/BrokerProcess.scala @@ -23,7 +23,7 @@ import org.apache.commons.exec._ import org.apache.commons.exec.environment.EnvironmentUtils import org.apache.commons.io.{FilenameUtils, IOUtils} import org.slf4j.LoggerFactory -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ /** * Represents the process used to evaluate broker code. diff --git a/kernel-api/src/main/scala/org/apache/toree/interpreter/broker/BrokerService.scala b/kernel-api/src/main/scala/org/apache/toree/interpreter/broker/BrokerService.scala index 0be0fc100..64206b7c0 100644 --- a/kernel-api/src/main/scala/org/apache/toree/interpreter/broker/BrokerService.scala +++ b/kernel-api/src/main/scala/org/apache/toree/interpreter/broker/BrokerService.scala @@ -20,7 +20,7 @@ package org.apache.toree.interpreter.broker import org.apache.toree.interpreter.broker.BrokerTypes.{Code, CodeResults} import scala.concurrent.Future -import scala.tools.nsc.interpreter._ +import java.io.{InputStream, OutputStream} /** * Represents the service that provides the high-level interface between the diff --git a/kernel-api/src/main/scala/org/apache/toree/interpreter/broker/BrokerState.scala b/kernel-api/src/main/scala/org/apache/toree/interpreter/broker/BrokerState.scala index 3d1e3abec..f79ddb373 100644 --- a/kernel-api/src/main/scala/org/apache/toree/interpreter/broker/BrokerState.scala +++ b/kernel-api/src/main/scala/org/apache/toree/interpreter/broker/BrokerState.scala @@ -23,7 +23,7 @@ import org.apache.toree.interpreter.broker.BrokerTypes._ import org.slf4j.LoggerFactory import scala.concurrent.{Future, Promise} -import scala.tools.nsc.interpreter.OutputStream +import java.io.{InputStream, OutputStream} /** * Represents the state structure of broker. @@ -35,7 +35,7 @@ import scala.tools.nsc.interpreter.OutputStream class BrokerState(private val maxQueuedCode: Int) { private val logger = LoggerFactory.getLogger(this.getClass) - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ @volatile private var _isReady: Boolean = false diff --git a/kernel-api/src/main/scala/org/apache/toree/kernel/api/KernelLike.scala b/kernel-api/src/main/scala/org/apache/toree/kernel/api/KernelLike.scala index b2f96e9bd..127bda24b 100644 --- a/kernel-api/src/main/scala/org/apache/toree/kernel/api/KernelLike.scala +++ b/kernel-api/src/main/scala/org/apache/toree/kernel/api/KernelLike.scala @@ -102,7 +102,7 @@ trait KernelLike { def config: Config - def addJars(uris: URI*) + def addJars(uris: URI*): Unit def sparkContext: SparkContext diff --git a/kernel-api/src/main/scala/org/apache/toree/security/KernelSecurityManager.scala b/kernel-api/src/main/scala/org/apache/toree/security/KernelSecurityManager.scala index 0b5955430..54d48cfb5 100644 --- a/kernel-api/src/main/scala/org/apache/toree/security/KernelSecurityManager.scala +++ b/kernel-api/src/main/scala/org/apache/toree/security/KernelSecurityManager.scala @@ -70,7 +70,7 @@ object KernelSecurityManager { * the only path by which we should permit System.exit to succeed within the notebook. * Note that dual SIGINTs occur from a non-restricted thread group and are also permitted. */ - def enableRestrictedExit() { + def enableRestrictedExit(): Unit = { val currentGroup = Thread.currentThread().getThreadGroup tlEnableRestrictedExit.set(currentGroup.getName == RestrictedGroupName) } diff --git a/kernel-api/src/main/scala/org/apache/toree/utils/ArgumentParsingSupport.scala b/kernel-api/src/main/scala/org/apache/toree/utils/ArgumentParsingSupport.scala index cd258f6eb..c65c5ab74 100644 --- a/kernel-api/src/main/scala/org/apache/toree/utils/ArgumentParsingSupport.scala +++ b/kernel-api/src/main/scala/org/apache/toree/utils/ArgumentParsingSupport.scala @@ -18,7 +18,7 @@ package org.apache.toree.utils import joptsimple.{OptionSpec, OptionParser} -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.language.implicitConversions import java.io.{PrintStream, OutputStream} diff --git a/kernel-api/src/main/scala/org/apache/toree/utils/MultiClassLoader.scala b/kernel-api/src/main/scala/org/apache/toree/utils/MultiClassLoader.scala index 624273535..864eefbdc 100644 --- a/kernel-api/src/main/scala/org/apache/toree/utils/MultiClassLoader.scala +++ b/kernel-api/src/main/scala/org/apache/toree/utils/MultiClassLoader.scala @@ -22,7 +22,7 @@ import java.net.{URL, URLClassLoader} import java.util import org.slf4j.LoggerFactory -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.util.{Failure, Success, Try} import scala.language.existentials @@ -38,11 +38,11 @@ import scala.language.existentials * implementations of this class loader */ class MultiClassLoader( - private val urls: Seq[URL], - private val classLoaders: Seq[ClassLoader] + private val urls: collection.Seq[URL], + private val classLoaders: collection.Seq[ClassLoader] ) extends URLClassLoader( classLoaders.flatMap({ - case urlClassLoader: URLClassLoader => urlClassLoader.getURLs.toSeq + case urlClassLoader: URLClassLoader => urlClassLoader.getURLs.to(collection.Seq) case _ => Nil }).distinct.toArray, /* Create a parent chain based on a each classloader's parent */ { @@ -77,20 +77,20 @@ class MultiClassLoader( } // NOTE: Using iterator to evaluate elements one at a time - classLoaders.toIterator + classLoaders.iterator .map(classLoader => tryFindClass(classLoader, name)) .find(_.isSuccess) .map(_.get) .getOrElse(throw new ClassNotFoundException(name)) } - override protected def findResource(name: String): URL = { + override def findResource(name: String): URL = { // NOTE: Using iterator to evaluate elements one at a time - classLoaders.toIterator.map(cl => _findResource(cl, name)).find(_ != null) + classLoaders.iterator.map(cl => _findResource(cl, name)).find(_ != null) .getOrElse(super.findResource(name)) } - override protected def findResources(name: String): util.Enumeration[URL] = { + override def findResources(name: String): util.Enumeration[URL] = { val internalResources = classLoaders .flatMap(cl => Try(_findResources(cl, name)).toOption) .map(_.asScala) diff --git a/kernel-api/src/test/scala/org/apache/toree/dependencies/CoursierDependencyDownloaderSpec.scala b/kernel-api/src/test/scala/org/apache/toree/dependencies/CoursierDependencyDownloaderSpec.scala index 8d5b217c5..c548fe9ca 100644 --- a/kernel-api/src/test/scala/org/apache/toree/dependencies/CoursierDependencyDownloaderSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/dependencies/CoursierDependencyDownloaderSpec.scala @@ -19,9 +19,11 @@ package org.apache.toree.dependencies import java.net.URL import java.nio.file.Files -import org.scalatest.{FunSpec, Matchers, OneInstancePerTest} +import org.scalatest.OneInstancePerTest +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class CoursierDependencyDownloaderSpec extends FunSpec with Matchers +class CoursierDependencyDownloaderSpec extends AnyFunSpec with Matchers with OneInstancePerTest { private val coursierDependencyDownloader = new CoursierDependencyDownloader diff --git a/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerBridgeSpec.scala b/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerBridgeSpec.scala index de30960a0..09ed66650 100644 --- a/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerBridgeSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerBridgeSpec.scala @@ -18,9 +18,11 @@ package org.apache.toree.interpreter.broker import org.apache.toree.kernel.api.KernelLike import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpec, Matchers, OneInstancePerTest} +import org.scalatest.OneInstancePerTest +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class BrokerBridgeSpec extends FunSpec with Matchers with OneInstancePerTest +class BrokerBridgeSpec extends AnyFunSpec with Matchers with OneInstancePerTest with MockitoSugar { private val mockBrokerState = mock[BrokerState] diff --git a/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerProcessHandlerSpec.scala b/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerProcessHandlerSpec.scala index 657fdece3..192946b0b 100644 --- a/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerProcessHandlerSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerProcessHandlerSpec.scala @@ -18,11 +18,16 @@ package org.apache.toree.interpreter.broker import org.apache.commons.exec.ExecuteException import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpec, Matchers, OneInstancePerTest} +import org.scalatest.OneInstancePerTest +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.concurrent.Eventually +import org.scalatest.concurrent.PatienceConfiguration.Timeout +import org.scalatest.time.{Millis, Seconds, Span} import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ -class BrokerProcessHandlerSpec extends FunSpec with Matchers +class BrokerProcessHandlerSpec extends AnyFunSpec with Matchers with OneInstancePerTest with MockitoSugar { private val mockBrokerBridge = mock[BrokerBridge] diff --git a/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerProcessSpec.scala b/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerProcessSpec.scala index f7a055d25..52fa1673e 100644 --- a/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerProcessSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerProcessSpec.scala @@ -22,12 +22,15 @@ import org.apache.commons.exec._ import org.apache.commons.io.FilenameUtils import org.mockito.ArgumentCaptor import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpec, Matchers, OneInstancePerTest} +import org.scalatest.OneInstancePerTest +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers + import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ -class BrokerProcessSpec extends FunSpec with Matchers +class BrokerProcessSpec extends AnyFunSpec with Matchers with OneInstancePerTest with MockitoSugar { private val TestProcessName = "test_process" @@ -203,7 +206,7 @@ class BrokerProcessSpec extends FunSpec with Matchers brokerProcess.start() verify(mockExecutor).execute(any(),environmentCaptor.capture() , any()) - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ val environment = environmentCaptor.getValue.asScala environment should contain theSameElementsAs TestEnvironment diff --git a/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerStateSpec.scala b/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerStateSpec.scala index 43374f881..e43939c48 100644 --- a/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerStateSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerStateSpec.scala @@ -16,11 +16,13 @@ */ package org.apache.toree.interpreter.broker -import org.scalatest.{FunSpec, Matchers, OneInstancePerTest} +import org.scalatest.OneInstancePerTest +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import scala.util.Success -class BrokerStateSpec extends FunSpec with Matchers with OneInstancePerTest { +class BrokerStateSpec extends AnyFunSpec with Matchers with OneInstancePerTest { private val TestMaxQueuedCode = 5 private val brokerState = new BrokerState(TestMaxQueuedCode) diff --git a/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerTransformerSpec.scala b/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerTransformerSpec.scala index 0f1e37e16..1266e7999 100644 --- a/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerTransformerSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/interpreter/broker/BrokerTransformerSpec.scala @@ -19,9 +19,11 @@ package org.apache.toree.interpreter.broker import org.apache.toree.interpreter.{ExecuteError, Results} import org.scalatest.concurrent.Eventually import scala.concurrent.Promise -import org.scalatest.{FunSpec, Matchers, OneInstancePerTest} +import org.scalatest.OneInstancePerTest +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class BrokerTransformerSpec extends FunSpec with Matchers +class BrokerTransformerSpec extends AnyFunSpec with Matchers with OneInstancePerTest with Eventually { private val brokerTransformer = new BrokerTransformer diff --git a/kernel-api/src/test/scala/org/apache/toree/magic/InternalClassLoaderSpec.scala b/kernel-api/src/test/scala/org/apache/toree/magic/InternalClassLoaderSpec.scala index b1f251b1e..526b22e55 100644 --- a/kernel-api/src/test/scala/org/apache/toree/magic/InternalClassLoaderSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/magic/InternalClassLoaderSpec.scala @@ -17,10 +17,12 @@ package org.apache.toree.magic -import org.scalatest.{Matchers, FunSpec} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers + import org.scalatestplus.mockito.MockitoSugar -class InternalClassLoaderSpec extends FunSpec with Matchers with MockitoSugar { +class InternalClassLoaderSpec extends AnyFunSpec with Matchers with MockitoSugar { abstract class MockClassLoader extends ClassLoader(null) { override def loadClass(name: String): Class[_] = null diff --git a/kernel-api/src/test/scala/org/apache/toree/magic/MagicManagerSpec.scala b/kernel-api/src/test/scala/org/apache/toree/magic/MagicManagerSpec.scala index 2bbd585f5..3ff3f7cb3 100644 --- a/kernel-api/src/test/scala/org/apache/toree/magic/MagicManagerSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/magic/MagicManagerSpec.scala @@ -20,9 +20,11 @@ package org.apache.toree.magic import org.apache.toree.plugins.dependencies.Dependency import org.apache.toree.plugins._ import org.mockito.Mockito._ -import org.mockito.Matchers.{eq => mockEq, _} +import org.mockito.ArgumentMatchers.{eq => mockEq, _} import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpec, Matchers, OneInstancePerTest} +import org.scalatest.OneInstancePerTest +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import test.utils import MagicManagerSpec._ @@ -60,7 +62,7 @@ private class ExceptionCellMagic extends CellMagic { } class MagicManagerSpec - extends FunSpec with Matchers with MockitoSugar with OneInstancePerTest + extends AnyFunSpec with Matchers with MockitoSugar with OneInstancePerTest { private val TestPluginName = "SomePlugin" private val TestMagicName = "SomeMagic" diff --git a/kernel-api/src/test/scala/org/apache/toree/utils/ArgumentParsingSupportSpec.scala b/kernel-api/src/test/scala/org/apache/toree/utils/ArgumentParsingSupportSpec.scala index 9be90a2b1..999e3b11e 100644 --- a/kernel-api/src/test/scala/org/apache/toree/utils/ArgumentParsingSupportSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/utils/ArgumentParsingSupportSpec.scala @@ -17,26 +17,28 @@ package org.apache.toree.utils -import org.scalatest.{BeforeAndAfter, Matchers, FunSpec} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import joptsimple.{OptionSet, OptionSpec, OptionParser} import org.scalatestplus.mockito.MockitoSugar import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import collection.JavaConverters._ -class ArgumentParsingSupportSpec extends FunSpec with Matchers - with BeforeAndAfter with MockitoSugar +class ArgumentParsingSupportSpec extends AnyFunSpec with Matchers + with BeforeAndAfterEach with MockitoSugar { private var mockOptions: OptionSet = _ private var mockParser: OptionParser = _ private var argumentParsingInstance: ArgumentParsingSupport = _ - before { + override def beforeEach(): Unit = { mockOptions = mock[OptionSet] mockParser = mock[OptionParser] - doReturn(mockOptions).when(mockParser).parse(anyVararg[String]()) + doReturn(mockOptions).when(mockParser).parse(anyVararg[String](): _*) argumentParsingInstance = new Object() with ArgumentParsingSupport { override protected lazy val parser: OptionParser = mockParser diff --git a/kernel-api/src/test/scala/org/apache/toree/utils/ConditionalOutputStreamSpec.scala b/kernel-api/src/test/scala/org/apache/toree/utils/ConditionalOutputStreamSpec.scala index 84ec8a528..cf8807738 100644 --- a/kernel-api/src/test/scala/org/apache/toree/utils/ConditionalOutputStreamSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/utils/ConditionalOutputStreamSpec.scala @@ -21,10 +21,12 @@ import java.io.OutputStream import org.scalatestplus.mockito.MockitoSugar import org.mockito.Mockito._ -import org.mockito.Matchers._ -import org.scalatest.{Matchers, FunSpec} +import org.mockito.ArgumentMatchers._ +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class ConditionalOutputStreamSpec extends FunSpec with Matchers with MockitoSugar { +class ConditionalOutputStreamSpec extends AnyFunSpec with Matchers with MockitoSugar { describe("ConditionalOutputStream") { describe("#()") { it("should throw an exception if the output stream is null") { diff --git a/kernel-api/src/test/scala/org/apache/toree/utils/DownloadSupportSpec.scala b/kernel-api/src/test/scala/org/apache/toree/utils/DownloadSupportSpec.scala index 30cc5615f..3e3837ec1 100644 --- a/kernel-api/src/test/scala/org/apache/toree/utils/DownloadSupportSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/utils/DownloadSupportSpec.scala @@ -20,23 +20,25 @@ package org.apache.toree.utils import java.io.FileNotFoundException import java.net.URL -import org.scalatest.{BeforeAndAfter, Matchers, FunSpec} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import scala.io.Source import scala.tools.nsc.io.File -class DownloadSupportSpec extends FunSpec with Matchers with BeforeAndAfter { +class DownloadSupportSpec extends AnyFunSpec with Matchers with BeforeAndAfterEach { val downloadDestinationUrl = new URL("file:///tmp/testfile2.ext") val testFileContent = "This is a test" val testFileName = "/tmp/testfile.txt" // Create a test file for downloading - before { + override def beforeEach(): Unit = { File(testFileName).writeAll(testFileContent) } // Cleanup what we made - after { + override def afterEach(): Unit = { if (File(testFileName).exists) File(testFileName).delete() if (File(downloadDestinationUrl.getPath).exists) File(downloadDestinationUrl.getPath).delete() } diff --git a/kernel-api/src/test/scala/org/apache/toree/utils/DynamicReflectionSupportSpec.scala b/kernel-api/src/test/scala/org/apache/toree/utils/DynamicReflectionSupportSpec.scala index dd9bf5c15..def730955 100644 --- a/kernel-api/src/test/scala/org/apache/toree/utils/DynamicReflectionSupportSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/utils/DynamicReflectionSupportSpec.scala @@ -19,13 +19,16 @@ package org.apache.toree.utils import java.io.OutputStream -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{GivenWhenThen, BeforeAndAfter, FunSpec, Matchers} +import org.scalatest.GivenWhenThen +import org.scalatest.BeforeAndAfter +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers class DynamicReflectionSupportSpec - extends FunSpec with Matchers with MockitoSugar { + extends AnyFunSpec with Matchers with MockitoSugar { describe("DynamicReflectionSupport") { describe("with a class instance") { diff --git a/kernel-api/src/test/scala/org/apache/toree/utils/KeyValuePairUtilsSpec.scala b/kernel-api/src/test/scala/org/apache/toree/utils/KeyValuePairUtilsSpec.scala index 5bd53dd18..dc7c49092 100644 --- a/kernel-api/src/test/scala/org/apache/toree/utils/KeyValuePairUtilsSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/utils/KeyValuePairUtilsSpec.scala @@ -18,9 +18,10 @@ package org.apache.toree.utils import joptsimple.util.KeyValuePair -import org.scalatest.{Matchers, FunSpec} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class KeyValuePairUtilsSpec extends FunSpec with Matchers { +class KeyValuePairUtilsSpec extends AnyFunSpec with Matchers { private object TestKeyValuePair { def apply(key: String, value: String) = KeyValuePair.valueOf(s"$key=$value") } diff --git a/kernel-api/src/test/scala/org/apache/toree/utils/MultiOutputStreamSpec.scala b/kernel-api/src/test/scala/org/apache/toree/utils/MultiOutputStreamSpec.scala index 53ff6c0ba..9efa4f7ca 100644 --- a/kernel-api/src/test/scala/org/apache/toree/utils/MultiOutputStreamSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/utils/MultiOutputStreamSpec.scala @@ -20,12 +20,14 @@ package org.apache.toree.utils import java.io.OutputStream import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, Matchers, FunSpec} -import org.mockito.Matchers._ +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ class MultiOutputStreamSpec - extends FunSpec with Matchers with MockitoSugar with BeforeAndAfter { + extends AnyFunSpec with Matchers with MockitoSugar with BeforeAndAfterEach { describe("MultiOutputStream") { val listOfMockOutputStreams = List(mock[OutputStream], mock[OutputStream]) diff --git a/kernel-api/src/test/scala/org/apache/toree/utils/ScheduledTaskManagerSpec.scala b/kernel-api/src/test/scala/org/apache/toree/utils/ScheduledTaskManagerSpec.scala index 563e06a71..44058556b 100644 --- a/kernel-api/src/test/scala/org/apache/toree/utils/ScheduledTaskManagerSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/utils/ScheduledTaskManagerSpec.scala @@ -23,9 +23,11 @@ import java.util.concurrent.{TimeUnit, CountDownLatch} import org.scalatest.concurrent.Eventually import org.scalatest.time.{Milliseconds, Span} -import org.scalatest.{BeforeAndAfter, Matchers, FunSpec} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class ScheduledTaskManagerSpec extends FunSpec with Matchers with BeforeAndAfter +class ScheduledTaskManagerSpec extends AnyFunSpec with Matchers with BeforeAndAfterEach with Eventually { private val TestTimeInterval = 30 @@ -81,12 +83,12 @@ class ScheduledTaskManagerSpec extends FunSpec with Matchers with BeforeAndAfter } } - before { + override def beforeEach(): Unit = { scheduledTaskManager = new ScheduledTaskManager scheduleVerifier = new ScheduleVerifier } - after { + override def afterEach(): Unit = { scheduledTaskManager.stop() } diff --git a/kernel-api/src/test/scala/org/apache/toree/utils/TaskManagerSpec.scala b/kernel-api/src/test/scala/org/apache/toree/utils/TaskManagerSpec.scala index 602900dec..0f643543b 100644 --- a/kernel-api/src/test/scala/org/apache/toree/utils/TaskManagerSpec.scala +++ b/kernel-api/src/test/scala/org/apache/toree/utils/TaskManagerSpec.scala @@ -22,15 +22,17 @@ import java.util.concurrent.{ExecutionException, RejectedExecutionException} import org.scalatest.concurrent.PatienceConfiguration.Timeout import org.scalatest.concurrent.{Eventually, ScalaFutures, TimeLimits} import org.scalatest.time.{Milliseconds, Seconds, Span} -import org.scalatest.{BeforeAndAfter, FunSpec, Matchers} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.scalatestplus.mockito.MockitoSugar import test.utils.UncaughtExceptionSuppression import scala.concurrent.Future import scala.runtime.BoxedUnit -class TaskManagerSpec extends FunSpec with Matchers with MockitoSugar - with BeforeAndAfter with ScalaFutures with UncaughtExceptionSuppression +class TaskManagerSpec extends AnyFunSpec with Matchers with MockitoSugar + with BeforeAndAfterEach with ScalaFutures with UncaughtExceptionSuppression with Eventually with TimeLimits { implicit override val patienceConfig = PatienceConfig( @@ -40,11 +42,11 @@ class TaskManagerSpec extends FunSpec with Matchers with MockitoSugar private val MaxTestTasks = 50000 private var taskManager: TaskManager = _ - before { + override def beforeEach(): Unit = { taskManager = new TaskManager } - after { + override def afterEach(): Unit = { taskManager = null } diff --git a/kernel/build.sbt b/kernel/build.sbt index f77546a5e..15ca68e64 100644 --- a/kernel/build.sbt +++ b/kernel/build.sbt @@ -21,4 +21,9 @@ libraryDependencies += Dependencies.guava // // TEST DEPENDENCIES // -libraryDependencies += Dependencies.akkaTestkit % "test" +libraryDependencies ++= Seq( + Dependencies.akkaTestkit % "test", + Dependencies.mockitoSugar % "test", + Dependencies.mockitoScala % "test", + Dependencies.mockitoScalaScalaTest % "test" +) \ No newline at end of file diff --git a/kernel/src/main/scala/org/apache/toree/Main.scala b/kernel/src/main/scala/org/apache/toree/Main.scala index 575633637..0e304a000 100644 --- a/kernel/src/main/scala/org/apache/toree/Main.scala +++ b/kernel/src/main/scala/org/apache/toree/Main.scala @@ -22,7 +22,7 @@ import org.apache.toree.boot.{CommandLineOptions, KernelBootstrap} import org.apache.toree.kernel.BuildInfo object Main extends App { - private val options = new CommandLineOptions(args) + private val options = new CommandLineOptions(args.toIndexedSeq) if (options.help) { options.printHelpOn(System.out) diff --git a/kernel/src/main/scala/org/apache/toree/boot/CommandLineOptions.scala b/kernel/src/main/scala/org/apache/toree/boot/CommandLineOptions.scala index 59c04371b..882bf7221 100644 --- a/kernel/src/main/scala/org/apache/toree/boot/CommandLineOptions.scala +++ b/kernel/src/main/scala/org/apache/toree/boot/CommandLineOptions.scala @@ -23,7 +23,7 @@ import com.typesafe.config.{Config, ConfigFactory} import joptsimple.{OptionParser, OptionSpec} import joptsimple.util.RegexMatcher._ -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ class CommandLineOptions(args: Seq[String]) { private val parser = new OptionParser() diff --git a/kernel/src/main/scala/org/apache/toree/boot/layer/ComponentInitialization.scala b/kernel/src/main/scala/org/apache/toree/boot/layer/ComponentInitialization.scala index 46f079664..922c7d612 100644 --- a/kernel/src/main/scala/org/apache/toree/boot/layer/ComponentInitialization.scala +++ b/kernel/src/main/scala/org/apache/toree/boot/layer/ComponentInitialization.scala @@ -33,7 +33,7 @@ import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import org.apache.toree.magic.MagicManager import org.apache.toree.plugins.PluginManager import org.apache.toree.utils.{LogLike, FileUtils} -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import org.apache.toree.plugins.AllInterpretersReady /** @@ -217,17 +217,19 @@ trait StandardComponentInitialization extends ComponentInitialization { // Load internal plugins under kernel module logger.debug("Loading internal plugins") val internalPlugins = pluginManager.initialize() - logger.info(internalPlugins.size + " internal plugins loaded") + val internalPluginsSize = internalPlugins.size + logger.info(s"$internalPluginsSize internal plugins loaded") // Load external plugins if provided logger.debug("Loading external plugins") val externalPlugins = if (magicUrlArray.nonEmpty) { val externalPlugins = pluginManager.loadPlugins( - magicUrlArray.map(_.getFile).map(new File(_)): _* + magicUrlArray.map(_.getFile).map(new File(_)).toIndexedSeq: _* ) pluginManager.initializePlugins(externalPlugins) externalPlugins } else Nil - logger.info(externalPlugins.size + " external plugins loaded") + val externalPluginsSize = externalPlugins.size + logger.info(s"$externalPluginsSize external plugins loaded") } } diff --git a/kernel/src/main/scala/org/apache/toree/boot/layer/InterpreterManager.scala b/kernel/src/main/scala/org/apache/toree/boot/layer/InterpreterManager.scala index b1e5fa9a1..1b5e0f3af 100644 --- a/kernel/src/main/scala/org/apache/toree/boot/layer/InterpreterManager.scala +++ b/kernel/src/main/scala/org/apache/toree/boot/layer/InterpreterManager.scala @@ -20,7 +20,7 @@ package org.apache.toree.boot.layer import org.apache.toree.kernel.api.KernelLike import com.typesafe.config.Config import org.apache.toree.interpreter._ -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import org.slf4j.LoggerFactory diff --git a/kernel/src/main/scala/org/apache/toree/kernel/api/Kernel.scala b/kernel/src/main/scala/org/apache/toree/kernel/api/Kernel.scala index cb90b81e4..3b410b6a7 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/api/Kernel.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/api/Kernel.scala @@ -138,9 +138,9 @@ class Kernel ( val (success, result) = output success match { case Results.Success => - (true, result.left.get) + (true, result.swap.toOption.get) case Results.Error => - (false, Map("text/plain" -> result.right.getOrElse("").toString)) + (false, Map("text/plain" -> result.getOrElse("").toString)) case Results.Aborted => (false, Map("text/plain" -> "Aborted!")) case Results.Incomplete => @@ -413,7 +413,7 @@ class Kernel ( if(config.getString("spark_context_initialization_mode") == "eager") { // explicitly enable eager initialization of spark context - SparkSession.builder.config(defaultSparkConf).getOrCreate + SparkSession.builder().config(defaultSparkConf).getOrCreate() } else { // default lazy initialization of spark context defaultSparkConf.getOption("spark.master") match { @@ -425,7 +425,7 @@ class Kernel ( // default timeout is 100ms and it is specified in reference.conf. import scala.concurrent.ExecutionContext.Implicits.global val sessionFuture = Future { - SparkSession.builder.config(defaultSparkConf).getOrCreate + SparkSession.builder().config(defaultSparkConf).getOrCreate() } try { @@ -441,7 +441,7 @@ class Kernel ( } case _ => - SparkSession.builder.config(defaultSparkConf).getOrCreate + SparkSession.builder().config(defaultSparkConf).getOrCreate() } } } diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/dispatch/StatusDispatch.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/dispatch/StatusDispatch.scala index 5a148d63c..e768f8065 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/dispatch/StatusDispatch.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/dispatch/StatusDispatch.scala @@ -26,7 +26,7 @@ import org.apache.toree.utils.LogLike import play.api.libs.json.Json class StatusDispatch(actorLoader: ActorLoader) extends Actor with LogLike { - private def sendStatusMessage(kernelStatus: KernelStatusType, parentHeader: Header) { + private def sendStatusMessage(kernelStatus: KernelStatusType, parentHeader: Header): Unit = { // Create the status message and send it to the relay val km : KernelMessage = KMBuilder() .withIds(Seq(MessageType.Outgoing.Status.toString.getBytes)) diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommCloseHandler.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommCloseHandler.scala index 7f27177c3..7f6d4b2f0 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommCloseHandler.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommCloseHandler.scala @@ -78,7 +78,7 @@ class CommCloseHandler( } } - private def handleParseError(invalid: Seq[(JsPath, Seq[JsonValidationError])]) = { + private def handleParseError(invalid: collection.Seq[(JsPath, collection.Seq[JsonValidationError])]) = { // TODO: Determine proper response for a parse failure logger.warn("Parse error for Comm Close! Not responding!") } diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommInfoRequestHandler.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommInfoRequestHandler.scala index a27e6208f..43ec7540c 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommInfoRequestHandler.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommInfoRequestHandler.scala @@ -25,7 +25,7 @@ import org.apache.toree.utils.MessageLogSupport import play.api.libs.json.Json import scala.concurrent.ExecutionContext.Implicits.global -import scala.concurrent.{Future, future} +import scala.concurrent.Future /** * Receives a CommInfoRequest KernelMessage and returns a CommInfoReply @@ -53,14 +53,14 @@ class CommInfoRequestHandler( override def process(kernelMessage: KernelMessage): Future[_] = Future { logKernelMessageAction("Initiating CommInfo request for", kernelMessage) - + import scala.language.existentials val commMap = (Json.parse(kernelMessage.contentString) \ "target_name").asOpt[String] match { case Some(targetName) => { buildCommMap(targetName) } case None => { //target_name is missing from the kernel message so return all comms over every target - commStorage.getTargets().map(buildCommMap(_)).reduce(_ ++ _) + commStorage.getTargets().map(buildCommMap(_)) } } val commInfoReply = CommInfoReply(commMap.asInstanceOf[Map[String, Map[String, String]]]) diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommMsgHandler.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommMsgHandler.scala index 37e958961..be3d37bfe 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommMsgHandler.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommMsgHandler.scala @@ -78,7 +78,7 @@ class CommMsgHandler( } } - private def handleParseError(invalid: Seq[(JsPath, Seq[JsonValidationError])]) = { + private def handleParseError(invalid: collection.Seq[(JsPath, collection.Seq[JsonValidationError])]) = { // TODO: Determine proper response for a parse failure logger.warn("Parse error for Comm Msg! Not responding!") } diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommOpenHandler.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommOpenHandler.scala index 6590eefaf..60d02889b 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommOpenHandler.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/CommOpenHandler.scala @@ -82,7 +82,7 @@ class CommOpenHandler( } } - private def handleParseError(invalid: Seq[(JsPath, Seq[JsonValidationError])]) = { + private def handleParseError(invalid: collection.Seq[(JsPath, collection.Seq[JsonValidationError])]) = { // TODO: Determine proper response for a parse failure logger.warn("Parse error for Comm Open! Not responding!") } diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/ExecuteRequestHandler.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/ExecuteRequestHandler.scala index 30b88ea67..5fa2ab184 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/ExecuteRequestHandler.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/ExecuteRequestHandler.scala @@ -131,7 +131,7 @@ class ExecuteRequestHandler( } } - def parseErrorHandler(invalid: Seq[(JsPath, Seq[JsonValidationError])]) = { + def parseErrorHandler(invalid: collection.Seq[(JsPath, collection.Seq[JsonValidationError])]) = { val errs = invalid.map (e => s"JSPath ${e._1} has error ${e._2}").toList logger.error(s"Validation errors when parsing ExecuteRequest: ${errs}") val replyError: ExecuteReply = ExecuteReplyError( @@ -161,7 +161,7 @@ class ExecuteRequestHandler( */ def relayErrorMessages(relayActor: ActorSelection, replyError: ExecuteReply, - skeletonBuilder: KMBuilder) { + skeletonBuilder: KMBuilder): Unit = { val executeReplyMsg = skeletonBuilder .withHeader(MessageType.Outgoing.ExecuteReply) .withMetadata(Metadata("status" -> replyError.status)) diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/InputRequestReplyHandler.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/InputRequestReplyHandler.scala index 220e452e2..4211ba95e 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/InputRequestReplyHandler.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/InputRequestReplyHandler.scala @@ -53,7 +53,7 @@ class InputRequestReplyHandler( // Is this an outgoing message to request data? if (kernelMessageType == inputRequestType) { val session = kernelMessage.parentHeader.session - responseMap(session) = sender + responseMap(session) = sender() logger.debug("Associating input request with session " + session) diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/InterpreterActor.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/InterpreterActor.scala index cde9ffe56..33b722a06 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/InterpreterActor.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/InterpreterActor.scala @@ -63,7 +63,7 @@ class InterpreterActor( /** * Initializes all child actors performing tasks for the interpreter. */ - override def preStart = { + override def preStart() = { executeRequestTask = interpreterTaskFactory.ExecuteRequestTask( context, InterpreterChildActorType.ExecuteRequestTask.toString) completeCodeTask = interpreterTaskFactory.CodeCompleteTask( @@ -85,7 +85,7 @@ class InterpreterActor( ex.getLocalizedMessage, ex.getStackTrace.map(_.toString).toList) ) - } pipeTo sender + } pipeTo sender() case (completeRequest: CompleteRequest) => logger.debug(s"InterpreterActor requesting code completion for code " + s"${completeRequest.code}") @@ -98,7 +98,7 @@ class InterpreterActor( ex.getLocalizedMessage, ex.getStackTrace.map(_.toString).toList) ) - } pipeTo sender + } pipeTo sender() case (isCompleteRequest: IsCompleteRequest) => logger.debug(s"InterpreterActor requesting is complete code ${isCompleteRequest.code}") (isCompleteTask ? isCompleteRequest) recover { @@ -106,6 +106,6 @@ class InterpreterActor( logger.warn(s"Could not determine completeness for code ${isCompleteRequest.code}: " + s"${ex.getMessage}") Left(IsCompleteReply("unknown", "")) - } pipeTo sender + } pipeTo sender() } } diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/CodeCompleteTaskActor.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/CodeCompleteTaskActor.scala index 92278391f..8b479059b 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/CodeCompleteTaskActor.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/CodeCompleteTaskActor.scala @@ -34,8 +34,8 @@ class CodeCompleteTaskActor(interpreter: Interpreter) override def receive: Receive = { case completeRequest: CompleteRequest => logger.debug("Invoking the interpreter completion") - sender ! interpreter.completion(completeRequest.code, completeRequest.cursor_pos) + sender() ! interpreter.completion(completeRequest.code, completeRequest.cursor_pos) case _ => - sender ! "Unknown message" // TODO: Provide a failure message type to be passed around? + sender() ! "Unknown message" // TODO: Provide a failure message type to be passed around? } } diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/ExecuteRequestTaskActor.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/ExecuteRequestTaskActor.scala index 9fd6b26f2..b101641c5 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/ExecuteRequestTaskActor.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/ExecuteRequestTaskActor.scala @@ -82,25 +82,25 @@ class ExecuteRequestTaskActor(interpreter: Interpreter) extends Actor with LogLi logger.debug(s"Interpreter execution result was ${success}") success match { case Results.Success => - val output = result.left.get - sender ! Left(output) + val output = result.swap.toOption.get + sender() ! Left(output) case Results.Error => - val error = result.right.get - sender ! Right(error) + val error = result.toOption.get + sender() ! Right(error) case Results.Aborted => - sender ! Right(new ExecuteAborted) + sender() ! Right(new ExecuteAborted) case Results.Incomplete => // If we get an incomplete it's most likely a syntax error, so // let the user know. - sender ! Right(new ExecuteError("Syntax Error.", "", List())) + sender() ! Right(new ExecuteError("Syntax Error.", "", List())) } } else { // If we get empty code from a cell then just return ExecuteReplyOk - sender ! Left("") + sender() ! Left("") } case unknownValue => logger.warn(s"Received unknown message type ${unknownValue}") - sender ! "Unknown message" // TODO: Provide a failure message type to be passed around? + sender() ! "Unknown message" // TODO: Provide a failure message type to be passed around? } private def buildOutputStream( diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/IsCompleteTaskActor.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/IsCompleteTaskActor.scala index 8cd698741..327fd9a9a 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/IsCompleteTaskActor.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/IsCompleteTaskActor.scala @@ -34,8 +34,8 @@ class IsCompleteTaskActor(interpreter: Interpreter) override def receive: Receive = { case req: IsCompleteRequest => logger.debug("Invoking the interpreter completion") - sender ! interpreter.isComplete(req.code) + sender() ! interpreter.isComplete(req.code) case _ => - sender ! "Unknown message" // TODO: Provide a failure message type to be passed around? + sender() ! "Unknown message" // TODO: Provide a failure message type to be passed around? } } diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/kernel/Utilities.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/kernel/Utilities.scala index 3df983037..0d4a7c681 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/kernel/Utilities.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/kernel/Utilities.scala @@ -77,21 +77,21 @@ object Utilities extends LogLike { } implicit def KernelMessageToZMQMessage(kernelMessage : KernelMessage) : ZMQMessage = { - val frames: scala.collection.mutable.ListBuffer[ByteString] = scala.collection.mutable.ListBuffer() - kernelMessage.ids.map((id : Array[Byte]) => frames += ByteString.apply(id) ) - frames += "" - frames += kernelMessage.signature - frames += Json.toJson(kernelMessage.header).toString() - frames += Json.toJson(kernelMessage.parentHeader).toString() - frames += Json.toJson(kernelMessage.metadata).toString - frames += kernelMessage.contentString + var frames: Seq[ByteString] = Seq() + kernelMessage.ids.map((id : Array[Byte]) => frames = frames :+ ByteString.apply(id) ) + frames = frames :+ "" + frames = frames :+ kernelMessage.signature + frames = frames :+ Json.toJson(kernelMessage.header).toString() + frames = frames :+ Json.toJson(kernelMessage.parentHeader).toString() + frames = frames :+ Json.toJson(kernelMessage.metadata).toString + frames = frames :+ kernelMessage.contentString ZMQMessage(frames : _*) } def parseAndHandle[T, U](json: String, reads: Reads[T], handler: T => U) : U = { parseAndHandle(json, reads, handler, - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => { + (invalid: collection.Seq[(JsPath, collection.Seq[JsonValidationError])]) => { logger.error(s"Could not parse JSON, ${json}") throw new Throwable(s"Could not parse JSON, ${json}") } @@ -100,7 +100,7 @@ object Utilities extends LogLike { def parseAndHandle[T, U](json: String, reads: Reads[T], handler: T => U, - errHandler: Seq[(JsPath, Seq[JsonValidationError])] => U) : U = { + errHandler: collection.Seq[(JsPath, collection.Seq[JsonValidationError])] => U) : U = { Json.parse(json).validate[T](reads).fold( errHandler, (content: T) => handler(content) diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/relay/ExecuteRequestRelay.scala b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/relay/ExecuteRequestRelay.scala index 4e87cf465..d6d9fce39 100644 --- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/relay/ExecuteRequestRelay.scala +++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/relay/ExecuteRequestRelay.scala @@ -75,13 +75,13 @@ case class ExecuteRequestRelay( future: Future[Either[ExecuteOutput, ExecuteFailure]] ): Future[(ExecuteReply, ExecuteResult)] = future.map { value => if (value.isLeft) { - val data = value.left.get + val data = value.swap.toOption.get ( ExecuteReplyOk(1, Some(Payloads()), Some(UserExpressions())), ExecuteResult(1, data, Metadata()) ) } else { - failureMatch(value.right.get) + failureMatch(value.toOption.get) } } diff --git a/kernel/src/main/scala/org/apache/toree/magic/builtin/AddDeps.scala b/kernel/src/main/scala/org/apache/toree/magic/builtin/AddDeps.scala index 913d64e2c..eb0112760 100644 --- a/kernel/src/main/scala/org/apache/toree/magic/builtin/AddDeps.scala +++ b/kernel/src/main/scala/org/apache/toree/magic/builtin/AddDeps.scala @@ -91,7 +91,7 @@ class AddDeps extends LineMagic with IncludeInterpreter } else { (x, "*") } - }: (String, String)).toSet + }: (String, String)).to(collection.Set) val repositoriesWithCreds = dependencyDownloader.resolveRepositoriesAndCredentials(repository, credentials) @@ -112,7 +112,7 @@ class AddDeps extends LineMagic with IncludeInterpreter ) // pass the new Jars to the kernel - kernel.addJars(uris.filter(_.getPath.endsWith(".jar")): _*) + kernel.addJars(uris.filter(_.getPath.endsWith(".jar")).toSeq: _*) } else { printHelp(printStream, """%AddDeps my.company artifact-id version""") } diff --git a/kernel/src/main/scala/org/apache/toree/magic/builtin/BuiltinLoader.scala b/kernel/src/main/scala/org/apache/toree/magic/builtin/BuiltinLoader.scala index 927ed444a..0c8f63ea6 100644 --- a/kernel/src/main/scala/org/apache/toree/magic/builtin/BuiltinLoader.scala +++ b/kernel/src/main/scala/org/apache/toree/magic/builtin/BuiltinLoader.scala @@ -21,7 +21,7 @@ import com.google.common.reflect.ClassPath import com.google.common.reflect.ClassPath.ClassInfo import org.apache.toree.magic.InternalClassLoader import com.google.common.base.Strings._ -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ /** * Represents a class loader that loads classes from the builtin package. diff --git a/kernel/src/main/scala/org/apache/toree/magic/builtin/Dataframe.scala b/kernel/src/main/scala/org/apache/toree/magic/builtin/Dataframe.scala index 3f00f820a..bf51390ba 100644 --- a/kernel/src/main/scala/org/apache/toree/magic/builtin/Dataframe.scala +++ b/kernel/src/main/scala/org/apache/toree/magic/builtin/Dataframe.scala @@ -84,7 +84,7 @@ class DataFrame extends CellMagic with IncludeKernelInterpreter } private def outputTypeToMimeType(): String = { - outputTypeMap.getOrElse(outputType, MIMEType.PlainText) + outputTypeMap.getOrElse(outputType(), MIMEType.PlainText) } private def convertToJson(rddCode: String): CellMagicOutput = { @@ -95,20 +95,20 @@ class DataFrame extends CellMagic with IncludeKernelInterpreter kernelInterpreter.read(rddVarName).map(variableVal => { _dataFrameConverter.convert( variableVal.asInstanceOf[org.apache.spark.sql.DataFrame], - outputType, - limit + outputType(), + limit() ).map(output => - CellMagicOutput(outputTypeToMimeType -> output) + CellMagicOutput(outputTypeToMimeType() -> output) ).get }).getOrElse(CellMagicOutput(MIMEType.PlainText -> DataFrameResponses.NoVariableFound(rddVarName))) case Results.Aborted => - logger.error(DataFrameResponses.ErrorMessage(outputType, DataFrameResponses.MagicAborted)) + logger.error(DataFrameResponses.ErrorMessage(outputType(), DataFrameResponses.MagicAborted)) CellMagicOutput( - MIMEType.PlainText -> DataFrameResponses.ErrorMessage(outputType, DataFrameResponses.MagicAborted) + MIMEType.PlainText -> DataFrameResponses.ErrorMessage(outputType(), DataFrameResponses.MagicAborted) ) case Results.Error => - val error = message.right.get.asInstanceOf[ExecuteError] - val errorMessage = DataFrameResponses.ErrorMessage(outputType, error.value) + val error = message.toOption.get.asInstanceOf[ExecuteError] + val errorMessage = DataFrameResponses.ErrorMessage(outputType(), error.value) logger.error(errorMessage) CellMagicOutput(MIMEType.PlainText -> errorMessage) case Results.Incomplete => diff --git a/kernel/src/test/scala/integration/InterpreterActorSpecForIntegration.scala b/kernel/src/test/scala/integration/InterpreterActorSpecForIntegration.scala index 159cbb427..401856a9a 100644 --- a/kernel/src/test/scala/integration/InterpreterActorSpecForIntegration.scala +++ b/kernel/src/test/scala/integration/InterpreterActorSpecForIntegration.scala @@ -32,7 +32,9 @@ import org.apache.toree.kernel.protocol.v5.interpreter.tasks.InterpreterTaskFact import com.typesafe.config.ConfigFactory import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfter import test.utils.UncaughtExceptionSuppression import test.utils.MaxAkkaTestTimeout @@ -49,7 +51,7 @@ class InterpreterActorSpecForIntegration extends TestKit( ConfigFactory.parseString(InterpreterActorSpecForIntegration.config), Main.getClass.getClassLoader ) -) with ImplicitSender with FunSpecLike with Matchers with BeforeAndAfter +) with ImplicitSender with FunSpecLike with Matchers with BeforeAndAfterEach with MockitoSugar with UncaughtExceptionSuppression { private val output = new ByteArrayOutputStream() diff --git a/kernel/src/test/scala/org/apache/toree/boot/CommandLineOptionsSpec.scala b/kernel/src/test/scala/org/apache/toree/boot/CommandLineOptionsSpec.scala index 2ec702098..4d85e15a2 100644 --- a/kernel/src/test/scala/org/apache/toree/boot/CommandLineOptionsSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/boot/CommandLineOptionsSpec.scala @@ -21,11 +21,12 @@ import java.io.File import com.typesafe.config.Config import joptsimple.OptionException -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ -class CommandLineOptionsSpec extends FunSpec with Matchers { +class CommandLineOptionsSpec extends AnyFunSpec with Matchers { describe("CommandLineOptions") { describe("when received --max-interpreter-threads=") { diff --git a/kernel/src/test/scala/org/apache/toree/comm/KernelCommManagerSpec.scala b/kernel/src/test/scala/org/apache/toree/comm/KernelCommManagerSpec.scala index 3d2c2a012..c8b54c392 100644 --- a/kernel/src/test/scala/org/apache/toree/comm/KernelCommManagerSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/comm/KernelCommManagerSpec.scala @@ -23,10 +23,12 @@ import org.apache.toree.kernel.protocol.v5.content.CommContent import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import org.scalatestplus.mockito.MockitoSugar import org.mockito.Mockito._ -import org.mockito.Matchers._ -import org.scalatest.{BeforeAndAfter, FunSpec, Matchers} +import org.mockito.ArgumentMatchers._ +import org.scalatest.BeforeAndAfter +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class KernelCommManagerSpec extends FunSpec with Matchers with BeforeAndAfter +class KernelCommManagerSpec extends AnyFunSpec with Matchers with BeforeAndAfterEach with MockitoSugar { private val TestTargetName = "some target" diff --git a/kernel/src/test/scala/org/apache/toree/comm/KernelCommWriterSpec.scala b/kernel/src/test/scala/org/apache/toree/comm/KernelCommWriterSpec.scala index ce81bef8a..d9685d383 100644 --- a/kernel/src/test/scala/org/apache/toree/comm/KernelCommWriterSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/comm/KernelCommWriterSpec.scala @@ -27,9 +27,10 @@ import akka.actor.{ActorSelection, ActorSystem} import akka.testkit.{TestProbe, TestKit} import com.typesafe.config.ConfigFactory import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ object KernelCommWriterSpec { val config =""" @@ -43,7 +44,7 @@ class KernelCommWriterSpec extends TestKit( ConfigFactory.parseString(KernelCommWriterSpec.config), org.apache.toree.Main.getClass.getClassLoader ) -) with FunSpecLike with Matchers with BeforeAndAfter with MockitoSugar +) with FunSpecLike with Matchers with BeforeAndAfterEach with MockitoSugar { private val commId = UUID.randomUUID().toString diff --git a/kernel/src/test/scala/org/apache/toree/global/ExecutionCounterSpec.scala b/kernel/src/test/scala/org/apache/toree/global/ExecutionCounterSpec.scala index e22c7840c..3507124ff 100644 --- a/kernel/src/test/scala/org/apache/toree/global/ExecutionCounterSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/global/ExecutionCounterSpec.scala @@ -17,9 +17,10 @@ package org.apache.toree.global -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class ExecutionCounterSpec extends FunSpec with Matchers { +class ExecutionCounterSpec extends AnyFunSpec with Matchers { describe("ExecutionCounter") { describe("#increment( String )"){ it("should increment value when key is not present"){ diff --git a/kernel/src/test/scala/org/apache/toree/kernel/api/DisplayMethodsSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/api/DisplayMethodsSpec.scala index c3ded29c4..fee2ceb63 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/api/DisplayMethodsSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/api/DisplayMethodsSpec.scala @@ -23,7 +23,9 @@ import org.apache.toree.kernel.protocol.v5 import org.apache.toree.kernel.protocol.v5.KernelMessage import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfter import play.api.libs.json.Json import test.utils.MaxAkkaTestTimeout @@ -33,7 +35,7 @@ class DisplayMethodsSpec extends TestKit( None, Some(org.apache.toree.Main.getClass.getClassLoader) )) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar - with BeforeAndAfter + with BeforeAndAfterEach { diff --git a/kernel/src/test/scala/org/apache/toree/kernel/api/KernelSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/api/KernelSpec.scala index da953d93e..bbec6d30a 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/api/KernelSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/api/KernelSpec.scala @@ -31,10 +31,12 @@ import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import org.apache.toree.plugins.PluginManager import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpec, Matchers} +import org.scalatest.BeforeAndAfter +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class KernelSpec extends FunSpec with Matchers with MockitoSugar - with BeforeAndAfter +class KernelSpec extends AnyFunSpec with Matchers with MockitoSugar + with BeforeAndAfterEach { private val BadCode = Some("abc foo bar") private val GoodCode = Some("val foo = 1") diff --git a/kernel/src/test/scala/org/apache/toree/kernel/api/StreamMethodsSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/api/StreamMethodsSpec.scala index 9aec97d10..41b698fab 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/api/StreamMethodsSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/api/StreamMethodsSpec.scala @@ -22,7 +22,9 @@ import akka.testkit.{ImplicitSender, TestKit, TestProbe} import org.apache.toree.kernel.protocol.v5 import org.apache.toree.kernel.protocol.v5.KernelMessage import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpecLike, BeforeAndAfter, Matchers} +import org.scalatest.BeforeAndAfter +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.Json import test.utils.MaxAkkaTestTimeout import org.mockito.Mockito._ @@ -34,7 +36,7 @@ class StreamMethodsSpec extends TestKit( Some(org.apache.toree.Main.getClass.getClassLoader) ) ) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar - with BeforeAndAfter + with BeforeAndAfterEach { private var kernelMessageRelayProbe: TestProbe = _ diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/dispatch/StatusDispatchSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/dispatch/StatusDispatchSpec.scala index ebc3574bb..06b6d623f 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/dispatch/StatusDispatchSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/dispatch/StatusDispatchSpec.scala @@ -24,7 +24,9 @@ import org.apache.toree.kernel.protocol.v5.content.KernelStatus import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfter import play.api.libs.json.Json import test.utils.MaxAkkaTestTimeout @@ -35,7 +37,7 @@ class StatusDispatchSpec extends TestKit( Some(org.apache.toree.Main.getClass.getClassLoader) ) ) -with FunSpecLike with Matchers with MockitoSugar with BeforeAndAfter{ +with FunSpecLike with Matchers with MockitoSugar with BeforeAndAfterEach{ var statusDispatchRef: ActorRef = _ var relayProbe: TestProbe = _ before { diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CodeCompleteHandlerSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CodeCompleteHandlerSpec.scala index 8bfe70a66..c7c893ec7 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CodeCompleteHandlerSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CodeCompleteHandlerSpec.scala @@ -25,14 +25,16 @@ import org.apache.toree.kernel.protocol.v5.content.CompleteRequest import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import org.apache.toree.kernel.protocol.v5Test._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpecLike, BeforeAndAfter, Matchers} +import org.scalatest.BeforeAndAfter +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.mockito.Mockito._ import test.utils.MaxAkkaTestTimeout class CodeCompleteHandlerSpec extends TestKit( ActorSystem("CodeCompleteHandlerSpec", None, Some(Main.getClass.getClassLoader)) ) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar - with BeforeAndAfter { + with BeforeAndAfterEach { var actorLoader: ActorLoader = _ var handlerActor: ActorRef = _ diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommCloseHandlerSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommCloseHandlerSpec.scala index b39a0cea9..1421fe9fa 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommCloseHandlerSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommCloseHandlerSpec.scala @@ -27,9 +27,11 @@ import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import org.apache.toree.kernel.protocol.v5.{KernelMessage, SystemActorType, KMBuilder} import org.apache.toree.comm.{CommRegistrar, CommWriter, CommCallbacks, CommStorage} import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfter import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import test.utils.MaxAkkaTestTimeout class CommCloseHandlerSpec extends TestKit( @@ -39,7 +41,7 @@ class CommCloseHandlerSpec extends TestKit( Some(org.apache.toree.Main.getClass.getClassLoader) ) ) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar - with BeforeAndAfter + with BeforeAndAfterEach { private val TestCommId = UUID.randomUUID().toString private var kmBuilder: KMBuilder = _ diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommInfoRequestHandlerSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommInfoRequestHandlerSpec.scala index 87bbe8cf6..717b86c5b 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommInfoRequestHandlerSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommInfoRequestHandlerSpec.scala @@ -25,10 +25,11 @@ import org.apache.toree.kernel.protocol.v5.content.CommInfoReply import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import org.apache.toree.kernel.protocol.v5.{Header, KernelMessage, Metadata, SystemActorType} import org.mockito.AdditionalMatchers.{not => mockNot} -import org.mockito.Matchers.{eq => mockEq} +import org.mockito.ArgumentMatchers.{eq => mockEq, _} import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.Json import scala.concurrent.duration._ diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommMsgHandlerSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommMsgHandlerSpec.scala index ac6db5223..e67fd9e6b 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommMsgHandlerSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommMsgHandlerSpec.scala @@ -26,16 +26,18 @@ import org.apache.toree.kernel.protocol.v5._ import org.apache.toree.comm._ import org.apache.toree.kernel.protocol.v5.content.{CommMsg, ClearOutput} import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfter import test.utils.MaxAkkaTestTimeout class CommMsgHandlerSpec extends TestKit( ActorSystem("CommMsgHandlerSpec", None, Some(Main.getClass.getClassLoader)) ) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar - with BeforeAndAfter + with BeforeAndAfterEach { private val TestCommId = UUID.randomUUID().toString diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommOpenHandlerSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommOpenHandlerSpec.scala index ba74458d9..28c008fd2 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommOpenHandlerSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/CommOpenHandlerSpec.scala @@ -29,15 +29,17 @@ import org.apache.toree.kernel.protocol.v5._ import org.apache.toree.comm._ import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfter import test.utils.MaxAkkaTestTimeout class CommOpenHandlerSpec extends TestKit( ActorSystem("CommOpenHandlerSpec", None, Some(Main.getClass.getClassLoader)) ) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar - with BeforeAndAfter + with BeforeAndAfterEach { private val TestCommId = UUID.randomUUID().toString private val TestTargetName = "some test target" diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/ExecuteRequestHandlerSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/ExecuteRequestHandlerSpec.scala index 6e6554b9a..baa47ecd5 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/ExecuteRequestHandlerSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/ExecuteRequestHandlerSpec.scala @@ -28,11 +28,13 @@ import org.apache.toree.kernel.protocol.v5.content._ import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import org.apache.toree.kernel.protocol.v5Test._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfter import play.api.libs.json.Json import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import scala.concurrent.duration._ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent._ @@ -44,7 +46,7 @@ class ExecuteRequestHandlerSpec extends TestKit( Some(org.apache.toree.Main.getClass.getClassLoader) ) ) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar - with BeforeAndAfter { + with BeforeAndAfterEach { private var mockActorLoader: ActorLoader = _ private var mockFactoryMethods: FactoryMethods = _ diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/GenericSocketMessageHandlerSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/GenericSocketMessageHandlerSpec.scala index cfaa07864..ecb46a67d 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/GenericSocketMessageHandlerSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/GenericSocketMessageHandlerSpec.scala @@ -24,7 +24,8 @@ import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import org.apache.toree.kernel.protocol.v5Test._ import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{Matchers, FunSpecLike} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import test.utils.MaxAkkaTestTimeout class GenericSocketMessageHandlerSpec extends TestKit( diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/InputRequestReplyHandlerSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/InputRequestReplyHandlerSpec.scala index bf245d514..05d1526e6 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/InputRequestReplyHandlerSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/InputRequestReplyHandlerSpec.scala @@ -28,7 +28,9 @@ import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import org.scalatest.concurrent.Eventually import org.scalatestplus.mockito.MockitoSugar import org.scalatest.time.{Milliseconds, Span} -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfter import test.utils.MaxAkkaTestTimeout import org.mockito.Mockito._ @@ -37,7 +39,7 @@ import collection.JavaConverters._ class InputRequestReplyHandlerSpec extends TestKit(ActorSystem("InputRequestReplyHandlerSystem", None, Some(Main.getClass.getClassLoader))) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar - with BeforeAndAfter with Eventually + with BeforeAndAfterEach with Eventually { implicit override val patienceConfig = PatienceConfig( timeout = scaled(Span(200, Milliseconds)), diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandlerSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandlerSpec.scala index 318ade0e0..1ef817748 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandlerSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandlerSpec.scala @@ -23,11 +23,12 @@ import org.apache.toree.kernel.protocol.v5.content.KernelInfoReply import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import org.apache.toree.kernel.protocol.v5._ import org.mockito.AdditionalMatchers.{not => mockNot} -import org.mockito.Matchers.{eq => mockEq} +import org.mockito.ArgumentMatchers.{eq => mockEq, _} import com.typesafe.config.ConfigFactory import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.Json import test.utils.MaxAkkaTestTimeout diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/ExecuteRequestTaskActorSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/ExecuteRequestTaskActorSpec.scala index 278be0cec..f798790d6 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/ExecuteRequestTaskActorSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/interpreter/tasks/ExecuteRequestTaskActorSpec.scala @@ -25,10 +25,11 @@ import com.typesafe.config.ConfigFactory import org.apache.toree.interpreter._ import org.apache.toree.kernel.protocol.v5._ import org.apache.toree.kernel.protocol.v5.content._ -import org.mockito.Matchers.{anyBoolean, anyString, anyObject} +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import test.utils.MaxAkkaTestTimeout object ExecuteRequestTaskActorSpec { diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/ActorLoaderSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/ActorLoaderSpec.scala index 44a53b75b..08845d0af 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/ActorLoaderSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/ActorLoaderSpec.scala @@ -21,7 +21,8 @@ import akka.actor.{ActorSystem, Props} import akka.testkit.{ImplicitSender, TestKit, TestProbe} import org.apache.toree.kernel.protocol.v5.{MessageType, SocketType} import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import test.utils.TestProbeProxyActor import test.utils.MaxAkkaTestTimeout diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/SimpleActorLoaderSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/SimpleActorLoaderSpec.scala index 28b57e638..47e7c53b3 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/SimpleActorLoaderSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/SimpleActorLoaderSpec.scala @@ -20,7 +20,8 @@ package org.apache.toree.kernel.protocol.v5.kernel import akka.actor.{ActorSelection, ActorSystem, Props} import akka.testkit.{TestKit, TestProbe} import org.apache.toree.kernel.protocol.v5.MessageType -import org.scalatest.{FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import test.utils.TestProbeProxyActor import test.utils.MaxAkkaTestTimeout diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/UtilitiesSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/UtilitiesSpec.scala index cfae79bc1..b9f728d0c 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/UtilitiesSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/UtilitiesSpec.scala @@ -20,12 +20,13 @@ package org.apache.toree.kernel.protocol.v5.kernel import akka.util.ByteString import org.apache.toree.communication.ZMQMessage import org.apache.toree.kernel.protocol.v5._ -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers /** * Refactored from old KernelMessageSpec. */ -class UtilitiesSpec extends FunSpec with Matchers { +class UtilitiesSpec extends AnyFunSpec with Matchers { val header: Header = Header( "", "", "", "", "" ) diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/HeartbeatSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/HeartbeatSpec.scala index 09d24f8e0..15e7a87cb 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/HeartbeatSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/HeartbeatSpec.scala @@ -22,7 +22,7 @@ import akka.testkit.{ImplicitSender, TestKit, TestProbe} import akka.util.ByteString import org.apache.toree.communication.ZMQMessage import com.typesafe.config.ConfigFactory -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar import org.scalatest.{FunSpecLike, Matchers} diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/IOPubSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/IOPubSpec.scala index 2fa56e59f..1a6d63d35 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/IOPubSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/IOPubSpec.scala @@ -24,10 +24,11 @@ import org.apache.toree.kernel.protocol.v5.kernel.Utilities import org.apache.toree.kernel.protocol.v5Test._ import Utilities._ import com.typesafe.config.ConfigFactory -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import test.utils.MaxAkkaTestTimeout object IOPubSpec { diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/ShellSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/ShellSpec.scala index e62d41ee8..7676d2973 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/ShellSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/ShellSpec.scala @@ -28,10 +28,11 @@ import org.apache.toree.kernel.protocol.v5.kernel.{ActorLoader, Utilities} import org.apache.toree.kernel.protocol.v5Test._ import Utilities._ import com.typesafe.config.ConfigFactory -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import test.utils.MaxAkkaTestTimeout object ShellSpec { diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/SocketConfigSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/SocketConfigSpec.scala index 3af75f657..f276ed130 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/SocketConfigSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/SocketConfigSpec.scala @@ -18,12 +18,13 @@ package org.apache.toree.kernel.protocol.v5.kernel.socket import com.typesafe.config.ConfigFactory -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.slf4j.LoggerFactory import play.api.libs.json.JsonValidationError import play.api.libs.json.{JsPath, JsValue, Json} -class SocketConfigSpec extends FunSpec with Matchers { +class SocketConfigSpec extends AnyFunSpec with Matchers { val logger = LoggerFactory.getLogger("jt4") //logger.error("WOOT!") diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/SocketConnectionSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/SocketConnectionSpec.scala index 9b2d2508d..6dd1b5f9b 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/SocketConnectionSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/SocketConnectionSpec.scala @@ -17,9 +17,10 @@ package org.apache.toree.kernel.protocol.v5.kernel.socket -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class SocketConnectionSpec extends FunSpec with Matchers { +class SocketConnectionSpec extends AnyFunSpec with Matchers { describe("SocketConnection"){ describe("#toString"){ it("should properly format connection string"){ diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/SocketFactorySpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/SocketFactorySpec.scala index b60b29839..b5d83aab9 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/SocketFactorySpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/SocketFactorySpec.scala @@ -17,9 +17,10 @@ package org.apache.toree.kernel.protocol.v5.kernel.socket -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class SocketFactorySpec extends FunSpec with Matchers { +class SocketFactorySpec extends AnyFunSpec with Matchers { describe("SocketFactory"){ describe("HeartbeatConnection"){ it("should be composed of transport ip and heartbeat port"){ diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/StdinSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/StdinSpec.scala index cb15ec099..10949422f 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/StdinSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/kernel/socket/StdinSpec.scala @@ -29,9 +29,10 @@ import org.apache.toree.kernel.protocol.v5.{KernelMessage, SystemActorType} import org.apache.toree.kernel.protocol.v5.kernel.ActorLoader import com.typesafe.config.ConfigFactory import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{Matchers, FunSpecLike} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import test.utils.MaxAkkaTestTimeout object StdinSpec { diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/magic/MagicParserSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/magic/MagicParserSpec.scala index 2cbde5f5d..d9245882e 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/magic/MagicParserSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/magic/MagicParserSpec.scala @@ -19,11 +19,12 @@ package org.apache.toree.kernel.protocol.v5.magic import org.apache.toree.magic.{CellMagic, Magic, MagicManager} import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ -class MagicParserSpec extends FunSpec with Matchers with MockitoSugar { +class MagicParserSpec extends AnyFunSpec with Matchers with MockitoSugar { describe("#parse") { it("should call parseCell if the code is a cell magic invocation") { val codeBlob = diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/relay/ExecuteRequestRelaySpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/relay/ExecuteRequestRelaySpec.scala index f52eb9e61..c65084c0c 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/relay/ExecuteRequestRelaySpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/relay/ExecuteRequestRelaySpec.scala @@ -31,7 +31,9 @@ import org.apache.toree.plugins.PluginManager import org.apache.toree.plugins.dependencies.DependencyManager import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfter import test.utils.MaxAkkaTestTimeout import scala.concurrent.duration.Duration @@ -49,7 +51,7 @@ class ExecuteRequestRelaySpec extends TestKit( org.apache.toree.Main.getClass.getClassLoader ) ) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar - with BeforeAndAfter + with BeforeAndAfterEach { var mockActorLoader: ActorLoader = _ var interpreterActorProbe: TestProbe = _ diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/relay/KernelMessageRelaySpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/relay/KernelMessageRelaySpec.scala index 08075a1f9..d161ba888 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/relay/KernelMessageRelaySpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/relay/KernelMessageRelaySpec.scala @@ -28,8 +28,10 @@ import org.mockito.Mockito._ import org.scalatest.concurrent.{PatienceConfiguration, ScalaFutures} import org.scalatestplus.mockito.MockitoSugar import org.scalatest.time.{Millis, Seconds, Span} -import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers} -import org.mockito.Matchers.{eq => mockEq} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.BeforeAndAfter +import org.mockito.ArgumentMatchers.{eq => mockEq, _} import org.mockito.AdditionalMatchers.{not => mockNot} import org.apache.toree.kernel.protocol.v5.KernelMessage import scala.concurrent._ @@ -46,7 +48,7 @@ class KernelMessageRelaySpec extends TestKit( ) ) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar - with BeforeAndAfter with ScalaFutures { + with BeforeAndAfterEach with ScalaFutures { private val IncomingMessageType = MessageType.Incoming.CompleteRequest.toString private val OutgoingMessageType = MessageType.Outgoing.CompleteReply.toString diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/stream/KernelInputStreamSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/stream/KernelInputStreamSpec.scala index 992522505..c3c6079c4 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/stream/KernelInputStreamSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/stream/KernelInputStreamSpec.scala @@ -31,7 +31,7 @@ import test.utils._ class KernelInputStreamSpec extends TestKit(ActorSystem("KernelInputStreamActorSystem", None, Some(Main.getClass.getClassLoader))) - with FunSpecLike with Matchers with GivenWhenThen with BeforeAndAfter + with FunSpecLike with Matchers with GivenWhenThen with BeforeAndAfterEach with MockitoSugar { diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/stream/KernelOuputStreamSpec.scala b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/stream/KernelOuputStreamSpec.scala index d669aa1d5..4e76a52ee 100644 --- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/stream/KernelOuputStreamSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/stream/KernelOuputStreamSpec.scala @@ -34,7 +34,7 @@ import test.utils.MaxAkkaTestTimeout class KernelOuputStreamSpec extends TestKit(ActorSystem("KernelOutputStreamActorSystem", None, Some(Main.getClass.getClassLoader))) - with FunSpecLike with Matchers with GivenWhenThen with BeforeAndAfter + with FunSpecLike with Matchers with GivenWhenThen with BeforeAndAfterEach with MockitoSugar { diff --git a/kernel/src/test/scala/org/apache/toree/magic/builtin/AddDepsSpec.scala b/kernel/src/test/scala/org/apache/toree/magic/builtin/AddDepsSpec.scala index c96f8d2a1..60a73412a 100644 --- a/kernel/src/test/scala/org/apache/toree/magic/builtin/AddDepsSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/magic/builtin/AddDepsSpec.scala @@ -23,13 +23,15 @@ import org.apache.toree.dependencies.{Credentials, DependencyDownloader} import org.apache.toree.utils.ArgumentParsingSupport import org.apache.toree.kernel.api.KernelLike import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpec, GivenWhenThen, Matchers} +import org.scalatest.GivenWhenThen +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.apache.toree.magic._ import org.apache.toree.magic.dependencies._ -class AddDepsSpec extends FunSpec with Matchers with MockitoSugar +class AddDepsSpec extends AnyFunSpec with Matchers with MockitoSugar with GivenWhenThen { describe("AddDeps"){ diff --git a/kernel/src/test/scala/org/apache/toree/magic/builtin/AddJarSpec.scala b/kernel/src/test/scala/org/apache/toree/magic/builtin/AddJarSpec.scala index 8117bcc5b..fc3eea8e6 100644 --- a/kernel/src/test/scala/org/apache/toree/magic/builtin/AddJarSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/magic/builtin/AddJarSpec.scala @@ -27,12 +27,13 @@ import com.typesafe.config.ConfigFactory import org.apache.spark.SparkContext import org.apache.toree.kernel.api.KernelLike import org.apache.toree.plugins.PluginManager -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.scalatestplus.mockito.MockitoSugar import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ -class AddJarSpec extends FunSpec with Matchers with MockitoSugar { +class AddJarSpec extends AnyFunSpec with Matchers with MockitoSugar { describe("AddJar"){ describe("#execute") { it("should call addJar on the provided kernel") { diff --git a/kernel/src/test/scala/org/apache/toree/magic/builtin/BuiltinLoaderSpec.scala b/kernel/src/test/scala/org/apache/toree/magic/builtin/BuiltinLoaderSpec.scala index b3192f1f1..7089a4c13 100644 --- a/kernel/src/test/scala/org/apache/toree/magic/builtin/BuiltinLoaderSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/magic/builtin/BuiltinLoaderSpec.scala @@ -18,9 +18,10 @@ package org.apache.toree.magic.builtin import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{Matchers, FunSpec} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class BuiltinLoaderSpec extends FunSpec with Matchers with MockitoSugar { +class BuiltinLoaderSpec extends AnyFunSpec with Matchers with MockitoSugar { describe("BuiltinLoader") { describe("#getClasses") { it("should return classes in a package") { diff --git a/kernel/src/test/scala/org/apache/toree/magic/builtin/DataFrameSpec.scala b/kernel/src/test/scala/org/apache/toree/magic/builtin/DataFrameSpec.scala index d3fdfdde1..7bbc515b2 100644 --- a/kernel/src/test/scala/org/apache/toree/magic/builtin/DataFrameSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/magic/builtin/DataFrameSpec.scala @@ -21,14 +21,16 @@ import org.apache.toree.interpreter._ import org.apache.toree.kernel.protocol.v5.MIMEType import org.apache.toree.magic.dependencies.IncludeKernelInterpreter import org.apache.toree.utils.DataFrameConverter -import org.mockito.Matchers.{anyString, eq => mockEq, _} +import org.mockito.ArgumentMatchers.{anyString, eq => mockEq, _} import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpec, Matchers} +import org.scalatest.BeforeAndAfter +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import scala.util.Success -class DataFrameSpec extends FunSpec with Matchers with MockitoSugar with BeforeAndAfter { +class DataFrameSpec extends AnyFunSpec with Matchers with MockitoSugar with BeforeAndAfterEach { def createMocks = { val interpreter = mock[Interpreter] diff --git a/kernel/src/test/scala/org/apache/toree/magic/builtin/HtmlSpec.scala b/kernel/src/test/scala/org/apache/toree/magic/builtin/HtmlSpec.scala index 5686ceba0..973839718 100644 --- a/kernel/src/test/scala/org/apache/toree/magic/builtin/HtmlSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/magic/builtin/HtmlSpec.scala @@ -20,9 +20,10 @@ package org.apache.toree.magic.builtin import org.apache.toree.kernel.protocol.v5.MIMEType import org.apache.toree.magic.CellMagicOutput import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class HtmlSpec extends FunSpec with Matchers with MockitoSugar { +class HtmlSpec extends AnyFunSpec with Matchers with MockitoSugar { describe("Html"){ describe("#execute") { it("should return the entire cell's contents with the MIME type of " + diff --git a/kernel/src/test/scala/org/apache/toree/magic/builtin/JavaScriptSpec.scala b/kernel/src/test/scala/org/apache/toree/magic/builtin/JavaScriptSpec.scala index 939ca61bb..1b3ad7091 100644 --- a/kernel/src/test/scala/org/apache/toree/magic/builtin/JavaScriptSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/magic/builtin/JavaScriptSpec.scala @@ -18,11 +18,12 @@ package org.apache.toree.magic.builtin import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.apache.toree.magic.CellMagicOutput import org.apache.toree.kernel.protocol.v5.MIMEType -class JavaScriptSpec extends FunSpec with Matchers with MockitoSugar { +class JavaScriptSpec extends AnyFunSpec with Matchers with MockitoSugar { describe("JavaScript"){ describe("#execute") { it("should return the entire cell's contents with the MIME type of text/javascript") { diff --git a/kernel/src/test/scala/org/apache/toree/magic/builtin/LSMagicSpec.scala b/kernel/src/test/scala/org/apache/toree/magic/builtin/LSMagicSpec.scala index 283659b23..67968dee5 100644 --- a/kernel/src/test/scala/org/apache/toree/magic/builtin/LSMagicSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/magic/builtin/LSMagicSpec.scala @@ -24,11 +24,12 @@ import org.apache.toree.interpreter.Interpreter import org.apache.toree.magic.dependencies.{IncludeOutputStream, IncludeInterpreter} import org.apache.toree.magic.{CellMagic, LineMagic} import org.apache.spark.SparkContext -import org.scalatest.{Matchers, FunSpec} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.scalatestplus.mockito.MockitoSugar import org.mockito.Mockito._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ class TestLSMagic(sc: SparkContext, intp: Interpreter, os: OutputStream) extends LSMagic @@ -39,7 +40,7 @@ class TestLSMagic(sc: SparkContext, intp: Interpreter, os: OutputStream) override val outputStream: OutputStream = os } -class LSMagicSpec extends FunSpec with Matchers with MockitoSugar { +class LSMagicSpec extends AnyFunSpec with Matchers with MockitoSugar { describe("LSMagic") { describe("#execute") { diff --git a/kernel/src/test/scala/org/apache/toree/utils/DataFrameConverterSpec.scala b/kernel/src/test/scala/org/apache/toree/utils/DataFrameConverterSpec.scala index eb5355adf..ae6f7156c 100644 --- a/kernel/src/test/scala/org/apache/toree/utils/DataFrameConverterSpec.scala +++ b/kernel/src/test/scala/org/apache/toree/utils/DataFrameConverterSpec.scala @@ -21,13 +21,15 @@ import org.apache.spark.sql.types.StructType import org.apache.spark.sql.{DataFrame, Row} import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterAll, FunSpec, Matchers} +import org.scalatest.BeforeAndAfterAll +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.{JsArray, JsDefined, JsString, JsValue, Json} import test.utils.SparkContextProvider import scala.collection.mutable -class DataFrameConverterSpec extends FunSpec with MockitoSugar with Matchers with BeforeAndAfterAll { +class DataFrameConverterSpec extends AnyFunSpec with MockitoSugar with Matchers with BeforeAndAfterAll { lazy val spark = SparkContextProvider.sparkContext diff --git a/macros/project/plugins.sbt b/macros/project/plugins.sbt index 982bb4ede..69d839d1c 100644 --- a/macros/project/plugins.sbt +++ b/macros/project/plugins.sbt @@ -16,4 +16,4 @@ */ resolvers += Resolver.sonatypeRepo("releases") -addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full) +addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full) diff --git a/plugins/build.sbt b/plugins/build.sbt index 88f9a4942..96a13b9f2 100644 --- a/plugins/build.sbt +++ b/plugins/build.sbt @@ -25,4 +25,9 @@ libraryDependencies ++= Seq( ) // Test dependencies -libraryDependencies += Dependencies.scalaCompiler.value % "test" +libraryDependencies ++= Seq( + Dependencies.scalaCompiler.value % "test", + Dependencies.mockitoSugar % "test", + Dependencies.mockitoScala % "test", + Dependencies.mockitoScalaScalaTest % "test" +) diff --git a/plugins/src/main/scala/org/apache/toree/plugins/Plugin.scala b/plugins/src/main/scala/org/apache/toree/plugins/Plugin.scala index 42f0eb82c..f933c13b2 100644 --- a/plugins/src/main/scala/org/apache/toree/plugins/Plugin.scala +++ b/plugins/src/main/scala/org/apache/toree/plugins/Plugin.scala @@ -70,31 +70,31 @@ trait Plugin { _internalPluginManager /** Represents all @init methods in the plugin. */ - @Internal private[plugins] final lazy val initMethods: Seq[PluginMethod] = { + @Internal private[plugins] final lazy val initMethods: collection.Seq[PluginMethod] = { allMethods.filter(_.isInit) } /** Represents all @destroy methods in the plugin. */ - @Internal private[plugins] final lazy val destroyMethods: Seq[PluginMethod] = { + @Internal private[plugins] final lazy val destroyMethods: collection.Seq[PluginMethod] = { allMethods.filter(_.isDestroy) } /** Represents all @event methods in the plugin. */ - @Internal private[plugins] final lazy val eventMethods: Seq[PluginMethod] = { + @Internal private[plugins] final lazy val eventMethods: collection.Seq[PluginMethod] = { allMethods.filter(_.isEvent) } /** Represents all @events methods in the plugin. */ - @Internal private[plugins] final lazy val eventsMethods: Seq[PluginMethod] = { + @Internal private[plugins] final lazy val eventsMethods: collection.Seq[PluginMethod] = { allMethods.filter(_.isEvents) } /** Represents all public/protected methods contained by this plugin. */ - private final lazy val allMethods: Seq[PluginMethod] = + private final lazy val allMethods: collection.Seq[PluginMethod] = getClass.getMethods.map(PluginMethod.apply(this, _: Method)) /** Represents mapping of event names to associated plugin methods. */ - @Internal private[plugins] final lazy val eventMethodMap: Map[String, Seq[PluginMethod]] = { + @Internal private[plugins] final lazy val eventMethodMap: Map[String, collection.Seq[PluginMethod]] = { val allEventMethods = (eventMethods ++ eventsMethods).distinct val allEventNames = allEventMethods.flatMap(_.eventNames).distinct allEventNames.map(name => diff --git a/plugins/src/main/scala/org/apache/toree/plugins/PluginManager.scala b/plugins/src/main/scala/org/apache/toree/plugins/PluginManager.scala index 25deefed0..05a474722 100644 --- a/plugins/src/main/scala/org/apache/toree/plugins/PluginManager.scala +++ b/plugins/src/main/scala/org/apache/toree/plugins/PluginManager.scala @@ -21,7 +21,7 @@ import java.util.concurrent.ConcurrentHashMap import org.apache.toree.plugins.dependencies._ import org.slf4j.LoggerFactory -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.util.{Failure, Success, Try} /** @@ -76,7 +76,7 @@ class PluginManager( * * @return The collection of loaded plugins */ - def initialize(): Seq[Plugin] = { + def initialize(): collection.Seq[Plugin] = { val newPlugins = internalPlugins.flatMap(t => loadPlugin(t._1, t._2).toOption ).toSeq @@ -96,7 +96,7 @@ class PluginManager( // Search for plugins in our new paths, then add loaded plugins to list // NOTE: Iterator returned from plugin searcher, so avoid building a // large collection by performing all tasks together - @volatile var newPlugins = collection.mutable.Seq[Plugin]() + @volatile var newPlugins = collection.Seq[Plugin]() pluginSearcher.search(paths: _*).foreach(ci => { // Add valid path to class loader pluginClassLoader.addURL(ci.location.toURI.toURL) @@ -110,7 +110,7 @@ class PluginManager( // Load the plugin using the given name and class loadPlugin(ci.name, klass).foreach(newPlugins :+= _) }) - newPlugins + newPlugins.toSeq } /** @@ -162,7 +162,7 @@ class PluginManager( def initializePlugins( plugins: Seq[Plugin], scopedDependencyManager: DependencyManager = DependencyManager.Empty - ): Seq[PluginMethodResult] = { + ): collection.Seq[PluginMethodResult] = { val pluginMethods = plugins.flatMap(_.initMethods) val results = invokePluginMethods( pluginMethods, @@ -199,7 +199,7 @@ class PluginManager( plugins: Seq[Plugin], scopedDependencyManager: DependencyManager = DependencyManager.Empty, destroyOnFailure: Boolean = true - ): Seq[PluginMethodResult] = { + ): collection.Seq[PluginMethodResult] = { val pluginMethods = plugins.flatMap(_.destroyMethods) val results = invokePluginMethods( pluginMethods, @@ -278,7 +278,7 @@ class PluginManager( def fireEvent( eventName: String, scopedDependencies: Dependency[_ <: AnyRef]* - ): Seq[PluginMethodResult] = { + ): collection.Seq[PluginMethodResult] = { val dependencyManager = new DependencyManager scopedDependencies.foreach(d => dependencyManager.add(d)) fireEvent(eventName, dependencyManager) @@ -295,7 +295,7 @@ class PluginManager( def fireEvent( eventName: String, scopedDependencyManager: DependencyManager = DependencyManager.Empty - ): Seq[PluginMethodResult] = { + ): collection.Seq[PluginMethodResult] = { val methods = plugins.flatMap(_.eventMethodMap.getOrElse(eventName, Nil)) invokePluginMethods(methods.toSeq, scopedDependencyManager) @@ -313,9 +313,9 @@ class PluginManager( * @return The collection of results in order of priority */ private def invokePluginMethods( - pluginMethods: Seq[PluginMethod], + pluginMethods: collection.Seq[PluginMethod], scopedDependencyManager: DependencyManager - ): Seq[PluginMethodResult] = { + ): collection.Seq[PluginMethodResult] = { // Continue trying to invoke plugins until we finish them all or // we reach a state where no plugin can be completed val completedMethods = Array.ofDim[PluginMethodResult](pluginMethods.size) @@ -360,7 +360,7 @@ class PluginManager( * @param pluginMethods The collection of plugin methods to sort * @return The sorted plugin methods */ - private def prioritizePluginMethods(pluginMethods: Seq[PluginMethod]) = + private def prioritizePluginMethods(pluginMethods: collection.Seq[PluginMethod]) = pluginMethods .groupBy(_.priority) .flatMap(_._2.sortWith(_.plugin.priority > _.plugin.priority)) diff --git a/plugins/src/main/scala/org/apache/toree/plugins/PluginMethod.scala b/plugins/src/main/scala/org/apache/toree/plugins/PluginMethod.scala index 50aafe34b..9f07eaddd 100644 --- a/plugins/src/main/scala/org/apache/toree/plugins/PluginMethod.scala +++ b/plugins/src/main/scala/org/apache/toree/plugins/PluginMethod.scala @@ -34,7 +34,7 @@ case class PluginMethod( method: Method ) { /** Represents the collection of names of events this method supports. */ - lazy val eventNames: Seq[String] = { + lazy val eventNames: collection.Seq[String] = { Option(method.getAnnotation(classOf[Event])) .map(_.name()).map(Seq(_)).getOrElse(Nil) ++ Option(method.getAnnotation(classOf[Events])) @@ -110,11 +110,11 @@ case class PluginMethod( } } // Validate arguments - val arguments: Seq[AnyRef] = dependencies.map(_.value.asInstanceOf[AnyRef]) + val arguments: Seq[Object] = dependencies.map(_.value.asInstanceOf[Object]).toSeq // Invoke plugin method method.invoke(plugin, arguments: _*) - }).map(SuccessPluginMethodResult.apply(this, _: AnyRef)).recover { + }).map(SuccessPluginMethodResult.apply(this, _: Object)).recover { case i: InvocationTargetException => FailurePluginMethodResult(this, i.getTargetException) case throwable: Throwable => diff --git a/plugins/src/main/scala/org/apache/toree/plugins/PluginSearcher.scala b/plugins/src/main/scala/org/apache/toree/plugins/PluginSearcher.scala index b63545d24..9ed47058c 100644 --- a/plugins/src/main/scala/org/apache/toree/plugins/PluginSearcher.scala +++ b/plugins/src/main/scala/org/apache/toree/plugins/PluginSearcher.scala @@ -75,8 +75,8 @@ class PluginSearcher { s"Failed to load class info from classpath: ${classFinder.classpath.mkString(",")}", _: Throwable )) - val stream = tryStream.getOrElse(Stream.empty) - ClassFinder.classInfoMap(stream.toIterator) + val stream = tryStream.getOrElse(LazyList.empty) + ClassFinder.classInfoMap(stream.iterator) } /** @@ -105,7 +105,7 @@ class PluginSearcher { extraClasses: Map[String, ClassInfo] ): Iterator[ClassInfo] = { @tailrec def classMatches( - classesToCheck: Seq[ClassInfo] + classesToCheck: collection.Seq[ClassInfo] ): Boolean = { if (classesToCheck.isEmpty) false else if (classesToCheck.exists(_.name == ancestor)) true @@ -120,7 +120,7 @@ class PluginSearcher { } } - classes.values.toIterator + classes.values.iterator .filter(_.isConcrete) .filter(c => classMatches(Seq(c))) } diff --git a/plugins/src/main/scala/org/apache/toree/plugins/dependencies/DependencyManager.scala b/plugins/src/main/scala/org/apache/toree/plugins/dependencies/DependencyManager.scala index 6348cd22e..09278e0e7 100644 --- a/plugins/src/main/scala/org/apache/toree/plugins/dependencies/DependencyManager.scala +++ b/plugins/src/main/scala/org/apache/toree/plugins/dependencies/DependencyManager.scala @@ -17,7 +17,7 @@ package org.apache.toree.plugins.dependencies import java.util.concurrent.ConcurrentHashMap -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.reflect.runtime.universe.{Type, TypeTag} import scala.util.Try diff --git a/plugins/src/test/scala-2.13/org/apache/toree/plugins/dependencies/ClassLoaderHelper.scala b/plugins/src/test/scala-2.13/org/apache/toree/plugins/dependencies/ClassLoaderHelper.scala new file mode 100644 index 000000000..20e185659 --- /dev/null +++ b/plugins/src/test/scala-2.13/org/apache/toree/plugins/dependencies/ClassLoaderHelper.scala @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ +package org.apache.toree.plugins.dependencies + +import java.net.URL +import java.lang.{ClassLoader => JClassLoader} + +import scala.reflect.internal.util.ScalaClassLoader + +object ClassLoaderHelper { + + def URLClassLoader(urls: Seq[URL], parent: JClassLoader): ScalaClassLoader.URLClassLoader = { + new scala.reflect.internal.util.ScalaClassLoader.URLClassLoader(urls, parent) + } +} diff --git a/plugins/src/test/scala/integration/PluginManagerSpecForIntegration.scala b/plugins/src/test/scala/integration/PluginManagerSpecForIntegration.scala index c97e61aca..dfc3ce0f1 100644 --- a/plugins/src/test/scala/integration/PluginManagerSpecForIntegration.scala +++ b/plugins/src/test/scala/integration/PluginManagerSpecForIntegration.scala @@ -18,9 +18,11 @@ package integration import org.apache.toree.plugins.{PluginManager, Plugin} import org.apache.toree.plugins.annotations.Init -import org.scalatest.{OneInstancePerTest, Matchers, FunSpec} +import org.scalatest.{OneInstancePerTest} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class PluginManagerSpecForIntegration extends FunSpec with Matchers +class PluginManagerSpecForIntegration extends AnyFunSpec with Matchers with OneInstancePerTest { private val pluginManager = new PluginManager diff --git a/plugins/src/test/scala/org/apache/toree/plugins/ImplicitsSpec.scala b/plugins/src/test/scala/org/apache/toree/plugins/ImplicitsSpec.scala index 247bfa738..82128e311 100644 --- a/plugins/src/test/scala/org/apache/toree/plugins/ImplicitsSpec.scala +++ b/plugins/src/test/scala/org/apache/toree/plugins/ImplicitsSpec.scala @@ -18,9 +18,11 @@ package org.apache.toree.plugins import org.apache.toree.plugins.dependencies.Dependency -import org.scalatest.{OneInstancePerTest, Matchers, FunSpec} +import org.scalatest.{OneInstancePerTest} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class ImplicitsSpec extends FunSpec with Matchers with OneInstancePerTest { +class ImplicitsSpec extends AnyFunSpec with Matchers with OneInstancePerTest { describe("Implicits") { describe("#$dep") { it("should convert values to dependencies with generated names") { diff --git a/plugins/src/test/scala/org/apache/toree/plugins/PluginClassLoaderSpec.scala b/plugins/src/test/scala/org/apache/toree/plugins/PluginClassLoaderSpec.scala index da61f5e8d..6f8568cac 100644 --- a/plugins/src/test/scala/org/apache/toree/plugins/PluginClassLoaderSpec.scala +++ b/plugins/src/test/scala/org/apache/toree/plugins/PluginClassLoaderSpec.scala @@ -18,9 +18,11 @@ package org.apache.toree.plugins import java.io.File -import org.scalatest.{OneInstancePerTest, Matchers, FunSpec} +import org.scalatest.{OneInstancePerTest} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class PluginClassLoaderSpec extends FunSpec with Matchers +class PluginClassLoaderSpec extends AnyFunSpec with Matchers with OneInstancePerTest { describe("PluginClassLoader") { diff --git a/plugins/src/test/scala/org/apache/toree/plugins/PluginManagerSpec.scala b/plugins/src/test/scala/org/apache/toree/plugins/PluginManagerSpec.scala index 17a7a99b3..172a58940 100644 --- a/plugins/src/test/scala/org/apache/toree/plugins/PluginManagerSpec.scala +++ b/plugins/src/test/scala/org/apache/toree/plugins/PluginManagerSpec.scala @@ -19,13 +19,15 @@ package org.apache.toree.plugins import java.io.File import org.apache.toree.plugins.dependencies.DependencyManager -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ -import org.scalatest.{FunSpec, Matchers, OneInstancePerTest} +import org.scalatest.OneInstancePerTest +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.scalatestplus.mockito.MockitoSugar import test.utils._ -class PluginManagerSpec extends FunSpec with Matchers +class PluginManagerSpec extends AnyFunSpec with Matchers with OneInstancePerTest with MockitoSugar { private val TestPluginName = "some.plugin.class.name" @@ -50,7 +52,7 @@ class PluginManagerSpec extends FunSpec with Matchers ) // When returning class information - doReturn(classInfoList.toIterator) + doReturn(classInfoList.iterator) .when(mockPluginSearcher).search(any[File]) doReturn(classOf[TestPlugin]) @@ -78,7 +80,7 @@ class PluginManagerSpec extends FunSpec with Matchers ) // When returning class information - doReturn(classInfoList.toIterator) + doReturn(classInfoList.iterator) .when(mockPluginSearcher).search(any[File]) doReturn(classOf[TestPlugin]) @@ -169,7 +171,7 @@ class PluginManagerSpec extends FunSpec with Matchers ) // When returning class information - doReturn(classInfoList.toIterator) + doReturn(classInfoList.iterator) .when(mockPluginSearcher).search(any[File]) doReturn(classOf[TestPlugin]) @@ -192,7 +194,7 @@ class PluginManagerSpec extends FunSpec with Matchers ) // When returning class information - doReturn(classInfoList.toIterator) + doReturn(classInfoList.iterator) .when(mockPluginSearcher).search(any[File]) doReturn(classOf[TestPlugin]) diff --git a/plugins/src/test/scala/org/apache/toree/plugins/PluginMethodResultSpec.scala b/plugins/src/test/scala/org/apache/toree/plugins/PluginMethodResultSpec.scala index 2e2831a60..f09ee2959 100644 --- a/plugins/src/test/scala/org/apache/toree/plugins/PluginMethodResultSpec.scala +++ b/plugins/src/test/scala/org/apache/toree/plugins/PluginMethodResultSpec.scala @@ -20,12 +20,14 @@ import java.lang.reflect.Method import org.apache.toree.plugins.annotations.{Priority, Event} import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{OneInstancePerTest, Matchers, FunSpec} +import org.scalatest.{OneInstancePerTest} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.mockito.Mockito._ import scala.util.{Failure, Success, Try} -class PluginMethodResultSpec extends FunSpec with Matchers +class PluginMethodResultSpec extends AnyFunSpec with Matchers with OneInstancePerTest with MockitoSugar { private val testResult = new AnyRef diff --git a/plugins/src/test/scala/org/apache/toree/plugins/PluginMethodSpec.scala b/plugins/src/test/scala/org/apache/toree/plugins/PluginMethodSpec.scala index ae7c334ee..e2d7e0137 100644 --- a/plugins/src/test/scala/org/apache/toree/plugins/PluginMethodSpec.scala +++ b/plugins/src/test/scala/org/apache/toree/plugins/PluginMethodSpec.scala @@ -19,9 +19,11 @@ package org.apache.toree.plugins import org.apache.toree.plugins.annotations._ import org.apache.toree.plugins.dependencies.{DepClassNotFoundException, DepUnexpectedClassException, DepNameNotFoundException} -import org.scalatest.{OneInstancePerTest, Matchers, FunSpec} +import org.scalatest.{OneInstancePerTest} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class PluginMethodSpec extends FunSpec with Matchers with OneInstancePerTest { +class PluginMethodSpec extends AnyFunSpec with Matchers with OneInstancePerTest { private val testThrowable = new Throwable private case class TestDependency(x: Int) private class TestPlugin extends Plugin { diff --git a/plugins/src/test/scala/org/apache/toree/plugins/PluginSearcherSpec.scala b/plugins/src/test/scala/org/apache/toree/plugins/PluginSearcherSpec.scala index d93af2740..4170f8d69 100644 --- a/plugins/src/test/scala/org/apache/toree/plugins/PluginSearcherSpec.scala +++ b/plugins/src/test/scala/org/apache/toree/plugins/PluginSearcherSpec.scala @@ -20,12 +20,17 @@ import java.io.File import org.clapper.classutil.{Modifier, ClassFinder} import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{OneInstancePerTest, Matchers, FunSpec} +import org.scalatest.{OneInstancePerTest} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.mockito.Mockito._ + +import scala.collection.immutable.LazyList + import test.utils.TestClassInfo -class PluginSearcherSpec extends FunSpec with Matchers +class PluginSearcherSpec extends AnyFunSpec with Matchers with OneInstancePerTest with MockitoSugar { private val mockClassFinder = mock[ClassFinder] @@ -75,7 +80,7 @@ class PluginSearcherSpec extends FunSpec with Matchers it("should find any plugins directly extending the Plugin class") { val expected = directPluginClassInfo.name - doReturn(classInfos.toStream).when(mockClassFinder).getClasses() + doReturn(classInfos.to(LazyList).toList).when(mockClassFinder).getClasses() val actual = pluginSearcher.internal.map(_.name) @@ -85,7 +90,7 @@ class PluginSearcherSpec extends FunSpec with Matchers it("should find any plugins directly extending the Plugin trait") { val expected = directAsInterfacePluginClassInfo.name - doReturn(classInfos.toStream).when(mockClassFinder).getClasses() + doReturn(classInfos.to(LazyList).toList).when(mockClassFinder).getClasses() val actual = pluginSearcher.internal.map(_.name) @@ -95,7 +100,7 @@ class PluginSearcherSpec extends FunSpec with Matchers it("should find any plugins indirectly extending the Plugin class") { val expected = indirectPluginClassInfo.name - doReturn(classInfos.toStream).when(mockClassFinder).getClasses() + doReturn(classInfos.to(LazyList).toList).when(mockClassFinder).getClasses() val actual = pluginSearcher.internal.map(_.name) @@ -105,7 +110,7 @@ class PluginSearcherSpec extends FunSpec with Matchers it("should find any plugins indirectly extending the Plugin trait") { val expected = indirectAsInterfacePluginClassInfo.name - doReturn(classInfos.toStream).when(mockClassFinder).getClasses() + doReturn(classInfos.to(LazyList).toList).when(mockClassFinder).getClasses() val actual = pluginSearcher.internal.map(_.name) @@ -118,7 +123,7 @@ class PluginSearcherSpec extends FunSpec with Matchers traitPluginClassInfo.name ) - doReturn(classInfos.toStream).when(mockClassFinder).getClasses() + doReturn(classInfos.to(LazyList).toList).when(mockClassFinder).getClasses() val actual = pluginSearcher.internal.map(_.name) @@ -130,7 +135,7 @@ class PluginSearcherSpec extends FunSpec with Matchers it("should find any plugins directly extending the Plugin class") { val expected = directPluginClassInfo.name - doReturn(classInfos.toStream).when(mockClassFinder).getClasses() + doReturn(classInfos.to(LazyList).toList).when(mockClassFinder).getClasses() val actual = pluginSearcher.search().map(_.name).toSeq @@ -140,7 +145,7 @@ class PluginSearcherSpec extends FunSpec with Matchers it("should find any plugins directly extending the Plugin trait") { val expected = directAsInterfacePluginClassInfo.name - doReturn(classInfos.toStream).when(mockClassFinder).getClasses() + doReturn(classInfos.to(LazyList).toList).when(mockClassFinder).getClasses() val actual = pluginSearcher.search().map(_.name).toSeq @@ -150,7 +155,7 @@ class PluginSearcherSpec extends FunSpec with Matchers it("should find any plugins indirectly extending the Plugin class") { val expected = indirectPluginClassInfo.name - doReturn(classInfos.toStream).when(mockClassFinder).getClasses() + doReturn(classInfos.to(LazyList).toList).when(mockClassFinder).getClasses() val actual = pluginSearcher.search().map(_.name).toSeq @@ -160,7 +165,8 @@ class PluginSearcherSpec extends FunSpec with Matchers it("should find any plugins indirectly extending the Plugin trait") { val expected = indirectAsInterfacePluginClassInfo.name - doReturn(classInfos.toStream).when(mockClassFinder).getClasses() + doReturn(classInfos.to(LazyList).toList).when(mockClassFinder).getClasses() + val actual = pluginSearcher.search().map(_.name).toSeq @@ -173,7 +179,8 @@ class PluginSearcherSpec extends FunSpec with Matchers traitPluginClassInfo.name ) - doReturn(classInfos.toStream).when(mockClassFinder).getClasses() + doReturn(classInfos.to(LazyList).toList).when(mockClassFinder).getClasses() + val actual = pluginSearcher.search().map(_.name).toSeq diff --git a/plugins/src/test/scala/org/apache/toree/plugins/PluginSpec.scala b/plugins/src/test/scala/org/apache/toree/plugins/PluginSpec.scala index 4bee3166f..e46dc85dd 100644 --- a/plugins/src/test/scala/org/apache/toree/plugins/PluginSpec.scala +++ b/plugins/src/test/scala/org/apache/toree/plugins/PluginSpec.scala @@ -21,12 +21,14 @@ import java.lang.reflect.Method import org.apache.toree.plugins.annotations._ import org.apache.toree.plugins.dependencies.DependencyManager import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{OneInstancePerTest, Matchers, FunSpec} +import org.scalatest.{OneInstancePerTest} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.mockito.Mockito._ -import org.mockito.Matchers.{eq => mockEq, _} +import org.mockito.ArgumentMatchers.{eq => mockEq, _} import scala.reflect.runtime.universe._ -class PluginSpec extends FunSpec with Matchers with OneInstancePerTest with MockitoSugar { +class PluginSpec extends AnyFunSpec with Matchers with OneInstancePerTest with MockitoSugar { private val mockPluginManager = mock[PluginManager] private val testPlugin = { val plugin = new TestPlugin @@ -238,7 +240,7 @@ class PluginSpec extends FunSpec with Matchers with OneInstancePerTest with Mock // New classOf[ExtendedTestPlugin].getDeclaredMethod("mixed4") ) - ).mapValues(m => m.map(PluginMethod.apply(extendedTestPlugin, _: Method))) + ).view.mapValues(m => m.map(PluginMethod.apply(extendedTestPlugin, _: Method))).toMap val actual = extendedTestPlugin.eventMethodMap diff --git a/plugins/src/test/scala/org/apache/toree/plugins/dependencies/DependencyManagerSpec.scala b/plugins/src/test/scala/org/apache/toree/plugins/dependencies/DependencyManagerSpec.scala index 4ee02c32c..16722a873 100644 --- a/plugins/src/test/scala/org/apache/toree/plugins/dependencies/DependencyManagerSpec.scala +++ b/plugins/src/test/scala/org/apache/toree/plugins/dependencies/DependencyManagerSpec.scala @@ -16,9 +16,11 @@ */ package org.apache.toree.plugins.dependencies -import org.scalatest.{OneInstancePerTest, Matchers, FunSpec} +import org.scalatest.{OneInstancePerTest} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class DependencyManagerSpec extends FunSpec with Matchers with OneInstancePerTest { +class DependencyManagerSpec extends AnyFunSpec with Matchers with OneInstancePerTest { private val dependencyManager = new DependencyManager describe("DependencyManager") { diff --git a/plugins/src/test/scala/org/apache/toree/plugins/dependencies/DependencySpec.scala b/plugins/src/test/scala/org/apache/toree/plugins/dependencies/DependencySpec.scala index b6b511a0b..cb9c4cc87 100644 --- a/plugins/src/test/scala/org/apache/toree/plugins/dependencies/DependencySpec.scala +++ b/plugins/src/test/scala/org/apache/toree/plugins/dependencies/DependencySpec.scala @@ -16,10 +16,12 @@ */ package org.apache.toree.plugins.dependencies -import org.scalatest.{FunSpec, OneInstancePerTest, Matchers} +import org.scalatest.OneInstancePerTest +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class DependencySpec extends FunSpec with Matchers with OneInstancePerTest { +class DependencySpec extends AnyFunSpec with Matchers with OneInstancePerTest { import scala.reflect.runtime.universe._ describe("Dependency") { diff --git a/project/Dependencies.scala b/project/Dependencies.scala index f0a8520c7..797f19c9b 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -22,30 +22,35 @@ object Dependencies { // Libraries - val akkaActor = "com.typesafe.akka" %% "akka-actor" % "2.5.31" // Apache v2 - val akkaSlf4j = "com.typesafe.akka" %% "akka-slf4j" % "2.5.31" // Apache v2 - val akkaTestkit = "com.typesafe.akka" %% "akka-testkit" % "2.5.31" // Apache v2 + val akkaActor = "com.typesafe.akka" %% "akka-actor" % "2.7.0" // Apache v2 + val akkaSlf4j = "com.typesafe.akka" %% "akka-slf4j" % "2.7.0" // Apache v2 + val akkaTestkit = "com.typesafe.akka" %% "akka-testkit" % "2.7.0" // Apache v2 val clapper = "org.clapper" %% "classutil" % "1.5.1" // BSD 3-clause license, used for detecting plugins val commonsExec = "org.apache.commons" % "commons-exec" % "1.3" // Apache v2 - val config = "com.typesafe" % "config" % "1.3.0" // Apache v2 + val config = "com.typesafe" % "config" % "1.4.2" // Apache v2 - val coursierVersion = "1.0.3" + val coursierVersion = "2.0.13" val coursier = "io.get-coursier" %% "coursier" % coursierVersion // Apache v2 val coursierCache = "io.get-coursier" %% "coursier-cache" % coursierVersion // Apache v2 - val ivy = "org.apache.ivy" % "ivy" % "2.4.0" // Apache v2 + val ivy = "org.apache.ivy" % "ivy" % "2.5.1" // Apache v2 // use the same jackson version in test than the one provided at runtime by Spark 3.0.0 - val jacksonDatabind = "com.fasterxml.jackson.core" % "jackson-databind" % "2.10.0" // Apache v2 + val jacksonDatabind = "com.fasterxml.jackson.core" % "jackson-databind" % "2.13.4" // Apache v2 val jeroMq = "org.zeromq" % "jeromq" % "0.4.3" // MPL v2 - val joptSimple = "net.sf.jopt-simple" % "jopt-simple" % "4.9" // MIT + val joptSimple = "net.sf.jopt-simple" % "jopt-simple" % "5.0.4" // MIT + + val mockito = "org.mockito" % "mockito-core" % "4.6.1" // MIT + + val mockitoScala = "org.mockito" % "mockito-scala_2.13" % "1.17.12" // MIT + val mockitoSugar = "org.scalatestplus" % "scalatestplus-mockito_2.13" % "1.0.0-M2" // MIT + val mockitoScalaScalaTest = "org.mockito" % "mockito-scala-scalatest_2.13" % "1.17.12" // MIT - val mockito = "org.mockito" % "mockito-all" % "1.10.19" // MIT val playJson = "com.typesafe.play" %% "play-json" % "2.7.4" // Apache v2 @@ -53,9 +58,9 @@ object Dependencies { val scalaLibrary = Def.setting{ "org.scala-lang" % "scala-library" % scalaVersion.value } // BSD 3-clause val scalaReflect = Def.setting{ "org.scala-lang" % "scala-reflect" % scalaVersion.value } // BSD 3-clause - val scalaTest = "org.scalatest" %% "scalatest" % "3.0.8" // Apache v2 + val scalaTest = "org.scalatest" %% "scalatest" % "3.2.15" // Apache v2 - val slf4jApi = "org.slf4j" % "slf4j-api" % "1.7.30" // MIT + val slf4jApi = "org.slf4j" % "slf4j-api" % "1.7.36" // MIT val sparkVersion = settingKey[String]("Version of Apache Spark to use in Toree") // defined in root build val sparkCore = Def.setting{ "org.apache.spark" %% "spark-core" % sparkVersion.value } // Apache v2 @@ -65,14 +70,14 @@ object Dependencies { val sparkSql = Def.setting{ "org.apache.spark" %% "spark-sql" % sparkVersion.value } // Apache v2 val sparkStreaming = Def.setting{ "org.apache.spark" %% "spark-streaming" % sparkVersion.value } // Apache v2 - val springCore = "org.springframework" % "spring-core" % "5.2.2.RELEASE"// Apache v2 + val springCore = "org.springframework" % "spring-core" % "5.2.22.RELEASE"// Apache v2 // NB: Updated from 14.0.1 as suggested in // https://github.com/google/guava/issues/3249, // https://github.com/google/guava/issues/3345 // to prevent test org.apache.toree.magic.builtin.BuiltinLoaderSpec // from failing on OpenJDK 11. - val guava = "com.google.guava" % "guava" % "31.0.1-jre" // Apache v2 + val guava = "com.google.guava" % "guava" % "31.1-jre" // Apache v2 // Projects diff --git a/project/build.properties b/project/build.properties index f7cc74b56..8d0f8d84b 100644 --- a/project/build.properties +++ b/project/build.properties @@ -15,4 +15,4 @@ # limitations under the License # -sbt.version=1.5.5 +sbt.version=1.8.2 diff --git a/project/plugins.sbt b/project/plugins.sbt index eb746b2ac..aa7714a8f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -30,4 +30,4 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1") // Provides the ability to generate dependency graphs -addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1") +addDependencyTreePlugin diff --git a/protocol/build.sbt b/protocol/build.sbt index 646189756..47ef20d9b 100644 --- a/protocol/build.sbt +++ b/protocol/build.sbt @@ -21,7 +21,12 @@ libraryDependencies ++= Seq( Dependencies.playJson excludeAll ExclusionRule(organization = "com.fasterxml.jackson.core"), Dependencies.jacksonDatabind, - Dependencies.slf4jApi + Dependencies.slf4jApi, + Dependencies.scalaTest % "test", + Dependencies.akkaTestkit % "test", + Dependencies.mockitoSugar % "test", + Dependencies.mockitoScala % "test", + Dependencies.mockitoScalaScalaTest % "test" ) enablePlugins(BuildInfoPlugin) diff --git a/protocol/src/main/scala/org/apache/toree/comm/CommWriter.scala b/protocol/src/main/scala/org/apache/toree/comm/CommWriter.scala index 8a668a869..ef146a1be 100644 --- a/protocol/src/main/scala/org/apache/toree/comm/CommWriter.scala +++ b/protocol/src/main/scala/org/apache/toree/comm/CommWriter.scala @@ -108,5 +108,5 @@ abstract class CommWriter( */ protected[comm] def sendCommKernelMessage[ T <: KernelMessageContent with CommContent - ](commContent: T) + ](commContent: T): Unit } diff --git a/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/KernelMessage.scala b/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/KernelMessage.scala index 8eeb5368f..feb8a4497 100644 --- a/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/KernelMessage.scala +++ b/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/KernelMessage.scala @@ -32,7 +32,7 @@ case class KernelMessage( var i = ids.length while ( equal && ( 0 < i ) ) { i = i - 1 - equal = (ids(i).deep == km.ids(i).deep ) + equal = (java.util.Objects.deepEquals(ids(i), km.ids(i))) } equal = true equal diff --git a/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/package.scala b/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/package.scala index 466a3ec9a..71864d528 100644 --- a/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/package.scala +++ b/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/package.scala @@ -36,7 +36,7 @@ package object v5 { Map.empty } else { // triple quotes due https://github.com/scala/bug/issues/6476 - kv.toMap.mapValues(v => Json.parse(s""""$v"""")) + kv.toMap.view.mapValues(v => Json.parse(s""""$v"""")).toMap } } diff --git a/protocol/src/test/scala/org/apache/toree/comm/CommCallbacksSpec.scala b/protocol/src/test/scala/org/apache/toree/comm/CommCallbacksSpec.scala index 21c16b737..fb9f760f5 100644 --- a/protocol/src/test/scala/org/apache/toree/comm/CommCallbacksSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/comm/CommCallbacksSpec.scala @@ -21,9 +21,10 @@ package org.apache.toree.comm import org.apache.toree.comm.CommCallbacks._ import org.apache.toree.kernel.protocol.v5._ -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class CommCallbacksSpec extends FunSpec with Matchers { +class CommCallbacksSpec extends AnyFunSpec with Matchers { private val testOpenCallback: OpenCallback = (_, _, _, _) => {} private val testMsgCallback: MsgCallback = (_, _, _) => {} diff --git a/protocol/src/test/scala/org/apache/toree/comm/CommManagerSpec.scala b/protocol/src/test/scala/org/apache/toree/comm/CommManagerSpec.scala index 1bb642984..dc9d339cf 100644 --- a/protocol/src/test/scala/org/apache/toree/comm/CommManagerSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/comm/CommManagerSpec.scala @@ -24,11 +24,13 @@ import org.apache.toree.kernel.protocol.v5.content.{CommClose, CommOpen} import org.mockito.invocation.InvocationOnMock import org.mockito.stubbing.Answer import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, Matchers, FunSpec} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.mockito.Mockito._ -import org.mockito.Matchers.{eq => mockEq, _} +import org.mockito.ArgumentMatchers.{eq => mockEq, _} -class CommManagerSpec extends FunSpec with Matchers with BeforeAndAfter +class CommManagerSpec extends AnyFunSpec with Matchers with BeforeAndAfterEach with MockitoSugar { private val TestTargetName = "some target" @@ -46,7 +48,7 @@ class CommManagerSpec extends FunSpec with Matchers with BeforeAndAfter private var mockCommRegistrar: CommRegistrar = _ private var commManager: CommManager = _ - before { + override def beforeEach(): Unit = { mockCommWriter = mock[CommWriter] mockCommRegistrar = mock[CommRegistrar] doReturn(mockCommRegistrar).when(mockCommRegistrar) diff --git a/protocol/src/test/scala/org/apache/toree/comm/CommRegistrarSpec.scala b/protocol/src/test/scala/org/apache/toree/comm/CommRegistrarSpec.scala index b8aa8ccee..c91c1c5e7 100644 --- a/protocol/src/test/scala/org/apache/toree/comm/CommRegistrarSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/comm/CommRegistrarSpec.scala @@ -22,10 +22,12 @@ import java.util.UUID import org.apache.toree.comm.CommCallbacks.{CloseCallback, MsgCallback, OpenCallback} import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpec, Matchers} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class CommRegistrarSpec extends FunSpec with Matchers with MockitoSugar - with BeforeAndAfter +class CommRegistrarSpec extends AnyFunSpec with Matchers with MockitoSugar + with BeforeAndAfterEach { private val TestTargetName = "some target name" private val TestCommId = UUID.randomUUID().toString @@ -36,7 +38,7 @@ class CommRegistrarSpec extends FunSpec with Matchers with MockitoSugar private var commStorage: CommStorage = _ private var commRegistrar: CommRegistrar = _ - before { + override def beforeEach(): Unit = { commStorage = new CommStorage() commRegistrar = new CommRegistrar(commStorage) } diff --git a/protocol/src/test/scala/org/apache/toree/comm/CommStorageSpec.scala b/protocol/src/test/scala/org/apache/toree/comm/CommStorageSpec.scala index 278590af9..95c8b48bf 100644 --- a/protocol/src/test/scala/org/apache/toree/comm/CommStorageSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/comm/CommStorageSpec.scala @@ -21,11 +21,13 @@ import org.apache.toree.kernel.protocol.v5 import org.apache.toree.kernel.protocol.v5.UUID import org.scalatestplus.mockito.MockitoSugar import org.mockito.Mockito._ -import org.scalatest.{BeforeAndAfter, Matchers, FunSpec} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import scala.collection.{immutable, mutable} -class CommStorageSpec extends FunSpec with Matchers with BeforeAndAfter +class CommStorageSpec extends AnyFunSpec with Matchers with BeforeAndAfterEach with MockitoSugar { private val TestTargetName = "some target" @@ -37,7 +39,7 @@ class CommStorageSpec extends FunSpec with Matchers with BeforeAndAfter private var linkStorage: mutable.Map[String, immutable.IndexedSeq[UUID]] = _ private var commStorage: CommStorage = _ - before { + override def beforeEach(): Unit = { mockLinks = mock[immutable.IndexedSeq[v5.UUID]] mockCommCallbacks = mock[CommCallbacks] callbackStorage = new mutable.HashMap[String, CommCallbacks]() diff --git a/protocol/src/test/scala/org/apache/toree/comm/CommWriterSpec.scala b/protocol/src/test/scala/org/apache/toree/comm/CommWriterSpec.scala index ac155f930..908df65b3 100644 --- a/protocol/src/test/scala/org/apache/toree/comm/CommWriterSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/comm/CommWriterSpec.scala @@ -22,12 +22,14 @@ import java.util.UUID import org.apache.toree.kernel.protocol.v5 import org.apache.toree.kernel.protocol.v5._ import org.apache.toree.kernel.protocol.v5.content._ -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ -import org.scalatest.{BeforeAndAfter, FunSpec, Matchers} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.scalatestplus.mockito.MockitoSugar -class CommWriterSpec extends FunSpec with Matchers with BeforeAndAfter +class CommWriterSpec extends AnyFunSpec with Matchers with BeforeAndAfterEach with MockitoSugar { private val TestCommId = UUID.randomUUID().toString @@ -41,7 +43,7 @@ class CommWriterSpec extends FunSpec with Matchers with BeforeAndAfter private var commWriter: CommWriter = _ - before { + override def beforeEach(): Unit = { commWriter = spy(new TestCommWriter()) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/HeaderBuilderSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/HeaderBuilderSpec.scala index 5513303be..a5a1158b1 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/HeaderBuilderSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/HeaderBuilderSpec.scala @@ -17,9 +17,10 @@ package org.apache.toree.kernel.protocol.v5 -import org.scalatest.{Matchers, FunSpec} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -class HeaderBuilderSpec extends FunSpec with Matchers { +class HeaderBuilderSpec extends AnyFunSpec with Matchers { describe("HeaderBuilder") { describe("#create") { it("should set the msg_id field to a unique ID if none is provided") { diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/HeaderSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/HeaderSpec.scala index 3fd25b163..9fd065ba7 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/HeaderSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/HeaderSpec.scala @@ -17,10 +17,11 @@ package org.apache.toree.kernel.protocol.v5 -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.{JsPath, JsValue, Json, JsonValidationError} -class HeaderSpec extends FunSpec with Matchers { +class HeaderSpec extends AnyFunSpec with Matchers { val headerJson: JsValue = Json.parse(""" { "msg_id": "", @@ -62,7 +63,7 @@ class HeaderSpec extends FunSpec with Matchers { val headerResults = headerJson.validate[Header] headerResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: Header) => valid ) should be (header) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/KMBuilderSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/KMBuilderSpec.scala index d6c957d27..aae1ccd29 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/KMBuilderSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/KMBuilderSpec.scala @@ -18,10 +18,11 @@ package org.apache.toree.kernel.protocol.v5 import org.apache.toree.kernel.protocol.v5.content.{CommOpen, StreamContent} -import org.scalatest.{Matchers, FunSpec} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json._ -class KMBuilderSpec extends FunSpec with Matchers { +class KMBuilderSpec extends AnyFunSpec with Matchers { describe("KMBuilder") { val emptyKM = KernelMessage( ids = Seq(), diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ClearOutputSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ClearOutputSpec.scala index c43ef74e9..0c282e42d 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ClearOutputSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ClearOutputSpec.scala @@ -18,10 +18,11 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json._ -class ClearOutputSpec extends FunSpec with Matchers { +class ClearOutputSpec extends AnyFunSpec with Matchers { val clearOutputJson: JsValue = Json.parse(""" { "wait": true @@ -58,7 +59,7 @@ class ClearOutputSpec extends FunSpec with Matchers { val CompleteRequestResults = clearOutputJson.validate[ClearOutput] CompleteRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ClearOutput) => valid ) should be (clearOutput) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CommCloseSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CommCloseSpec.scala index 2cf0e403d..84606f751 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CommCloseSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CommCloseSpec.scala @@ -18,10 +18,11 @@ package org.apache.toree.kernel.protocol.v5.content import org.apache.toree.kernel.protocol.v5._ -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json._ -class CommCloseSpec extends FunSpec with Matchers { +class CommCloseSpec extends AnyFunSpec with Matchers { val commCloseJson: JsValue = Json.parse(""" { "comm_id": "", @@ -59,7 +60,7 @@ class CommCloseSpec extends FunSpec with Matchers { val CompleteRequestResults = commCloseJson.validate[CommClose] CompleteRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: CommClose) => valid ) should be (commClose) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CommMsgSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CommMsgSpec.scala index dafd1b7c4..837e402e5 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CommMsgSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CommMsgSpec.scala @@ -17,12 +17,13 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ import org.apache.toree.kernel.protocol.v5._ -class CommMsgSpec extends FunSpec with Matchers { +class CommMsgSpec extends AnyFunSpec with Matchers { val commMsgJson: JsValue = Json.parse(""" { "comm_id": "", @@ -87,7 +88,7 @@ class CommMsgSpec extends FunSpec with Matchers { val CompleteRequestResults = commMsgJson.validate[CommMsg] CompleteRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: CommMsg) => valid ) should be (commMsg) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CommOpenSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CommOpenSpec.scala index a604c41bd..e3c0e44ca 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CommOpenSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CommOpenSpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json._ import org.apache.toree.kernel.protocol.v5.MsgData -class CommOpenSpec extends FunSpec with Matchers { +class CommOpenSpec extends AnyFunSpec with Matchers { val commOpenJson: JsValue = Json.parse(""" { "comm_id": "", @@ -60,7 +61,7 @@ class CommOpenSpec extends FunSpec with Matchers { val CompleteRequestResults = commOpenJson.validate[CommOpen] CompleteRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: CommOpen) => valid ) should be (commOpen) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteReplyErrorSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteReplyErrorSpec.scala index c24315df0..1c8974a6a 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteReplyErrorSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteReplyErrorSpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class CompleteReplyErrorSpec extends FunSpec with Matchers { +class CompleteReplyErrorSpec extends AnyFunSpec with Matchers { val completeReplyErrorJson: JsValue = Json.parse(""" { "matches": [], @@ -60,7 +61,7 @@ class CompleteReplyErrorSpec extends FunSpec with Matchers { val CompleteReplyOkResults = completeReplyErrorJson.validate[CompleteReplyError] CompleteReplyOkResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: CompleteReplyError) => valid ) should be (completeReplyError) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteReplyOkSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteReplyOkSpec.scala index 607ff5af1..630cc88b5 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteReplyOkSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteReplyOkSpec.scala @@ -17,10 +17,11 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json._ -class CompleteReplyOkSpec extends FunSpec with Matchers { +class CompleteReplyOkSpec extends AnyFunSpec with Matchers { val completeReplyOkJson: JsValue = Json.parse(""" { "matches": [], @@ -56,7 +57,7 @@ class CompleteReplyOkSpec extends FunSpec with Matchers { val CompleteReplyOkResults = completeReplyOkJson.validate[CompleteReplyOk] CompleteReplyOkResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: CompleteReplyOk) => valid ) should be (completeReplyOk) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteReplySpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteReplySpec.scala index 6e942bf28..faf8aff58 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteReplySpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteReplySpec.scala @@ -17,10 +17,11 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.{JsPath, JsValue, Json, JsonValidationError} -class CompleteReplySpec extends FunSpec with Matchers { +class CompleteReplySpec extends AnyFunSpec with Matchers { val completeReplyJson: JsValue = Json.parse(""" @@ -63,7 +64,7 @@ class CompleteReplySpec extends FunSpec with Matchers { val CompleteReplyResults = completeReplyJson.validate[CompleteReply] CompleteReplyResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: CompleteReply) => valid ) should be (completeReply) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteRequestSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteRequestSpec.scala index fe19ed473..5224ad830 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteRequestSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/CompleteRequestSpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class CompleteRequestSpec extends FunSpec with Matchers { +class CompleteRequestSpec extends AnyFunSpec with Matchers { val completeRequestJson: JsValue = Json.parse(""" { "code": "", @@ -59,7 +60,7 @@ class CompleteRequestSpec extends FunSpec with Matchers { val CompleteRequestResults = completeRequestJson.validate[CompleteRequest] CompleteRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: CompleteRequest) => valid ) should be (completeRequest) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ConnectReplySpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ConnectReplySpec.scala index 92b557725..05c09fe80 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ConnectReplySpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ConnectReplySpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json.{JsPath, JsValue, Json} -class ConnectReplySpec extends FunSpec with Matchers { +class ConnectReplySpec extends AnyFunSpec with Matchers { val connectReplyJson: JsValue = Json.parse(""" @@ -61,7 +62,7 @@ class ConnectReplySpec extends FunSpec with Matchers { val ConnectReplyResults = connectReplyJson.validate[ConnectReply] ConnectReplyResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ConnectReply) => valid ) should be (connectReply) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ConnectRequestSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ConnectRequestSpec.scala index 580ea7d73..4ecfaa341 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ConnectRequestSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ConnectRequestSpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class ConnectRequestSpec extends FunSpec with Matchers { +class ConnectRequestSpec extends AnyFunSpec with Matchers { val connectRequestJson: JsValue = Json.parse(""" {} """) @@ -54,7 +55,7 @@ class ConnectRequestSpec extends FunSpec with Matchers { val ConnectRequestResults = connectRequestJson.validate[ConnectRequest] ConnectRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ConnectRequest) => valid ) should be (connectRequest) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/DisplayDataSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/DisplayDataSpec.scala index 49e426b47..02ea9983c 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/DisplayDataSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/DisplayDataSpec.scala @@ -17,14 +17,13 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.FunSuite - -import org.scalatest.{Matchers, FunSpec} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ import org.apache.toree.kernel.protocol.v5._ -class DisplayDataSpec extends FunSpec with Matchers { +class DisplayDataSpec extends AnyFunSpec with Matchers { val displayDataJson: JsValue = Json.parse(""" { "source": "", @@ -63,7 +62,7 @@ class DisplayDataSpec extends FunSpec with Matchers { val displayDataResults = displayDataJson.validate[DisplayData] displayDataResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: DisplayData) => valid ) should be (displayData) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ErrorContentSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ErrorContentSpec.scala index 5f54f772a..d39315694 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ErrorContentSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ErrorContentSpec.scala @@ -17,10 +17,11 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{Matchers, FunSpec} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json._ -class ErrorContentSpec extends FunSpec with Matchers { +class ErrorContentSpec extends AnyFunSpec with Matchers { val errorJson: JsValue = Json.parse(""" { "ename": "", @@ -57,7 +58,7 @@ class ErrorContentSpec extends FunSpec with Matchers { val CompleteRequestResults = errorJson.validate[ErrorContent] CompleteRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ErrorContent) => valid ) should be (error) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteInputSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteInputSpec.scala index a1aed332d..63da8abe1 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteInputSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteInputSpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class ExecuteInputSpec extends FunSpec with Matchers { +class ExecuteInputSpec extends AnyFunSpec with Matchers { val executeInputJson: JsValue = Json.parse(""" { "code": "", @@ -59,7 +60,7 @@ class ExecuteInputSpec extends FunSpec with Matchers { val executeInputResults = executeInputJson.validate[ExecuteInput] executeInputResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ExecuteInput) => valid ) should be (executeInput) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplyAbortSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplyAbortSpec.scala index c47f490b5..9d3876dd6 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplyAbortSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplyAbortSpec.scala @@ -18,11 +18,12 @@ package org.apache.toree.kernel.protocol.v5.content import org.apache.toree.kernel.protocol.v5._ -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class ExecuteReplyAbortSpec extends FunSpec with Matchers { +class ExecuteReplyAbortSpec extends AnyFunSpec with Matchers { val executeReplyAbortJson: JsValue = Json.parse(""" { "status": "abort", @@ -54,7 +55,7 @@ class ExecuteReplyAbortSpec extends FunSpec with Matchers { val ExecuteReplyAbortResults = executeReplyAbortJson.validate[ExecuteReplyAbort] ExecuteReplyAbortResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ExecuteReplyAbort) => valid ) should be (executeReplyAbort) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplyErrorSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplyErrorSpec.scala index f204e5278..231c8ccfa 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplyErrorSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplyErrorSpec.scala @@ -17,13 +17,14 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ import org.apache.toree.kernel.protocol.v5._ -class ExecuteReplyErrorSpec extends FunSpec with Matchers { +class ExecuteReplyErrorSpec extends AnyFunSpec with Matchers { val executeReplyErrorJson: JsValue = Json.parse(""" { "status": "error", @@ -58,7 +59,7 @@ class ExecuteReplyErrorSpec extends FunSpec with Matchers { val ExecuteReplyErrorResults = executeReplyErrorJson.validate[ExecuteReplyError] ExecuteReplyErrorResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ExecuteReplyError) => valid ) should be (executeReplyError) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplyOkSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplyOkSpec.scala index 56f7b6bb5..4efb57c36 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplyOkSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplyOkSpec.scala @@ -17,13 +17,14 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ import org.apache.toree.kernel.protocol.v5._ -class ExecuteReplyOkSpec extends FunSpec with Matchers { +class ExecuteReplyOkSpec extends AnyFunSpec with Matchers { val executeReplyOkJson: JsValue = Json.parse(""" { "status": "ok", @@ -57,7 +58,7 @@ class ExecuteReplyOkSpec extends FunSpec with Matchers { val executeReplyOkResults = executeReplyOkJson.validate[ExecuteReplyOk] executeReplyOkResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ExecuteReplyOk) => valid ) should be (executeReplyOk) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplySpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplySpec.scala index f08121c79..15284d044 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplySpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteReplySpec.scala @@ -18,11 +18,12 @@ package org.apache.toree.kernel.protocol.v5.content import org.apache.toree.kernel.protocol.v5._ -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class ExecuteReplySpec extends FunSpec with Matchers { +class ExecuteReplySpec extends AnyFunSpec with Matchers { val executeReplyJson: JsValue = Json.parse(""" { "status": "", @@ -60,7 +61,7 @@ class ExecuteReplySpec extends FunSpec with Matchers { val executeReplyResults = executeReplyJson.validate[ExecuteReply] executeReplyResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ExecuteReply) => valid ) should be (executeReply) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteRequestSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteRequestSpec.scala index fdd1e6624..e3e448f32 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteRequestSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteRequestSpec.scala @@ -17,12 +17,13 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{Matchers, FunSpec} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ import org.apache.toree.kernel.protocol.v5._ -class ExecuteRequestSpec extends FunSpec with Matchers { +class ExecuteRequestSpec extends AnyFunSpec with Matchers { val executeRequestJson: JsValue = Json.parse(""" { "code": "", @@ -63,7 +64,7 @@ class ExecuteRequestSpec extends FunSpec with Matchers { val executeRequestResults = executeRequestJson.validate[ExecuteRequest] executeRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ExecuteRequest) => valid ) should be (executeRequest) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteResultSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteResultSpec.scala index c88c00c03..7ddc455f8 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteResultSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ExecuteResultSpec.scala @@ -17,13 +17,14 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ import org.apache.toree.kernel.protocol.v5._ -class ExecuteResultSpec extends FunSpec with Matchers { +class ExecuteResultSpec extends AnyFunSpec with Matchers { val executeResultJson: JsValue = Json.parse(""" { "execution_count": 999, @@ -96,7 +97,7 @@ class ExecuteResultSpec extends FunSpec with Matchers { val CompleteRequestResults = executeResultJson.validate[ExecuteResult] CompleteRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ExecuteResult) => valid ) should be (executeResult) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/HistoryReplySpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/HistoryReplySpec.scala index 56d0c1756..309dee4ad 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/HistoryReplySpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/HistoryReplySpec.scala @@ -17,13 +17,14 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ import org.apache.toree.kernel.protocol.v5._ -class HistoryReplySpec extends FunSpec with Matchers { +class HistoryReplySpec extends AnyFunSpec with Matchers { val historyReplyJson: JsValue = Json.parse(""" { "history": ["", "", ""] @@ -60,7 +61,7 @@ class HistoryReplySpec extends FunSpec with Matchers { val CompleteRequestResults = historyReplyJson.validate[HistoryReply] CompleteRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: HistoryReply) => valid ) should be (historyReply) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/HistoryRequestSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/HistoryRequestSpec.scala index ddadbd3d9..827ca05a2 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/HistoryRequestSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/HistoryRequestSpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class HistoryRequestSpec extends FunSpec with Matchers { +class HistoryRequestSpec extends AnyFunSpec with Matchers { val historyRequestJson: JsValue = Json.parse(""" { "output": true, @@ -66,7 +67,7 @@ class HistoryRequestSpec extends FunSpec with Matchers { val CompleteRequestResults = historyRequestJson.validate[HistoryRequest] CompleteRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: HistoryRequest) => valid ) should be (historyRequest) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InputReplySpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InputReplySpec.scala index d78dee5a0..7b7e1cf7e 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InputReplySpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InputReplySpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class InputReplySpec extends FunSpec with Matchers { +class InputReplySpec extends AnyFunSpec with Matchers { val inputReplyJson: JsValue = Json.parse(""" { "value": "" @@ -58,7 +59,7 @@ class InputReplySpec extends FunSpec with Matchers { val CompleteReplyResults = inputReplyJson.validate[InputReply] CompleteReplyResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: InputReply) => valid ) should be (inputReply) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InputRequestSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InputRequestSpec.scala index 089184aef..7e8b68ead 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InputRequestSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InputRequestSpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class InputRequestSpec extends FunSpec with Matchers { +class InputRequestSpec extends AnyFunSpec with Matchers { val inputRequestJson: JsValue = Json.parse(""" { "prompt": "", @@ -59,7 +60,7 @@ class InputRequestSpec extends FunSpec with Matchers { val CompleteRequestResults = inputRequestJson.validate[InputRequest] CompleteRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: InputRequest) => valid ) should be (inputRequest) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectReplyErrorSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectReplyErrorSpec.scala index e00c0e5e5..5f3930cb6 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectReplyErrorSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectReplyErrorSpec.scala @@ -18,11 +18,12 @@ package org.apache.toree.kernel.protocol.v5.content import org.apache.toree.kernel.protocol.v5._ -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class InspectReplyErrorSpec extends FunSpec with Matchers { +class InspectReplyErrorSpec extends AnyFunSpec with Matchers { val inspectReplyErrorJson: JsValue = Json.parse(""" { "status": "error", @@ -58,7 +59,7 @@ class InspectReplyErrorSpec extends FunSpec with Matchers { val InspectReplyErrorResults = inspectReplyErrorJson.validate[InspectReplyError] InspectReplyErrorResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: InspectReplyError) => valid ) should be (inspectReplyError) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectReplyOkSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectReplyOkSpec.scala index 7dfaed792..327e2109a 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectReplyOkSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectReplyOkSpec.scala @@ -17,13 +17,14 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ import org.apache.toree.kernel.protocol.v5._ -class InspectReplyOkSpec extends FunSpec with Matchers { +class InspectReplyOkSpec extends AnyFunSpec with Matchers { val inspectReplyOkJson: JsValue = Json.parse(""" { "status": "ok", @@ -56,7 +57,7 @@ class InspectReplyOkSpec extends FunSpec with Matchers { val InspectReplyOkResults = inspectReplyOkJson.validate[InspectReplyOk] InspectReplyOkResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: InspectReplyOk) => valid ) should be (inspectReplyOk) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectReplySpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectReplySpec.scala index a2e1d94ab..28f64571b 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectReplySpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectReplySpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class InspectReplySpec extends FunSpec with Matchers { +class InspectReplySpec extends AnyFunSpec with Matchers { val inspectReplyJson: JsValue = Json.parse(""" { "status": "", @@ -60,7 +61,7 @@ class InspectReplySpec extends FunSpec with Matchers { val InspectReplyResults = inspectReplyJson.validate[InspectReply] InspectReplyResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: InspectReply) => valid ) should be (inspectReply) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectRequestSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectRequestSpec.scala index 3ec5c2d36..e215df1e5 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectRequestSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/InspectRequestSpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class InspectRequestSpec extends FunSpec with Matchers { +class InspectRequestSpec extends AnyFunSpec with Matchers { val inspectRequestJson: JsValue = Json.parse(""" { "code": "", @@ -60,7 +61,7 @@ class InspectRequestSpec extends FunSpec with Matchers { val InspectRequestResults = inspectRequestJson.validate[InspectRequest] InspectRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: InspectRequest) => valid ) should be (inspectRequest) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/KernelInfoReplySpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/KernelInfoReplySpec.scala index 7de743ffa..fe66d996f 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/KernelInfoReplySpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/KernelInfoReplySpec.scala @@ -18,11 +18,12 @@ package org.apache.toree.kernel.protocol.v5.content import org.apache.toree.kernel.protocol.v5.LanguageInfo -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class KernelInfoReplySpec extends FunSpec with Matchers { +class KernelInfoReplySpec extends AnyFunSpec with Matchers { val kernelInfoReplyJson: JsValue = Json.parse(""" { "protocol_version": "x.y.z", @@ -63,7 +64,7 @@ class KernelInfoReplySpec extends FunSpec with Matchers { val kernelInfoReplyResults = kernelInfoReplyJson.validate[KernelInfoReply] kernelInfoReplyResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: KernelInfoReply) => valid ) should be (kernelInfoReply) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/KernelInfoRequestSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/KernelInfoRequestSpec.scala index 6e7d78e16..4a33ea540 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/KernelInfoRequestSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/KernelInfoRequestSpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class KernelInfoRequestSpec extends FunSpec with Matchers { +class KernelInfoRequestSpec extends AnyFunSpec with Matchers { val kernelInfoRequestJson: JsValue = Json.parse(""" {} """) @@ -55,7 +56,7 @@ class KernelInfoRequestSpec extends FunSpec with Matchers { val KernelInfoRequestResults = kernelInfoRequestJson.validate[KernelInfoRequest] KernelInfoRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: KernelInfoRequest) => valid ) should be (kernelInfoRequest) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/KernelStatusSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/KernelStatusSpec.scala index ab68bf9ed..1bf57ed6b 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/KernelStatusSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/KernelStatusSpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json.{JsPath, JsValue, Json} -class KernelStatusSpec extends FunSpec with Matchers { +class KernelStatusSpec extends AnyFunSpec with Matchers { val kernelStatusJson: JsValue = Json.parse(""" { "execution_state": "" @@ -56,7 +57,7 @@ class KernelStatusSpec extends FunSpec with Matchers { val kernelStatusResults = kernelStatusJson.validate[KernelStatus] kernelStatusResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: KernelStatus) => valid ) should be (kernelStatus) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ShutdownReplySpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ShutdownReplySpec.scala index b543ee9f8..4353e4098 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ShutdownReplySpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ShutdownReplySpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class ShutdownReplySpec extends FunSpec with Matchers { +class ShutdownReplySpec extends AnyFunSpec with Matchers { val shutdownReplyJson: JsValue = Json.parse(""" { "restart": true @@ -58,7 +59,7 @@ class ShutdownReplySpec extends FunSpec with Matchers { val ShutdownReplyResults = shutdownReplyJson.validate[ShutdownReply] ShutdownReplyResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ShutdownReply) => valid ) should be (shutdownReply) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ShutdownRequestSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ShutdownRequestSpec.scala index 4e5128d18..8a6e0f15d 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ShutdownRequestSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/ShutdownRequestSpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class ShutdownRequestSpec extends FunSpec with Matchers { +class ShutdownRequestSpec extends AnyFunSpec with Matchers { val shutdownRequestJson: JsValue = Json.parse(""" { "restart": true @@ -58,7 +59,7 @@ class ShutdownRequestSpec extends FunSpec with Matchers { val ShutdownRequestResults = shutdownRequestJson.validate[ShutdownRequest] ShutdownRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: ShutdownRequest) => valid ) should be (shutdownRequest) } diff --git a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/StreamContentSpec.scala b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/StreamContentSpec.scala index 9d770803b..860602183 100644 --- a/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/StreamContentSpec.scala +++ b/protocol/src/test/scala/org/apache/toree/kernel/protocol/v5/content/StreamContentSpec.scala @@ -17,11 +17,12 @@ package org.apache.toree.kernel.protocol.v5.content -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import play.api.libs.json.JsonValidationError import play.api.libs.json._ -class StreamContentSpec extends FunSpec with Matchers { +class StreamContentSpec extends AnyFunSpec with Matchers { val streamJson: JsValue = Json.parse(""" { "text": "", @@ -47,7 +48,7 @@ class StreamContentSpec extends FunSpec with Matchers { it("should also work with asOpt") { // This is safer, but we lose the error information as it returns // None if the conversion fails - val newCompleteRequest = streamJson.asOpt[StreamContent] + val newCompleteRequest = streamJson.validate[StreamContent] newCompleteRequest.get should be (stream) } @@ -57,7 +58,7 @@ class StreamContentSpec extends FunSpec with Matchers { val CompleteRequestResults = streamJson.validate[StreamContent] CompleteRequestResults.fold( - (invalid: Seq[(JsPath, Seq[JsonValidationError])]) => println("Failed!"), + (invalid: scala.collection.Seq[(JsPath, scala.collection.Seq[JsonValidationError])]) => println("Failed!"), (valid: StreamContent) => valid ) should be (stream) } @@ -68,4 +69,3 @@ class StreamContentSpec extends FunSpec with Matchers { } } } - diff --git a/scala-interpreter/build.sbt b/scala-interpreter/build.sbt index 39dcb023e..ef20a8203 100644 --- a/scala-interpreter/build.sbt +++ b/scala-interpreter/build.sbt @@ -19,3 +19,11 @@ import sbt.Tests.{Group, SubProcess} libraryDependencies ++= Dependencies.sparkAll.value libraryDependencies += "com.github.jupyter" % "jvm-repr" % "0.1.0" + +libraryDependencies ++= Seq( + Dependencies.scalaTest % "test", + Dependencies.mockitoSugar % "test", + Dependencies.mockitoScala % "test", + Dependencies.mockitoScalaScalaTest % "test" +) + diff --git a/scala-interpreter/src/main/scala-2.11/org/apache/toree/kernel/interpreter/scala/ScalaInterpreterSpecific.scala b/scala-interpreter/src/main/scala-2.11/org/apache/toree/kernel/interpreter/scala/ScalaInterpreterSpecific.scala index c941935b3..22251d86b 100644 --- a/scala-interpreter/src/main/scala-2.11/org/apache/toree/kernel/interpreter/scala/ScalaInterpreterSpecific.scala +++ b/scala-interpreter/src/main/scala-2.11/org/apache/toree/kernel/interpreter/scala/ScalaInterpreterSpecific.scala @@ -444,13 +444,6 @@ trait ScalaInterpreterSpecific extends SettingsProducerLike { this: ScalaInterpr } } -/** - * Due to a bug in the scala interpreter under scala 2.11 (SI-8935) with IMain.valueOfTerm we can hack around it by - * binding an instance of ExceptionHack into iMain and interpret the "_exceptionHack.lastException = lastException". - * This makes it possible to extract the exception. - * - * TODO: Revisit this once Scala 2.12 is released. - */ class ExceptionHack { var lastException: Throwable = _ } diff --git a/scala-interpreter/src/main/scala-2.12/org/apache/toree/kernel/interpreter/scala/ScalaInterpreterSpecific.scala b/scala-interpreter/src/main/scala-2.12/org/apache/toree/kernel/interpreter/scala/ScalaInterpreterSpecific.scala index 393cbeedc..1b8b620ed 100644 --- a/scala-interpreter/src/main/scala-2.12/org/apache/toree/kernel/interpreter/scala/ScalaInterpreterSpecific.scala +++ b/scala-interpreter/src/main/scala-2.12/org/apache/toree/kernel/interpreter/scala/ScalaInterpreterSpecific.scala @@ -440,13 +440,6 @@ trait ScalaInterpreterSpecific extends SettingsProducerLike { this: ScalaInterpr } } -/** - * Due to a bug in the scala interpreter under scala 2.11 (SI-8935) with IMain.valueOfTerm we can hack around it by - * binding an instance of ExceptionHack into iMain and interpret the "_exceptionHack.lastException = lastException". - * This makes it possible to extract the exception. - * - * TODO: Revisit this once Scala 2.12 is released. - */ class ExceptionHack { var lastException: Throwable = _ } diff --git a/scala-interpreter/src/main/scala-2.13/org/apache/toree/kernel/interpreter/scala/ScalaInterpreterSpecific.scala b/scala-interpreter/src/main/scala-2.13/org/apache/toree/kernel/interpreter/scala/ScalaInterpreterSpecific.scala new file mode 100644 index 000000000..9ca73403d --- /dev/null +++ b/scala-interpreter/src/main/scala-2.13/org/apache/toree/kernel/interpreter/scala/ScalaInterpreterSpecific.scala @@ -0,0 +1,449 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package org.apache.toree.kernel.interpreter.scala + +import java.io._ +import java.net.URL + +import org.apache.toree.global.StreamState +import org.apache.toree.interpreter.imports.printers.{WrapperConsole, WrapperSystem} +import org.apache.toree.interpreter.{ExecuteError, Interpreter} +import scala.tools.nsc.interpreter._ +import scala.tools.nsc.interpreter.shell._ +import scala.language.postfixOps +import scala.concurrent.Future +import scala.tools.nsc.{Global, Settings, util} +import scala.util.Try + +trait ScalaInterpreterSpecific extends SettingsProducerLike { this: ScalaInterpreter => + private val ExecutionExceptionName = "lastException" + + private[toree] var iMain: IMain = _ + private var completer: Completion = _ + private val exceptionHack = new ExceptionHack() + + def _runtimeClassloader = { + _thisClassloader + } + + protected def newIMain(settings: Settings, out: PrintWriter): IMain = { + val s = new IMain(settings, new ReplReporterImpl(settings, out)) + s.initializeCompiler() + s + } + + protected def convertAnnotationsToModifiers( + annotationInfos: List[Global#AnnotationInfo] + ) = annotationInfos map { + case a if a.toString == "transient" => "@transient" + case a => + logger.debug(s"Ignoring unknown annotation: $a") + "" + } filterNot { + _.isEmpty + } + + protected def convertScopeToModifiers(scopeSymbol: Global#Symbol) = { + (if (scopeSymbol.isImplicit) "implicit" else "") :: + Nil + } + + protected def buildModifierList(termNameString: String) = { + import scala.language.existentials + val termSymbol = iMain.symbolOfTerm(termNameString) + + + convertAnnotationsToModifiers( + if (termSymbol.hasAccessorFlag) termSymbol.accessed.annotations + else termSymbol.annotations + ) ++ convertScopeToModifiers(termSymbol) + } + + + protected def refreshDefinitions(): Unit = { + iMain.definedTerms.foreach(termName => { + val termNameString = termName.toString + val termTypeString = iMain.typeOfTerm(termNameString).toLongString + iMain.valueOfTerm(termNameString) match { + case Some(termValue) => + val modifiers = buildModifierList(termNameString) + logger.debug(s"Rebinding of $termNameString as " + + s"${modifiers.mkString(" ")} $termTypeString") + Try(iMain.beQuietDuring { + iMain.bind( + termNameString, termTypeString, termValue, modifiers + ) + }) + case None => + logger.debug(s"Ignoring rebinding of $termNameString") + } + }) + } + + protected def reinitializeSymbols(): Unit = { + val global = iMain.global + import global._ + new Run // Initializes something needed for Scala classes + } + + /** + * Adds jars to the runtime and compile time classpaths. Does not work with + * directories or expanding star in a path. + * @param jars The list of jar locations + */ + override def addJars(jars: URL*): Unit = { + iMain.addUrlsToClassPath(jars:_*) + // the Scala interpreter will invalidate definitions for any package defined in + // the new Jars. This can easily include org.* and make the kernel inaccessible + // because it is bound using the previous package definition. To avoid problems, + // it is necessary to refresh variable definitions to use the new packages and + // to rebind the global definitions. + refreshDefinitions() + bindVariables() + } + + /** + * Binds a variable in the interpreter to a value. + * @param variableName The name to expose the value in the interpreter + * @param typeName The type of the variable, must be the fully qualified class name + * @param value The value of the variable binding + * @param modifiers Any annotation, scoping modifiers, etc on the variable + */ + override def bind( + variableName: String, + typeName: String, + value: Any, + modifiers: List[String] + ): Unit = { + logger.warn(s"Binding $modifiers $variableName $typeName $value") + require(iMain != null) + val sIMain = iMain + + val bindRep = new sIMain.ReadEvalPrint() + iMain.interpret(s"import $typeName") + bindRep.compile(""" + |object %s { + | var value: %s = _ + | def set(x: Any) = value = x.asInstanceOf[%s] + |} + """.stripMargin.format(bindRep.evalName, typeName, typeName) + ) + bindRep.callEither("set", value) match { + case Left(ex) => + logger.error("Set failed in bind(%s, %s, %s)".format(variableName, typeName, value)) + logger.error(util.stackTraceString(ex)) + Results.Error + + case Right(_) => + val line = "%sval %s = %s.value".format(modifiers map (_ + " ") mkString, variableName, bindRep.evalPath) + logger.debug("Interpreting: " + line) + iMain.interpret(line) + } + + } + + + /** + * Executes body and will not print anything to the console during the execution + * @param body The function to execute + * @tparam T The return type of body + * @return The return value of body + */ + override def doQuietly[T](body: => T): T = { + require(iMain != null) + iMain.withoutWarnings[T](body) + } + + + /** + * Stops the interpreter, removing any previous internal state. + * @return A reference to the interpreter + */ + override def stop(): Interpreter = { + logger.info("Shutting down interpreter") + + // Shut down the task manager (kills current execution + if (taskManager != null) taskManager.stop() + taskManager = null + + // Erase our completer + completer = null + + // Close the entire interpreter (loses all state) + if (iMain != null) iMain.close() + iMain = null + + this + } + + /** + * Returns the name of the variable created from the last execution. + * @return Some String name if a variable was created, otherwise None + */ + override def lastExecutionVariableName: Option[String] = { + require(iMain != null) + + // TODO: Get this API method changed back to public in Apache Spark + val lastRequestMethod = classOf[IMain].getDeclaredMethod("lastRequest") + lastRequestMethod.setAccessible(true) + + val mostRecentVariableName = iMain.mostRecentVar + + iMain.allDefinedNames.map(_.toString).find(_ == mostRecentVariableName) + } + + /** + * Mask the Console and System objects with our wrapper implementations + * and dump the Console methods into the public namespace (similar to + * the Predef approach). + * @param in The new input stream + * @param out The new output stream + * @param err The new error stream + */ + override def updatePrintStreams( + in: InputStream, + out: OutputStream, + err: OutputStream + ): Unit = { + val inReader = new BufferedReader(new InputStreamReader(in)) + val outPrinter = new PrintStream(out) + val errPrinter = new PrintStream(err) + + iMain.beQuietDuring { + iMain.bind( + "Console", classOf[WrapperConsole].getName, + new WrapperConsole(inReader, outPrinter, errPrinter), + List("""@transient""") + ) + iMain.bind( + "System", classOf[WrapperSystem].getName, + new WrapperSystem(in, out, err), + List("""@transient""") + ) + iMain.interpret("import Console._") + } + } + + /** + * Retrieves the contents of the variable with the provided name from the + * interpreter. + * @param variableName The name of the variable whose contents to read + * @return An option containing the variable contents or None if the + * variable does not exist + */ + override def read(variableName: String): Option[Any] = { + require(iMain != null) + + try { + iMain.valueOfTerm(variableName) + } catch { + // if any error returns None + case e: Throwable => { + logger.debug(s"Error reading variable name: ${variableName}", e) + clearLastException() + None + } + } + } + + /** + * Starts the interpreter, initializing any internal state. + * @return A reference to the interpreter + */ + override def start(): Interpreter = { + require(iMain == null && taskManager == null) + + taskManager = newTaskManager() + + logger.debug("Initializing task manager") + taskManager.start() + + iMain = newIMain(settings, new PrintWriter(lastResultOut, true)) + + //logger.debug("Initializing interpreter") + //iMain.initializeSynchronous() + + logger.debug("Initializing completer") + completer = new ReplCompletion(iMain) + + iMain.beQuietDuring { + //logger.info("Rerouting Console and System related input and output") + //updatePrintStreams(System.in, multiOutputStream, multiOutputStream) + + // ADD IMPORTS generates too many classes, client is responsible for adding import + logger.debug("Adding org.apache.spark.SparkContext._ to imports") + iMain.interpret("import org.apache.spark.SparkContext._") + + logger.debug("Adding the hack for the exception handling retrieval.") + iMain.bind("_exceptionHack", classOf[ExceptionHack].getName, exceptionHack, List("@transient")) + } + + this + } + + /** + * Attempts to perform code completion via the command. + * @param code The current cell to complete + * @param pos The cursor position + * @return The cursor position and list of possible completions + */ + override def completion(code: String, pos: Int): (Int, List[String]) = { + + require(completer != null) + + logger.debug(s"Attempting code completion for ${code}") + val result = completer.complete(code, pos) + + (result.cursor, result.candidates.map(_.toString)) + } + + /** + * Attempts to perform completeness checking for a statement by seeing if we can parse it + * using the scala parser. + * + * @param code The current cell to complete + * @return tuple of (completeStatus, indent) + */ + override def isComplete(code: String): (String, String) = { + import scala.language.existentials + val result = iMain.withoutWarnings { + val parse = iMain.parse(code) + parse match { + case Left(Results.Error) => ("invalid", "") + case Right(_) => ("invalid", "") + case Left(Results.Success) => + val lines = code.split("\n", -1) + val numLines = lines.length + // for multiline code blocks, require an empty line before executing + // to mimic the behavior of ipython + if (numLines > 1 && lines.last.matches("\\s*\\S.*")) { + ("incomplete", startingWhiteSpace(lines.last)) + } else { + ("complete", "") + } + case Left(Results.Incomplete) => + val lines = code.split("\n", -1) + // For now lets just grab the indent of the current line, if none default to 2 spaces. + ("incomplete", startingWhiteSpace(lines.last)) + } + } + lastResultOut.reset() + result + } + + private def startingWhiteSpace(line: String): String = { + val indent = "^\\s+".r.findFirstIn(line).getOrElse("") + // increase the indent if the line ends with => or { + if (line.matches(".*(?:(?:\\{)|(?:=>))\\s*")) { + indent + " " + } else { + indent + } + } + + override def newSettings(args: List[String]): Settings = { + val s = new Settings() + + val dir = ScalaInterpreter.ensureTemporaryFolder() + + s.processArguments(args ++ + List( + "-Yrepl-class-based", + "-Yrepl-outdir", s"$dir" + // useful for debugging compiler classpath or package issues + // "-uniqid", "-explaintypes", "-usejavacp", "-Ylog-classpath" + ), processAll = true) + s + } + + protected def interpretAddTask(code: String, silent: Boolean): Future[Results.Result] = { + if (iMain == null) throw new IllegalArgumentException("Interpreter not started yet!") + + taskManager.add { + // Add a task using the given state of our streams + StreamState.withStreams { + if (silent) { + iMain.withoutWarnings { + iMain.interpret(code) + } + } else { + iMain.interpret(code) + } + } + } + } + + private def retrieveLastException: Throwable = { + iMain.withoutWarnings { + iMain.interpret("_exceptionHack.lastException = lastException") + } + exceptionHack.lastException + } + + private def clearLastException(): Unit = { + iMain.directBind( + ExecutionExceptionName, + classOf[Throwable].getName, + null + ) + exceptionHack.lastException = null + } + + protected def interpretConstructExecuteError(output: String) = { + Option(retrieveLastException) match { + // Runtime error + case Some(e) => + val ex = e.asInstanceOf[Throwable] + clearLastException() + + // The scala REPL does a pretty good job of returning us a stack trace that is free from all the bits that the + // interpreter uses before it. + // + // The REPL emits its message as something like this, so trim off the first and last element + // + // java.lang.ArithmeticException: / by zero + // at failure(:17) + // at call_failure(:19) + // ... 40 elided + + val formattedException = output.split("\n") + + ExecuteError( + ex.getClass.getName, + ex.getLocalizedMessage, + formattedException.toList + ) + // Compile time error, need to check internal reporter + case _ => + if (iMain.reporter.hasErrors) + // TODO: This wrapper is not needed when just getting compile + // error that we are not parsing... maybe have it be purely + // output and have the error check this? + ExecuteError( + "Compile Error", output, List() + ) + else + // May as capture the output here. Could be useful + ExecuteError("Unknown Error", output, List()) + } + } +} + +class ExceptionHack { + var lastException: Throwable = _ +} diff --git a/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaDisplayers.scala b/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaDisplayers.scala index 08a8f07b7..ffd01a816 100644 --- a/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaDisplayers.scala +++ b/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaDisplayers.scala @@ -19,7 +19,7 @@ package org.apache.toree.kernel.interpreter.scala import java.util -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.collection.mutable import scala.util.Try import org.apache.spark.SparkContext diff --git a/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala b/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala index 82b7c9b7e..eef7e0ebf 100644 --- a/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala +++ b/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala @@ -31,11 +31,12 @@ import org.slf4j.LoggerFactory import org.apache.toree.kernel.BuildInfo import org.apache.toree.kernel.protocol.v5.MIMEType import scala.annotation.tailrec -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.concurrent.{Await, Future} import scala.language.reflectiveCalls import scala.tools.nsc.Settings -import scala.tools.nsc.interpreter.{IR, OutputStream} +import scala.tools.nsc.interpreter.Results +import java.io.OutputStream import scala.tools.nsc.util.ClassPath import scala.util.matching.Regex import scala.concurrent.duration.Duration @@ -131,7 +132,7 @@ class ScalaInterpreter(private val config:Config = ConfigFactory.load) extends I } protected def interpreterArgs(kernel: KernelLike): List[String] = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ if (kernel == null || kernel.config == null) { List() } @@ -188,7 +189,7 @@ class ScalaInterpreter(private val config:Config = ConfigFactory.load) extends I } override def interpret(code: String, silent: Boolean = false, output: Option[OutputStream]): - (Results.Result, Either[ExecuteOutput, ExecuteFailure]) = { + (org.apache.toree.interpreter.Results.Result, Either[ExecuteOutput, ExecuteFailure]) = { interpretBlock(code, silent) } @@ -277,7 +278,7 @@ class ScalaInterpreter(private val config:Config = ConfigFactory.load) extends I } protected def interpretBlock(code: String, silent: Boolean = false): - (Results.Result, Either[ExecuteOutput, ExecuteFailure]) = { + (org.apache.toree.interpreter.Results.Result, Either[ExecuteOutput, ExecuteFailure]) = { logger.trace(s"Interpreting line: $code") @@ -294,23 +295,23 @@ class ScalaInterpreter(private val config:Config = ConfigFactory.load) extends I Await.result(futureResultAndExecuteInfo, Duration.Inf) } - protected def interpretMapToCustomResult(future: Future[IR.Result]): Future[Results.Result] = { + protected def interpretMapToCustomResult(future: Future[Results.Result]): Future[org.apache.toree.interpreter.Results.Result] = { import scala.concurrent.ExecutionContext.Implicits.global future map { - case IR.Success => Results.Success - case IR.Error => Results.Error - case IR.Incomplete => Results.Incomplete + case Results.Success => org.apache.toree.interpreter.Results.Success + case Results.Error => org.apache.toree.interpreter.Results.Error + case Results.Incomplete => org.apache.toree.interpreter.Results.Incomplete } recover { - case ex: ExecutionException => Results.Aborted + case ex: ExecutionException => org.apache.toree.interpreter.Results.Aborted } } - protected def interpretMapToResultAndOutput(future: Future[Results.Result]): - Future[(Results.Result, Either[Map[String, String], ExecuteError])] = { + protected def interpretMapToResultAndOutput(future: Future[org.apache.toree.interpreter.Results.Result]): + Future[(org.apache.toree.interpreter.Results.Result, Either[Map[String, String], ExecuteError])] = { import scala.concurrent.ExecutionContext.Implicits.global future map { - case result @ (Results.Success | Results.Incomplete) => + case result @ (org.apache.toree.interpreter.Results.Success | org.apache.toree.interpreter.Results.Incomplete) => val lastOutput = lastResultOut.toString("UTF-8").trim lastResultOut.reset() @@ -320,17 +321,17 @@ class ScalaInterpreter(private val config:Config = ConfigFactory.load) extends I val output = obj.map(Displayers.display(_).asScala.toMap).getOrElse(Map.empty) (result, Left(output)) - case Results.Error => + case org.apache.toree.interpreter.Results.Error => val lastOutput = lastResultOut.toString("UTF-8").trim lastResultOut.reset() val (obj, defStr, text) = prepareResult(lastOutput) defStr.foreach(kernel.display.content(MIMEType.PlainText, _)) val output = interpretConstructExecuteError(text.get) - (Results.Error, Right(output)) + (org.apache.toree.interpreter.Results.Error, Right(output)) - case Results.Aborted => - (Results.Aborted, Right(null)) + case org.apache.toree.interpreter.Results.Aborted => + (org.apache.toree.interpreter.Results.Aborted, Right(null)) } } diff --git a/scala-interpreter/src/test/scala-2.11/scala/ScalaInterpreterSpec.scala b/scala-interpreter/src/test/scala-2.11/scala/ScalaInterpreterSpec.scala index 9d024f1bb..50ce652be 100644 --- a/scala-interpreter/src/test/scala-2.11/scala/ScalaInterpreterSpec.scala +++ b/scala-interpreter/src/test/scala-2.11/scala/ScalaInterpreterSpec.scala @@ -25,7 +25,7 @@ import org.apache.toree.interpreter.Results.Result import org.apache.toree.interpreter._ import org.apache.toree.kernel.api.KernelLike import org.apache.toree.utils.TaskManager -import org.mockito.Matchers._ +import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ import org.scalatest.mock.MockitoSugar import org.scalatest.{BeforeAndAfter, FunSpec, Matchers} @@ -34,8 +34,8 @@ import scala.tools.nsc.Settings import scala.tools.nsc.interpreter.{IMain, IR, JPrintWriter} import scala.tools.nsc.util.ClassPath -class ScalaInterpreterSpec extends FunSpec - with Matchers with MockitoSugar with BeforeAndAfter +class ScalaInterpreterSpec extends AnyFunSpec + with Matchers with MockitoSugar with BeforeAndAfterEach { private var interpreter: ScalaInterpreter = _ private var interpreterNoPrintStreams: ScalaInterpreter = _ diff --git a/scala-interpreter/src/test/scala/integration/interpreter/scala/AddExternalJarMagicSpecForIntegration.scala b/scala-interpreter/src/test/scala/integration/interpreter/scala/AddExternalJarMagicSpecForIntegration.scala index fd96c5426..ccbc14b6f 100644 --- a/scala-interpreter/src/test/scala/integration/interpreter/scala/AddExternalJarMagicSpecForIntegration.scala +++ b/scala-interpreter/src/test/scala/integration/interpreter/scala/AddExternalJarMagicSpecForIntegration.scala @@ -19,19 +19,22 @@ package integration.interpreter.scala import java.io.{ByteArrayOutputStream, File} +import org.apache.toree.kernel.api.KernelLike +import org.apache.toree.kernel.interpreter.scala.ScalaInterpreter import org.apache.spark.toree.test.utils.JarUtils import org.apache.toree.annotations.SbtForked import org.apache.toree.global.StreamState import org.apache.toree.interpreter._ -import org.apache.toree.kernel.api.KernelLike -import org.apache.toree.kernel.interpreter.scala.ScalaInterpreter -import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfter, FunSpec, Ignore, Matchers} +import org.mockito.scalatest.MockitoSugar +import org.scalatest.{BeforeAndAfterEach, Ignore} +import org.scalatest.funspec.AnyFunSpecLike +import org.scalatest.matchers.should.Matchers + @SbtForked @Ignore class AddExternalJarMagicSpecForIntegration - extends FunSpec with Matchers with MockitoSugar with BeforeAndAfter + extends AnyFunSpecLike with Matchers with MockitoSugar with BeforeAndAfterEach { private val outputResult = new ByteArrayOutputStream() @@ -39,7 +42,7 @@ class AddExternalJarMagicSpecForIntegration private var tempdir: File = _ - before { + override def beforeEach(): Unit = { interpreter = new ScalaInterpreter { override protected def bindKernelVariable(kernel: KernelLike): Unit = { } } @@ -51,7 +54,7 @@ class AddExternalJarMagicSpecForIntegration tempdir = JarUtils.createTemporaryDir() } - after { + override def afterEach(): Unit = { interpreter.stop() outputResult.reset() } diff --git a/scala-interpreter/src/test/scala/integration/interpreter/scala/JVMReprSpec.scala b/scala-interpreter/src/test/scala/integration/interpreter/scala/JVMReprSpec.scala index 0d10834a2..5b43259fb 100644 --- a/scala-interpreter/src/test/scala/integration/interpreter/scala/JVMReprSpec.scala +++ b/scala-interpreter/src/test/scala/integration/interpreter/scala/JVMReprSpec.scala @@ -28,19 +28,22 @@ import org.apache.toree.interpreter.Results.Success import org.apache.toree.kernel.api.{DisplayMethodsLike, KernelLike} import org.apache.toree.kernel.interpreter.scala.ScalaInterpreter import org.mockito.Mockito.doReturn -import org.scalatest.{BeforeAndAfter, FunSpec, Ignore, Matchers} +import org.scalatest.Ignore +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.scalatestplus.mockito.MockitoSugar import scala.util.Random @SbtForked @Ignore -class JVMReprSpec extends FunSpec with Matchers with MockitoSugar with BeforeAndAfter { +class JVMReprSpec extends AnyFunSpec with Matchers with MockitoSugar with BeforeAndAfterEach { private val outputResult = new ByteArrayOutputStream() private var interpreter: Interpreter = _ - before { + override def beforeEach(): Unit = { val mockKernel = mock[KernelLike] val mockDisplayMethods = mock[DisplayMethodsLike] doReturn(mockDisplayMethods).when(mockKernel).display @@ -50,7 +53,7 @@ class JVMReprSpec extends FunSpec with Matchers with MockitoSugar with BeforeAnd StreamState.setStreams(outputStream = outputResult) } - after { + override def afterEach(): Unit = { interpreter.stop() outputResult.reset() } diff --git a/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlInterpreter.scala b/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlInterpreter.scala index 29e988aa0..871db33e6 100644 --- a/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlInterpreter.scala +++ b/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlInterpreter.scala @@ -25,7 +25,7 @@ import org.apache.toree.kernel.BuildInfo import scala.concurrent.Await import scala.concurrent.duration._ -import scala.tools.nsc.interpreter.{InputStream, OutputStream} +import java.io.{InputStream, OutputStream} /** * Represents an interpreter interface to Spark SQL. diff --git a/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlService.scala b/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlService.scala index 4c6fd1a3a..0c0c6e543 100644 --- a/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlService.scala +++ b/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlService.scala @@ -16,7 +16,7 @@ */ package org.apache.toree.kernel.interpreter.sql -import java.io.ByteArrayOutputStream +import java.io.{ByteArrayOutputStream, OutputStream} import org.apache.toree.interpreter.broker.BrokerService import org.apache.toree.kernel.api.KernelLike diff --git a/src/test/scala/system/StdinForSystemSpec.scala b/src/test/scala/system/StdinForSystemSpec.scala index e44e4a519..4b832b560 100644 --- a/src/test/scala/system/StdinForSystemSpec.scala +++ b/src/test/scala/system/StdinForSystemSpec.scala @@ -20,13 +20,15 @@ package system import org.apache.toree.kernel.protocol.v5.client.SparkKernelClient import org.scalatest.concurrent.Eventually import org.scalatest.time.{Seconds, Milliseconds, Span} -import org.scalatest.{BeforeAndAfterAll, FunSpec, Matchers} +import org.scalatest.BeforeAndAfterAll +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import test.utils.root.{SparkKernelClientDeployer, SparkKernelDeployer} /** * Tests all stdin-related functionality between the client and kernel. */ -class StdinForSystemSpec extends FunSpec with Matchers with BeforeAndAfterAll +class StdinForSystemSpec extends AnyFunSpec with Matchers with BeforeAndAfterAll with Eventually { implicit override val patienceConfig = PatienceConfig(