|
|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SOA World Conference
Virtualization Conference $200 Savings Expire May 16, 2008... – Register Today!
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON FrontPage Feature
Java Annotations + Compiler API + Annotation Processing = Remarkable Results
Effective Development of Java Conformance Tests Meta-Programming
By: Dmitry Fazunenko
Apr. 18, 2008 04:15 AM
Digg This!
Page 2 of 3
« previous page
next page »
Test Development To develop a high-quality TCK you have to produce a huge number of tests. There are three ways of creating new tests: developing new ones, reusing existing tests, or automatically generating tests from the specification. The last option is the best, but unfortunately it exists only in theory. Reusing tests is cheaper than developing new ones so the development of most TCKs starts with a search for existing tests that can be used. The more tests you can reuse, the less you need to develop. But when dealing with thousands of files, the task becomes daunting. Java technologies tend to evolve and most of them have several releases. Each release requires a separate TCK that might include tests for new features as well as bug fixes and tests that improve the coverage in existing areas. So it's important to be able to include tests easily and incorporate newly developed code and bug fixes. Meta-programming can help.
Meta-programming The writing of programs that write or manipulate other programs (or themselves) as their data or that do part of the work that is otherwise done at compile time during runtime. http://en.wikipedia.org/wiki/Metaprogramming Representing the test as data for further processing enables the program to achieve the expected results by modifying control programs of several kilobytes, not by adopting thousands of tests. When all existing and applicable tests are found, tests are decorated according to TCK requirements and HTML files don't contain orphans. Additionally, not keeping data that can be calculated guarantees consistency and enables the program to write less code. It also enables the generation of similar tests from one template. Honestly, it's more convenient for engineers to develop code in pure Java than in any other format. While applying this approach will increase development time minimally, it will save resources for further reuse of tests by other TCKs. Sun represents a TCK test as its code and related attributes (meta-information). In the past Sun used Perl as a language for test data definitions. Developers wrote simple Perl programs consisting mostly of variable settings and invocations of library methods:
require $ENV{TESTGEN}; # import test generation library All generation functionality was implemented in the Perl library. It was possible to customize generation by defining the TESTGEN environment variable pointing to the alternative library. Behind the simplicity are a number of serious restrictions: the necessity of manually synchronizing generation libraries between different TCKs, the difficulty in reading test attributes, and unchecked variable names. The XML language fits the purpose of specifying meta-info better. The XML language lets us keep data in a well-defined format unified across all TCKs. In its turn the unified format results in a set of shared tools that implement processing functionality common for all TCKs (see Listing 2). Tools are customizable, so all TCKs use the same tools and just provide their own specific plug-ins. Figure 1 demonstrates how tests are processed during the build. Tests for all TCKs are stored in a common Test Repository so newly developed tests as well as bug fixes made by one TCK are available for all TCKs. A set of tools is shared between all TCKs: the Filtering Tool and the Generation Tool. TCK provides test selection criteria to the Filtering Tool, which selects only those tests applicable to the technology. Selected tests are passed to the Generation Tool, which generates test sources as they need to be presented in TCK. The Generation Tool is implemented to extract tests from templates in a way suitable for most TCKs, but it can be customized when needed through test generation customization. In this approach, TCK needs to define only its own test selection criteria and test generation customization. Test sources and tools can be taken from a general repository.
Implementation
public interface AttributeFilter { Page 2 of 3 « previous page next page » LATEST JAVA STORIES & POSTS
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING JAVA NEWS
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||