|
1 /* |
|
2 * Copyright 2011 Tomas Zeman <tzeman@volny.cz> |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 package fis.base.model |
|
17 |
|
18 import net.liftweb.common._ |
|
19 import net.liftweb.mapper.DB |
|
20 import net.liftweb.squerylrecord.SquerylRecord |
|
21 import org.scalatest._ |
|
22 import org.scalatest.matchers.ShouldMatchers |
|
23 |
|
24 abstract class AbstractTest extends FlatSpec with ShouldMatchers with Logger |
|
25 with BeforeAndAfterEach with BeforeAndAfterAll { |
|
26 |
|
27 val db = this.getClass.getSimpleName |
|
28 val h2vendor = H2Vendor(db) |
|
29 val ci = TestConnectionIdentifier(db) |
|
30 |
|
31 override def beforeAll() { |
|
32 beforeEach() |
|
33 } |
|
34 |
|
35 override def beforeEach() { |
|
36 super.beforeEach |
|
37 DB.defineConnectionManager(ci, h2vendor) |
|
38 SquerylRecord.init(() => new EntityViewH2Adapter) |
|
39 } |
|
40 |
|
41 override def afterEach() { |
|
42 h2vendor.closeAllConnections_! |
|
43 } |
|
44 |
|
45 def doInDB(block: => Any) { |
|
46 DB.use(ci) { _ => block } |
|
47 } |
|
48 |
|
49 } |
|
50 |
|
51 import org.squeryl.Schema |
|
52 |
|
53 trait DropAndCreate { self: Schema => |
|
54 def dropAndCreate { |
|
55 drop |
|
56 create |
|
57 } |
|
58 } |
|
59 |
|
60 |
|
61 // vim: set ts=2 sw=2 et: |