Nov 10, 2010

Setting Up Lift Environment

Lift enviroment

Lift is a very new web framework and, inevitably, unstable. Therefore, to make Lift work, the versions of Scala, Apache Maven, and Lift itself “must” be compatible.

For the website whowish.com; Lift 2.1, Scala 2.8.0, and Apache Maven 2.2.1 are chosen.

Installation
The installation steps are:

1. Install Netbeans 6.9
2. Install Scala 2.8.0 final (Please read README)
3. Install Scala Plugin for Netbeans 6.9 (Please read README.png)
4. Install Apache Maven 2.2.1 (Please read README)
5. Create a project that uses Lift 2.1 with Scala 2.8.0 by creating manual archetype with these parameters:

* archetype_group_id = net.liftweb
* archetype_artifact_id = lift-archetype-basic_2.8.0
* archetype_version = 2.1
* archetype_repository = http://scala-tools.org/repo-releases
* remote_repositories = http://scala-tools.org/repo-releases
* group_id = your group id
* artifact_id = your artifact id (which is project identity)
* version = your project version

6. Add DbUnit and MySQL dependencies by add these lines to pom.xml under dependencies tag:

* add dbunit 2.2
* add mysql-connector-java 5.1.13

7. That’s it... Congratulation !

Configure it to run with jetty

1. Right-click on Project and select Propeties
2. Go to Actions
3. Select Run Project and, under Execute Goals, type jetty:run
4. Select Debug Project and, under Execute Goals, type jetty:run

5. Go to pom.xml, find <plugin> of Jetty, and change scanIntervalSeconds to 0.

(Right now continuous recompilation on Jetty does not work ...)

Testing

Right-click on the project and choose either Run or Debug

Unit Testing with database mock-up

We are using DbUnit to set the database (MySQL) to a predefined state (coded in XML) and, after running a test code, DbUnit can compare the present state of the database with an expected state (coded in XML)