Wednesday Feb 10, 2010

Using Selenium TestNG/JUnit and XPath Checker to Automate GlassFish v3 AdminGUI Server

It's been almost 2 years since I first use Selenium/TestNG to automate test cases for SocialSite Project. At that time, I'm not aware of using XPath checker or DOM inspector to identify a web element locator ID.

The Selenium APIs and TestNG harness are much more improving and robust now. Writers should be able to search for any answers from the web since more testers/developers are writing Selenium. My long time headache problem which to open a single browser for running with multiple classes is resolved in TestNG interface ITestContext - put it before and after you start/stop your test class

public void startBrowser(ITestContext context){
        browser = new DefaultSelenium();
        browser.start(); }

public void stopBrowser(ITestContext context) {
       browser = (DefaultSelenium) context.getAttribute("browser",browser);
       browser.stop(); }

I'm writing test for both JUnit and testNG frameworks.  JUnit harness has been widely using in developers community so if one doesn't often share the workspace with developers, I suggest using TestNG frameworks

TestNG has more annotations which provides more flexibility, less test depedency, advanced parametric and re-runable features. In addition, TestNG result is automatically reported in xml/html format.

Click here for my GlassFish V3 Acceptance Test Model

My preferences to the xpath links

Tuesday Feb 09, 2010

Add GlassFish v2/v3 Servers for Eclipse Bundle with Oracle Enterprise 11gR1 Package

There are few extra steps needed to add GlassFish V3 server to the Eclipse bunlde with Oracle WebLogic Server 11gR1 (10.3.2) Package

1. From the Eclipse IDE, select Help-> Install New Software menu tab

2. Click Add button then enter  to the add site (please, see the attached figure) -> click OK button -> continue with the procedure.

3. After restart the Eclipse IDE, change to Java EE Perspective -> select Servers tab -> right-click, select New-> Server menu -> expand GlassFish node, select a right GlassFish Server to add.

Note: If you are located inside a proxy domain please, configure the proxy server before downloading the GlassFish Plugin for the Eclipse bundle with Oracle WebLogic Server 11gR1 (10.3.2) Package.

Monday Jun 29, 2009

Running Netbean GlassFish V3 qa-functional Test

The GlassFish V3 plugin qa-functional test is running a little bit different than its previous GlassFish V2.x version which uses XTest for the harness.
Below is the procedure to check out the Netbean web-main, build and run with GlassFish V3 plugin qa-functional test.
Software requirements:
Mercurial hg, ant1.7.1, jdk1.5.0_17, jdk1.6.0_13. GlassFish V3 promoted build
Install Software (Solaris x86): 
Checkout, build and run-test
%hg clone
%cd web-main; ant
%ant -f glassfish.javaee/build.xml -Dtest-qa-functional-sys-prop.v3.server.path=/root/V3-B51-SDK/glassfish -Dtest-qa-functional-sys-prop.v3.server.javaExe=/usr/jdk/jdk1.6.0_12/bin/java test-qa-functional
Where: /root/V3-B51-SDK/glassfish is GlassFish V3 Server installed location
Generate report
%cd glassfish.javaee; ant test-generate-html
Fix the PermGem Memory Problem:
export ANT_OPTS="-Xmx512m -XX:MaxPermSize=128m"

Thursday Jun 25, 2009

GlassFish Eclipse Tools Bundle Hands on Lab Experience

It was my privilege and unforgivable experience to present the GlassFish Eclipse Tools Bundle 1.0 at JavaOne 2009 Conferrence

Click Here to download the Lab Exercise

Friday Aug 29, 2008

Glassfish V3 Prelude Server with Netbean 6.5

Below is the simple steps to create and execute a sample Servlet Web Module with NB 6.5 for Glasfish V3 Server.

1.  Go to  download the latest 6.5 bits
2.  Install the Netbean IDE - by default Glassfish V2 and V3 sevrers were bunbdled with NB 6.5 as described in the figure below:

3. Start Netbean IDE (you can start from command line or from the Desktop icon)
    -If you click at Services tab > expand  the Servers node, you should see Glassfish V3 prelude server listed there
    -Right-click at Glassfish V3 node should allow you to start the server or view the server log or launch the  admin GUI console as described in the figure below:

