Sunday, February 15, 2009

GlassFish and Java memory allocation

Last week I was very confused and bewildered when all of a sudden I could no longer find my compiled JSPs.
We are using GlassFish application server and normally one can find the compiled JSPs in the generated folder.
Anyway after the amusement passed I realised that something must have changed and remembered one of my mottos "Remember the solution!"
Basically what happened was that the server Java JDK was upgraded to 1.6
One of the features of 1.6 is memory allocation. Thus JSPs are compiled and stored in memory. The benefits are obvious, performance! That's where the JSPs have gone!
Anyway, GlassFish has a setting, keepGenerated. Prior version 1.6 this setting is set to true. In 1.6 the default is false. If you are using 1.6 and want to debug the compiled JSPs change keepgenerated (found in default-web.xml and sun-web.xml) to false.
Remember the solution!

Friday, February 13, 2009

Selenium and https

Selenium is a great tool to automate tests for your website. Unfortunately there is a glitch when some of the pages redirect to https.
Selenium can't accept a certificate and when running FireFox, FireFox runs with a new clean profile so the exception to the https site is lost.
A way around this problem is to create a "selenium profile" and when running Selenium Server one specifies the custom profile to be used, thus the exception will be in the profile and the tests will pass!

Here is a breakdown of the steps involved to get it running:
1. Close down instances of FireFox
2. Run FireFox from command line as follows: C:\Program Files\Mozilla Firefox\firefox.exe -ProfileManager
3. Profile dialog loads up, create a new profile. I called it SeleniumProfile and added a new folder in my selenium test suite, something as follows: /mysuite/seleniumprofile
4. Browse to the HTTPS page (with self-signed certificate) and accept the self-signed certificate when prompted. An exception is added in the profil
5. Close the browser.
6. Add the profile to the Selenium Server. The command will look something as follows:

java -jar selenium-server.jar -firefoxProfileTemplate "C:\mysuite\seleniumprofile"

That's it, kick in your lovely automated tests and let them roll without https problems!