Shay Shmeltzer's Oracle Development Tools Tips

  • August 9, 2007

Setting HttpUnit in Oracle JDeveloper

Shay Shmeltzer
Director of Product Management - Oracle

One way to test Web application is with HttpUnit framework that is based on Junit. One nice thing about JDeveloper is that because of the built-in support for JUnit you also get a nice HttpUnit testing environment.

Here are the steps to follow.

1. Download HttpUnit and extract it to your drive.

2. In JDeveloper take your Web project and go into project properties->libraries. Click the "Add JAR" button and add the files from the lib and jars directory.


3. Create a new JUnit test case class:

4. Write the code for your test in the new class.

For example:

public void testPlus() throws MalformedURLException, IOException,

SAXException {

WebConversation wc = new WebConversation();

WebRequest req =

new GetMethodWebRequest("");

WebResponse resp = wc.getResponse(req);

WebForm form = resp.getFormWithName("form1");

assertEquals("1", form.getParameterValue("form1:var1"));

assertEquals("2", form.getParameterValue("form1:var2"));

form.setParameter("form1:var1", "1");

form.setParameter("form1:var2", "2");

assertEquals("2", form.getParameterValue("form1:var2"));


5. Run your Web page (this will start the embedded OC4J).

6. Run your test:


7. View the results:


8. If you have errors double click the row in the JUnit log window to jump to the actual test code that failed.

A few other tips.

1. HttpUnit requires you to understand the structure of the HTML page you are testing. One nice trick I use is to copy the source of the HTML page from the browser and paste it into a new HTML file in JDeveloper, then I can use the visual designer and structure pane to find out exactly the components I need to check.

2. Remember that if you want to monitor the HTTP messages, you can use the built in HTTP monitor in JDeveloper.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.