Tutorial 0

Installing, running and JUniting

As you know, Gerbo is a object mapper. What is this? It is a way, that makes you stop using SQL queries inside java code, because this is bad! It is bad because it is hardcoded, you change your way of programming, and make your code vendor dependent.
With Gerbo, you can (almost) forget about SQL, inside your java code, you will have no SQl, and no OQL queries at all.
Given a XML file, which contains the database tables description, Gerbo generates some classes, that will do the trick. In the next tutorial, you will see what kind of classes Gerbo generates, how to use them and how to write a simple XML file for the database tables.
For now, lets concentrate on how to run Gerbo, and run the gerbo generated classes.

Here is a small checklist, you need to have this:

You also need these jars: Velocity, for Gerbo; JUnit, mmMySql driver, for Gerbo generated classes, but they all come along with Gerbo zip package.

Now, you must compile Gerbo and run it. The default xml file that will be read, is the one inside examples/portal.xml. You can change the target xml file inside build.xml.
The classes will be generated for package test.tester, you can also change this inside build.xml.
Compiling and running:
  $ ant run

You should not receive any errors, neither compile time, neither run time. Send me an email if something occurs (remember to use jdk1.4).

This will create all necessaries directories, compile Gerbo, that is inside /src, and then generate some java classes, inside /generated/src.
Take a good look inside /generated/src, you will see some classes named as the tables from the xml file and some other ones. You will also realize that the classes have been javadoced 100%, with examples and good explanations, this is nice.

Now, before compiling and running the generated classes, we will need to setup the database.properties file. It is inside your /generated/src directory, if you didnt change the package name, follow inside /generated/src/test/tester/model/config/Database.properties.
  # This will make the DatabaseBroker singleton be initilized with a property file with 
  # the name of the vendor plus ".sql". Case sensitive.

  # for the connection pool, not in use right now

You should change the database.connection.string property, to use your username and password name.
The user should have access to fully use the specified database named NAME. And the database NAME should be created by yourself, so log in MySQL and CREATE DATABASE NAME; or the name that you like most.
Now we can compile these classes, and run a JUnit test, (you can see it inside generated/src/test/tester/GerboTest.java).
This JUnit test case is generated exclusive for your xml file, when running it, it will create the tables, and then insert, delete, select and make some assertions based on the number of rows for each table, PRETTY cool.
  $ ant run-generated

You should get:
Time: 1.021

OK (5 tests)

If you get something different from this, with an error, please send me an email. Remember to check first for your MySQL configuration, the username and password must be valid, and the database must be already created.
If you would like, you can uncomment a line inside GerboTest.java, making a GUI test instead of a text based test:

	    // if you want a graphical front end	
	    // you can uncommnet the following line
	    // or run your runner