PageRenderTime 22ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/scalate-util/src/test/scala/org/fusesource/scalate/util/FunSuiteSupport.scala

http://github.com/scalate/scalate
Scala | 55 lines | 25 code | 7 blank | 23 comment | 1 complexity | 5592fae73bf64de5ded0d41edcc367d7 MD5 | raw file
  1. /**
  2. * Copyright (C) 2009-2011 the original author or authors.
  3. * See the notice.md file distributed with this work for additional
  4. * information regarding copyright ownership.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.fusesource.scalate
  19. import java.io.File
  20. import collection.immutable.Map
  21. import util.Log
  22. import xml.NodeSeq
  23. import org.junit.runner.RunWith
  24. import org.scalatest.junit.JUnitRunner
  25. import org.scalatest.{ConfigMap, BeforeAndAfterAll, FunSuite}
  26. import org.slf4j.LoggerFactory
  27. /**
  28. * @version $Revision : 1.1 $
  29. */
  30. @RunWith(classOf[JUnitRunner])
  31. abstract class FunSuiteSupport extends FunSuite with Log with BeforeAndAfterAll {
  32. protected var _basedir = "."
  33. /**
  34. * Returns the base directory of the current project
  35. */
  36. def baseDir = new File(_basedir)
  37. override protected def beforeAll(map: ConfigMap): Unit = {
  38. _basedir = map.get("basedir") match {
  39. case Some(basedir) => basedir.toString
  40. case _ => System.getProperty("basedir", ".")
  41. }
  42. debug("using basedir: %s", _basedir)
  43. }
  44. def assertType(anyRef: AnyRef, expectedClass: Class[_]): Unit = {
  45. assert(anyRef != null, "expected instance of " + expectedClass.getName)
  46. expect(expectedClass) {anyRef.getClass}
  47. }
  48. }