diff --git a/build.sbt b/build.sbt index c5e01867b..e1376d0b5 100644 --- a/build.sbt +++ b/build.sbt @@ -9,11 +9,13 @@ ThisBuild / startYear := Some(2006) ThisBuild / organizationName := "WorldWide Conferencing, LLC" val scala213Version = "2.13.16" +val scala3LTSVersion = "3.3.6" ThisBuild / scalaVersion := scala213Version +ThisBuild / crossScalaVersions := Seq(scala213Version, scala3LTSVersion) -ThisBuild / libraryDependencies ++= Seq(specs2, specs2Matchers, specs2Mock, scalacheck, scalactic, scalatest) +ThisBuild / libraryDependencies ++= Seq(specs2, specs2Matchers, scalacheck, scalactic, scalatest) ThisBuild / scalacOptions ++= Seq("-deprecation") @@ -56,7 +58,7 @@ lazy val common = coreProject("common") .settings( description := "Common Libraries and Utilities", - libraryDependencies ++= Seq(slf4j_api, logback, slf4j_log4j12, scala_xml, scala_parser) + libraryDependencies ++= Seq(slf4j_api, logback, slf4j_log4j12, scala_xml, scala_parser, scalamock) ) lazy val actor = @@ -154,7 +156,8 @@ lazy val webkit = mockito_scalatest, jquery, jasmineCore, - jasmineAjax + jasmineAjax, + specs2Mock ), libraryDependencies ++= { CrossVersion.partialVersion(scalaVersion.value) match { @@ -197,58 +200,3 @@ lazy val webkit = ) .enablePlugins(SbtWeb) - -// Persistence Projects -// -------------------- -lazy val persistence: Seq[ProjectReference] = - Seq(db, proto, mapper, record, mongodb, mongodb_record) - -lazy val db = - persistenceProject("db") - .dependsOn(util, webkit) - .settings(libraryDependencies += mockito_scalatest) - -lazy val proto = - persistenceProject("proto") - .dependsOn(webkit) - -lazy val mapper = - persistenceProject("mapper") - .dependsOn(db, proto) - .settings( - description := "Mapper Library", - Test / parallelExecution := false, - libraryDependencies ++= Seq(h2, derby, jbcrypt), - Test / initialize := { - System.setProperty( - "derby.stream.error.file", - ((Test / crossTarget).value / "derby.log").absolutePath - ) - } - ) - -lazy val record = - persistenceProject("record") - .dependsOn(proto) - .settings(libraryDependencies ++= Seq(jbcrypt)) - -lazy val mongodb = - persistenceProject("mongodb") - .dependsOn(json_ext, util) - .settings( - Test / parallelExecution := false, - libraryDependencies ++= Seq(mongo_java_driver, mongo_java_driver_async), - Test / initialize := { - System.setProperty( - "java.util.logging.config.file", - ((Test / resourceDirectory).value / "logging.properties").absolutePath - ) - } - ) - -lazy val mongodb_record = - persistenceProject("mongodb-record") - .dependsOn(record, mongodb) - .settings( - Test / parallelExecution := false - ) diff --git a/core/common/src/main/scala/net/liftweb/common/Box.scala b/core/common/src/main/scala/net/liftweb/common/Box.scala index a6faecbd3..ea6d073a7 100644 --- a/core/common/src/main/scala/net/liftweb/common/Box.scala +++ b/core/common/src/main/scala/net/liftweb/common/Box.scala @@ -275,7 +275,7 @@ sealed trait BoxTrait extends OptionImplicits { * res1: net.liftweb.common.Box[Int] = Full(5) * }}} */ - def asA[B](in: T forSome { type T })(implicit m: Manifest[B]): Box[B] = { + def asA[B](in: Any)(implicit m: Manifest[B]): Box[B] = { (Box !! in).asA[B] } } @@ -1118,11 +1118,11 @@ object BoxOrRaw { RawBoxOrRaw(r: T) implicit def boxToBoxOrRaw[T, Q](r: Box[Q])(implicit ev: Q => T): BoxOrRaw[T] = { - BoxedBoxOrRaw(r.map(v => v: T)) + BoxedBoxOrRaw(r.map(v => ev(v))) } implicit def optionToBoxOrRaw[T, Q](r: Option[Q])(implicit ev: Q => T): BoxOrRaw[T] = { - BoxedBoxOrRaw(r.map(v => v: T)) + BoxedBoxOrRaw(r.map(v => ev(v))) } implicit def borToBox[T](in: BoxOrRaw[T]): Box[T] = in.box diff --git a/core/common/src/main/scala/net/liftweb/common/BoxLogging.scala b/core/common/src/main/scala/net/liftweb/common/BoxLogging.scala index 6aae0a13c..da8e7aa3a 100644 --- a/core/common/src/main/scala/net/liftweb/common/BoxLogging.scala +++ b/core/common/src/main/scala/net/liftweb/common/BoxLogging.scala @@ -143,7 +143,7 @@ trait BoxLogging { } } - private def logFailure(message: String, logFn: (String, Option[Throwable])=>Unit): Unit = { + def logFailure(message: String, logFn: (String, Option[Throwable])=>Unit): Unit = { doLog(message, logFn, ()=>logFn(s"$message: Box was Empty.", None)) } diff --git a/core/common/src/main/scala/net/liftweb/common/Conversions.scala b/core/common/src/main/scala/net/liftweb/common/Conversions.scala index 7fb20fdca..0a03a4bd0 100644 --- a/core/common/src/main/scala/net/liftweb/common/Conversions.scala +++ b/core/common/src/main/scala/net/liftweb/common/Conversions.scala @@ -48,7 +48,7 @@ sealed trait StringOrNodeSeq { * their needs dictate. */ object StringOrNodeSeq { - implicit def strTo[T](str: T)(implicit ev: T => String): StringOrNodeSeq = + implicit def strTo(str: String): StringOrNodeSeq = new StringOrNodeSeq { def nodeSeq: NodeSeq = Text(str) } diff --git a/core/common/src/main/scala/net/liftweb/common/LRU.scala b/core/common/src/main/scala/net/liftweb/common/LRU.scala index 7cabb659a..f70b21ef6 100644 --- a/core/common/src/main/scala/net/liftweb/common/LRU.scala +++ b/core/common/src/main/scala/net/liftweb/common/LRU.scala @@ -131,9 +131,9 @@ class LRUMap[K, V](initMaxSize: Int, loadFactor: Box[Float], expiredFunc: ((K, V def remove(key: K): Unit = { localMap.get(key) match { case null => - case v => - v.remove - localMap.remove(key) + case v => + v.remove + localMap.remove(key) } } @@ -148,9 +148,9 @@ class LRUMap[K, V](initMaxSize: Int, loadFactor: Box[Float], expiredFunc: ((K, V localMap.get(key) match { case null => val what = new LinkedListElem[K, V] {def value1 = key} - what.value2 = value - addAtHead(what) - localMap.put(key, what) + what.value2 = value + addAtHead(what) + localMap.put(key, what) doRemoveIfTooMany() diff --git a/core/common/src/test/scala/net/liftweb/common/BoxLoggingSpec.scala b/core/common/src/test/scala/net/liftweb/common/BoxLoggingSpec.scala index c5d099c2d..285b812b7 100644 --- a/core/common/src/test/scala/net/liftweb/common/BoxLoggingSpec.scala +++ b/core/common/src/test/scala/net/liftweb/common/BoxLoggingSpec.scala @@ -3,10 +3,10 @@ package common import org.slf4j.{Logger=>SLF4JLogger} -import org.specs2.mock.Mockito +import org.scalamock.specs2.MockContext import org.specs2.mutable.Specification -class BoxLoggingSpec extends Specification with Mockito { +class BoxLoggingSpec extends Specification { class MockBoxLoggingClass extends BoxLogging { var loggedErrors = List[(String, Option[Throwable])]() var loggedWarns = List[(String, Option[Throwable])]() @@ -410,44 +410,45 @@ class BoxLoggingSpec extends Specification with Mockito { import net.liftweb.common.Logger import org.slf4j.{Logger => SLF4JLogger} - val mockLogger = mock[SLF4JLogger] - mockLogger.isErrorEnabled() returns true + "log to the Lift logger" in new MockContext { + val mockLogger = mock[SLF4JLogger] + (mockLogger.isErrorEnabled: () => Boolean).expects().returning(true).anyNumberOfTimes() - class MyLoggable extends LoggableBoxLogging { - override val logger = new Logger { - override protected def _logger = mockLogger + class MyLoggable extends LoggableBoxLogging { + override val logger = new Logger { + override protected def _logger = mockLogger + } } - } - "log to the Lift logger" in { + (mockLogger.error(_: String)).expects(*).once() + (mockLogger.error(_: String, _: Throwable)).expects(*, *).once() + val result = new MyLoggable { Failure("Failed").logFailure("Second") Failure("Excepted", Full(new Exception("uh-oh")), Empty).logFailure("Third") } - - (there was one(mockLogger).error(any[String])) and - (there was one(mockLogger).error(any[String], any[Exception])) } } "when logging with in SLF4J context" in { import org.slf4j.{Logger => SLF4JLogger} - val mockLogger = mock[SLF4JLogger] + "log to the SLF4J logger" in new MockContext { + val mockLogger = mock[SLF4JLogger] + (mockLogger.isErrorEnabled: () => Boolean).expects().returning(true).anyNumberOfTimes() - class TestClass extends SLF4JBoxLogging { - val logger = mockLogger - } + class TestClass extends SLF4JBoxLogging { + val logger = mockLogger + } + + (mockLogger.error(_: String)).expects(*).once() + (mockLogger.error(_: String, _: Throwable)).expects(*, *).once() - "log to the SLF4J logger" in { new TestClass { Failure("Failed").logFailure("Second") Failure("Excepted", Full(new Exception("uh-oh")), Empty).logFailure("Third") } - - there was one(mockLogger).error(any[String]) - there was one(mockLogger).error(any[String], any[Exception]) } } } diff --git a/core/common/src/test/scala/net/liftweb/common/BoxSpec.scala b/core/common/src/test/scala/net/liftweb/common/BoxSpec.scala index 7d35c31f7..1977aa4c6 100644 --- a/core/common/src/test/scala/net/liftweb/common/BoxSpec.scala +++ b/core/common/src/test/scala/net/liftweb/common/BoxSpec.scala @@ -49,13 +49,13 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator { "A Box" can { "be created from a Option. It is Empty if the option is None" in { - Box(None) must beEmpty + Box(None) must be_==(Empty) } "be created from a Option. It is Full(x) if the option is Some(x)" in { Box(Some(1)) must_== Full(1) } "be created from a List containing one element. It is Empty if the list is empty" in { - Box(Nil) must beEmpty + Box(Nil) must be_==(Empty) } "be created from a List containing one element. It is Full(x) if the list is List(x)" in { Box(List(1)) must_== Full(1) @@ -122,7 +122,7 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator { Full(1) filter {_ > 0} must_== Full(1) } "define a 'filter' method, returning Empty if the filter is not satisfied" in { - Full(1) filter {_ == 0} must beEmpty + Full(1) filter {_ == 0} must be_==(Empty) } "define a 'filterMsg' method, returning a Failure if the filter predicate is not satisfied" in { Full(1).filterMsg("not equal to 0")(_ == 0) must_== Failure("not equal to 0", Empty, Empty) @@ -136,10 +136,10 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator { Full(1) map { _.toString } must_== Full("1") } "define a 'flatMap' method transforming its value in another Box. If the value is transformed in a Full box, the total result is a Full box" in { - Full(1) flatMap { x: Int => if (x > 0) Full("full") else Empty } must_== Full("full") + Full(1) flatMap { (x: Int) => if (x > 0) Full("full") else Empty } must_== Full("full") } "define a 'flatMap' method transforming its value in another Box. If the value is transformed in an Empty box, the total result is an Empty box" in { - Full(0) flatMap { x: Int => if (x > 0) Full("full") else Empty } must beEmpty + Full(0) flatMap { (x: Int) => if (x > 0) Full("full") else Empty } must be_==(Empty) } "define a 'flatten' method if it contains another Box." in { "If the inner box is a Full box, the final result is identical to that box" in { @@ -157,7 +157,7 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator { Full("Albus") collect { case "Albus" => "Dumbledore"} must_== Full("Dumbledore") } "If the partial-function is not defined for the contents of this box, returns Empty" in { - Full("Hermione") collect { case "Albus" => "Dumbledore"} must beEmpty + Full("Hermione") collect { case "Albus" => "Dumbledore"} must be_==(Empty) } } "define a 'transform' method that takes a PartialFunction to transform this box into another box" in { @@ -193,7 +193,7 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator { } "define a 'pass' method passing the can to a function and returning itself (alias: $)" in { var empty = false - def emptyString(s: Box[String]) = s foreach {c: String => empty = c.isEmpty} + def emptyString(s: Box[String]) = s foreach {(c: String) => empty = c.isEmpty} Full("") $ emptyString _ empty must beTrue } @@ -290,7 +290,7 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator { } "return itself if filtered with a predicate" in { val empty: Box[Int] = Empty - empty.filter {_ > 0} must beEmpty + empty.filter {_ > 0} must be_==(Empty) } "define an 'exists' method returning false" in { val empty: Box[Int] = Empty @@ -302,7 +302,7 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator { } "define a 'filter' method, returning Empty" in { val empty: Box[Int] = Empty - empty filter {_ > 0} must beEmpty + empty filter {_ > 0} must be_==(Empty) } "define a 'filterMsg' method, returning a Failure" in { Empty.filterMsg("not equal to 0")(_ == 0) must_== Failure("not equal to 0", Empty, Empty) @@ -314,16 +314,16 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator { total must_== 0 } "define a 'map' method returning Empty" in { - Empty map {_.toString} must beEmpty + Empty map {_.toString} must be_==(Empty) } "define a 'flatMap' method returning Empty" in { - Empty flatMap {x: Int => Full("full")} must beEmpty + Empty flatMap {(x: Int) => Full("full")} must be_==(Empty) } "define a 'flatten' method returning Empty" in { - Empty.flatten must beEmpty + Empty.flatten must be_==(Empty) } "define a 'collect' method returning Empty" in { - Empty collect { case _ => "Some Value" } must beEmpty + Empty collect { case _ => "Some Value" } must be_==(Empty) } "define a 'transform' method that takes a PartialFunction to transform this Empty box into another box" in { "If the partial-function is defined for Empty, returns the result of applying the partial function to it" in { @@ -399,7 +399,7 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator { "A Failure is an Empty Box which" should { "return itself if mapped, flatMapped or flattened" in { Failure("error", Empty, Empty) map {_.toString} must_== Failure("error", Empty, Empty) - Failure("error", Empty, Empty) flatMap {x: String => Full(x.toString)} must_== Failure("error", Empty, Empty) + Failure("error", Empty, Empty) flatMap {(x: String) => Full(x.toString)} must_== Failure("error", Empty, Empty) Failure("error", Empty, Empty).flatten must_== Failure("error", Empty, Empty) } "define a 'collect' method returning itself" in { diff --git a/core/util/src/main/scala/net/liftweb/util/HtmlParser.scala b/core/util/src/main/scala/net/liftweb/util/HtmlParser.scala index e58eedabd..23f2772f1 100644 --- a/core/util/src/main/scala/net/liftweb/util/HtmlParser.scala +++ b/core/util/src/main/scala/net/liftweb/util/HtmlParser.scala @@ -358,20 +358,20 @@ trait Html5Parser { if (capture) { val text = buffer.toString() if (text.length() > 0) { - hStack.push(createText(text)) + hStack = hStack.prepended(createText(text)) } } buffer.setLength(0) } } - saxer.scopeStack.push(TopScope) + saxer.scopeStack = saxer.scopeStack.prepended(TopScope) hp.setContentHandler(saxer) val is = new InputSource(in) is.setEncoding("UTF-8") hp.parse(is) - saxer.scopeStack.pop() + saxer.scopeStack = saxer.scopeStack.drop(1) in.close() saxer.rootElem match { diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 7007e44cc..9b7a92621 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -41,10 +41,10 @@ object Dependencies { lazy val scala_compiler: ModuleMap = "org.scala-lang" % "scala-compiler" % _ lazy val scalaz7_core = "org.scalaz" %% "scalaz-core" % "7.2.28" lazy val slf4j_api = "org.slf4j" % "slf4j-api" % slf4jVersion - lazy val scala_xml = "org.scala-lang.modules" %% "scala-xml" % "1.3.0" + lazy val scala_xml = "org.scala-lang.modules" %% "scala-xml" % "2.1.0" lazy val scala_parallel_collections = "org.scala-lang.modules" %% "scala-parallel-collections" % "0.2.0" lazy val rhino = "org.mozilla" % "rhino" % "1.7.15" - lazy val scala_parser = "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2" + lazy val scala_parser = "org.scala-lang.modules" %% "scala-parser-combinators" % "2.4.0" lazy val xerces = "xerces" % "xercesImpl" % "2.11.0" // Aliases @@ -72,18 +72,20 @@ object Dependencies { lazy val derby = "org.apache.derby" % "derby" % "10.7.1.1" % Test lazy val h2database = "com.h2database" % "h2" % "1.2.147" % Test - lazy val specs2 = "org.specs2" %% "specs2-core" % "4.9.4" % Test + lazy val specs2 = "org.specs2" %% "specs2-core" % "4.21.0" % Test lazy val scalacheck = "org.specs2" %% "specs2-scalacheck" % specs2.revision % Test lazy val specs2Prov = "org.specs2" %% "specs2-core" % specs2.revision % Provided lazy val specs2Matchers = "org.specs2" %% "specs2-matcher-extra" % specs2.revision % Test lazy val specs2MatchersProv = "org.specs2" %% "specs2-matcher-extra" % specs2.revision % Provided lazy val specs2Mock = "org.specs2" %% "specs2-mock" % specs2.revision % Test - lazy val scalactic = "org.scalactic" %% "scalactic" % "3.1.2" % Test - lazy val scalatest = "org.scalatest" %% "scalatest" % "3.1.2" % Test + lazy val scalactic = "org.scalactic" %% "scalactic" % "3.2.19" % Test + lazy val scalatest = "org.scalatest" %% "scalatest" % "3.2.19" % Test lazy val scalatest_junit = "org.scalatestplus" %% "junit-4-12" % "3.1.2.0" % Test lazy val mockito_scalatest = "org.mockito" %% "mockito-scala-scalatest" % "1.14.3" % Test + lazy val scalamock = "org.scalamock" %% "scalamock" % "7.4.1" % Test + // Aliases lazy val h2 = h2database diff --git a/project/metals.sbt b/project/metals.sbt index a41ee3179..69465cb55 100644 --- a/project/metals.sbt +++ b/project/metals.sbt @@ -3,6 +3,6 @@ // This file enables sbt-bloop to create bloop config files. -addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.10") +addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.13") // format: on