Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 6 additions & 58 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -154,7 +156,8 @@ lazy val webkit =
mockito_scalatest,
jquery,
jasmineCore,
jasmineAjax
jasmineAjax,
specs2Mock
),
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
Expand Down Expand Up @@ -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
)
6 changes: 3 additions & 3 deletions core/common/src/main/scala/net/liftweb/common/Box.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions core/common/src/main/scala/net/liftweb/common/LRU.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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()

Expand Down
41 changes: 21 additions & 20 deletions core/common/src/test/scala/net/liftweb/common/BoxLoggingSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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])]()
Expand Down Expand Up @@ -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])
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions core/common/src/test/scala/net/liftweb/common/BoxSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions core/util/src/main/scala/net/liftweb/util/HtmlParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading