PageRenderTime 24ms CodeModel.GetById 21ms app.highlight 1ms RepoModel.GetById 1ms 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 */
18package org.fusesource.scalate
19
20import java.io.File
21import collection.immutable.Map
22import util.Log
23import xml.NodeSeq
24
25import org.junit.runner.RunWith
26import org.scalatest.junit.JUnitRunner
27import org.scalatest.{ConfigMap, BeforeAndAfterAll, FunSuite}
28import org.slf4j.LoggerFactory
29
30/**
31 * @version $Revision : 1.1 $
32 */
33@RunWith(classOf[JUnitRunner])
34abstract class FunSuiteSupport extends FunSuite with Log with BeforeAndAfterAll {
35  protected var _basedir = "."
36
37  /**
38   * Returns the base directory of the current project
39   */
40  def baseDir = new File(_basedir)
41
42
43  override protected def beforeAll(map: ConfigMap): Unit = {
44    _basedir = map.get("basedir") match {
45      case Some(basedir) => basedir.toString
46      case _ => System.getProperty("basedir", ".")
47    }
48    debug("using basedir: %s", _basedir)
49  }
50
51  def assertType(anyRef: AnyRef, expectedClass: Class[_]): Unit = {
52    assert(anyRef != null, "expected instance of " + expectedClass.getName)
53    expect(expectedClass) {anyRef.getClass}
54  }
55}