Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Removed all the open_! calls #1333

Closed
wants to merge 1 commit into from

3 participants

@fmpwizard
Owner

We deprecated open_!, so I'm replacing it for openOrThrowException or map/flatMap/etc where appropriate.

@fmpwizard fmpwizard was assigned
@nafg
@tuhlmann
Collaborator
@fmpwizard
Owner

I agree with Torsten, when I use openOrThrowException, I'm using the String parameter to explain why it was ok to use it (sometimes it is a test, sometimes we checked that the box is full just a line abobe it, etc).

@fmpwizard fmpwizard closed this in ac5316b
@fmpwizard fmpwizard reopened this
@fmpwizard fmpwizard closed this in 9281228
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 17, 2012
  1. @fmpwizard
This page is out of date. Refresh to see the latest.
Showing with 209 additions and 197 deletions.
  1. +31 −32 core/actor/src/main/scala/net/liftweb/actor/LiftActor.scala
  2. +1 −1  core/common/src/main/scala/net/liftweb/common/LRU.scala
  3. +3 −3 core/common/src/test/scala/net/liftweb/common/BoxSpec.scala
  4. +1 −1  core/util/src/main/scala/net/liftweb/util/FatLazy.scala
  5. +0 −1  core/util/src/main/scala/net/liftweb/util/JSONParser.scala
  6. +1 −1  core/util/src/test/scala/net/liftweb/util/BindHelpersSpec.scala
  7. +2 −2 core/util/src/test/scala/net/liftweb/util/BundleBuilderSpec.scala
  8. +2 −2 core/util/src/test/scala/net/liftweb/util/ClassHelpersSpec.scala
  9. +7 −7 core/util/src/test/scala/net/liftweb/util/Html5ParserSpec.scala
  10. +5 −5 core/util/src/test/scala/net/liftweb/util/JsonParserSpec.scala
  11. +1 −1  core/util/src/test/scala/net/liftweb/util/MailerSpec.scala
  12. +3 −3 core/util/src/test/scala/net/liftweb/util/PCDataXmlParserSpec.scala
  13. +1 −1  core/util/src/test/scala/net/liftweb/util/XmlParserSpec.scala
  14. +1 −1  persistence/couchdb/src/main/scala/net/liftweb/couchdb/CouchRecord.scala
  15. +2 −2 persistence/couchdb/src/main/scala/net/liftweb/couchdb/Database.scala
  16. +7 −1 persistence/couchdb/src/main/scala/net/liftweb/couchdb/DocumentHelpers.scala
  17. +1 −1  persistence/couchdb/src/test/scala/net/liftweb/couchdb/CouchDocumentSpec.scala
  18. +11 −7 persistence/couchdb/src/test/scala/net/liftweb/couchdb/CouchQuerySpec.scala
  19. +14 −9 persistence/couchdb/src/test/scala/net/liftweb/couchdb/CouchRecordSpec.scala
  20. +1 −1  persistence/mapper/src/main/scala/net/liftweb/mapper/AjaxMapper.scala
  21. +1 −1  persistence/mapper/src/main/scala/net/liftweb/mapper/HasManyThrough.scala
  22. +5 −5 persistence/mapper/src/main/scala/net/liftweb/mapper/MappedField.scala
  23. +1 −1  persistence/mapper/src/main/scala/net/liftweb/mapper/MappedForeignKey.scala
  24. +5 −5 persistence/mapper/src/main/scala/net/liftweb/mapper/MetaMapper.scala
  25. +2 −1  persistence/mapper/src/main/scala/net/liftweb/mapper/view/ModelView.scala
  26. +1 −1  persistence/mapper/src/main/scala/net/liftweb/mapper/view/TableEditor.scala
  27. +3 −3 persistence/mapper/src/test/scala/net/liftweb/mapper/DbSpec.scala
  28. +3 −3 persistence/mapper/src/test/scala/net/liftweb/mapper/MappedBooleanSpec.scala
  29. +3 −3 persistence/mapper/src/test/scala/net/liftweb/mapper/MappedDecimalSpec.scala
  30. +1 −1  persistence/mapper/src/test/scala/net/liftweb/mapper/MappedLongForeignKeySpec.scala
  31. +22 −22 persistence/mapper/src/test/scala/net/liftweb/mapper/MapperSpec.scala
  32. +1 −1  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/MongoMetaRecord.scala
  33. +1 −1  persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/MongoRecordExamplesSpec.scala
  34. +3 −3 persistence/proto/src/main/scala/net/liftweb/proto/Crudify.scala
  35. +3 −3 persistence/proto/src/main/scala/net/liftweb/proto/ProtoUser.scala
  36. +1 −1  web/testkit/src/main/scala/net/liftweb/http/testing/TestRunner.scala
  37. +1 −3 web/webkit/src/main/scala/net/liftweb/builtin/snippet/Comet.scala
  38. +4 −4 web/webkit/src/main/scala/net/liftweb/http/LiftScreen.scala
  39. +3 −3 web/webkit/src/main/scala/net/liftweb/http/LiftServlet.scala
  40. +2 −2 web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala
  41. +1 −1  web/webkit/src/main/scala/net/liftweb/http/Req.scala
  42. +6 −6 web/webkit/src/main/scala/net/liftweb/http/S.scala
  43. +2 −2 web/webkit/src/main/scala/net/liftweb/http/Templates.scala
  44. +2 −2 web/webkit/src/main/scala/net/liftweb/http/provider/servlet/HTTPRequestServlet.scala
  45. +1 −1  web/webkit/src/main/scala/net/liftweb/http/rest/RestHelper.scala
  46. +1 −1  web/webkit/src/test/scala/net/liftweb/http/ReqSpec.scala
  47. +15 −15 web/webkit/src/test/scala/net/liftweb/http/SnippetSpec.scala
  48. +1 −1  web/webkit/src/test/scala/net/liftweb/sitemap/MenuDSLSpec.scala
  49. +6 −6 web/webkit/src/test/scala/net/liftweb/webapptest/OneShot.scala
  50. +2 −2 web/webkit/src/test/scala/net/liftweb/webapptest/ToHeadUsages.scala
  51. +11 −11 web/wizard/src/test/scala/net/liftweb/wizard/WizardSpec.scala
