*** LAB 2 - Events Portal  ***

This is a sample project for LAB 2 in "Web Programming" 2011 course.

***   Application modules   ***

Application consists of two modules:

    - "lab02-events-core" : contains Java classes - domain model, services, Spring MVC classes
                         : is packaged in JAR file, which is later placed into Web module's folder "/WEB-INF/lib/"

    - "lab02-events-portal": Web module
                          : "\lab02-events-portal\src\main\webapp" contains Web application resources (jsp, css, images etc)

***       Preparation       ***

1) Create "events" database and user in MySQL using a script

If database and user already exist (you have created it during the first lab),
then to avoid schema incompatibility better drop schema (delete all tables).
Otherwise you may experience persistence problems during execution!
Necessary tables will be created on application start up.

2) To modify projects in Eclipse execute "mvn eclipse:eclipse" respectively from
"lab02-events-core" and "lab02-events-portal".
In Eclipse delete main "lab02-events" root project (do not delete contents) and import sub-projects in Eclipse separately.

3) Run Java program (you have to be familiar with this program from the first lab).
Program will import users data from XML file to the database.

4) Execute "mvn install" from \lab02-events

***       Packaging         ***
To build a WAR file execute "mvn package" from the root folder "lab02-events".
Application WAR file will be created in "\lab02-events\lab02-events-portal\target".
Deploy "lab02-events-portal.war" on application server (Jetty, Tomcat, JBoss or any other) and run application.
Application was tested on Jetty integrated with Maven.

***  Running with Jetty     ***

Jetty is a web server integrated with Maven, which can be simply launched from command line.
To rebuild application and start Jetty simply run \lab02-events\run_jetty.bat
To start with remote debugging enabled run \lab02-events\run_jetty_debug.bat

These scripts consist of two steps, which can be executed separately:

1) To package "lab02-events-core" in JAR file and install it into local Maven repository:
Go to \lab02-events\lab02-events-core\ and execute 
	mvn install
You have to perform this step each time when you change code in "lab02-events-core" and want these changes to appear in packaged web application.

2) To deploy lab02-events-portal.war and start Jetty (without re-packaging "lab02-events-core"):
Go to  \lab02-events\lab02-events-portal\ and execute
	mvn clean package jetty:run

***  Launching application  ***

Application can be accessed by opening the following URL in a browser: 

For login use any user listed in \lab02-events\lab02-events-core\src\main\resources\data\users.xml (be sure that data is imported into database).
E.g. jwhite/jwhite.
Or you may create your own user directly in database.

***  Selenium tests         ***

There are two possibilities to execute prepared Selenium tests:
* using Selenium IDE
* integrating Selenium Core into a project

1) Install Selenium IDE (Firefox plugin, not yet available for FF 8), available at
In Selenium IDE select: File > Open Test Suite... > \lab02-events\lab02-events-portal\src\main\webapp\tests\events-suite\TestSuite.html
Play suite tests.

2) To be able to run Selenium tests directly in a browser you will need to download Selenium Core from
Download and unzip it under \lab02-events\lab02-events-portal\src\main\webapp\selenium-core
When application is running on server Selenium tests can be accessed by URL
Precondition for tests - users data imported into database (UsersImportTool program executed).

*** Integrating your Lab1 solution ***

For sure you will want to update "lab02-events-core" content with a
certain part of your solution for the first lab - domain model classes that you have made persistent entities, services etc.
Do it, but be careful, this may require additional tuning.

***   Remote debugging     ***

To run Jetty with remote debugging mode enabled execute: run_jetty_debug.bat

For a tip on how to debug server-side code see - 03_Server-Side Debugging_2011_10_20..ppt

*** Problems & Questions ***

If you experience any problem or observe any strangeness or have any question,
please don't delay it, write on e-mail or ask during a lecture!

*** GOOD LUCK !!! ***