Sunday Nov 20, 2005

"Free" Product Defect Dashboard


Some call it a bug, metrics or quality dashboard or just plain quality report. It's immeasurably valuable for keeping the product cycle in check. When running on the company intranet, an entire product team can view and track product quality, such as the number of defects currently open, find and fix rates, the list of defects to fix by engineer, list of fixed defects to evaluate, ...


Creator is perfect for developing Quality Dashboards. For one, Creator is now free (please ignore the morbid looking header image). In this entry, I'll show how easy it is to produce a Dashboard using Creator 2 EA2. I'm presuming that the implementor has SQL access to the bug database. Creator supports the major databases, Oracle, Microsoft SQL Server, DB2, Sybase
and even MySQL using the MySQL JDBC 3.1 driver.

Predefined list of supported databases



Adding the MySQL driver


If you're proficient in SQL, write an SQL query. You can write and test a query using Creator.







In the Servers pane...
Add a datasource for your database. Select the datasource, expand to select the table to execute a queries against, right-click and choose View Data Here you can execute your query. The query can be pasted here with Ctrl-V


Once the query is returning the desired results, create a new Web Application. From the Palette window, drop a Basic Table onto the Designer white grid area.


Then expand your Datasource to find your table (or view)
Next, drag and drop the table onto the Designer (not the Table component). Next, in the Outline window, find the SessionBean1 node and select the rowset just added.
As the rowset is selected, the Properties window will show the rowset's properties. See the "command" property. Copy/Paste the query written above as the command property's value

Rowset Command


Next, select the Table component, right-click and choose Table Layout. Here you can bind the Table component to the database table (through the
CachedRowSetDataProvider)



Table (component) customizer


A CachedRowSetDataProvider, which represents the database table binds to the Table. The Table component's columns will get filled in with the identical name as the names of your
database table's columns.


If a binding error occurs, you may see the Component Error page. Then you should go back and test your query using View Data as mentioned above.


If all's well, click the Green arrow at the top.
Now this deploys to your local Sun Java Application Server.
To make your dashboard accessible by others, install Creator on a remote server. Then you can add this remote server to Creator through the Server window.


If there's an error, check the local Deployment Server's log file - there's a context menu in the Servers window for the local Deployment Server.

In the Add Remote Server dialog, I suggest to choose the "Data Sources Automatically Configured by JSCreator"
A driveradapter.jar file will be created and you'll have to copy this to the lib folder under
the Sun Java Application Server installation and restart Sun Java Application Server.



Adding a remote server



Next look in Projects and right-click on Project name and choose Deploy to Remote Server. Now you'll have the application running on http://remote_server:28080/qualitydashboard


Something like this (confidential stuff smudged)
Sample Dashboard
For Creator releases, I have one dashboard setup just the same way. The Personal edition is not a production server and there might be 10 users accessing simultaneously, but this App Server stands up.


If a dashboard requires multiple "reports" contained in Table components so multiple queries are executed then it will take awhile for the page to load. To get around this I use an open source test library called HttpUnit. The idea is to produce an html file which is produced only when needed, every couple of minutes or so, depending on how long it takes to execute a query. Basically your server requires a JDK installation, then write a simple HttpUnit program. Here's one below:




import com.meterware.httpunit.*;
import java.util.*;
import java.io.*;

public class QDBMain {

public static void main(String argv[]) {
String url = "http://server:28080/qualitydashboard";
String result = "";
WebRequest req = null;
WebResponse resp = null;
TableCell statusCell = null;
WebTable statusTable;
WebConversation wc = null;
Enumeration keys = null;
String pageContents;

try {

wc = new WebConversation();
req = new GetMethodWebRequest(url);
resp = wc.getResponse( req );
pageContents = resp.getText();

} catch (Exception e) {
pageContents = "Dashboard is down";
System.out.println("Site is down: " + e);

}

}

}



Next, assuming your server is running Linux or Solaris or other, write a shell script and create a cron job:


#/bin/bash
cd /usr/local/bin/dashboards/scripts/
CLASSPATH=.:/home/jbaker1/classes/httpunit/httpunit-1.6/lib/httpunit.jar:/home/jbaker1/classes/httpunit/httpunit-1.6/jars/Tidy.jar:/home/jbaker1/classes/httpunit/httpunit-1.6/jars/js.jar
export CLASSPATH
java QDBMain > QDBMain.html

# Only copy the resulting html file if expected html was produced
UP=$(grep Thresher QDBMain.html)
if [[ -n $UP ]]; then
cp QDBMain.html uptime
cp QDBMain.html /home/jbaker1/public_html/qcdb_fcs
fi




Next, create a cron job to execute this shell script as frequently as needed.


Now users only depend on the company web server. If you're using Linux, Soloris or other flavor of *NIX, The html file can be created in public_html of your user directory. Now there's no load on your Creator-installed Sun Java Application Server, PE.


If you'd like to learn more about HttpUnit, see http://httpunit.org. Also, I've written an article posted on the NetBeans site.

Comments:

Dear John, I found your article "Integrating HttpUnit with XTest", and would like to ask you some question regarding testing web applciation developed in Creator. I generated some testing code using httpunit for one of the simple web applications I downloaded from sun's website. I can test what components are on the page. However, whenever I tried to generate a WebResponse, I get the error msg about "scrollTo is not defined". I was told by httpunit's creator that httpunit does not support scrollTo. The problem is that there is no scroll bar on the webpage, and there is no scrollTo property defined. I tried other simple cases, all geneated the same error message. It seems that you can use webconversation.getResponse successfully. Do you think my error msg is due to the Creator version? I am using Creator 2. Many thanks. Xiaoyan

Posted by Xiaoyan on July 25, 2006 at 06:38 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed