Skip to content

Commit

Permalink
Ref #872, #873, #817
Browse files Browse the repository at this point in the history
- More cleanup and class/sus names consistencies
- Remove deprecation warnings
- Remove junit references, import cleanups
  • Loading branch information
indrajitr committed Feb 24, 2011
1 parent 91c7a82 commit 1f54b5d
Show file tree
Hide file tree
Showing 29 changed files with 189 additions and 239 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ object CombParserHelpersSpec extends Specification("CombParserHelpers Specificat
val number: String => Boolean = val number: String => Boolean =
(s: String) => { (s: String) => {
aNumber(s) match { aNumber(s) match {
case Success(x, y) => case Success(x, y) => s.toInt == x
s.toInt == x
case _ => true case _ => true
} }
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import util._




object DbProviders { object DbProviders {
def asList = PostgreSqlProvider :: MySqlProvider :: DerbyProvider :: H2Provider :: H2MemoryProvider :: Nil def asList = PostgreSqlProvider :: MySqlProvider :: DerbyProvider :: H2FileProvider :: H2MemoryProvider :: Nil
// Uncomment to run tests faster, but only against H2 def asList = H2MemoryProvider :: Nil // Uncomment to run tests faster, but only against H2 def asList = H2MemoryProvider :: Nil




Expand Down Expand Up @@ -132,7 +132,7 @@ object DbProviders {
override def required_? = true override def required_? = true
} }


object H2Provider extends Provider with FileDbSetup { object H2FileProvider extends Provider with FileDbSetup {
def name = "H2" def name = "H2"
def filePath = "target/tests_h2_lift" def filePath = "target/tests_h2_lift"
def vendor = new Vendor("org.h2.Driver") { def vendor = new Vendor("org.h2.Driver") {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import http.provider.HTTPRequest
/** /**
* Systems under specification for Mapper. * Systems under specification for Mapper.
*/ */
object MapperSpecs extends Specification("Mapper Specification") { object MapperSpec extends Specification("Mapper Specification") {


val doLog = false val doLog = false


Expand Down Expand Up @@ -98,19 +98,28 @@ object MapperSpecs extends Specification("Mapper Specification") {
Schemifier.schemify(true, if (doLog) Schemifier.infoF _ else ignoreLogger _, DbProviders.SnakeConnectionIdentifier, SampleModelSnake, SampleTagSnake) Schemifier.schemify(true, if (doLog) Schemifier.infoF _ else ignoreLogger _, DbProviders.SnakeConnectionIdentifier, SampleModelSnake, SampleTagSnake)
} }


/*
doBeforeSpec { doBeforeSpec {
providers.foreach(provider => { providers.foreach(provider => {
try {provider.setupDB} catch { case e if !provider.required_? => skip("Provider %s not available: %s".format(provider, e)) } try {provider.setupDB} catch { case e if !provider.required_? => skip("Provider %s not available: %s".format(provider, e)) }
Thread.sleep(50) // Yuck! FIXME Thread.sleep(50) // Yuck! FIXME
// println("Setup done for =>>> " + provider) // println("Setup done for =>>> " + provider)
}) })
} }
*/


providers.foreach(provider => { providers.foreach(provider => {


("Mapper for " + provider.name) should { ("Mapper for " + provider.name) should {


doBefore { cleanup() } doBefore {
(try {
provider.setupDB
cleanup
} catch {
case e if !provider.required_? => skip("Provider %s not available: %s".format(provider, e))
}) must not(throwAnException[Exception]).orSkipExample
}
setSequential() setSequential()


"schemify" in { "schemify" in {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import java.util.{Calendar, Date}


import org.bson.types.ObjectId import org.bson.types.ObjectId
import org.specs.Specification import org.specs.Specification
import org.specs.runner.JUnit4


import net.liftweb.record.field._ import net.liftweb.record.field._


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import scala.xml.Text


import org.bson.types.ObjectId import org.bson.types.ObjectId
import org.specs.Specification import org.specs.Specification
import org.specs.runner.JUnit4


import net.liftweb.record._ import net.liftweb.record._


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import net.liftweb.record.field._
import net.liftweb.util.TimeHelpers._ import net.liftweb.util.TimeHelpers._


import org.specs.Specification import org.specs.Specification
import org.specs.runner.JUnit4


import com.mongodb._ import com.mongodb._
import org.bson.types.ObjectId import org.bson.types.ObjectId
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import java.util.regex.Pattern


import org.bson.types.ObjectId import org.bson.types.ObjectId
import org.specs.Specification import org.specs.Specification
import org.specs.runner.JUnit4


import net.liftweb.record.field.Countries import net.liftweb.record.field.Countries


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package field


import org.bson.types.ObjectId import org.bson.types.ObjectId
import org.specs.Specification import org.specs.Specification
import org.specs.runner.JUnit4


import net.liftweb.common._ import net.liftweb.common._
import net.liftweb.json.ext.EnumSerializer import net.liftweb.json.ext.EnumSerializer
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package field


import org.bson.types.ObjectId import org.bson.types.ObjectId
import org.specs.Specification import org.specs.Specification
import org.specs.runner.JUnit4


import net.liftweb.common._ import net.liftweb.common._
import net.liftweb.json.ext.EnumNameSerializer import net.liftweb.json.ext.EnumNameSerializer
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import java.util.Calendar


object DBHelper { object DBHelper {
def initSquerylRecordWithInMemoryDB() { def initSquerylRecordWithInMemoryDB() {
SquerylRecord.initWithSquerylSession { SquerylRecord.initWithSquerylSession {
val session = Session.create(DriverManager.getConnection("jdbc:h2:mem:testSquerylRecordDB;DB_CLOSE_DELAY=-1", "sa", ""), new H2Adapter) val session = Session.create(DriverManager.getConnection("jdbc:h2:mem:testSquerylRecordDB;DB_CLOSE_DELAY=-1"), new H2Adapter)
//session.setLogger(statement => println(statement)) //session.setLogger(statement => println(statement))
session session
} }
Expand All @@ -50,14 +50,14 @@ object DBHelper {
*/ */
def createSchema() { def createSchema() {
inTransaction { inTransaction {
try { try {
//MySchema.printDdl //MySchema.printDdl
MySchema.dropAndCreate MySchema.dropAndCreate
MySchema.createTestData MySchema.createTestData
} catch { } catch {
case e => e.printStackTrace() case e => e.printStackTrace()
throw e; throw e;
} }
} }
} }
} }
Expand Down Expand Up @@ -145,13 +145,13 @@ object Employee extends Employee with MetaRecord[Employee]
* Test record: One or more employees can have a room (one-to-many-relation). * Test record: One or more employees can have a room (one-to-many-relation).
*/ */
class Room private() extends Record[Room] with KeyedRecord[Long] { class Room private() extends Record[Room] with KeyedRecord[Long] {
override def meta = Room override def meta = Room

override val idField = new LongField(this) override val idField = new LongField(this)

val name = new StringField(this, 50) val name = new StringField(this, 50)

lazy val employees = MySchema.roomAssignments.right(this) lazy val employees = MySchema.roomAssignments.right(this)
} }


object Room extends Room with MetaRecord[Room] object Room extends Room with MetaRecord[Room]
Expand Down Expand Up @@ -179,9 +179,9 @@ object MySchema extends Schema {
oneToManyRelation(companies, employees).via((c, e) => c.id === e.companyId) oneToManyRelation(companies, employees).via((c, e) => c.id === e.companyId)


val roomAssignments = manyToManyRelation(employees, rooms). val roomAssignments = manyToManyRelation(employees, rooms).
via[RoomAssignment]((employee, room, roomAssignment) => via[RoomAssignment]((employee, room, roomAssignment) =>
(roomAssignment.employeeId === employee.idField, roomAssignment.roomId === room.idField)) (roomAssignment.employeeId === employee.idField, roomAssignment.roomId === room.idField))

on(employees)(e => on(employees)(e =>
declare(e.companyId defineAs (indexed("idx_employee_companyId")), declare(e.companyId defineAs (indexed("idx_employee_companyId")),
e.email defineAs indexed("idx_employee_email"))) e.email defineAs indexed("idx_employee_email")))
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ package squerylrecord
import org.specs.Specification import org.specs.Specification
import record.{BaseField, Record} import record.{BaseField, Record}
import RecordTypeMode._ import RecordTypeMode._
import MySchema.{TestData => td} import MySchema.{TestData => td, _}
import MySchema.{companies, employees, rooms, roomAssignments}




/** /**
Expand Down Expand Up @@ -55,7 +54,7 @@ object SquerylRecordSpec extends Specification("SquerylRecord Specification") {
transaction { transaction {
val orderedCompanies = from(companies)(c => val orderedCompanies = from(companies)(c =>
select(c) orderBy (c.name)) select(c) orderBy (c.name))
val ids = orderedCompanies.map(c => c.id) val ids = orderedCompanies.map(_.id)
ids must containInOrder( ids must containInOrder(
td.allCompanies.sortBy(_.name.is).map(_.id)) td.allCompanies.sortBy(_.name.is).map(_.id))
} }
Expand Down Expand Up @@ -263,7 +262,7 @@ object SquerylRecordSpec extends Specification("SquerylRecord Specification") {
def check(fieldExtractor: (T) => BaseField) { def check(fieldExtractor: (T) => BaseField) {
val f1 = fieldExtractor(r1) val f1 = fieldExtractor(r1)
val f2 = fieldExtractor(r2) val f2 = fieldExtractor(r2)
f1.is must_== f2.is f1.get must_== f2.get
f1.name must_== f2.name f1.name must_== f2.name
} }


Expand Down
11 changes: 5 additions & 6 deletions project/build/LiftFrameworkProject.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class LiftFrameworkProject(info: ProjectInfo) extends ParentProject(info) with L
lazy val framework_doc = project(".", "lift-framework-doc", new DefaultProject(_) with LiftDefaultDocProject) lazy val framework_doc = project(".", "lift-framework-doc", new DefaultProject(_) with LiftDefaultDocProject)




private def coreProject = frameworkProject("core") _ private def coreProject = frameworkProject("core") _
private def webProject = frameworkProject("web") _ private def webProject = frameworkProject("web") _
private def persistenceProject = frameworkProject("persistence") _ private def persistenceProject = frameworkProject("persistence") _


private def frameworkProject(base: String)(path: String, libs: ModuleID*)(deps: Project*) = private def frameworkProject(base: String)(path: String, libs: ModuleID*)(deps: Project*) =
Expand All @@ -85,12 +85,12 @@ class LiftFrameworkProject(info: ProjectInfo) extends ParentProject(info) with L
// ------------ // ------------
class FrameworkProject(info: ProjectInfo, libs: ModuleID*) extends DefaultProject(info) with LiftDefaultProject { class FrameworkProject(info: ProjectInfo, libs: ModuleID*) extends DefaultProject(info) with LiftDefaultProject {


override def libraryDependencies = super.libraryDependencies ++ libs ++ Seq(TestScope.junit) override def libraryDependencies = super.libraryDependencies ++ libs


// FIXME: Build fails with -Xcheckinit -Xwarninit // FIXME: Build fails with -Xcheckinit -Xwarninit
override def compileOptions = super.compileOptions.toList -- compileOptions("-Xcheckinit", "-Xwarninit").toList override def compileOptions = super.compileOptions.toList -- compileOptions("-Xcheckinit", "-Xwarninit").toList


// System property hack for derby.log, webapptests // System properties necessary during test
override def testAction = override def testAction =
super.testAction dependsOn super.testAction dependsOn
task { task {
Expand All @@ -101,10 +101,9 @@ class LiftFrameworkProject(info: ProjectInfo) extends ParentProject(info) with L


// FIXME: breaks with SBT // FIXME: breaks with SBT
override def testOptions = override def testOptions =
// TestFilter((name: String) => name.startsWith("net.liftweb.mapper")) ::
ExcludeTests( ExcludeTests(
// Web tests // Web tests
"net.liftweb.webapptest.OneShot" :: "net.liftweb.webapptest.ToHeadUsages" :: "net.liftweb.http.SnippetSpec" :: Nil) :: "net.liftweb.http.SnippetSpec" :: Nil) ::
super.testOptions.toList super.testOptions.toList
} }


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -126,5 +126,3 @@ object MockHttpRequestSpec extends Specification("MockHttpRequest Specification"


} }
} }


Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
package net.liftweb package net.liftweb
package builtin.snippet package builtin.snippet


import common._ import xml._
import http.{LiftRules,LiftSession,S} import org.specs.Specification


import org.specs._ import common._
import runner._ import http._
import Sugar._


import scala.xml.{Null,Text,UnprefixedAttribute,XML}


class MsgSpecTest extends Runner(MsgSpec) with JUnit with Console /**
object MsgSpec extends Specification { * System under specification for Msg.
*/
object MsgSpec extends Specification("Msg Specification") {
def withSession[T](f: => T) : T = def withSession[T](f: => T) : T =
S.initIfUninitted(new LiftSession("test", "", Empty))(f) S.initIfUninitted(new LiftSession("test", "", Empty))(f)


Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010 WorldWide Conferencing, LLC * Copyright 2010-2011 WorldWide Conferencing, LLC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
Expand All @@ -14,19 +14,21 @@
* limitations under the License. * limitations under the License.
*/ */


package net.liftweb { package net.liftweb
package builtin.snippet { package builtin.snippet


import _root_.org.specs._ import xml.XML
import _root_.org.specs.runner._ import org.specs.Specification
import _root_.org.specs.Sugar._
import _root_.net.liftweb.http.{LiftRules,LiftSession,S}
import _root_.net.liftweb.common._


import _root_.scala.xml.XML import common._
import http._


/**
* System under specification for Msgs.
*/
object MsgsSpec extends Specification("Msgs Specification") {


class MsgsSpecTest extends Runner(MsgsSpec) with JUnit with Console
object MsgsSpec extends Specification {
def withSession[T](f: => T) : T = def withSession[T](f: => T) : T =
S.initIfUninitted(new LiftSession("test", "", Empty))(f) S.initIfUninitted(new LiftSession("test", "", Empty))(f)


Expand Down Expand Up @@ -69,5 +71,3 @@ object MsgsSpec extends Specification {
} }
} }
} }

}} // Close nested packages
28 changes: 14 additions & 14 deletions web/webkit/src/test/scala/net/liftweb/http/BindingsSpec.scala
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010 WorldWide Conferencing, LLC * Copyright 2010-2011 WorldWide Conferencing, LLC
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
Expand All @@ -14,20 +14,22 @@
* limitations under the License. * limitations under the License.
*/ */


package net.liftweb { package net.liftweb
package http { package http


import _root_.net.liftweb.util.Helpers._ import xml.{NodeSeq, Text}
import _root_.org.specs._ import org.specs.Specification
import _root_.org.specs.runner._
import _root_.org.specs.Sugar._ import common._
import scala.xml.NodeSeq import util.Helpers._
import scala.xml.Text
import _root_.net.liftweb.common._
import Bindings._ import Bindings._


class BindingsSpecTest extends Runner(BindingsSpec) with JUnit with Console
object BindingsSpec extends Specification { /**
* System under specification for Bindings.
*/
object BindingsSpec extends Specification("Bindings Bindings") {

case class MyClass(str: String, i: Int, other: MyOtherClass) case class MyClass(str: String, i: Int, other: MyOtherClass)
case class MyOtherClass(foo: String) case class MyOtherClass(foo: String)


Expand Down Expand Up @@ -106,5 +108,3 @@ object BindingsSpec extends Specification {
} }
} }
} }

}}
Loading

0 comments on commit 1f54b5d

Please sign in to comment.