|
This User's Guide describes Java Application Verification Kit (AVK) for the Enterprise and the technical recommendations behind it. This Guide covers the following topics:
IntroductionThis Guide describes what Java AVK for the Enterprise does and how to use the tools provided as part of the kit. It also describes the features of Sun Java System Application Server Platform Edition 9 ("the Application Server") that support the kit. Java AVK for the Enterprise helps developers create applications that are both correct and portable. Why Portability MattersPortability is one of the most attractive aspects of the Java programming language. Applications coded in the Java programming language can run unchanged in many different types of stand-alone or client operating environments. The Java Platform, Enterprise Edition (Java EE) extends the portability benefits of the Java language to the enterprise, providing a single set of specifications for application servers and an extensive set of compatibility tests. It allows you to run applications across different types of Java EE servers. Given the large investment most businesses have in client-server applications, the Java EE platform can save companies a lot of development time and money. With the portability features of the Java EE platform, there is little or no need to rewrite code for different servers. Whatever product you use to develop your enterprise applications, you need to ensure that your code will be easy to migrate from one application server to another. To do this, you need to make sure that your code does not use vendor-specific extensions to the Java EE platform. Java AVK for the Enterprise is designed to help developers avoid such situations. Java AVK for the Enterprise is designed to identify enterprise applications developed with Java EE technology that are intended to be portable across different implementations of the Java EE platform. Creating Portable Applications: Using Java BluePrintsThe Java BluePrints program provides an extensive set of guidelines, design patterns, and sample applications that serve as models for developers writing portable applications. In particular, the Java Adventure Builder Reference application showcases how to design interoperable and portable web services on the Java EE 5 platform, and the Java Pet Store Sample Application shows how to use the capabilities of the Java EE platform to develop robust, scalable, portable, and maintainable enterprise applications. We recommend that anyone implementing a Java EE application study these applications.
See What Java AVK for the Enterprise DoesJava AVK for the Enterprise is a set of tools intended to help developers test their applications for correct use of Java EE APIs and portability across Java EE compatible application servers. The Java AVK for the Enterprise tools determine that an application suite follows the Java EE platform specification (including all the specifications for the technologies that are part of the platform) and that it runs on the Application Server. They do this in two stages:
This section covers the following topics: The Application ServerSun Java System Application Server Platform Edition 9 implements the Java EE 5 specification to deliver one of the best application runtimes for next-generation enterprise applications and web services. Application Server 9 implements the Java EE standards technologies listed at http://java.sun.com/javaee/technologies/index.jsp, including the following new or updated technologies:
The Application Server includes various tools to help developers prototype Java EE applications and learn about the Java EE platform and technologies. Java AVK for the Enterprise requires an application to use the Application Server to confirm that it runs on a complete and correct implementation of the Java EE 5 platform. Terms UsedHere are a few terms that apply to Java AVK for the Enterprise.
ScopeA Java EE application suite is composed of one or more deployment units, and each unit can contain one or more deployment descriptors. If the deployment unit is an EAR file, its deployment descriptor lists its components as modules; each component may also have a deployment descriptor. The deployment unit can also be a standalone module. There are four types of modules:
Note: A Java Persistence API entity is not a module; instead, it is packaged within a module, which can be either an EJB JAR file, a web WAR file, or a client JAR file. Java AVK for the Enterprise performs dynamic verification on only a subset of the Java EE components:
At this release, Java AVK for the Enterprise does not perform dynamic verification on resource adapters (RAR files). CoverageGood programming practice can lead to specific code paths that are difficult or inappropriate to test. These include:
To provide flexibility to permit these reasonable cases, Java AVK for the Enterprise sets a coverage guideline of 80% EJB method execution. The reporting tool presents coverage status based on this guideline. Different organizations may choose different internal guidelines to meet their own processes and requirements. The reporting tool provides detailed results information that will be useful. The following criteria are tracked or required by the Java AVK for the Enterprise tools:
What Java AVK for the Enterprise Includes
To install Java AVK for the Enterprise 5, refer to the Installation Instructions. Java AVK for the Enterprise is installed in the This section describes what you get when you install Java AVK for the Enterprise. It covers the following topics:
The installation process for Java AVK for the Enterprise installs the Application Server at Application Server Directory Structure
Table 1 describes the most important directories within
Application Server Tools
The Application Server comes with a set of tools for managing the server and for packaging, deploying, and running Java EE applications. Many of these tools are listed in Table 2. Most of the commands that invoke these tools are in the
Java AVK for the Enterprise ToolsYou will use the following tools to verify your application suite:
Verifying an Application SuiteThis section describes the steps to verify an application suite using Java AVK for the Enterprise. Here is an overview of these steps:
The following sections describe these steps in detail. Adding the Ant Tasks to your Build File
You will find a sample <JAVKE_HOME>/samples
This file also contains some sample Ant targets that you can run in order to become familiar with the tasks before you adapt them for your own code. The code for running the targets is also in the
You can either add the necessary code to the <import file="./javke_targets.xml" />
The tasks you can use are defined as follows in the sample
<taskdef name="ArchiveTest"
classname="org.apache.tools.ant.taskdefs.optional.sun.verification.StaticArchive
Test"
classpath="${cpath}" />
<taskdef name="TranslateRuntimeDD"
classname="org.apache.tools.ant.taskdefs.optional.sun.verification.TranslateRuntimeDD"
classpath="${cpath}"/>
You must define the classpath to include the following:
<property name="cpath" value="${avk.home}/lib/javke-ant.jar"/>
You must also define a property named
The file in the
You do not have to have the Application Server running in order to use these tasks. The following sections provide details about using the tasks. Performing Static Verification TestsThe tasks that perform the static verification tests do the following:
Static Archive Testing
Use the
<target name="static-archive-test" description="static archive tests for
application containing web components, reporting on all tests">
<ArchiveTest appname="${avk.home}/samples/bookstore/bookstore.war"
reportingOpts="a" />
</target>
The
>ant static-archive-test
Buildfile: build.xml
static-archive-test:
[exec] INFO: Verifying: [ bookstore ]
[exec] INFO: Compiling JSPs in [ bookstore ]
[exec] INFO:
[exec] # of Failures : 0
[exec] # of Warnings : 0
[exec] # of Errors : 0
[exec] INFO: Look in file "/opt/sun/javke5/reporttool/static/bookstore.war.txt" for detailed results.
[echo] See "/opt/sun/javke5/reporttool/static/verifierSummary.html" for results.
BUILD SUCCESSFUL
You can use the attributes listed in Table 3 to change the reports. For example, you could specify the following to generate reports showing only failures, on only the application client and enterprise bean components of an EAR file:
<target name="archive-test" description="static archive tests">
<ArchiveTest appname="./MyApp.ear"
reportingOpts="f"
partitionOpts="appclient,ejb" />
</target>
The summary page from the static archive tests shows the failures, warnings, passes and nonapplicable test results for each of the modules of the Java EE platform contained in the application. Each result contains a link to detailed information, including a description of the test that was run, the assertion in the specification being tested, and the name of the test. In addition, the summary includes a section that lists any errors the static archive tests encountered. If your code contains proprietary APIs, you will need to provide portable, functionally equivalent alternative code that can be executed instead of the proprietary APIs. You will need to rebuild your application using the alternative code in order to verify it. Note: For a few static archive tests, execution of the tests stops after the first failed test. Once you have corrected a failure, run the static archive test task again in order to find and correct further failures. Translating Runtime Deployment DescriptorsEvery application server has its own runtime deployment descriptors that specify implementation-specific aspects of deployment. An application that previously ran on another Java EE server must convert its runtime deployment descriptors to work with the Application Server. This process does not replace your original module or application; instead, it creates a new one with new deployment descriptors.
Use the
<target name="translate-dd" description="translate runtime DD for
deployment">
<TranslateRuntimeDD
archivename="${avk.home}/samples/weblogic_6_x/HelloWorld/HelloWorld.ear"
srcServer="weblogic6" />
Both the
If you run the
>ant translate-dd
Buildfile: build.xml
translate-dd:
[java] Extracting archives :-
[java] -------------------
[java] Extracting: HelloWorld.ear
[java] xx
[java] Extracting: helloworld.war
[java] x
[java] Extracting: HelloWorldEJB.jar
[java] x
[java] Clean up...
[java] Pre-processing input :-
[java] -------------------
[java] ||||||||||||||
[java] Migration Status :-
[java] ----------------
[java] |||||||||||||||||||
[java] ---------------------- Output SUMMARY ------------------------
[java] Java:
[java] Total files processed : - 0
[java] Succeded : - 0
[java] Failed : - 0
[java] Partially Processed : - 0
[java] Unchanged : - 0
[java] JSP:
[java] Total files processed : - 1
[java] Succeded : - 0
[java] Failed : - 0
[java] Partially Processed : - 0
[java] Unchanged : - 1
[java] XML:
[java] Total files processed : - 4
[java] Succeded : - 1
[java] Failed : - 0
[java] Partially Processed : - 0
[java] Unchanged : - 3
[java] HTML:
[java] Total files processed : - 1
[java] Succeded : - 0
[java] Failed : - 0
[java] Partially Processed : - 0
[java] Unchanged : - 1
[java] Configuration:
[java] Total files processed : - 0
[java] Succeded : - 0
[java] Failed : - 0
[java] Partially Processed : - 0
[java] Unchanged : - 0
[java] --------------------- End of SUMMARY ------------------------
[echo] See "C:\Sun\javke5\reporttool\translate\translationSummary.html" for results.
[echo] We attempted to create an ear file even if minor errors occurred. The application
with translated deployment descriptors is in a new .ear file located in
C:\Sun\javke5\reporttool\translate\Input_Archives\asmtbuild
BUILD SUCCESSFUL
Do not use the new EAR file created by the task. Instead, open the
Note: The task also generates new standard descriptors ( Starting the Application ServerAfter you perform static archive testing, start the Application Server. To start the server's default domain, use the following command:
Use the asadmin start-domain --verbose For database access, you can use the Java DB database that is part of the Application Server. It has a preconfigured Java Database Connectivity (JDBC) resource and connection pool. See the Sun Java System Application Server Platform Edition 9 Developer's Guide for details on using the JDBC API for database access. If your application uses a database, start the database now. Use the following command: asadmin start-database Creating Resources for the Application Suite
If your application uses server resources, you create them administratively. You can use the Admin Console or the To use the Admin Console, open the following URL in a browser: http://localhost:4848/Enter your administrative username and password (created when you installed the Application Server).
You can use the Admin Console help system, the Specifying Runtime InformationBefore you deploy your application, you should verify that any runtime information required by the Application Server is correct. Much of this information consists of the Java Naming and Directory Interface (JNDI) API names of any resources used by the application. A Java EE 5 application commonly uses source file annotations to specify resource injection for components. An application from a previous version of Java EE uses runtime deployment descriptors. In addition, you may need to create database tables for your persistence units or entity beans. For information on doing this, and for details on using the Java Persistence API in the Application Server, see the Sun Java System Application Server Platform Edition 9 Developer's Guide. Some examples in the Java EE 5 Tutorial also show how to create database tables. Deploying the Application Suite
Next, deploy the application suite on the Application Server. Use the If you are new to the Application Server, you can learn how to create, package, and deploy an application by following the instructions in the Getting Started chapter of the Java EE 5 Tutorial. Starting a Dynamic Verification SessionTo start a dynamic verification session, use the following command:
This command starts a verification session for the specified applications. First it creates a file named Dynamic verification uses the call-flow tracing capability of the Application Server.
After you run the
Executing the Application SuiteAfter you deploy the application suite, you must run it so as to invoke as much of its functionality as possible. In this step, you either manually or automatically invoke the JSP pages, servlets, and public EJB methods. Using the
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UNIX: | <JAVKE_HOME>/bin/report |
| Windows: | <JAVKE_HOME>\bin\report |
The command generates HTML pages describing all relevant information found during the testing process. The HTML pages are generated in the following directory:
<AS_HOME>/domains/domain1/logs/reporttool/<timestamp_dir>/results
The name of the <timestamp_dir> indicates the time at which the startverification command was run (for example, 2006-05-02-13-22).
The top-level page of the report is named suiteSummary.html. The report command opens the page in the browser specified in your avk.properties file. If you do not specify the BROWSER property, it looks for the Firefox browser in a default location that is probably incorrect.
The results generated by the command are described in Interpreting the Results.
The Java AVK for the Enterprise reporting tool compares introspection and instrumentation results and produces reports from that comparison. From the comparison of the results, the reporting tool generates a set of HTML files and displays the URL of the top-level summary report.
The reporting tool provides a status of Pass or Fail when summarizing the results. These numbers are based on the criteria mentioned in Coverage.
The summary page of the generated reports contains pointers to the results of the static archive tests, a summary of the EJB method coverage for each module, and a summary of the web component coverage.
Note: At this release, the link to the results of the static archive tests is always incorrect, reporting that static archive tests were not run.
The two kinds of coverage reports are described in the following sections:
EJB method coverage is reported by EAR file or module. The guideline is that at least 80% of the EJB methods within each module must be covered.
The EJB Method Coverage page expands the EAR file or module contents and lists the JAR files and beans in each file, with the coverage. The Methods Called column shows the number of methods called versus the total number of methods for each bean. Clicking on the bean name brings up the EJB Method Coverage Detail page, which displays the status of each method within that bean. The first table contains the methods that were not called successfully. Either those methods were not called at all, or an exception was thrown during the call. The next table shows all methods that were called successfully. This information can be used to determine which methods need to be invoked to increase the coverage to meet the guidelines if the guidelines were not met.
Web component coverage is reported by context. The guideline is that 100% of the JSP pages and servlets must be called with no exceptions generated.
The table on the summary page reports the percentage of the web components that were called. Clicking on either Passed or Failed brings up the Web Component Coverage page, which lists each component by the context root, whether or not it was called, and if so, whether there was an exception. This information can be used to determine which web components must be called to increase the coverage to meet the guidelines.
The coverage reports do not list JSP pages that are included by other JSP pages using an include directive. Instead, the reports list only the JSP pages that contain the include directives for these pages. JSP pages included with an include action, however, are listed in the coverage reports.
When you have finished generating reports, end the dynamic verification session. Use the following command:
| UNIX: | <JAVKE_HOME>/bin/stopverification |
| Windows: | <JAVKE_HOME>\bin\stopverification |
This command produces a final coverage report and then turns off the the Application Server settings that enable dynamic verification.
You can leave the Application Server running. If you want to stop the server, use the following command:
| UNIX: | <AS_HOME>/bin/asadmin stop-domain
|
| Windows: | <AS_HOME>\bin\asadmin stop-domain
or Programs->Sun Microsystems->Application Server PE->Stop Default Server |
Stopping the Application Server also ends the dynamic verification session, if you did not previously end the session.
This section describes how the tools collect dynamic data and generate metrics using two primary mechanisms: introspection and instrumentation. It covers the following topics:
The introspection process generates the list of required EJB methods to be invoked. The list contains all public methods in the bean's remote and local interfaces, the onMessage method for message-driven beans, and all create methods for session and entity beans. It excludes the methods that are on the Exclude List (the file <JAVKE_HOME>/config/appVerification/ExcludeList.xml). A list of excluded methods is provided as input to the introspection process, and in addition, other methods are excluded when the tool is dynamically generating the final required list. For example, all CMP and CMR fields supporting set and get methods are excluded from the final list, and all remove methods, finder methods, and the create methods for message-driven beans are excluded as well.
The list of required web components contains all servlets and JSP pages that have entries in the web.xml file and all files ending with .jsp.
This combination of the EJB and web component lists is the master list that determines which EJB methods and web components must be called. This information is used in calculating the percentage numbers.
Java AVK for the Enterprise logs all invocations during execution. For EJB components, that means all invocations of public business methods, of the ejbCreate method for stateful session beans and entity beans, and of the ejbRemove method. In addition, Java AVK for the Enterprise records any system exceptions that were thrown while a method was executed. Each web component that is invoked is also recorded. The combination of these two lists is the total list of invoked entities. This total list is used when comparing against what was generated from introspection.
Each time the report command runs, it compares the instrumentation and introspection results and produces the results. Snapshots from each run will be merged with existing reports.
Technical support from Sun is available. For details, go to the Java AVK for the Enterprise web page:
http://java.sun.com/j2ee/verified/avk_enterprise.html
For more information about the Java programming language, the Java EE platform, and portability, refer to the following:
http://java.sun.com/developer/technicalArticles/J2EE/build/index.html
http://java.sun.com/developer/technicalArticles/J2EE/build/build2.html
Related Links |
| ||||||||||||||||||
|
| ||||||||||||