YOUR FEEDBACK
iPhone 3G and the Things I will Need From My New iPhone
Alex wrote: Joke of an article. First of all it is ILLEGAL and more import...


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 2 of 3   « previous page   next page »

Test Development
Tests aren't only the largest part of any TCK, but the main component. Their number and quality define how well the specification is covered and, as a result, the likelihood of incompatibilities in the implementation. Some TCKs are very large. For example, the TCK for Java SE 6.0 contains more than 100,000 tests. Effective management of such big products is impossible without applying special techniques that let one to do mass updates or easily add or remove tests without breaking other functionality.

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
Wikipedia defines meta-programming as:

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
$package = "applet";      # meta information describing
$class = "Applet";      # api under test
$method = "public Applet()"; #
$code = '{
a = new Applet();
if (a.isVisible() == true && a.isEnabled() == true
&& a.isValid() == false) { // Check result
return Status.passed("OKAY");
} else {
return Status.failed("Incorrect ' . $class . ' object created");
}
}';
&gen; # invocation of test generation method

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
This section covers the technical implementation of shared tools.
Internal Test Representation: A DTD defines about 50 elements that can be used in XML test descriptions. For each element a corresponding Java class was created. The specially developed parser reads XML test descriptions and creates a Java object representing the test. An XML emitter can write Java objects back to XML. This technique is known as marshaling and unmarshaling. It lets tools use the Internal Representation API and doesn't involve XML.
Filtering Tool: The purpose of the Filtering tool is to select tests that apply to a specific technology. Based on TCK properties, the Filtering tool creates an instance of AttributeFilter:

public interface AttributeFilter {
    public boolean accept(TestGroup tg);
    public boolean accept(TestGroup tg, TestCase tc);
}



Page 2 of 3   « previous page   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
AJAX and RIA Technology Will Be Free for All: Sun CEO
'Java's always been a RIA platform - before the world really wanted one,' claimed Sun's CEO Jonathan Schwartz recently, as he reflected on the reinvention of the Java platform as represented by JavaFX. 'What's a rich internet application?' Schwartz wrote. 'It depends on your pers
Adobe's Kevin Lynch and Microsoft's Scott Guthrie to Keynote AJAX World RIA Conference & Expo
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted
Quest Software's JProbe Now Available as Eclipse Plug-In
Quest Software announced the latest release of its Java profiler, JProbe 8.0, which is now offered as a plug-in to the Eclipse Java Integrated Development Environment (IDE). The release of this capability aligns with the increased adoption of the open source development. Launchin
What Does the Future Hold for the Java Language?
Before Java I was a Smalltalk guy. I remember switching from one language to the other and the tipping point that you reach when you've mastered the new language and how many months it takes, not to mention the years, to do really good design and know-how, which patterns to apply
White Paper: "Ensuring Code Quality in Multi-Threaded Applications"
Today, the world of software development is presented with a new challenge. To fully leverage this new class of multi-core hardware, software developers must change the way they create applications. By turning their focus to multi-threaded applications, developers will be able to
AccuRev and Rally Software Partner to Scale Agile Software Development Best Practices
AccuRev and Rally announced a technology partnership that will integrate AccuRev software change and configuration management (SCCM) with Rally's Agile lifecycle management solutions. The combined solution will provide a platform to manage multiple Agile processes and ongoing cus
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

SPONSORED BY INFRAGISTICS
SOA in a JVM: OSGi Service Platform - A Dynamic Component System for Java
There are many forces that influence technological evolution. After a decade of building enterprise
AJAX and Enterprise RIA Tools - JSF, Flex, and JavaFX
2008 is going to be an important year for Rich Internet Applications. Most organizations are deliver
Final Voting Phase on OpenAjax Browser Wishlist
The OpenAjax Alliance is developing an Ajax industry wishlist for future browsers, using a dedicated
AJAX World RIA Conference News - Netflix UI Guru To Present on Crafting Rich Web Interfaces
In every field of design one of the first things students do is learn from the work of others. They
Infragistics Releases CTP UI Components for Microsoft Silverlight Beta 2
Infragistics announced the availability of two Community Technology Preview (CTP) User Interface (UI
Yahoo User Interface 2.5.2 Released
The YUI development team has released version 2.5.2; you can download the new release from SourceFor
ADS BY GOOGLE
BREAKING JAVA NEWS
XS2Theworld's Speaking Travel Guide Wins MCA 2008 Award