Permalink
Browse files

fixed build

  • Loading branch information...
fmpwizard committed Jun 27, 2012
1 parent 71f6558 commit ada3e023ba55ebabcdf468608b4489eb09f0a50c
@@ -43,6 +43,11 @@ import Helpers._
object MongoFieldSpec extends Specification("MongoField Specification") with MongoTestKit {
import fixtures._
+ val session = new LiftSession("", randomString(20), Empty)
+ def inLiftSession(a: =>Any) = S.initIfUninitted(session) { a }
+ new SpecContext {
+ aroundExpectations(inLiftSession(_))
+ }
def passBasicTests[A](
example: A,
mandatory: MandatoryTypedField[A],
@@ -39,6 +39,11 @@ import scala.xml.{NodeSeq, Elem, Node, Text}
* Systems under specification for RecordField.
*/
object FieldSpec extends Specification("Record Field Specification") {
+ val session = new LiftSession("", randomString(20), Empty)
+ def inLiftSession(a: =>Any) = S.initIfUninitted(session) { a }
+ new SpecContext {
+ aroundExpectations(inLiftSession(_))
+ }
def passBasicTests[A](example: A, mandatory: MandatoryTypedField[A], legacyOptional: MandatoryTypedField[A], optional: OptionalTypedField[A])(implicit m: scala.reflect.Manifest[A]): Unit = {
val canCheckDefaultValues =
!mandatory.defaultValue.isInstanceOf[Calendar] // don't try to use the default value of date/time typed fields, because it changes from moment to moment!
@@ -285,16 +290,19 @@ object FieldSpec extends Specification("Record Field Specification") {
}
"CountryField" should {
- val rec = FieldTypeTestRecord.createRecord
- val country = Countries.Canada
- passBasicTests(country, rec.mandatoryCountryField, rec.legacyOptionalCountryField, rec.optionalCountryField)
- passConversionTests(
- country,
- rec.mandatoryCountryField,
- Str(country.toString),
- JInt(country.id),
- Full(<select tabindex="1" name=".*" id="mandatoryCountryField_id"><option value=".*" selected="selected">{country.toString}</option></select>)
- )
+ val session = new LiftSession("", randomString(20), Empty)
+ S.initIfUninitted(session){
+ val rec = FieldTypeTestRecord.createRecord
+ val country = Countries.Canada
+ passBasicTests(country, rec.mandatoryCountryField, rec.legacyOptionalCountryField, rec.optionalCountryField)
+ passConversionTests(
+ country,
+ rec.mandatoryCountryField,
+ Str(country.toString),
+ JInt(country.id),
+ Full(<select tabindex="1" name=".*" id="mandatoryCountryField_id"><option value=".*" selected="selected">{country.toString}</option></select>)
+ )
+ }
}
"DateTimeField" should {
@@ -20,19 +20,36 @@ package record
import java.util.Calendar
import org.specs.Specification
+import util.Helpers._
+import json.JsonAST.JField
+import json.JsonAST.JInt
+import json.JsonAST.JString
+import http.js.JE.Str
+import json.JsonAST.JObject
+import json.JsonAST.JDouble
+import json.JsonAST.JBool
+
+//import org.specs.Specification.
import json.JsonAST._
import util._
import http.js.JE._
import field.Countries
import fixtures._
+import http.{S, LiftSession}
+import common.Empty
/**
* Systems under specification for Record.
*/
object RecordSpec extends Specification("Record Specification") {
+ val session = new LiftSession("", randomString(20), Empty)
+ def inLiftSession(a: =>Any) = S.initIfUninitted(session) { a }
+ new SpecContext {
+ aroundExpectations(inLiftSession(_))
+ }
"Record field introspection" should {
val rec = FieldTypeTestRecord.createRecord
val allExpectedFieldNames: List[String] = (for {
@@ -160,148 +177,153 @@ object RecordSpec extends Specification("Record Specification") {
}
"Record" should {
- val gu: Array[Byte] = Array(18, 19, 20)
- val cal = Calendar.getInstance
- val fttr = FieldTypeTestRecord.createRecord
- .mandatoryBinaryField(gu)
- .mandatoryBooleanField(false)
- .mandatoryCountryField(Countries.USA)
- .mandatoryDateTimeField(cal)
- .mandatoryDecimalField(BigDecimal("3.14"))
- .mandatoryDoubleField(1999)
- .mandatoryEmailField("test@liftweb.net")
- .mandatoryEnumField(MyTestEnum.ONE)
- .mandatoryIntField(99)
- .mandatoryLocaleField("en_US")
- .mandatoryLongField(100L)
- .mandatoryPostalCodeField("55401")
- .mandatoryStringField("foobar")
- .mandatoryTextareaField("foobar")
- .mandatoryTimeZoneField("America/Chicago")
-
- val json = "{\"mandatoryBooleanField\": false, \"mandatoryCountryField\": 1, \"mandatoryDateTimeField\": \""+Helpers.toInternetDate(cal.getTime)+"\",\"mandatoryDecimalField\": \"3.14\", \"mandatoryDoubleField\": 1999.0,\"mandatoryEmailField\":\"test@liftweb.net\",\"mandatoryEnumField\":0,\"mandatoryIntField\":99,\"mandatoryLocaleField\":\"en_US\",\"mandatoryLongField\":100,\"mandatoryPostalCodeField\":\"55401\",\"mandatoryStringField\":\"foobar\",\"mandatoryTextareaField\":\"foobar\",\"mandatoryTimeZoneField\":\"America/Chicago\",\"mandatoryBinaryField\":\"EhMU\"}"
-
- val fttrAsJsObj = JsObj(
- ("mandatoryBooleanField", JsFalse),
- ("legacyOptionalBooleanField", JsNull),
- ("optionalBooleanField", JsNull),
- ("mandatoryCountryField", Str(Countries.USA.toString)),
- ("legacyOptionalCountryField", JsNull),
- ("optionalCountryField", JsNull),
- ("mandatoryDateTimeField", Str(Helpers.toInternetDate(cal.getTime))),
- ("legacyOptionalDateTimeField", JsNull),
- ("optionalDateTimeField", JsNull),
- ("mandatoryDecimalField", Num(3.14)),
- ("legacyOptionalDecimalField", JsNull),
- ("optionalDecimalField", JsNull),
- ("mandatoryDoubleField", Num(1999.0)),
- ("legacyOptionalDoubleField", JsNull),
- ("optionalDoubleField", JsNull),
- ("mandatoryEmailField", Str("test@liftweb.net")),
- ("legacyOptionalEmailField", JsNull),
- ("optionalEmailField", JsNull),
- ("mandatoryEnumField", Str(MyTestEnum.ONE.toString)),
- ("legacyOptionalEnumField", JsNull),
- ("optionalEnumField", JsNull),
- ("mandatoryIntField", Num(99)),
- ("legacyOptionalIntField", JsNull),
- ("optionalIntField", JsNull),
- ("mandatoryLocaleField", Str("en_US")),
- ("legacyOptionalLocaleField", JsNull),
- ("optionalLocaleField", JsNull),
- ("mandatoryLongField", Num(100)),
- ("legacyOptionalLongField", JsNull),
- ("optionalLongField", JsNull),
- ("mandatoryPostalCodeField", Str("55401")),
- ("legacyOptionalPostalCodeField", JsNull),
- ("optionalPostalCodeField", JsNull),
- ("mandatoryStringField", Str("foobar")),
- ("legacyOptionalStringField", JsNull),
- ("optionalStringField", JsNull),
- ("mandatoryTextareaField", Str("foobar")),
- ("legacyOptionalTextareaField", JsNull),
- ("optionalTextareaField", JsNull),
- ("mandatoryTimeZoneField", Str("America/Chicago")),
- ("legacyOptionalTimeZoneField", JsNull),
- ("optionalTimeZoneField", JsNull),
- ("optionalBinaryField", JsNull),
- ("legacyOptionalBinaryField", JsNull),
- ("mandatoryBinaryField", Str("121314"))
- )
-
- "convert to JsExp (via asJSON)" in {
- fttr.asJSON mustEqual fttrAsJsObj
- }
+ val session = new LiftSession("", randomString(20), Empty)
+ S.initIfUninitted(session){
+ val gu: Array[Byte] = Array(18, 19, 20)
+ val cal = Calendar.getInstance
+
+ val fttr = FieldTypeTestRecord.createRecord
+ .mandatoryBinaryField(gu)
+ .mandatoryBooleanField(false)
+ .mandatoryCountryField(Countries.USA)
+ .mandatoryDateTimeField(cal)
+ .mandatoryDecimalField(BigDecimal("3.14"))
+ .mandatoryDoubleField(1999)
+ .mandatoryEmailField("test@liftweb.net")
+ .mandatoryEnumField(MyTestEnum.ONE)
+ .mandatoryIntField(99)
+ .mandatoryLocaleField("en_US")
+ .mandatoryLongField(100L)
+ .mandatoryPostalCodeField("55401")
+ .mandatoryStringField("foobar")
+ .mandatoryTextareaField("foobar")
+ .mandatoryTimeZoneField("America/Chicago")
+
+
+ val json = "{\"mandatoryBooleanField\": false, \"mandatoryCountryField\": 1, \"mandatoryDateTimeField\": \""+Helpers.toInternetDate(cal.getTime)+"\",\"mandatoryDecimalField\": \"3.14\", \"mandatoryDoubleField\": 1999.0,\"mandatoryEmailField\":\"test@liftweb.net\",\"mandatoryEnumField\":0,\"mandatoryIntField\":99,\"mandatoryLocaleField\":\"en_US\",\"mandatoryLongField\":100,\"mandatoryPostalCodeField\":\"55401\",\"mandatoryStringField\":\"foobar\",\"mandatoryTextareaField\":\"foobar\",\"mandatoryTimeZoneField\":\"America/Chicago\",\"mandatoryBinaryField\":\"EhMU\"}"
+
+ val fttrAsJsObj = JsObj(
+ ("mandatoryBooleanField", JsFalse),
+ ("legacyOptionalBooleanField", JsNull),
+ ("optionalBooleanField", JsNull),
+ ("mandatoryCountryField", Str(Countries.USA.toString)),
+ ("legacyOptionalCountryField", JsNull),
+ ("optionalCountryField", JsNull),
+ ("mandatoryDateTimeField", Str(Helpers.toInternetDate(cal.getTime))),
+ ("legacyOptionalDateTimeField", JsNull),
+ ("optionalDateTimeField", JsNull),
+ ("mandatoryDecimalField", Num(3.14)),
+ ("legacyOptionalDecimalField", JsNull),
+ ("optionalDecimalField", JsNull),
+ ("mandatoryDoubleField", Num(1999.0)),
+ ("legacyOptionalDoubleField", JsNull),
+ ("optionalDoubleField", JsNull),
+ ("mandatoryEmailField", Str("test@liftweb.net")),
+ ("legacyOptionalEmailField", JsNull),
+ ("optionalEmailField", JsNull),
+ ("mandatoryEnumField", Str(MyTestEnum.ONE.toString)),
+ ("legacyOptionalEnumField", JsNull),
+ ("optionalEnumField", JsNull),
+ ("mandatoryIntField", Num(99)),
+ ("legacyOptionalIntField", JsNull),
+ ("optionalIntField", JsNull),
+ ("mandatoryLocaleField", Str("en_US")),
+ ("legacyOptionalLocaleField", JsNull),
+ ("optionalLocaleField", JsNull),
+ ("mandatoryLongField", Num(100)),
+ ("legacyOptionalLongField", JsNull),
+ ("optionalLongField", JsNull),
+ ("mandatoryPostalCodeField", Str("55401")),
+ ("legacyOptionalPostalCodeField", JsNull),
+ ("optionalPostalCodeField", JsNull),
+ ("mandatoryStringField", Str("foobar")),
+ ("legacyOptionalStringField", JsNull),
+ ("optionalStringField", JsNull),
+ ("mandatoryTextareaField", Str("foobar")),
+ ("legacyOptionalTextareaField", JsNull),
+ ("optionalTextareaField", JsNull),
+ ("mandatoryTimeZoneField", Str("America/Chicago")),
+ ("legacyOptionalTimeZoneField", JsNull),
+ ("optionalTimeZoneField", JsNull),
+ ("optionalBinaryField", JsNull),
+ ("legacyOptionalBinaryField", JsNull),
+ ("mandatoryBinaryField", Str("121314"))
+ )
+
+ "convert to JsExp (via asJSON)" in {
+ fttr.asJSON mustEqual fttrAsJsObj
+ }
- /* Test broken
- "convert to JsExp (via asJsExp)" in {
- fttr.asJsExp mustEqual fttrAsJsObj
- }*/
-
- "convert to JValue" in {
- fttr.asJValue mustEqual JObject(List(
- JField("mandatoryBooleanField", JBool(false)),
- JField("legacyOptionalBooleanField", JNothing),
- JField("optionalBooleanField", JNothing),
- JField("mandatoryCountryField", JInt(Countries.USA.id)),
- JField("legacyOptionalCountryField", JNothing),
- JField("optionalCountryField", JNothing),
- JField("mandatoryDateTimeField", JString(Helpers.toInternetDate(cal.getTime))),
- JField("legacyOptionalDateTimeField", JNothing),
- JField("optionalDateTimeField", JNothing),
- JField("mandatoryDecimalField", JString("3.14")),
- JField("legacyOptionalDecimalField", JNothing),
- JField("optionalDecimalField", JNothing),
- JField("mandatoryDoubleField", JDouble(1999.0)),
- JField("legacyOptionalDoubleField", JNothing),
- JField("optionalDoubleField", JNothing),
- JField("mandatoryEmailField", JString("test@liftweb.net")),
- JField("legacyOptionalEmailField", JNothing),
- JField("optionalEmailField", JNothing),
- JField("mandatoryEnumField", JInt(MyTestEnum.ONE.id)),
- JField("legacyOptionalEnumField", JNothing),
- JField("optionalEnumField", JNothing),
- JField("mandatoryIntField", JInt(99)),
- JField("legacyOptionalIntField", JNothing),
- JField("optionalIntField", JNothing),
- JField("mandatoryLocaleField", JString("en_US")),
- JField("legacyOptionalLocaleField", JNothing),
- JField("optionalLocaleField", JNothing),
- JField("mandatoryLongField", JInt(100)),
- JField("legacyOptionalLongField", JNothing),
- JField("optionalLongField", JNothing),
- JField("mandatoryPostalCodeField", JString("55401")),
- JField("legacyOptionalPostalCodeField", JNothing),
- JField("optionalPostalCodeField", JNothing),
- JField("mandatoryStringField", JString("foobar")),
- JField("legacyOptionalStringField", JNothing),
- JField("optionalStringField", JNothing),
- JField("mandatoryTextareaField", JString("foobar")),
- JField("legacyOptionalTextareaField", JNothing),
- JField("optionalTextareaField", JNothing),
- JField("mandatoryTimeZoneField", JString("America/Chicago")),
- JField("legacyOptionalTimeZoneField", JNothing),
- JField("optionalTimeZoneField", JNothing),
- JField("mandatoryBinaryField", JString("EhMU")),
- JField("legacyOptionalBinaryField", JNothing),
- JField("optionalBinaryField", JNothing)
- ))
- }
+ /* Test broken
+ "convert to JsExp (via asJsExp)" in {
+ fttr.asJsExp mustEqual fttrAsJsObj
+ }*/
+
+ "convert to JValue" in {
+ fttr.asJValue mustEqual JObject(List(
+ JField("mandatoryBooleanField", JBool(false)),
+ JField("legacyOptionalBooleanField", JNothing),
+ JField("optionalBooleanField", JNothing),
+ JField("mandatoryCountryField", JInt(Countries.USA.id)),
+ JField("legacyOptionalCountryField", JNothing),
+ JField("optionalCountryField", JNothing),
+ JField("mandatoryDateTimeField", JString(Helpers.toInternetDate(cal.getTime))),
+ JField("legacyOptionalDateTimeField", JNothing),
+ JField("optionalDateTimeField", JNothing),
+ JField("mandatoryDecimalField", JString("3.14")),
+ JField("legacyOptionalDecimalField", JNothing),
+ JField("optionalDecimalField", JNothing),
+ JField("mandatoryDoubleField", JDouble(1999.0)),
+ JField("legacyOptionalDoubleField", JNothing),
+ JField("optionalDoubleField", JNothing),
+ JField("mandatoryEmailField", JString("test@liftweb.net")),
+ JField("legacyOptionalEmailField", JNothing),
+ JField("optionalEmailField", JNothing),
+ JField("mandatoryEnumField", JInt(MyTestEnum.ONE.id)),
+ JField("legacyOptionalEnumField", JNothing),
+ JField("optionalEnumField", JNothing),
+ JField("mandatoryIntField", JInt(99)),
+ JField("legacyOptionalIntField", JNothing),
+ JField("optionalIntField", JNothing),
+ JField("mandatoryLocaleField", JString("en_US")),
+ JField("legacyOptionalLocaleField", JNothing),
+ JField("optionalLocaleField", JNothing),
+ JField("mandatoryLongField", JInt(100)),
+ JField("legacyOptionalLongField", JNothing),
+ JField("optionalLongField", JNothing),
+ JField("mandatoryPostalCodeField", JString("55401")),
+ JField("legacyOptionalPostalCodeField", JNothing),
+ JField("optionalPostalCodeField", JNothing),
+ JField("mandatoryStringField", JString("foobar")),
+ JField("legacyOptionalStringField", JNothing),
+ JField("optionalStringField", JNothing),
+ JField("mandatoryTextareaField", JString("foobar")),
+ JField("legacyOptionalTextareaField", JNothing),
+ JField("optionalTextareaField", JNothing),
+ JField("mandatoryTimeZoneField", JString("America/Chicago")),
+ JField("legacyOptionalTimeZoneField", JNothing),
+ JField("optionalTimeZoneField", JNothing),
+ JField("mandatoryBinaryField", JString("EhMU")),
+ JField("legacyOptionalBinaryField", JNothing),
+ JField("optionalBinaryField", JNothing)
+ ))
+ }
- "get set from json string using lift-json parser" in {
- val fttrFromJson = FieldTypeTestRecord.fromJsonString(json)
- fttrFromJson must notBeEmpty
- fttrFromJson foreach { r =>
- r.mandatoryDecimalField.value mustEqual fttr.mandatoryDecimalField.value
- r mustEqual fttr
+ "get set from json string using lift-json parser" in {
+ val fttrFromJson = FieldTypeTestRecord.fromJsonString(json)
+ fttrFromJson must notBeEmpty
+ fttrFromJson foreach { r =>
+ r.mandatoryDecimalField.value mustEqual fttr.mandatoryDecimalField.value
+ r mustEqual fttr
+ }
}
- }
- "get set from json string using util.JSONParser" in {
- val fttrFromJSON = FieldTypeTestRecord.fromJSON(json)
- fttrFromJSON must notBeEmpty
- fttrFromJSON foreach { r =>
- r mustEqual fttr
+ "get set from json string using util.JSONParser" in {
+ val fttrFromJSON = FieldTypeTestRecord.fromJSON(json)
+ fttrFromJSON must notBeEmpty
+ fttrFromJSON foreach { r =>
+ r mustEqual fttr
+ }
}
}
}
Oops, something went wrong.

0 comments on commit ada3e02

Please sign in to comment.