View
63 core/actor/src/main/scala/net/liftweb/actor/LiftActor.scala
@@ -211,20 +211,19 @@ trait SpecializedLiftActor[T] extends SimpleActor[T] {
}
}
-/**
- * A list of LoanWrappers that will be executed around the evaluation of mailboxes
- */
-protected def aroundLoans: List[CommonLoanWrapper] = Nil
-
-/**
- * You can wrap calls around the evaluation of the mailbox. This allows you to set up
- * the environment
- */
-protected def around[R](f: => R): R = aroundLoans match {
- case Nil => f
- case xs => CommonLoanWrapper(xs)(f)
-}
+ /**
+ * A list of LoanWrappers that will be executed around the evaluation of mailboxes
+ */
+ protected def aroundLoans: List[CommonLoanWrapper] = Nil
+ /**
+ * You can wrap calls around the evaluation of the mailbox. This allows you to set up
+ * the environment
+ */
+ protected def around[R](f: => R): R = aroundLoans match {
+ case Nil => f
+ case xs => CommonLoanWrapper(xs)(f)
+ }
private def proc2(ignoreProcessing: Boolean) {
var clearProcessing = true
baseMailbox.synchronized {
@@ -257,27 +256,27 @@ protected def around[R](f: => R): R = aroundLoans match {
while (keepOnDoingHighPriory) {
val hiPriPfBox = highPriorityReceive
- if (hiPriPfBox.isDefined) {
- val hiPriPf = hiPriPfBox.open_!
- findMailboxItem(baseMailbox.next, mb => testTranslate(hiPriPf.isDefinedAt)(mb.item)) match {
- case Full(mb) =>
- mb.remove()
- try {
- execTranslate(hiPriPf)(mb.item)
- } catch {
- case e: Exception => if (eh.isDefinedAt(e)) eh(e)
- }
- case _ =>
- baseMailbox.synchronized {
- if (msgList.isEmpty) {
- keepOnDoingHighPriory = false
+ hiPriPfBox.map{
+ hiPriPf =>
+ findMailboxItem(baseMailbox.next, mb => testTranslate(hiPriPf.isDefinedAt)(mb.item)) match {
+ case Full(mb) =>
+ mb.remove()
+ try {
+ execTranslate(hiPriPf)(mb.item)
+ } catch {
+ case e: Exception => if (eh.isDefinedAt(e)) eh(e)
}
- else {
- putListIntoMB()
+ case _ =>
+ baseMailbox.synchronized {
+ if (msgList.isEmpty) {
+ keepOnDoingHighPriory = false
+ }
+ else {
+ putListIntoMB()
+ }
}
- }
- } }
- else {keepOnDoingHighPriory = false}
+ }
+ }.openOr{keepOnDoingHighPriory = false}
}
val pf = messageHandler
View
2  core/common/src/main/scala/net/liftweb/common/LRU.scala
@@ -85,7 +85,7 @@ class LRUMap[K, V](initMaxSize: Int, loadFactor: Box[Float], expiredFunc: ((K, V
Full(v.value2)
}
- def apply(key: K) = get(key).open_!
+ def apply(key: K) = get(key).openOrThrowException("Simulating what happens with a regular Map, use contains(key) to check if it is present or not.")
def contains(key: K): Boolean = localMap.containsKey(key)
View
6 core/common/src/test/scala/net/liftweb/common/BoxSpec.scala
@@ -71,7 +71,7 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator {
Empty.isDefined must beFalse
}
"be implicitly defined from an Option. The open_! method can be used on an Option for example" in {
- Some(1).open_! must_== 1
+ Some(1).openOrThrowException("This is a test") must_== 1
}
"be defined from some legacy code (possibly passing null values). If the passed value is not null, a Full(value) is returned" in {
Box.legacyNullTest("s") must_== Full("s")
@@ -98,7 +98,7 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator {
Full(1).isDefined must beTrue
}
"return its value when opened" in {
- Full(1).open_! must_== 1
+ Full(1).openOrThrowException("This is a test") must_== 1
}
"return its value when opened with openOr(default value)" in {
Full(1) openOr 0 must_== 1
@@ -223,7 +223,7 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator {
Empty.isDefined must beFalse
}
"throw an exception if opened" in {
- {Empty.open_!; ()} must throwA[NullPointerException]
+ {Empty.openOrThrowException("See what happens?, at least we expect it in this case :)"); ()} must throwA[NullPointerException]
}
"return a default value if opened with openOr" in {
Empty.openOr(1) must_== 1
View
2  core/util/src/main/scala/net/liftweb/util/FatLazy.scala
@@ -48,7 +48,7 @@ class FatLazy[T](f: => T) {
value match {
case Full(v) => v
case _ => value = Full(f)
- value.open_!
+ value.openOrThrowException("We just checked that this is a Full box.")
}
}
View
1  core/util/src/main/scala/net/liftweb/util/JSONParser.scala
@@ -19,7 +19,6 @@ package util
import scala.util.parsing.combinator.{Parsers, ImplicitConversions}
import common._
-
object JSONParser extends SafeSeqParser with ImplicitConversions {
implicit def strToInput(in: String): Input = new scala.util.parsing.input.CharArrayReader(in.toCharArray)
type Elem = Char
View
2  core/util/src/test/scala/net/liftweb/util/BindHelpersSpec.scala
@@ -190,7 +190,7 @@ object BindHelpersSpec extends Specification {
e => e.attribute("id").
filter(_.text == "3").
map(i => e)
- }.open_! must ==/ (<woof id="3"/>)
+ }.openOrThrowException("Test") must ==/ (<woof id="3"/>)
}
"not find an ide" in {
View
4 core/util/src/test/scala/net/liftweb/util/BundleBuilderSpec.scala
@@ -36,7 +36,7 @@ object BundleBuilderSpec extends Specification {
<div name="dog" lang="en">Dog</div>
<div name="dog" lang="fr">Chien</div>
<div name="cat"><div>hi</div></div>
- </div>, Locale.US).open_!
+ </div>, Locale.US).openOrThrowException("Test")
b.getObject("dog") must_== "Dog"
b.getObject("cat").asInstanceOf[NodeSeq] must ==/ (<div>hi</div>)
@@ -47,7 +47,7 @@ object BundleBuilderSpec extends Specification {
<div name="dog" lang="zz">Dog</div>
<div name="dog" lang="fr" default="true" >Chien</div>
<div name="cat"><div>hi</div></div>
- </div>, Locale.US).open_!
+ </div>, Locale.US).openOrThrowException("Test")
b.getObject("dog") must_== "Chien"
b.getObject("cat").asInstanceOf[NodeSeq] must ==/ (<div>hi</div>)
View
4 core/util/src/test/scala/net/liftweb/util/ClassHelpersSpec.scala
@@ -174,10 +174,10 @@ object ClassHelpersSpec extends Specification {
createInvoker("length", null) must_== Empty
}
"return a Full can with the function from Unit to a can containing the result of the method to invoke" in {
- createInvoker("length", "").open_!.apply().get must_== 0
+ createInvoker("length", "").openOrThrowException("Test").apply().get must_== 0
}
"The invoker function will throw the cause exception if the method can't be called" in {
- createInvoker("get", "").open_!.apply must throwA[Exception]
+ createInvoker("get", "").openOrThrowException("Test").apply must throwA[Exception]
}
}
View
14 core/util/src/test/scala/net/liftweb/util/Html5ParserSpec.scala
@@ -54,12 +54,12 @@ object Html5ParserSpec extends Specification with PendingUntilFixed with Html5Pa
val (page1, page2, page3) = (new String(p._1), new String(p._2), new String(p._3))
"parse valid page type1" in {
- val parsed = parse(page1).open_!
+ val parsed = parse(page1).openOrThrowException("Test")
(parsed \\ "script").length must be >= 4
}
"parse valid page type2" in {
- val parsed = parse(page2).open_!
+ val parsed = parse(page2).openOrThrowException("Test")
(parsed \\ "script").length must be >= 4
}
@@ -76,7 +76,7 @@ object Html5ParserSpec extends Specification with PendingUntilFixed with Html5Pa
}
"change <lift:head> to <head>" in {
- val parsed = parse("<div><lift:head>123</lift:head></div>").open_!
+ val parsed = parse("<div><lift:head>123</lift:head></div>").openOrThrowException("Test")
val heads = parsed \\ "head"
heads.length must_== 1
heads.text must_== "123"
@@ -85,17 +85,17 @@ object Html5ParserSpec extends Specification with PendingUntilFixed with Html5Pa
"Parse stuff with lift: namespace" in {
val parsed = parse("""<lift:surround with="dog"><div/></lift:surround>""")
- val e = parsed.open_!.asInstanceOf[Elem]
+ val e = parsed.openOrThrowException("Test").asInstanceOf[Elem]
e.prefix must_== "lift"
e.label must_== "surround"
- (parsed.open_! \ "@with").text must_== "dog"
+ (parsed.openOrThrowException("Test") \ "@with").text must_== "dog"
}
"Parse stuff without lift: namespace" in {
val parsed = parse("""<div with="dog"><div/></div>""")
- val e = parsed.open_!.asInstanceOf[Elem]
+ val e = parsed.openOrThrowException("Test").asInstanceOf[Elem]
e.label must_== "div"
- (parsed.open_! \ "@with").text must_== "dog"
+ (parsed.openOrThrowException("Test") \ "@with").text must_== "dog"
}
}
View
10 core/util/src/test/scala/net/liftweb/util/JsonParserSpec.scala
@@ -95,26 +95,26 @@ object JsonParserSpec extends Specification {
"Parse doubles" in {
val p2 = JSONParser.parse("51.348484")
p2.isDefined must be_==(true)
- p2.open_! must_== 51.348484
+ p2.openOrThrowException("Test") must_== 51.348484
}
"Parse negative doubles" in {
val p2 = JSONParser.parse("-51.348484")
p2.isDefined must be_==(true)
- p2.open_! must_== -51.348484
+ p2.openOrThrowException("Test") must_== -51.348484
}
"Parse negative longs" in {
val p2 = JSONParser.parse("-517272833222")
p2.isDefined must be_==(true)
- p2.open_! must_== -517272833222L
+ p2.openOrThrowException("Test") must_== -517272833222L
}
"complex JSON objects #2" in {
val p2 = JSONParser.parse(
"""{"command":"setPoint","params":{"mf":51.3256123,"$a":-0.6379592,"x":-0.6379592,"y":51.3256123}}""")
p2.isDefined must be_==(true)
- val params = p2.open_!.asInstanceOf[Map[String, Map[String, Any]]].apply("params")
+ val params = p2.openOrThrowException("Test").asInstanceOf[Map[String, Map[String, Any]]].apply("params")
params("mf") must_== 51.3256123D
params("$a") must_== -0.6379592D
params("y") must_== 51.3256123D
@@ -132,7 +132,7 @@ object JsonParserSpec extends Specification {
val p2 = JSONParser.parse(
"""-0.5033""")
p2.isDefined must be_==(true)
- p2.open_! must_== -0.5033
+ p2.openOrThrowException("Test") must_== -0.5033
}
View
2  core/util/src/test/scala/net/liftweb/util/MailerSpec.scala
@@ -44,7 +44,7 @@ object MailerSpec extends Specification {
while (lastMessage.isEmpty) {
MailerSpec.this.wait(100)
}
- lastMessage.open_!
+ lastMessage.openOrThrowException("Test")
}
}
View
6 core/util/src/test/scala/net/liftweb/util/PCDataXmlParserSpec.scala
@@ -65,15 +65,15 @@ val data3 = """<?xml version="1.0" encoding="UTF-8"?>
"PCDataMarkupParser" should {
"Parse a document with whitespace" in {
- PCDataXmlParser(data1).open_! must ==/ (<html>dude</html>)
+ PCDataXmlParser(data1).openOrThrowException("Test") must ==/ (<html>dude</html>)
}
"Parse a document with doctype" in {
- PCDataXmlParser(data2).open_! must ==/ (<html>dude</html>)
+ PCDataXmlParser(data2).openOrThrowException("Test") must ==/ (<html>dude</html>)
}
"Parse a document with xml and doctype" in {
- PCDataXmlParser(data3).open_!.apply(0).label must_== "html"
+ PCDataXmlParser(data3).openOrThrowException("Test").apply(0).label must_== "html"
}
}
View
2  core/util/src/test/scala/net/liftweb/util/XmlParserSpec.scala
@@ -43,7 +43,7 @@ object XmlParserSpec extends Specification {
</lift:surround>
val bis = new ByteArrayInputStream(actual.toString.getBytes("UTF-8"))
- val parsed = PCDataXmlParser(bis).open_!
+ val parsed = PCDataXmlParser(bis).openOrThrowException("Test")
parsed must ==/(expected)
}
View
2  persistence/couchdb/src/main/scala/net/liftweb/couchdb/CouchRecord.scala
@@ -89,7 +89,7 @@ trait CouchRecord[MyType <: CouchRecord[MyType]] extends JSONRecord[MyType] {
case Full(database) => database
case _ =>
_database = Full(_calcDatabase)
- _database.open_!
+ _database.openOrThrowException("We just made this a Full Box")
}
/** Set the current database (if any) for this record */
View
4 persistence/couchdb/src/main/scala/net/liftweb/couchdb/Database.scala
@@ -69,7 +69,7 @@ trait Document extends Request with FetchableAsJObject {
def @@ (rev: String): DocumentRevision = at(rev)
/** Refine to a particular revision of the document by getting _rev from a given JObject. */
- def at(doc: JObject): DocumentRevision = at(doc._rev.open_!)
+ def at(doc: JObject): DocumentRevision = at(doc._rev.openOrThrowException("legacy code"))
/** Alias for at */
def @@ (doc: JObject): DocumentRevision = at(doc)
@@ -198,7 +198,7 @@ class Database(couch: Request, database: String) extends Request(couch / databas
def apply(id: String): Document = new Request(this / id) with Document { }
/** Access a particular document in the database with _id from a given JObject */
- def apply(doc: JObject): Document = this(doc._id.open_!.s)
+ def apply(doc: JObject): Document = this(doc._id.openOrThrowException("legacy code").s)
/** Access a series of documents by ID. */
def apply(ids: Seq[String]): AllDocs = all.includeDocs.keys(ids.map(JString): _*)
View
8 persistence/couchdb/src/main/scala/net/liftweb/couchdb/DocumentHelpers.scala
@@ -27,7 +27,13 @@ object DocumentHelpers {
def forceStore(http: Http, database: Database, doc: JObject): Box[JObject] =
tryo(http(database(doc) fetch)) match {
case Full(existingDoc) =>
- tryo(http(database store updateIdAndRev(doc, existingDoc._id.open_!, existingDoc._rev.open_!))).flatMap(b => b)
+ tryo{
+ http(database.store(updateIdAndRev(
+ doc,
+ existingDoc._id.openOrThrowException("We just got this document, so it has an id"),
+ existingDoc._rev.openOrThrowException("We just got this document, so it has a rev"))))
+ }.flatMap(b => b)
+
case Failure(_, Full(StatusCode(404, _)), _) =>
tryo(http(database store doc)).flatMap(b => b)
View
2  persistence/couchdb/src/test/scala/net/liftweb/couchdb/CouchDocumentSpec.scala
@@ -47,7 +47,7 @@ object CouchDocumentSpec extends Specification {
private final def verifyAndOpen[A](b: Box[A]): A = {
b.isDefined must_== true
- b.open_!
+ b.openOrThrowException("This is a test")
}
"A document" should {
View
18 persistence/couchdb/src/test/scala/net/liftweb/couchdb/CouchQuerySpec.scala
@@ -43,7 +43,7 @@ object CouchQuerySpec extends Specification {
private def verifyAndOpen[A](b: Box[A]): A = {
b.isDefined must_== true
- b.open_!
+ b.openOrThrowException("This is a test")
}
"Queries" should {
@@ -98,7 +98,11 @@ object CouchQuerySpec extends Specification {
val (design, docs) = prep(http, database)
val students = findStudents(docs)
- verifyAndOpen(http(database(List(students(0)._id.open_!, students(3)._id.open_!, students(5)._id.open_!)) query)) must beLike {
+ verifyAndOpen(http(database(List(
+ students(0)._id.openOrThrowException("This is a test"),
+ students(3)._id.openOrThrowException("This is a test"),
+ students(5)._id.openOrThrowException("This is a test"))
+ ) query)) must beLike {
case QueryResults(Full(count), Full(offset), rows) =>
sortedAndPrintedValues(rows.flatMap(_.doc).toList) must_== sortedAndPrintedValues(students(0)::students(3)::students(5)::Nil)
}
@@ -125,7 +129,7 @@ object CouchQuerySpec extends Specification {
verifyAndOpen(http(database.design("test").view("students_by_age").from(11) query)) must beLike {
case QueryResults(_, _, rows) =>
(rows.flatMap(_.value.asA[JObject]).toList.sortWith(compareName) must_==
- students.filter(_.getInt("age").map(_ >= 11).open_!).sortWith(compareName))
+ students.filter(_.getInt("age").map(_ >= 11).openOrThrowException("This is a test")).sortWith(compareName))
}
}
@@ -137,7 +141,7 @@ object CouchQuerySpec extends Specification {
verifyAndOpen(http(database.design("test").view("students_by_age").to(12) query)) must beLike {
case QueryResults(_, _, rows) =>
(rows.flatMap(_.value.asA[JObject]).toList.sortWith(compareName) must_==
- students.filter(_.getInt("age").map(_ <= 12).open_!).sortWith(compareName))
+ students.filter(_.getInt("age").map(_ <= 12).openOrThrowException("This is a test")).sortWith(compareName))
}
}
@@ -150,7 +154,7 @@ object CouchQuerySpec extends Specification {
case QueryResults(_, _, rows) =>
rows.length must_== 2
(rows.flatMap(_.value.asA[JObject]).toList.sortWith(compareName) must_==
- students.filter(_.getInt("age").map(_ == 11).open_!))
+ students.filter(_.getInt("age").map(_ == 11).openOrThrowException("This is a test")))
}
}
@@ -172,7 +176,7 @@ object CouchQuerySpec extends Specification {
case QueryResults(_, _, rows) =>
rows.length must_== 3
(rows.flatMap(_.value.asA[JObject]).toList.sortWith(compareName) must_==
- students.filter(_.getInt("age").map(_ <= 11).open_!))
+ students.filter(_.getInt("age").map(_ <= 11).openOrThrowException("This is a test")))
}
}
@@ -185,7 +189,7 @@ object CouchQuerySpec extends Specification {
case QueryResults(_, _, rows) =>
rows.length must_== 4
(rows.flatMap(_.value.asA[JObject]).toList must_==
- students.filter(_.getInt("age").map(age => age >= 11 && age <= 12).open_!))
+ students.filter(_.getInt("age").map(age => age >= 11 && age <= 12).openOrThrowException("This is a test")))
}
}
}
View
23 persistence/couchdb/src/test/scala/net/liftweb/couchdb/CouchRecordSpec.scala
@@ -108,7 +108,7 @@ object CouchRecordSpec extends Specification {
newRec.id.valueBox.isDefined must_== true
newRec.rev.valueBox.isDefined must_== true
- val Full(foundRec) = Person.fetch(newRec.id.valueBox.open_!)
+ val Full(foundRec) = Person.fetch(newRec.id.valueBox.openOrThrowException("This is a test"))
assertEqualPerson(foundRec, testRec1)
foundRec.id.valueBox must_== newRec.id.valueBox
foundRec.rev.valueBox must_== newRec.rev.valueBox
@@ -119,7 +119,7 @@ object CouchRecordSpec extends Specification {
val newRec = testRec1
newRec save
- val foundDoc = Http(defaultDatabase(newRec.id.valueBox.open_!) fetch)
+ val foundDoc = Http(defaultDatabase(newRec.id.valueBox.openOrThrowException("This is a test")) fetch)
compact(render(stripIdAndRev(foundDoc))) must_== compact(render(testDoc1))
}
@@ -129,7 +129,7 @@ object CouchRecordSpec extends Specification {
newRec.save
newRec.id.valueBox.isDefined must_== true
- val id = newRec.id.valueBox.open_!
+ val id = newRec.id.valueBox.openOrThrowException("This is a test")
Person.fetch(id).isDefined must_== true
newRec.delete_!.isDefined must_== true
@@ -137,7 +137,7 @@ object CouchRecordSpec extends Specification {
newRec.delete_!.isDefined must_== false
newRec.save
- Http(defaultDatabase(newRec.id.valueBox.open_!) @@ newRec.rev.valueBox.open_! delete)
+ Http(defaultDatabase(newRec.id.valueBox.openOrThrowException("This is a test")) @@ newRec.rev.valueBox.openOrThrowException("This is a test") delete)
newRec.delete_!.isDefined must_== false
}
@@ -155,7 +155,8 @@ object CouchRecordSpec extends Specification {
val expectedRows = newRec1::newRec3::Nil
- Person.fetchMany(newRec1.id.valueBox.open_!, newRec3.id.valueBox.open_!).map(_.toList) must beLike {
+ Person.fetchMany(newRec1.id.valueBox.openOrThrowException("This is a test"),
+ newRec3.id.valueBox.openOrThrowException("This is a test")).map(_.toList) must beLike {
case Full(foundRows) => assertEqualRows(foundRows, expectedRows); 1 must_== 1
}
}
@@ -228,14 +229,14 @@ object CouchRecordSpec extends Specification {
newRec.saved_? must_== true
- val foundRecBox = Person.fetchFrom(database2, newRec.id.valueBox.open_!)
+ val foundRecBox: Box[Person] = newRec.id.valueBox.flatMap{ id => Person.fetchFrom(database2, id)}
foundRecBox.isDefined must_== true
val Full(foundRec) = foundRecBox
assertEqualPerson(foundRec, testRec1)
foundRec.id.valueBox must_== newRec.id.valueBox
foundRec.rev.valueBox must_== newRec.rev.valueBox
- Person.fetch(newRec.id.valueBox.open_!).isDefined must_== false
+ newRec.id.valueBox.flatMap(id => Person.fetch(id)).isDefined must_== false
}
"support multiple databases for fetching in bulk" in {
@@ -258,11 +259,15 @@ object CouchRecordSpec extends Specification {
val expectedRows = newRec1::newRec3::Nil
- Person.fetchManyFrom(database2, newRec1.id.valueBox.open_!, newRec3.id.valueBox.open_!).map(_.toList) must beLike {
+ Person.fetchManyFrom(database2,
+ newRec1.id.valueBox.openOrThrowException("This is a test"),
+ newRec3.id.valueBox.openOrThrowException("This is a test")
+ ).map(_.toList) must beLike {
case Full(foundRows) => assertEqualRows(foundRows, expectedRows); 1 must_== 1
}
- Person.fetchMany(newRec1.id.valueBox.open_!, newRec3.id.valueBox.open_!) must beLike {
+ Person.fetchMany(newRec1.id.valueBox.openOrThrowException("This is a test"),
+ newRec3.id.valueBox.openOrThrowException("This is a test")) must beLike {
case Full(seq) => seq.isEmpty must_== true
}
}
View
2  persistence/mapper/src/main/scala/net/liftweb/mapper/AjaxMapper.scala
@@ -29,7 +29,7 @@ trait AjaxEditableField[FieldType,OwnerType <: Mapper[OwnerType]] extends Mapped
if (editableField) {
<xml:group>{
toForm.map { form =>
- SHtml.ajaxEditable(super.asHtml, toForm.open_!, () => {fieldOwner.save; onSave; net.liftweb.http.js.JsCmds.Noop})
+ SHtml.ajaxEditable(super.asHtml, form, () => {fieldOwner.save; onSave; net.liftweb.http.js.JsCmds.Noop})
} openOr super.asHtml
}</xml:group>
} else {
View
2  persistence/mapper/src/main/scala/net/liftweb/mapper/HasManyThrough.scala
@@ -37,7 +37,7 @@ class HasManyThrough[From <: KeyedMapper[ThroughType, From],
DB.use(owner.connectionIdentifier) { conn =>
val query = "SELECT DISTINCT "+otherSingleton._dbTableNameLC+".* FROM "+otherSingleton._dbTableNameLC+","+
through._dbTableNameLC+" WHERE "+
- otherSingleton._dbTableNameLC+"."+otherSingleton.indexedField(otherSingleton.asInstanceOf[To]).open_!._dbColumnNameLC+" = "+
+ otherSingleton._dbTableNameLC+"."+otherSingleton.indexedField(otherSingleton.asInstanceOf[To]).openOrThrowException("legacy code")._dbColumnNameLC+" = "+
through._dbTableNameLC+"."+throughToField._dbColumnNameLC+" AND "+
through._dbTableNameLC+"."+throughFromField._dbColumnNameLC+" = ?"
DB.prepareStatement(query, conn) { st =>
View
10 persistence/mapper/src/main/scala/net/liftweb/mapper/MappedField.scala
@@ -140,11 +140,11 @@ trait BaseMappedField extends SelectableField with Bindable with MixableMappedFi
val name = dbColumnName
val conn = DB.currentConnection
- if (conn.isDefined) {
- val rc = conn.open_!
- if (rc.metaData.storesMixedCaseIdentifiers) name
- else name.toLowerCase
- } else name
+ conn.map{
+ c =>
+ if (c.metaData.storesMixedCaseIdentifiers) name
+ else name.toLowerCase
+ }.openOr(name)
}
/**
View
2  persistence/mapper/src/main/scala/net/liftweb/mapper/MappedForeignKey.scala
@@ -127,7 +127,7 @@ with LifecycleCallbacks {
override protected def dirty_?(b: Boolean) = synchronized { // issue 165
// invalidate if the primary key has changed Issue 370
if (_obj.isEmpty || (_calcedObj && _obj.isDefined &&
- _obj.open_!.primaryKeyField.is != this.i_is_!)) {
+ _obj.openOrThrowException("_obj was just checked as full.").primaryKeyField.is != this.i_is_!)) {
_obj = Empty
_calcedObj = false
}
View
10 persistence/mapper/src/main/scala/net/liftweb/mapper/MetaMapper.scala
@@ -869,7 +869,7 @@ trait MetaMapper[A<:Mapper[A]] extends BaseMetaMapper with Mapper[A] {
val ret = if (saved_?(toSave)) {
_beforeUpdate(toSave)
val ret: Boolean = if (!dirty_?(toSave)) true else {
- val ret: Boolean = DB.prepareStatement("UPDATE "+MapperRules.quoteTableName.vend(_dbTableNameLC)+" SET "+whatToSet(toSave)+" WHERE "+thePrimaryKeyField.open_! +" = ?", conn) {
+ val ret: Boolean = DB.prepareStatement("UPDATE "+MapperRules.quoteTableName.vend(_dbTableNameLC)+" SET "+whatToSet(toSave)+" WHERE "+thePrimaryKeyField.openOrThrowException("Cross your fingers") +" = ?", conn) {
st =>
var colNum = 1
@@ -1083,7 +1083,7 @@ trait MetaMapper[A<:Mapper[A]] extends BaseMetaMapper with Mapper[A] {
* A partial function that takes an instance of A and a field name and returns the mapped field
*/
lazy val fieldMatcher: PartialFunction[(A, String), MappedField[Any, A]] = {
- case (actual, fieldName) if _mappedFields.contains(fieldName) => fieldByName[Any](fieldName, actual).open_! // we know this is defined
+ case (actual, fieldName) if _mappedFields.contains(fieldName) => fieldByName[Any](fieldName, actual).openOrThrowException("we know this is defined")
}
def createInstance: A = rootClass.newInstance.asInstanceOf[A]
@@ -1347,7 +1347,7 @@ trait MetaMapper[A<:Mapper[A]] extends BaseMetaMapper with Mapper[A] {
val conn = DB.currentConnection
if (conn.isDefined) {
- val rc = conn.open_!
+ val rc = conn.openOrThrowException("We just checked that this is a Full Box")
if (rc.metaData.storesMixedCaseIdentifiers) name
else name.toLowerCase
} else name
@@ -2035,7 +2035,7 @@ trait KeyedMetaMapper[Type, A<:KeyedMapper[Type, A]] extends MetaMapper[A] with
* @return a mapped object of this metamapper's type
*/
def editSnippetSetup: A = {
- objFromIndexedParam.open_!
+ objFromIndexedParam.openOrThrowException("Comment says this is broken")
}
/**
* Default setup behavior for the view snippet. BROKEN! MUST OVERRIDE IF
@@ -2044,7 +2044,7 @@ trait KeyedMetaMapper[Type, A<:KeyedMapper[Type, A]] extends MetaMapper[A] with
* @return a mapped object of this metamapper's type
*/
def viewSnippetSetup: A = {
- objFromIndexedParam.open_!
+ objFromIndexedParam.openOrThrowException("Comment says this is broken")
}
/**
* Default callback behavior of the edit snippet. Called when the user
View
3  persistence/mapper/src/main/scala/net/liftweb/mapper/view/ModelView.scala
@@ -170,7 +170,8 @@ class ModelView[T <: Mapper[T]](var entity: T, val snippet: ModelSnippet[T]) {
def edit(name: String) = {
entity.fieldByName(name).map { (field: net.liftweb.mapper.MappedField[_,_]) =>
TheBindParam(name, field.toForm.openOr(field.asHtml))
- }.open_!
+ }.openOrThrowException("If nobody has complained about this giving a NPE, I'll assume it is safe")
+
}
}
View
2  persistence/mapper/src/main/scala/net/liftweb/mapper/view/TableEditor.scala
@@ -207,7 +207,7 @@ package snippet {
private def getInstance: Box[TableEditorImpl[_]] = S.attr("table").map(TableEditor.map(_))
def dispatch = {
case "edit" =>
- val o = getInstance.open_!
+ val o = getInstance.openOrThrowException("if we don't have the table attr, we want the dev to know about it.")
o.edit _
}
}
View
6 persistence/mapper/src/test/scala/net/liftweb/mapper/DbSpec.scala
@@ -50,12 +50,12 @@ object DbSpec extends Specification {
val session = new LiftSession("hello", "", Empty)
val elwood = S.initIfUninitted(session) {
- val r = User.find(By(User.firstName, "Elwood")).open_!
+ val r = User.find(By(User.firstName, "Elwood"))
S.queryLog.size must_== 1
r
}
- statements.size must_==1
- elwood.firstName.is must_== "Elwood"
+ statements.size must_== 1
+ elwood.map( _.firstName.is) must_== Full("Elwood")
}
}
}
View
6 persistence/mapper/src/test/scala/net/liftweb/mapper/MappedBooleanSpec.scala
@@ -44,8 +44,8 @@ object MappedBooleanSpec extends Specification {
val charlie = Dog2.create
charlie.isDog(true).save
- val read = Dog2.find(charlie.dog2id).open_!
- read.dirty_? must_== false
+ val read = Dog2.find(charlie.dog2id)
+ read.map(_.dirty_?) must_== Full(false)
}
"be marked dirty on update if value has changed" in {
@@ -53,7 +53,7 @@ object MappedBooleanSpec extends Specification {
val charlie = Dog2.create
charlie.save
- val read = Dog2.find(charlie.dog2id).open_!
+ val read = Dog2.find(charlie.dog2id).openOrThrowException("This is a test")
read.dirty_? must_== false
read.isDog(false)
read.dirty_? must_== false
View
6 persistence/mapper/src/test/scala/net/liftweb/mapper/MappedDecimalSpec.scala
@@ -44,8 +44,8 @@ object MappedDecimalSpec extends Specification {
val charlie = Dog.create
charlie.price(42.42).save
- val read = Dog.find(charlie.id).open_!
- read.dirty_? must_== false
+ val read = Dog.find(charlie.id)
+ read.map(_.dirty_?) must_== Full(false)
}
"be marked dirty on update" in {
@@ -53,7 +53,7 @@ object MappedDecimalSpec extends Specification {
val charlie = Dog.create
charlie.price(42.42).save
- val read = Dog.find(charlie.id).open_!
+ val read = Dog.find(charlie.id).openOrThrowException("This is a test")
read.dirty_? must_== false
read.price(100.42)
read.price(100.42)
View
2  persistence/mapper/src/test/scala/net/liftweb/mapper/MappedLongForeignKeySpec.scala
@@ -56,7 +56,7 @@ object MappedLongForeignKeySpec extends Specification with org.specs2.specificat
ret
}
dog.owner(user).save
- val d2 = Dog.find(dog.id).open_!
+ val d2 = Dog.find(dog.id).openOrThrowException("Test")
d2.id.is must_== user.id.is
(d2.owner == user) must_== true
(d2.owner == d2) must_== false
View
44 persistence/mapper/src/test/scala/net/liftweb/mapper/MapperSpec.scala
@@ -67,10 +67,10 @@ class MapperSpec extends Specification with BeforeExample {
("Mapper for " + provider.name) should {
"schemify" in {
- val elwood = SampleModel.find(By(SampleModel.firstName, "Elwood")).open_!
- val madeline = SampleModel.find(By(SampleModel.firstName, "Madeline")).open_!
- val archer = SampleModel.find(By(SampleModel.firstName, "Archer")).open_!
- val notNull = SampleModel.find(By(SampleModel.firstName, "NotNull")).open_!
+ val elwood = SampleModel.find(By(SampleModel.firstName, "Elwood")).openOrThrowException("Test")
+ val madeline = SampleModel.find(By(SampleModel.firstName, "Madeline")).openOrThrowException("Test")
+ val archer = SampleModel.find(By(SampleModel.firstName, "Archer")).openOrThrowException("Test")
+ val notNull = SampleModel.find(By(SampleModel.firstName, "NotNull")).openOrThrowException("Test")
elwood.firstName.is must_== "Elwood"
madeline.firstName.is must_== "Madeline"
@@ -81,7 +81,7 @@ class MapperSpec extends Specification with BeforeExample {
val disabled = SampleModel.find(By(SampleModel.status, SampleStatus.Disabled))
- val meow = SampleTag.find(By(SampleTag.tag, "Meow")).open_!
+ val meow = SampleTag.find(By(SampleTag.tag, "Meow")).openOrThrowException("Test")
meow.tag.is must_== "Meow"
@@ -133,17 +133,17 @@ class MapperSpec extends Specification with BeforeExample {
}
"Can JSON decode and write back" in {
- val m = SampleModel.find(2).open_!
+ val m = SampleModel.find(2).openOrThrowException("Test")
val json = m.encodeAsJson()
val rebuilt = SampleModel.buildFromJson(json)
rebuilt.firstName("yak").save
- val recalled = SampleModel.find(2).open_!
+ val recalled = SampleModel.find(2).openOrThrowException("Test")
recalled.firstName.is must_== "yak"
}
"You can put stuff in a Set" in {
- val m1 = SampleModel.find(1).open_!
- val m2 = SampleModel.find(1).open_!
+ val m1 = SampleModel.find(1).openOrThrowException("Test")
+ val m2 = SampleModel.find(1).openOrThrowException("Test")
(m1 == m2) must_== true
@@ -245,9 +245,9 @@ class MapperSpec extends Specification with BeforeExample {
}
"work with Mixed case" in {
- val elwood = Mixer.find(By(Mixer.name, "Elwood")).open_!
- val madeline = Mixer.find(By(Mixer.name, "Madeline")).open_!
- val archer = Mixer.find(By(Mixer.name, "Archer")).open_!
+ val elwood = Mixer.find(By(Mixer.name, "Elwood")).openOrThrowException("Test")
+ val madeline = Mixer.find(By(Mixer.name, "Madeline")).openOrThrowException("Test")
+ val archer = Mixer.find(By(Mixer.name, "Archer")).openOrThrowException("Test")
elwood.name.is must_== "Elwood"
madeline.name.is must_== "Madeline"
@@ -259,11 +259,11 @@ class MapperSpec extends Specification with BeforeExample {
}
"work with Mixed case update and delete" in {
- val elwood = Mixer.find(By(Mixer.name, "Elwood")).open_!
+ val elwood = Mixer.find(By(Mixer.name, "Elwood")).openOrThrowException("Test")
elwood.name.is must_== "Elwood"
elwood.name("FruitBar").weight(966).save
- val fb = Mixer.find(By(Mixer.weight, 966)).open_!
+ val fb = Mixer.find(By(Mixer.weight, 966)).openOrThrowException("Test")
fb.name.is must_== "FruitBar"
fb.weight.is must_== 966
@@ -276,11 +276,11 @@ class MapperSpec extends Specification with BeforeExample {
}
"work with Mixed case update and delete for Dog2" in {
- val elwood = Dog2.find(By(Dog2.name, "Elwood")).open_!
+ val elwood = Dog2.find(By(Dog2.name, "Elwood")).openOrThrowException("Test")
elwood.name.is must_== "Elwood"
elwood.name("FruitBar").actualAge(966).save
- val fb = Dog2.find(By(Dog2.actualAge, 966)).open_!
+ val fb = Dog2.find(By(Dog2.actualAge, 966)).openOrThrowException("Test")
fb.name.is must_== "FruitBar"
fb.actualAge.is must_== 966
@@ -300,8 +300,8 @@ class MapperSpec extends Specification with BeforeExample {
val i1 = Thing.create.name("frog").saveMe
val i2 = Thing.create.name("dog").saveMe
- Thing.find(By(Thing.thing_id, i1.thing_id.is)).open_!.name.is must_== "frog"
- Thing.find(By(Thing.thing_id, i2.thing_id.is)).open_!.name.is must_== "dog"
+ Thing.find(By(Thing.thing_id, i1.thing_id.is)).openOrThrowException("Test").name.is must_== "frog"
+ Thing.find(By(Thing.thing_id, i2.thing_id.is)).openOrThrowException("Test").name.is must_== "dog"
}
@@ -331,7 +331,7 @@ class MapperSpec extends Specification with BeforeExample {
"CreatedAt and UpdatedAt work" in {
val now = Helpers.now
- val dog = Dog2.find().open_!
+ val dog = Dog2.find().openOrThrowException("Test")
val oldUpdate = dog.updatedAt.is
@@ -343,7 +343,7 @@ class MapperSpec extends Specification with BeforeExample {
dog.name("ralph").save
- val dog2 = Dog2.find(dog.dog2id.is).open_!
+ val dog2 = Dog2.find(dog.dog2id.is).openOrThrowException("Test")
dog.createdAt.is.getTime must_== dog2.createdAt.is.getTime
oldUpdate.getTime must_!= dog2.updatedAt.is.getTime
@@ -359,11 +359,11 @@ class MapperSpec extends Specification with BeforeExample {
}
"Save flag results in update rather than insert" in {
- val elwood = SampleModel.find(By(SampleModel.firstName, "Elwood")).open_!
+ val elwood = SampleModel.find(By(SampleModel.firstName, "Elwood")).openOrThrowException("Test")
elwood.firstName.is must_== "Elwood"
elwood.firstName("Frog").save
- val frog = SampleModel.find(By(SampleModel.firstName, "Frog")).open_!
+ val frog = SampleModel.find(By(SampleModel.firstName, "Frog")).openOrThrowException("Test")
frog.firstName.is must_== "Frog"
SampleModel.findAll().length must_== 4
View
2  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/MongoMetaRecord.scala
@@ -328,7 +328,7 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]
.map(field => (field.name, fieldDbValue(field)))
.partition(pair => pair._2.isDefined)
- val fieldsToSet = fullFields.map(pair => (pair._1, pair._2.open_!)) // these are all Full
+ val fieldsToSet = fullFields.map(pair => (pair._1, pair._2.openOrThrowException("these are all Full")))
val fieldsToUnset: List[String] = otherFields.filter(
pair => pair._2 match {
View
2  ...ce/mongodb-record/src/test/scala/net/liftweb/mongodb/record/MongoRecordExamplesSpec.scala
@@ -387,7 +387,7 @@ class MongoRecordExamplesSpec extends Specification with MongoTestKit {
// fetch a refdoc
val refFromFetch = md1.refdoc.obj
refFromFetch.isDefined must_== true
- refFromFetch.open_!.id must_== ref1.id
+ refFromFetch.openOrThrowException("we know this is Full").id must_== ref1.id
// query for a single doc with a JObject query
val md1a = MainDoc.find(("name") -> "md1")
View
6 persistence/proto/src/main/scala/net/liftweb/proto/Crudify.scala
@@ -238,7 +238,7 @@ trait Crudify {
Full(NamedPF(name) {
case RewriteRequest(pp , _, _) if hasParamFor(pp, viewPath) =>
(RewriteResponse(viewPath),
- findForParam(pp.wholePath.last).open_!)
+ findForParam(pp.wholePath.last).openOrThrowException("legacy code, it was open_!"))
})
override def calcTemplate = Full(viewTemplate)
@@ -285,7 +285,7 @@ trait Crudify {
Full(NamedPF(name) {
case RewriteRequest(pp , _, _) if hasParamFor(pp, editPath) =>
(RewriteResponse(editPath),
- findForParam(pp.wholePath.last).open_!)
+ findForParam(pp.wholePath.last).openOrThrowException("legacy code, it was open_!"))
})
override def calcTemplate = Full(editTemplate)
@@ -415,7 +415,7 @@ trait Crudify {
Full(NamedPF(name) {
case RewriteRequest(pp , _, _) if hasParamFor(pp, deletePath) =>
(RewriteResponse(deletePath),
- findForParam(pp.wholePath.last).open_!)
+ findForParam(pp.wholePath.last).openOrThrowException("legacy code, it was open_!"))
})
override def calcTemplate = Full(deleteTemplate)
View
6 persistence/proto/src/main/scala/net/liftweb/proto/ProtoUser.scala
@@ -578,7 +578,7 @@ trait ProtoUser {
def logUserIn(who: TheUserType, postLogin: () => Nothing): Nothing = {
if (destroySessionOnLogin) {
- S.session.open_!.destroySessionAndContinueInNewSession(() => {
+ S.session.openOrThrowException("we have a session here").destroySessionAndContinueInNewSession(() => {
logUserIn(who)
postLogin()
})
@@ -1008,7 +1008,7 @@ trait ProtoUser {
}
def changePassword = {
- val user = currentUser.open_! // we can do this because the logged in test has happened
+ val user = currentUser.openOrThrowException("we can do this because the logged in test has happened")
var oldPassword = ""
var newPassword: List[String] = Nil
@@ -1060,7 +1060,7 @@ trait ProtoUser {
def edit = {
val theUser: TheUserType =
- mutateUserOnEdit(currentUser.open_!) // we know we're logged in
+ mutateUserOnEdit(currentUser.openOrThrowException("we know we're logged in"))
val theName = editPath.mkString("")
View
2  web/testkit/src/main/scala/net/liftweb/http/testing/TestRunner.scala
@@ -162,7 +162,7 @@ case class TestResults(res: List[Tracker]) {
val append = (failedTests, failedAsserts) match {
case (ft,fa) if ft.length == 0 && fa.length == 0 => ""
case (ft, fa) =>
- "\n"+ft.length+" Failed Tests:\n"+ft.map(v => v.name+" "+v.exception.open_!.getMessage+" \n"+
+ "\n"+ft.length+" Failed Tests:\n"+ft.map(v => v.name+" "+v.exception.openOrThrowException("This should be safe").getMessage+" \n"+
v.trace.map(st => " "+st.toString).mkString("\n")).mkString("\n")
}
View
4 web/webkit/src/main/scala/net/liftweb/builtin/snippet/Comet.scala
@@ -93,9 +93,7 @@ object Comet extends DispatchSnippet with LazyLoggable {
c.buildSpan(when, response.inSpan)
case e =>
- if (c.cometRenderTimeoutHandler().isDefined) {
- c.cometRenderTimeoutHandler().open_!
- } else {
+ c.cometRenderTimeoutHandler().openOr{
throw new CometTimeoutException("type: "+theType+" name: "+name)
}
}}} openOr {
View
8 web/webkit/src/main/scala/net/liftweb/http/LiftScreen.scala
@@ -574,7 +574,7 @@ trait AbstractScreen extends Factory {
override def name: String = underlying.map(_.name) openOr "N/A"
- override def default = underlying.open_!.get
+ override def default = underlying.openOrThrowException("legacy code").get
override implicit def manifest: Manifest[ValueType] = man
@@ -586,11 +586,11 @@ trait AbstractScreen extends Factory {
case AFilter(f) => f
}.toList
- override def is = underlying.open_!.get
+ override def is = underlying.openOrThrowException("Legacy code").get
- override def get = underlying.open_!.get
+ override def get = underlying.openOrThrowException("Legacy code").get
- override def set(v: T) = underlying.open_!.set(setFilter.foldLeft(v)((v, f) => f(v)))
+ override def set(v: T) = underlying.openOrThrowException("Legacy code").set(setFilter.foldLeft(v)((v, f) => f(v)))
override def uniqueFieldId: Box[String] = paramFieldId or underlying.flatMap(_.uniqueFieldId) or super.uniqueFieldId
View
6 web/webkit/src/main/scala/net/liftweb/http/LiftServlet.scala
@@ -267,10 +267,10 @@ class LiftServlet extends Loggable {
LiftRules.statelessDispatch.toList).map(_.apply() match {
case Full(a) => Full(LiftRules.convertResponse((a, Nil, S.responseCookies, req)))
case r => r
- });
+ })
tmpStatelessHolder.isDefined
}) {
- val f = tmpStatelessHolder.open_!
+ val f = tmpStatelessHolder.openOrThrowException("This is a full box here, checked on previous line")
f match {
case Full(v) => Full(v)
case Empty => LiftRules.notFoundOrIgnore(req, Empty)
@@ -283,7 +283,7 @@ class LiftServlet extends Loggable {
def doSession(r2: Req, s2: LiftSession, continue: Box[() => Nothing]): () => Box[LiftResponse] = {
try {
S.init(r2, s2) {
- dispatchStatefulRequest(S.request.open_!, liftSession, r2, continue)
+ dispatchStatefulRequest(S.request.openOrThrowException("I'm pretty sure this is a full box here"), liftSession, r2, continue)
}
} catch {
case cre: ContinueResponseException =>
View
4 web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala
@@ -136,8 +136,8 @@ object LiftSession {
}
}).map {
case uc: UnitConstructor => uc.makeOne
- case pc: PConstructor => pc.makeOne(pp.open_!.v) // open_! okay
- case psc: PAndSessionConstructor => psc.makeOne(pp.open_!.v, session)
+ case pc: PConstructor => pc.makeOne(pp.openOrThrowException("It's ok").v)
+ case psc: PAndSessionConstructor => psc.makeOne(pp.openOrThrowException("It's ok").v, session)
}
}
View
2  web/webkit/src/main/scala/net/liftweb/http/Req.scala
@@ -552,7 +552,7 @@ object Req {
!updated.startsWith("http://") &&
!updated.startsWith("https://") &&
!updated.startsWith("#"))
- rewrite.open_!.apply(updated) else updated)
+ rewrite.openOrThrowException("legacy code").apply(updated) else updated)
}
/**
View
12 web/webkit/src/main/scala/net/liftweb/http/S.scala
@@ -2471,9 +2471,9 @@ for {
val future: LAFuture[Any] = new LAFuture
updateFunctionMap(name, new S.ProxyFuncHolder(value) {
- override def apply(in: List[String]): Any = future.get(5000).open_!
+ override def apply(in: List[String]): Any = future.get(5000).openOrThrowException("legacy code")
- override def apply(in: FileParamHolder): Any = future.get(5000).open_!
+ override def apply(in: FileParamHolder): Any = future.get(5000).openOrThrowException("legacy code")
})
future
@@ -2489,7 +2489,7 @@ for {
override def apply(in: List[String]): Any = {
val ns = fixShot()
if (ns) {
- theFuture.get(5000).open_!
+ theFuture.get(5000).openOrThrowException("legacy code")
} else {
val future = theFuture
try {
@@ -2506,7 +2506,7 @@ for {
val ns = fixShot()
if (ns) {
- theFuture.get(5000).open_!
+ theFuture.get(5000).openOrThrowException("legacy code")
} else {
val future = theFuture
try {
@@ -2771,7 +2771,7 @@ for {
def doRender(session: LiftSession): NodeSeq =
session.processSurroundAndInclude("external render", xhtml)
- if (inS.value) doRender(session.open_!)
+ if (inS.value) doRender(session.openOrThrowException("legacy code"))
else {
val req = Req(httpRequest, LiftRules.statelessRewrite.toList,
Nil,
@@ -2992,7 +2992,7 @@ for {
def idMessages(f: => List[(NodeSeq, Box[String])]): List[(String, List[NodeSeq])] = {
val res = new HashMap[String, List[NodeSeq]]
f filter (_._2.isEmpty == false) foreach (_ match {
- case (node, id) => val key = id open_!; res += (key -> (res.getOrElseUpdate(key, Nil) ::: List(node)))
+ case (node, id) => val key = id openOrThrowException("legacy code"); res += (key -> (res.getOrElseUpdate(key, Nil) ::: List(node)))
})
res toList
View
4 web/webkit/src/main/scala/net/liftweb/http/Templates.scala
@@ -179,7 +179,7 @@ object Templates {
resolver(key)
} else {
val lrCache = LiftRules.templateCache
- val cache = if (lrCache.isDefined) lrCache.open_! else NoCache
+ val cache = if (lrCache.isDefined) lrCache.openOrThrowException("passes isDefined") else NoCache
val parserFunction: InputStream => Box[NodeSeq] =
S.htmlProperties.htmlParser
@@ -231,7 +231,7 @@ object Templates {
}
if (xmlb.isDefined) {
found = true
- ret = (cache(key) = xmlb.open_!)
+ ret = (cache(key) = xmlb.openOrThrowException("passes isDefined"))
} else if (xmlb.isInstanceOf[Failure] &&
(Props.devMode | Props.testMode)) {
val msg = xmlb.asInstanceOf[Failure].msg
View
4 web/webkit/src/main/scala/net/liftweb/http/provider/servlet/HTTPRequestServlet.scala
@@ -158,9 +158,9 @@ class HTTPRequestServlet(val req: HttpServletRequest, val provider: HTTPProvider
def resumeInfo : Option[(Req, LiftResponse)] = asyncProvider.flatMap(_.resumeInfo)
- def suspend(timeout: Long): RetryState.Value = asyncProvider.open_!.suspend(timeout) // open_! is bad, but presumably, the suspendResume support was checked
+ def suspend(timeout: Long): RetryState.Value = asyncProvider.openOrThrowException("open_! is bad, but presumably, the suspendResume support was checked").suspend(timeout)
- def resume(what: (Req, LiftResponse)): Boolean = asyncProvider.open_!.resume(what)
+ def resume(what: (Req, LiftResponse)): Boolean = asyncProvider.openOrThrowException("open_! is bad, but presumably, the suspendResume support was checked").resume(what)
lazy val suspendResumeSupport_? = {
LiftRules.asyncProviderMeta.
View
2  web/webkit/src/main/scala/net/liftweb/http/rest/RestHelper.scala
@@ -336,7 +336,7 @@ trait RestHelper extends LiftRules.DispatchPF {
() => {
pf(r).box match {
case Full(resp) =>
- val selType = selection(r).open_! // Full because pass isDefinedAt
+ val selType = selection(r).openOrThrowException("Full because pass isDefinedAt")
if (cvt.isDefinedAt((selType, resp, r)))
Full(cvt((selType, resp, r)))
else emptyToResp(ParamFailure("Unabled to convert the message",
View
2  web/webkit/src/test/scala/net/liftweb/http/ReqSpec.scala
@@ -41,7 +41,7 @@ object ReqSpec extends Specification {
val uac = new UserAgentCalculator {
def userAgent = Full("Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-HK) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5")
}
- uac.safariVersion.open_! must_== 5
+ uac.safariVersion.openOrThrowException("legacy code") must_== 5
}
"Do the right thing with iPhone" in {
View
30 web/webkit/src/test/scala/net/liftweb/http/SnippetSpec.scala
@@ -95,7 +95,7 @@ object SnippetSpec extends Specification {
}
}
- ret.open_! must ==/( res)
+ ret.openOrThrowException("legacy code") must ==/( res)
}
@@ -111,7 +111,7 @@ object SnippetSpec extends Specification {
}
}
- ret.open_! must ==/( res)
+ ret.openOrThrowException("legacy code") must ==/( res)
}
"Snippet invocation works class='l:foo'" in {
@@ -126,7 +126,7 @@ object SnippetSpec extends Specification {
}
}
- ret.open_! must ==/( res)
+ ret.openOrThrowException("legacy code") must ==/( res)
}
"Snippet invocation works class='l:foo' and ? for attr sep" in {
@@ -148,7 +148,7 @@ object SnippetSpec extends Specification {
}
}
- ret.open_! must ==/( res)
+ ret.openOrThrowException("legacy code") must ==/( res)
}
@@ -171,7 +171,7 @@ object SnippetSpec extends Specification {
}
}
- ret.open_! must ==/( res)
+ ret.openOrThrowException("legacy code") must ==/( res)
}
@@ -195,7 +195,7 @@ object SnippetSpec extends Specification {
}
}
- ret.open_! must ==/( res)
+ ret.openOrThrowException("legacy code") must ==/( res)
}
@@ -218,7 +218,7 @@ object SnippetSpec extends Specification {
}
}
- ret.open_! must ==/( res)
+ ret.openOrThrowException("legacy code") must ==/( res)
}
@@ -235,7 +235,7 @@ object SnippetSpec extends Specification {
}
}
- ret.open_! must ==/( res)
+ ret.openOrThrowException("legacy code") must ==/( res)
}
"Snippet invocation fails class='l:bar'" in {
@@ -248,7 +248,7 @@ object SnippetSpec extends Specification {
}
}
- (ret.open_! \ "@class").text must_== "snippeterror"
+ (ret.openOrThrowException("legacy code") \ "@class").text must_== "snippeterror"
}
object myInfo extends SessionVar("")
@@ -280,7 +280,7 @@ object SnippetSpec extends Specification {
}
}
- (ret.open_! \ "@class").text must_== "snippeterror"
+ (ret.openOrThrowException("legacy code") \ "@class").text must_== "snippeterror"
}
"Snippet invocation succeeds in normal mode" in {
@@ -297,7 +297,7 @@ object SnippetSpec extends Specification {
}
}
- ret.open_! must ==/(res)
+ ret.openOrThrowException("legacy code") must ==/(res)
}
"Snippet invocation fails in stateless mode (function table)" in {
@@ -313,7 +313,7 @@ object SnippetSpec extends Specification {
}
}
- (ret.open_! \ "@class").text must_== "snippeterror"
+ (ret.openOrThrowException("legacy code") \ "@class").text must_== "snippeterror"
}
"Snippet invocation succeeds in normal mode (function table)" in {
@@ -330,7 +330,7 @@ object SnippetSpec extends Specification {
}
}
- ret.open_! must ==/(res)
+ ret.openOrThrowException("legacy code") must ==/(res)
}
"run string input" in {
@@ -366,7 +366,7 @@ object SnippetSpec extends Specification {
<lift:Meower>Moo</lift:Meower>)
}
- ret.open_! must ==/ (<yak/>)
+ ret.openOrThrowException("legacy code") must ==/ (<yak/>)
*/
pending
}
@@ -382,7 +382,7 @@ object SnippetSpec extends Specification {
<input class="lift:Splunker"/>)
}
- (ret.open_! \ "@name").text.length must be > 0
+ (ret.openOrThrowException("legacy code") \ "@name").text.length must be > 0
*/
pending
}
View
2  web/webkit/src/test/scala/net/liftweb/sitemap/MenuDSLSpec.scala
@@ -94,7 +94,7 @@ object MenuDslSpec extends Specification {
)
- val complete = SiteMap(menu).kids(0).makeMenuItem(List()).open_!
+ val complete = SiteMap(menu).kids(0).makeMenuItem(List()).openOrThrowException("legacy code")
complete.kids.size must_== 2
complete.kids(0).kids.size must_== 3
View
12 web/webkit/src/test/scala/net/liftweb/webapptest/OneShot.scala
@@ -64,7 +64,7 @@ object OneShot extends Specification with RequestKit {
xml <- resp.xml
} yield xml
- bx.open_! must ==/ (<int>45</int>).when(jetty.running)
+ bx.openOrThrowException("legacy code") must ==/ (<int>45</int>).when(jetty.running)
} finally {
LiftRules.sessionCreator = tmp
}
@@ -82,7 +82,7 @@ object OneShot extends Specification with RequestKit {
xml <- resp2.xml
} yield xml
- bx.open_! must ==/ (<int>33</int>).when(jetty.running)
+ bx.openOrThrowException("legacy code") must ==/ (<int>33</int>).when(jetty.running)
} finally {
LiftRules.sessionCreator = tmp
}
@@ -102,8 +102,8 @@ object OneShot extends Specification with RequestKit {
xml2 <- resp3.xml
} yield (xml, xml2)
- bx.open_!._1 must ==/ (<int>33</int>).when(jetty.running)
- bx.open_!._2 must ==/ (<int>45</int>).when(jetty.running)
+ bx.openOrThrowException("legacy code")._1 must ==/ (<int>33</int>).when(jetty.running)
+ bx.openOrThrowException("legacy code")._2 must ==/ (<int>45</int>).when(jetty.running)
} finally {
LiftRules.sessionCreator = tmp
}
@@ -124,8 +124,8 @@ object OneShot extends Specification with RequestKit {
xml2 <- resp3.xml
} yield (xml, xml2)
- bx.open_!._1 must ==/(<int>33</int>).when(jetty.running)
- bx.open_!._2 must ==/(<str>meow</str>).when(jetty.running)
+ bx.openOrThrowException("legacy code")._1 must ==/(<int>33</int>).when(jetty.running)
+ bx.openOrThrowException("legacy code")._2 must ==/(<str>meow</str>).when(jetty.running)
} finally {
LiftRules.sessionCreator = tmp
View
4 web/webkit/src/test/scala/net/liftweb/webapptest/ToHeadUsages.scala
@@ -112,7 +112,7 @@ object ToHeadUsages extends Specification {
"pages " should {
"Templates should recognize entities" in {
- val ns = Templates(List("index")).open_!
+ val ns = Templates(List("index")).openOrThrowException("legacy code")
val str = AltXML.toXML(ns(0), false, false, false)
val idx = str.indexOf("&mdash;")
@@ -120,7 +120,7 @@ object ToHeadUsages extends Specification {
}
"Templates should not recognize entities" in {
- val ns = Templates(List("index")).open_!
+ val ns = Templates(List("index")).openOrThrowException("legacy code")
val str = AltXML.toXML(ns(0), false, true, false)
val idx = str.indexOf("&mdash;")
View
22 web/wizard/src/test/scala/net/liftweb/wizard/WizardSpec.scala
@@ -75,28 +75,28 @@ object WizardSpec extends Specification {
"A wizard must transition from first screen to second screen" in {
S.initIfUninitted(session) {
- MyWizard.currentScreen.open_! must_== MyWizard.nameAndAge
+ MyWizard.currentScreen.openOrThrowException("legacy code") must_== MyWizard.nameAndAge
MyWizard.nextScreen
- MyWizard.currentScreen.open_! must_== MyWizard.nameAndAge
+ MyWizard.currentScreen.openOrThrowException("legacy code") must_== MyWizard.nameAndAge
MyWizard.nameAndAge.name.set("David")
MyWizard.nameAndAge.age.set(14)
MyWizard.nextScreen
- MyWizard.currentScreen.open_! must_== MyWizard.parentName
+ MyWizard.currentScreen.openOrThrowException("legacy code") must_== MyWizard.parentName
MyWizard.prevScreen
- MyWizard.currentScreen.open_! must_== MyWizard.nameAndAge
+ MyWizard.currentScreen.openOrThrowException("legacy code") must_== MyWizard.nameAndAge
MyWizard.nameAndAge.age.set(45)
MyWizard.nextScreen
- MyWizard.currentScreen.open_! must_== MyWizard.favoritePet
+ MyWizard.currentScreen.openOrThrowException("legacy code") must_== MyWizard.favoritePet
S.clearCurrentNotices
@@ -112,24 +112,24 @@ object WizardSpec extends Specification {
"A wizard must be able to snapshot itself" in {
val ss = S.initIfUninitted(session) {
- MyWizard.currentScreen.open_! must_== MyWizard.nameAndAge
+ MyWizard.currentScreen.openOrThrowException("legacy code") must_== MyWizard.nameAndAge
MyWizard.nextScreen
- MyWizard.currentScreen.open_! must_== MyWizard.nameAndAge
+ MyWizard.currentScreen.openOrThrowException("legacy code") must_== MyWizard.nameAndAge
MyWizard.nameAndAge.name.set("David")
MyWizard.nameAndAge.age.set(14)
MyWizard.nextScreen
- MyWizard.currentScreen.open_! must_== MyWizard.parentName
+ MyWizard.currentScreen.openOrThrowException("legacy code") must_== MyWizard.parentName
MyWizard.createSnapshot
}
S.initIfUninitted(session) {
- MyWizard.currentScreen.open_! must_== MyWizard.nameAndAge
+ MyWizard.currentScreen.openOrThrowException("legacy code") must_== MyWizard.nameAndAge
}
S.initIfUninitted(session) {
@@ -137,13 +137,13 @@ object WizardSpec extends Specification {
MyWizard.prevScreen
- MyWizard.currentScreen.open_! must_== MyWizard.nameAndAge
+ MyWizard.currentScreen.openOrThrowException("legacy code") must_== MyWizard.nameAndAge
MyWizard.nameAndAge.age.set(45)
MyWizard.nextScreen
- MyWizard.currentScreen.open_! must_== MyWizard.favoritePet
+ MyWizard.currentScreen.openOrThrowException("legacy code") must_== MyWizard.favoritePet
S.clearCurrentNotices
Something went wrong with that request. Please try again.