YOUR FEEDBACK
NGASI Releases AppServer Manager 8.1
Dave Jenkins wrote: The remote server management is a welcomed added feature...


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


Java Annotations + Compiler API + Annotation Processing = Remarkable Results
Effective Development of Java Conformance Tests Meta-Programming

Digg This!

Page 1 of 3   next page »

This article presents a case study of the use of meta-programming in Java compatibility testing. It shows how parts of the source code can be shared between different products and modified to generate programs targeting specific functions and describes the approach Sun Microsystems has used for building Technology Compatibility Kits (TCK) for more than five years.

In modern Java TCKs, testing components for multiple products are stored in a single repository not as pure Java language, but as XML files where code is annotated with attributes called metadata. A set of tools is used to select only tests that are applicable for a particular product and transform them into final Java programs. These post-processing tools written in Java provide a simple and efficient way to generate testing components that match specific product needs.

Here we'll illustrate Sun's approach by providing examples of test storage formats and the processing scheme used by the conversion tools. We'll also draw a comparison with Sun's former approach, which used Perl for test generation, and explain why Sun moved to the XML-based methodology.

TCKs
The international community develops and evolves Java technology specifications using the Java Community Process (JCP). The JCP produces high-quality specifications in Internet time, using an inclusive consensus-building approach that produces a specification; a reference implementation that demonstrates that the specification can be implemented; and a technology compatibility kit, or TCK, a suite of tests, tools, and documentation used to test implementations for compliance with the specification.

There are as many TCKs as there are Java technologies, and these technologies might be deeply intertwined despite their differences. For example, both the Java Platform Standard Edition (SE) and the Java Platform Micro Edition (ME) include the Java Virtual Machine (JVM) and the java.lang package, so most tests written for the Java SE VM can be reused to test the Java ME VM.

Each separate TCK has its own requirements for tests such as performance targets or maximum memory size. As a rule, the kernel of the test is the same across TCKs, but the test might take different forms. For example, for Java SE several tests can be combined in one class; while for Java ME, due to a restriction on class file size, each test case should be put in its own class.

Sun Microsystems has a long history of successful TCK development. During the past 10 years, about 100 TCKs with millions of tests were shipped. This success would have been impossible without effective reuse or sharing of tests between TCKs. At the heart of the approach applied at Sun for TCK development is meta-programming, which implies that sources are generated from metadata.

This article describes how this approach is implemented. Even though the area of conformance testing is narrow, the underlying principles can be generalized:

  • All tests are stored as templates, not as tests to be included in the product.
  • Each test is represented as code with attributes (meta information).
  • Templates are stored in a single repository shared across different TCKs.
  • Tests applicable for a particular technology are selected by attributes at the TCK build stage based on selection criteria set by the TCK.
  • All TCKs use the same tools for extracting test sources from templates, but tools can be customized according to particular TCK needs.
  • All TCKs abide by the general policy regulating the rules for writing tests.
TCK Structure
Each TCK product consists of the following components:
  • Test Monitor: Tool for test configuration and execution
  • Tests: Programs returning either a passed or failed status
  • Libraries: Code shared by tests
  • Product Documentation

    Each test consists of:

  • Test sources: Java source code and data files
  • Class files: Compiled sources
  • Test descriptions: HTML files that consist of Test Monitor instructions showing how to execute tests, links to test sources and data files, and human-readable test documentation
The minimal test unit is a method or Test Case. Test Cases with similar functionality are combined in one class or Test Group. Listing 1 provides a sample fragment of the test source code.

Some tests require arguments be passed or some action performed prior to execution. This information is specified in the Test Description and stored in an HTML file. The Test Monitor reads the Test Description and runs the test according to the instructions. Besides execution instructions, the HTML file contains test documentation, which lets one understand what the test checks for and how without reading the sources.

Here is a sample fragment of an HTML file:

Test Specifications and Descriptions for Applet
       * public Applet()
       * public void start() List of tested methods
       * public void stop()
public Applet() (See Table 1 and Table 2)



Page 1 of 3   next page »

About Dmitry Fazunenko
Dmitry Fazunenko is a lead TCK programmer at Sun Microsystems Inc. His expertise is in developing Technology Compatibility Kits for Java SE platforms. He has been working in this area for a decade and during the past six years, he has focused on developing and improving techniques for effective test development.

LATEST JAVA STORIES & POSTS
Virtualization Journal Attracts JavaOne Attendees to SYS-CON Media Booth
Virtualization Journal now reaches more than 60,000 online readers with monthly digital editions and weekly newsletters. The premier issue of the magazine's print edition, which debuts on May 6, 2008, at JavaOne in San Francisco, as a media sponsor of this event, will be availabl
Sun Challenges Linux
Sun's mule train has finally pulled into Indiana after three years on the road. Indiana is the Linux-friendly Fedora-like OpenSolaris project meant to move the Solaris-shy Linux community off Linux and on to Solaris tempted by Solaris widgetry like the highly scalable, rollback-e
AJAX World - Sun Talks Up its Late-to-the-Party AIR-Silverlight Rival
At Java One this week Sun has been selling its year -old-but-still-upcoming - and definitely late-to-the-party - Adobe AIR- and Microsoft Silverlight-competitive JavaFX Rich Client environment as a potential revenue-generator capable of putting ads on mobile applications and JavaF
MySQL Backs Off Closed Source Plan
MySQL has backed off a plan to charge for some encryption and compression backup widgetry in the next version of the database - and, heavens, NOT OPEN SOURCE THE STUFF, an idea it trotted a few weeks ago and predictably caught hell for. Sun, which bought MySQL for a billion dolla
JavaOne Archives - Dvorak Comments on AMD Intel Lawsuit on SYS-CON.TV
Conference in San Francisco. Dvorak held forth on a number of topics, including the new AMD/Intel lawsuit, the viability of Java and Sun, the value of (or lack thereof) of corporate PR, and whether or not a new book about Silicon Valley is really worth reading.
Microsoft To Keynote 4th International Virtualization Conference & Expo
Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs t
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE
BREAKING JAVA NEWS
Day Software to Present at Henry Stewart DAM Show
Day Software (SWX:DAYN) (OTCQX:DYIHY), a leading provider of global content management