Java 2EE and XML Development

Скачать в pdf «Java 2EE and XML Development»

Testing web components

Since J2EE applications prefer the thin-client model, most J2EE test plans must accommodate some form of Web-based testing. Web components, such as servlets and JSP, must be tested over HTTP at a data (page) and protocol level. The low-tech version of this testing is performed by humans using web browsers to compare execution results to the success conditions of individual tests. The problems with this method include the amount of time and resources required, the potential for incomplete coverage of the test plan, and the possibility of human error.

Automating web unit tests can b
e accomplished with open source tools, including SourceForge’s HTTP Unit testing framework noted earlier. Using these tools does not save much time up front, since the tests themselves must be coded. However, rerunning unit tests many times is easy, and can be an essential part of your overall code integration methodology.

For more automated and advanced web testing requirements, there are several test suites on the market that can be used in place of human testers to make web testing faster and more meaningful. In addition, these tools can perform load and performance testing as well. A popular example is the product suite offered
by Mercury Interactive, which includes a functional testing tool (WinRunner) and a performance testing tool (LoadRunner). These tools do not eliminate the need for human testers, as the tests must be scripted by someone. However, once the test scripts have been recorded and the completeness of the test plan verified, running tests and collecting meaningful statistics is much easier.

Testing EJB components

Testing EJB components is the most difficult part of J2EE testing. Testing whether a behavior is executing properly is relatively simple, but determining the root cause of any errors often requires some detective work. In general, testing your EJB components requires a two-phase approach. The first occurs during development, when detailed logging is built into the EJB methods themselves. Note that, if you are using JDK version prior to 1.4, this logging capability should be encapsulated into its own subsystem (see the Fagade software pattern) so that your components don’t become dependent on your vendor’s proprietary logging mechanisms. This is depicted in figure 1.8.

Скачать в pdf «Java 2EE and XML Development»