Skip to content

Instantly share code, notes, and snippets.

@b0c1
Created May 3, 2013 08:38
Show Gist options
  • Save b0c1/5507967 to your computer and use it in GitHub Desktop.
Save b0c1/5507967 to your computer and use it in GitHub Desktop.
Activate vs Scalatra. Round 1
package hu.finesolution.sepia.test.core.controller
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.mock.MockitoSugar
import org.scalatest.{FunSuite, BeforeAndAfter}
import org.scalatra.test.scalatest.ScalatraSuite
import org.scalatra.ScalatraServlet
import net.fwbrasil.activate.ActivateContext
import net.fwbrasil.activate.storage.relational.PooledJdbcRelationalStorage
import net.fwbrasil.activate.storage.relational.idiom.h2Dialect
object h2Context extends ActivateContext {
val storage = new PooledJdbcRelationalStorage {
val jdbcDriver = "org.h2.Driver"
val user = ""
val password = ""
val url = "jdbc:h2:mem:my_database;DB_CLOSE_DELAY=-1"
val dialect = h2Dialect
}
}
import h2Context._
class Test(var name: String) extends Entity
class TestMigration extends Migration {
def timestamp = 20130523001l
def up = {
table[Test].createTable(
_.column[String]("name")
)
}
}
class ManifestExample[T <: AnyRef](implicit m: Manifest[T]) extends ScalatraServlet {
get("/") {
"hi"
}
}
@RunWith(classOf[JUnitRunner])
class CrudTest extends FunSuite with ScalatraSuite with MockitoSugar with BeforeAndAfter {
addServlet(new ManifestExample[Test](), "/*")
test("Test creat") {
get("/") {
status should equal(200)
body should include("hi")
}
}
before {
transactional {
all[Test].foreach(_.delete)
}
}
}
@b0c1
Copy link
Author

b0c1 commented May 3, 2013

The exception:
An exception or error caused a run to abort.
java.lang.ExceptionInInitializerError
at hu.finesolution.sepia.test.core.controller.CrudTest$$anonfun$2.apply$mcV$sp(CrudTest.scala:61)
at hu.finesolution.sepia.test.core.controller.CrudTest$$anonfun$2.apply(CrudTest.scala:61)
at hu.finesolution.sepia.test.core.controller.CrudTest$$anonfun$2.apply(CrudTest.scala:61)
at org.scalatest.BeforeAndAfter$class.runTest(BeforeAndAfter.scala:166)
at hu.finesolution.sepia.test.core.controller.CrudTest.runTest(CrudTest.scala:48)
at org.scalatest.FunSuite$$anonfun$runTests$1.apply(FunSuite.scala:1304)
at org.scalatest.FunSuite$$anonfun$runTests$1.apply(FunSuite.scala:1304)
at org.scalatest.SuperEngine$$anonfun$org$scalatest$SuperEngine$$runTestsInBranch$1.apply(Engine.scala:260)
at org.scalatest.SuperEngine$$anonfun$org$scalatest$SuperEngine$$runTestsInBranch$1.apply(Engine.scala:249)
at scala.collection.immutable.List.foreach(List.scala:318)
at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:249)
at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:326)
at org.scalatest.FunSuite$class.runTests(FunSuite.scala:1304)
at hu.finesolution.sepia.test.core.controller.CrudTest.runTests(CrudTest.scala:48)
at org.scalatest.Suite$class.run(Suite.scala:2303)
at hu.finesolution.sepia.test.core.controller.CrudTest.org$scalatest$FunSuite$$super$run(CrudTest.scala:48)
at org.scalatest.FunSuite$$anonfun$run$1.apply(FunSuite.scala:1310)
at org.scalatest.FunSuite$$anonfun$run$1.apply(FunSuite.scala:1310)
at org.scalatest.SuperEngine.runImpl(Engine.scala:362)
at org.scalatest.FunSuite$class.run(FunSuite.scala:1310)
at hu.finesolution.sepia.test.core.controller.CrudTest.org$scalatest$BeforeAndAfterAll$$super$run(CrudTest.scala:48)
at org.scalatest.BeforeAndAfterAll$class.run(BeforeAndAfterAll.scala:213)
at hu.finesolution.sepia.test.core.controller.CrudTest.org$scalatest$BeforeAndAfter$$super$run(CrudTest.scala:48)
at org.scalatest.BeforeAndAfter$class.run(BeforeAndAfter.scala:208)
at hu.finesolution.sepia.test.core.controller.CrudTest.run(CrudTest.scala:48)
at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:60)
at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:1604)
at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:1601)
at scala.collection.immutable.List.foreach(List.scala:318)
at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:1601)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:705)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:704)
at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:1645)
at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:703)
at org.scalatest.tools.Runner$.run(Runner.scala:592)
at org.scalatest.tools.Runner.run(Runner.scala)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest1(ScalaTestRunner.java:213)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:37)
Caused by: java.util.NoSuchElementException: None.get
at scala.None$.get(Option.scala:313)
at scala.None$.get(Option.scala:311)
at net.fwbrasil.activate.entity.EntityMetadata.(EntityMetadata.scala:113)
at net.fwbrasil.activate.entity.EntityHelper$$anonfun$initialize$1.apply(EntityHelper.scala:43)
at net.fwbrasil.activate.entity.EntityHelper$$anonfun$initialize$1.apply(EntityHelper.scala:39)
at scala.collection.immutable.List.foreach(List.scala:318)
at net.fwbrasil.activate.entity.EntityHelper$.initialize(EntityHelper.scala:39)
at net.fwbrasil.activate.entity.EntityContext$class.$init$(Entity.scala:238)
at hu.finesolution.sepia.test.core.controller.h2Context$.(CrudTest.scala:16)
at hu.finesolution.sepia.test.core.controller.h2Context$.(CrudTest.scala)
... 38 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment