Presentation on Quality Assurance with the JDeveloper Auditing Framework, covering:
- how to use default auditing framework
- creating custom rules and fixes to implement company and project standards
- SuppressWarnings JDeveloper extension to suppresswarnings in XML files
- ADF Code Guidelines JDeveloper extension
- SonarQube plugin for JDeveloper (ojaudit)
18. Setting up JDev Extension Project
● Install Extension SDK (Help>CheckForUpdates)
● File > New > Applications >
Extension Application
● extension.xml and MANIFEST.MF
● Bundled as .ZIP
● Can be distributed through custom JDeveloper
Update Center
(aka network drive or URL)
33. AuditContext
● Provides Traversal State
● report() for Violations, Metrics,
Suppressions
● Holds State for Analyzer
○ Setting Attributes for Child Constructs
○ Setting Attributes for Parent Construct
○ (Sharing Attributes between Analyzers)
34. ● AuditContext creates Analyzer State Keys
● enter() on root-node (Workspaces) invoked
once, so can initialize keys
39. Transform subclass
● apply(context, construct)
○ applies fix by changing source
○ TransformContext argument contains editor location,
violation, etc
○ Construct is the object with the violation (eg. a
JavaMethod or XMLElement)
● isQueryRequired(context, construct)
and query(context, construct)
○ queries the user for additional info when applying fix
63. ADF Code Guidelines Extension
● JDeveloper extension available today
● ADF Code Guidelines auditing during
development
● Community project at java.net: adfemgauditrules
● Contribute and discuss at ADF EMG
● JDeveloper 12c only
○ at least for now. No reason why this can’t be
backported to JDeveloper 11g
65. OJAudit
● Command line auditing
● JDEV_HOME/jdev/bin/ojaudit -help
● Output in XML/text/HTML or custom xsl
66.
67. Automated QA
● Simple solution: Run ojaudit from CI server
and publish output
● Benefit: Same rules during development and
CI QA
● @SuppressWarnings and
<!--SuppressWarning--> keep list of
violations short and actionable
70. SonarQube
●
●
●
●
●
●
Tool to manage Code Quality
Rules, Violations, Metrics, Test Coverage, etc
Free Open Source
Initially Java, but now 20+ languages
Historical data, thus trends
Highly extensible through plugins
71.
72.
73.
74.
75. ADF EMG SonarQube plugin
● SonarQube plugin
○ runs ojaudit
○ converts ojaudit output to SonarQube violations
●
●
●
●
www.sonarqube.com for base product
Watch ADF EMG for availability of plugin
Not specific to ADF, but for any JDev project
Tested with JDeveloper 12c, but should work
with any version
76. Further Reading
● www.olrichs.nl
● www.redheap.com
● ADF Enterprise Methodology Group
○ Google Groups
● http://docs.oracle.com
JDeveloper Doc (not ADF documentation)
○ Developing Extensions for JDeveloper
○ Java API Reference for Extension SDK