4. To deploy a simple Servlet Web Project, click Project Tab > from File menu, select New Project > expand Samples > Java Web > select Servlets Example > click Next > choose a location for the project > click Finish button

5. Change server run time to Glassfish V3 Prelude (by default it's set to V2), right-click at ServletsExample project > select Run > change server from Glassfish V2 to Glassfish V3 > click OK

6. Right-click at ServletExamples project > select Run menu
       Glassfish V3 Server will be started (if not) > ServletExamples project is deployed and executed as shown in the figure below

Wednesday Jul 09, 2008

Eclipse Plugin for Glassfish Version 1.0.4 Release

The Plugin was published yesterday (July 08, 2008)

Release note and bugs fixed in this release.
The GF Plugin can be downloaded from within the Eclipse for Java EE Developers using the download additional server adapters link on the New Server Wizard.

Download Eclipse 3.4 Ganymede version

To Configure Eclipse 3.4 with Glassfish, please follow the instruction from Arun's Blog

For questions and comments:

For issues:

Thursday Jun 12, 2008

How to Connect Glassfish Derby from Eclipse IDE

Below is the steps to connect Glassfish V2 "sun-appserv-samples" Derby database from Eclipse JEE 3.3 version: (Please, use Eclipse IDE for Java EE Developer version and the instruction from this document to have GF server setup)

From IDE Window menu,  select Open Perspective > Other > choose Database Development

On the Database Development panel (figure below), righ-click Databases > select New from the menu
to create a New Connection Profile and choose 'Generic JDBC Conenction' from the list.

Click Next to enter a name for the
connection profile, name it as 'TestDerbyPool' > click Next and click ...

From Driver Definition panel, select Derby > 10.2 > click Add to add a new driver

From the New Driver Definition panel, select Derby > 10.2 > Derby Client JDBC Driver > click OK

From Edit Driver Denifition panel, remove the default derbyclient.jar file > click Add Jar/Zip to add the derbyclient.jar file from Glassfish directory > edit the properties as described in the following figure:
        Connection URL:      jdbc:derby://localhost:1527/sample;create=true
        Database Name:       sun-appserv-samples
        Driver Class:             org.apache.derby.jdbc.ClientDriver
        Password:                APP
        User ID:                   APP

Click OK > OK button to go back to the New JDBC Connection Profile panel. Now you should have all the fields values configured

Start the Derby database and click  Test Connection button. You should receive the Success and tables dialogs below:

For information to connect to Derby by using DTP please, click here

Thursday Apr 17, 2008

Glassfish V3 with Netbean 6.1

Today, I just download Netbean 6.1 RC and try to see if it works with Glassfish V3 server. I'm impressed. It took me <5 minutes to have Glassfish V3 installed and configured with Netbean IDE. The procedure is so much simple and fast now.

It's required only 2 steps to configure Glassfish V3 with Netbean IDE. The Glassfish server was installed during the adding server process. View the screencast below to see how simple it is.
Steps to add Glassfish V3 to Netbean 6.x IDE

Thursday Mar 20, 2008

Create MySQL jdbc Connection Pool from Glassfish Admin GUI

To create a mySQL dbc connection pool from Glassfish V2 Admin GUI console, please follow 2 steps below
    1. Create a new mysql test account
    2. Create jdbc connection pool

1. Create a new mysql user account
    a. Start database from a command prompt
        $../<GlassFish-Installed>/mysql/bin/mysqld-nt.exe --defaults-file=../<GlassFish-Installed>/mysql/mysql.ini
         (For Solaris machine replace mysqld-nt.exe by mysqld_safe)
    b. Login as database admin to create a testUser account
        $../<GlassFish-Installed>/mysql/bin/mysql -u root
         mysql> grant all privileges on \*.\* to 'testUser'@'localhost' identified by 'testPassword';
2. Create jdbc connection pool and test the connection
     a. Start domain1
        ../<GlassFish-Installed>bin/asadmin start-domain
     b. Create jdbc connection pool for mySQL
          -From Admin GUI Console > expand Resources node > JDBC > Connection Pools > click New button and enter information below:
                Name: testMYSQL
                Resources Type: javax.sql.DataSource
                Database Vendor: MySQL
            Click Next to proceed to the next panel
            Go to Additional Properties and enter:
                databaseName: test
                User: testUser
                Password: testPassword
                ServerName: localhost
           Click Finish button
           Click testMYSQL > select ping to test the connection

Wednesday Mar 19, 2008

Run Netbean Plugin Automation test with Glassfish V2 by using Jemmy/Jelly and XTest Tools

1. Requirements
      a. Software: Glassfish V2, Python 2.2.4 or later version and Mercurial 0.9.5
          Note: for Mercurial if you need to build it, please click here
      b. Netbean account (userID/password)
2. Getting a Copy of Netbean Repository
      a. Create a template working directory (nb_all)
          $mkdir nb_all
          $cd nb_all
      b. Run the mercurial command below to check out all netbean modules
         $hg clone http://hg.netbeans-DOT-org/main
     c. Configure your user name and write access to configuration files
         Edit ../main/.hg/hgrc and add lines
            username =
            host =
            default =
            default-push =
         (Replace jhacker with your username. Replace secretpass with your password and with your proxy server if you have one)
         For full mercurial instruction please visit
3. Build Netbean j2ee and xtest Modules
       To build  j2ee module
            $cd main
            $ant -f  nbbuild/build.xml  -Dcluster.config=j2ee
            $cd xtest
    Note: to fix the outOfMemory problem, for bash/ksh shell set (export ANT_OPTS="-Xms256m -Xmx256m";)
                fix PermGen OutOfMemory problem (export ANT_OPTS="-Xmx512m -XX:MaxPermSize=128m"
4. Execute Test (resources, webapp and ejb/jfs) Module
$cd  /opt/SUNWappserver/bin  (assume you installed Glassfish server at that directory)
$./asadmin start-domain domain1
           $copy  cfg-qa-functional.xml.cfg-res  to cfg-qa-functional.xml  (to run only resources and configuration test suite)
$cd ../main/j2ee.sun.appsrv81/test
           $ant  -Dsjsas.server.path=/opt/SUNWappserver

Tuesday Feb 19, 2008

Record a Simple Glassfish Test Case with Selenium

This screencast shows you steps to record a simple glassfish deployment test case with selenium.

After click Play, please wait for the screencast to load

Monday Feb 11, 2008

Glassfish GUI Automation with Selenium (Java)

Want to try Glassfish Admin GUI with Selenium and experience the differences between SilkTest and Selenium tools

1. Run Selenium from the build 
If you build admin-gui module you can find the README.SeleniumRC file under the ../glassfish/admin-gui/tests directory. Just follow the instruction from the file, you should be able to setup and run Selenium JBI tests with Glassfish Admin GUI. If you encounter a failure from your browser, open selenium test case files under java directory and replace statement
selenium.waitForCondition("Selenium.browserbot.isNewPageLoaded()", TIMEOUT_PERIOD) by
selenium.waitForPageToLoad( TIMEOUT_PERIOD)

2. Run Selenium with Glassfish V2 binary bit
    1. You must setup the environment by installing Selenium IDE on your Firefox browser
    2. Having ant 1.6.5 and jdk1.5.0_11 or latest version installed on your system
    3. Create a AdminGUITest directory on your system and copy the following 4 files to the ../AdminGUITest/lib directory
selenium-server.jar , selenium-java-client.jar, selenium-java-client-driver-tests.jar and testng-5.5-jdk15.jar  and junit.jar
     4. Copy the simple test harness (AdminGUITest.jar file) to your AdminGUI directory and unjar the file
     5. Update file  with your setup environment
     6. Start the selenium remote server (assume you're using a window system)
cd  %AdminGUITest.home%
             java -jar selenium-server.jar
     7. Start glassfish domain1
     8. Run the first AdminGUI test case
             cd  %AdminGUITest.home%
      ant run-test
3. Differences between SilkTest and Selenium

Features Selenium SilkTest
HTLM Web Object Support Yes Yes
Easy Creation Object Scripts (Record and Playback) Yes
Scripting in variety languages (Java, Perl, C#, PHP, ..) Yes No (Only 4test language)
Ability to run test with build scripts (maven, ant,..) Yes No
Support Different Browsers Yes Yes
Reusability of Scripts Yes Yes
Commercial Support Yes Yes
Test Debugging Yes Yes
Result Reporting Fair Yes
Exception Handling Fair Yes
Java Objects (beyond the browsers) No Yes
Https protocol support Yes (some configuration required)
Capable of record exactly same as end-user desire Fair Yes
Organize tests according to the manual Test Plan No Yes
Data Driven Test Framework No Yes
Mechanism to create test independently (one test should not depend on other) No
Support Multiple OS Yes Yes
Comprehesive Test (run for > 8 hrs)
Weak Yes

Thursday Dec 20, 2007

Glassfish GUI Automation Tools (SilkTest)

Why SilkTest / Selenium 

If you want to automate your applications with Glassfish Admin GUI. There are few software tools that you can use such as: SilkTest, Selenium, Httpunit, WinRunner,  Among those tools I found SilkTest and Selenium work best to automate Glassfish Admin GUI test cases. This blog shows you the steps to setup and configure SilkTest for Glassfish Admin GUI. For selenium, please click this link

SilkTest 2006 R2 and SilkTest 7.6 are the two versions we are currently using for Glassfish V2. Since SilkTest is mainly installed and executed on a Window machine, you should write your test to run with IE browser. It doesn't matter if Glassfish installed on a Solaris, a Linux or a MacOS machine; you will not find any problem to run SilkTest on a client window machine.

The browser we've been testing is IE 6/7, but Silktest can also run with FireFox or Mozilla browsers. If you have Glassfish installed on a machine which is different than SilkTest automation suites
installed, please do the extra step (1 or 2) below:

1. For Solaris
  -Login the Solaris machine as root
  -Edit /etc/hosts.equiv file > add + + line in the file.
  -Go to root directory > edit file .rhosts > add a line + + in the file.
On the window where SilkTest installed, put rsh.exe name in the machine PATH. rsh.exe file should be located under c:\\windows\\system32 directory

2. For Linux:
  -Login the Linux machine as root.
  -Edit /etc/pam.d/rsh file >  change all “required” to “sufficient”
  -Edit /etc/securetty file > add “rsh” at the bottom
  -To check if rsh working, on window, type: rsh <LinixHostname> -l root ls. You should see all files under Linux root machine listed.

Config SilkTest:
    -From window, click Start menu->Programs->SilkTest->Extension Enabler.
    -Select to enable extension by selecting
“IE DOM” from Primary Extension of the correct IE version. Remeber to disable all extensions for all other browsers and java application. > click “OK” button when done. (Please see the
picture below)

    -Again click Start menu->Programs->SilkTest->SilkTest to bring up SilkTest > click Options menu > Extensions > enable only IE version to test and disable all other extensions > click “OK” button when done.
    -Click Options menu > Agent > click Timing tab > give 60 in the “Window timeout” field >
Uncheck all check boxes in verification click “OK” button when done.  (Please, see the figure below)

    -Click Options menu > Runtime and remove all content in Use Path field > make sure only “extend\\” appears in the “Use Files” field and the correct IE browser version in the “Default browser” field.  (click here for the runtime option picture)

That is much you need to do.

Wednesday Dec 19, 2007

Webservice Monitoring Realtime Statistic for Glassfish V2

I encountered question how to view the Webservice Monitoring Realtime
Statistic for Glassfish V2 project. This blog lists the steps to configure Webservice Monitoring Realtime Statistic.

-First, please follow the instruction from the technical article Managing and Monitoring Web Services in Project GlassFish to configure your Web service monitoring managing level.
-From admin GUI console, click Common Tasks menu > View Monitoring Data > Call Flow  >
select to enable Call Flow Monitoring > click to save the changes

For EE version, in addition to the steps above, please start the Derby database.

Thursday Jun 01, 2006

Writing a Simple XSLT Transformation Rule File

XSLT transformation rule can be applied to a Web Service endpoint. The transformation rule will enable fine-grained control of web service requests and responses. To config, please use the following document

For a simple web service application, down load the template files below. Replace the bold text in the template files with your appropriate web service method name and its result data. For example, if your web service application has a method named myMethod and the method returns a string "Hello World" then just replace sayHello by myMethod and the return string "This is ...TEST" by "Hello World"

For JAX-WS application, replace http://service/ with your targetNamespace value. For JAX-RPC, replace by wsdl-port xmlns:wsdl-port_ns_ value from webservices.xml file

Template Files




« July 2016