Xml Validation Test Suite With Camv


Published on

Guide to using the CAMV test suite approach for XML testing. Download CAMV open source tool from http://www.cameditor.org and see videos here: http://www.youtube.com/watch?v=yaCwiIX5lM4

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Xml Validation Test Suite With Camv

  1. 1. XML Validation <br />Test Suites<br />with CAMV<br />Exchange Development<br />Deploy<br />Requirements<br />CAMV<br />Model<br /> Data<br />Test<br />NIEM Team, Oracle Public Sector<br />Build<br /> Exchange<br />Generate<br />Dictionary<br />Technology Introduction – September 2011<br />
  2. 2. DisclaimerNotice<br />The following is not intended to outline Oracle general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions.<br />The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.<br />Slide 2<br />
  3. 3. Test Suites Introduction<br />A key need in working with XML information exchanges, is developing examples and matching templates including rules, context, and roles for correctly managing information exchange content between partners. The W3C Schema by themselves are not sufficient. <br />Learn how to use open source tooling, XPath rules, and the OASIS CAM templates standard to create automated testing tools.<br />Integrating SQL table lookup validation rules<br />The CAMV validation engine can also be used in production environments to manage live information exchanges.<br />Slide 3<br />
  4. 4. Contents<br /><ul><li>Part 1</li></ul>The XML Validation Framework<br />XPath Rules Techniques<br />Code lists and SQL lookups<br />Rules use cases<br /><ul><li>Part 2
  5. 5. Example CAM templates
  6. 6. CAMV validation examples
  7. 7. NIEM example test suite
  8. 8. Elections example test suite
  9. 9. SQL table database lookups
  10. 10. Running validations from visual CAM Editor
  11. 11. Results handling techniques
  12. 12. Summary</li></ul>* National Information Exchange Model (NIEM) – see http://www.niem.gov<br />Slide 4<br />
  13. 13. XML Validation Framework<br />Architecture and Deployment<br />Exchange Development<br />Deploy<br />Requirements<br />CAMV<br />Model<br /> Data<br />Test<br />Build<br /> Exchange<br />Generate<br />Dictionary<br />
  14. 14. XML Validation Framework<br />Slide 6<br />
  15. 15. CAMV Engine<br />Slide 7<br />
  16. 16. CAMV Validation Engine<br />Standalone XML validator using XPath rules<br />Context aware and declarative rules approach<br />Integrated with CAM editor menus for instant testing<br />External code list and SQL table lookup support<br />Callable via Spring framework or Java API; thread safe and server container deployable<br />Configurable error levels – error, warning<br />Java error results object returned<br />Embedded validation results attributes in XML results<br />Slide 8<br />
  17. 17. CAMV<br />CAM Editor<br />XSLT<br />CAM Editor / CAMV Environment<br />Reports<br />Single XML Test Instance<br />XML Validation Result<br />CAM Editor<br />CAM template<br />Slide 9<br />
  18. 18. CAMV<br />XSLT<br />CAMV / ANT Script Environment<br />CAM template(s)<br />Reports<br />CAMV Control Script XML<br />XML Test<br />Instances<br />ANT<br />2<br />XML Validation<br />Results<br />1<br />Slide 10<br />
  19. 19. CAMV Test Control Script XML (single)<br />Singleton Test Case Example<br /><camvTestSuite><br /> <testCase><br /> <Example-Test-v19-3><br /> <cxxfile>Test-Template-v19.cxx</cxxfile><br /> <xmlfile>Test-Instance-v19-3.xml</xmlfile><br /> <verbose>true</verbose><br /> <inlineErrors>true</inlineErrors><br /><parameters><br /> <abc>Param1</abc><br /> <cde>Param2</cde><br /> </parameters><br /> </Example-Test-v19-3><br /> </testCase> <br /></camvTestSuite><br />Test case name<br />Validation Template<br />Test XML instance<br />Optional items<br />Slide 11<br />
  20. 20. CAMV Test Control Script XML (multi-instance)<br />Multi-Test Folder Example<br />Test case name<br /><camvTestSuite><br /><testCase><br /><Example-Test-With-Folder><br /><cxxfile>../samples/templates/EML-330-list-v7.cxx</cxxfile><br /> <testdir>../samples/XMLsamples/UOCAVA/330</testdir><br /> <verbose>true</verbose><br /> <inlineErrors>true</inlineErrors><br /><parameters><br /> <abc>Param1</abc><br /> <cde>Param2</cde><br /> </parameters><br /></Example-Test-With-Folder><br /></testCase> <br /></camvTestSuite><br />Validation Template<br />Test XML instances folder<br />Optional items<br />Slide 12<br />
  21. 21. Linux GTK ANT Configuration<br />Linux distributions (e.g. Ubuntu) has ANT pre-installed in /usr/share/ant/lib<br />Download Ant-contrib from <br />http://ant-contrib.sourceforge.net/<br />Copy ant-contrib jar file to /lib directory inside ANT installation<br />Slide 13<br />
  22. 22. Mac OS ANT Configuration<br />Mac OS X 1.7+ “Lion” comes pre-installed - use command : ant –version and it will self-configure<br />Mac OS X 1.6 and earlier – need to install “Xcode” development software first<br />Download Ant-contrib from <br />http://ant-contrib.sourceforge.net/<br />Copy ant-contrib jar file to /lib directory inside ANT installation<br />Slide 14<br />
  23. 23. ANT – Windows configuration<br />Download ANT from <br />http://ant.apache.org<br />Download Ant-contrib from <br />http://ant-contrib.sourceforge.net/<br />Copy ant-contrib jar file to /lib directory inside ANT installation<br />Set the ANT_HOME environment variable to the directory where you installed ANT<br />Add %ANT_HOME%/bin folder to executable path<br />Slide 15<br />
  24. 24. Windows System Path Settings<br />1<br />2<br />3<br />Slide 16<br />
  25. 25. Running CAMV with ANT<br />Go to CAMV location on Sourceforge<br />http://www.cameditor.org/#CAMV_Testing<br />Download CAMV release JAR and Test example ZIP<br />Unpack test example from ZIP and put CAMV jar into folder<br />Go to the command line (run cmd)<br />Switch to folder where CAMV test suite is located<br />ANT runAll<br />Output is automatically placed in folder called CAMVTestResultslocated within the test instance location folder(s)<br />Slide 17<br />
  26. 26. Reviewing Validation Results HTML<br />Slide 18<br />
  27. 27. XPath Rules Techniques<br />Quick Syntax Primer<br />Controlling Scope, Context, Evaluation<br />Dynamic Structure Components<br />Useful XPath Resources<br />Exchange Development<br />Deploy<br />Requirements<br />CAMV<br />Model<br /> Data<br />Test<br />Build<br /> Exchange<br />Generate<br />Dictionary<br />
  28. 28. XPath Syntax Primer<br />XPath is a simple assertion language where expressions reference components hierarchically within an XML instance structure – e.g.<br />/animals/canines/domestic/dogs/poodle[1]<br />/animals/canines/domestic/*<br />CAMV uses the XPath v2.0 Java library<br />In CAM templates XPath is used extensively to provide rules and content details for XML structure components <br />Slide 20<br />
  29. 29. XPath Functions<br />Slide 21<br />
  30. 30. CAM XPath Extensions (most used)<br />Slide 22<br />
  31. 31. CAM templates and XPath expressions<br />Within a CAM template XPath expressions are found in the <as:BusinessUseContext> section of the template.<br />Slide 23<br />
  32. 32. Rules Use Cases<br />Typical Business Needs<br />Quick Examples<br />Exchange Development<br />Deploy<br />Requirements<br />CAMV<br />Model<br /> Data<br />Test<br />Build<br /> Exchange<br />Generate<br />Dictionary<br />
  33. 33. Standard Pattern for Business Rules<br />Claim – An English statement of a business rule that conveys its meaning.Example: A Chapter MUST have a Title.<br />Test – A formal statement of a business rule that can be parsed and processed by machine.Example: <Assert test="count(para) &gt;=1"><br />Diagnostic – An English statement that identifies and explains what happened or was found when a Test fails.Example: Chapter "X" does not have a Title.<br />Outcome – Error, Warning, Pass<br />Slide 25<br />
  34. 34. Controlling Scope and Context<br />Condition controls if and when the content rule action applies<br />Condition can control structure as well; optional, mandatory, exclude<br />Condition can reference different component(s) for contextual rule actions <br />Slide 26<br />
  35. 35. Some more examples<br />Business Rule: Items with color attributes don't need a tray number—the color is sufficient for picking the item: <br /><as:constraintcondition="exists(//Item/@color)" action="makeOptional(//Item/TrayNumber)" /> <br />Business Rule: If order weight exceeds 25 kg, purchase order must specify a freight carrier:<br /><as:constraintcondition="//Item/@weight > 25" action="makeMandatory(//Item/FreightHandler)"> <br />Using XPath axis referencing (when things are not adjacent in hierarchy): <br /><as:constraintcondition="exists(ancestor::Item/@color)" action="makeOptional(//Item/TrayNumber)" /> <br />* Excerpted from Michael Sorens DEVX CAM article examples<br />Slide 27<br />
  36. 36. Useful XPath Resources<br />Michael Sorens article on using CAM from DEVX.com<br />http://www.devx.com/xml/Article/41150<br />Martin Roberts – tutorial on writing CAM rules<br />http://merryflame.co.uk/jcam/site/tutorials/CAMTemplateBasics.htm<br />XPath tutorial resources<br />Search on XPath tutorial<br />Books available<br />Tools – XPath expression constructors<br />Slide 28<br />
  37. 37. Code Lists and SQL Lookups<br />Introduction to CAM code lists<br />Advantages<br />Tools and Hints<br />Exchange Development<br />Deploy<br />Requirements<br />CAMV<br />Model<br /> Data<br />Test<br />Build<br /> Exchange<br />Generate<br />Dictionary<br />
  38. 38. Code lists<br />CAM lookup() function allows referencing to external XML lists of values<br />Can replace use of restrictValues() static lists<br />Database - CAM lookup() function can reference SQL table for dynamic value checking<br />Where to get code lists?<br />Import XSD enumeration schema into CAM lookup lists<br />Convert UBL Genericode into CAM lookup lists<br />Dump from database into lookup list XML format<br />Direct via SQL table lookup<br />Slide 30<br />
  39. 39. CAM Code list XML format<br />Code list name<br />Code value<br />Textual value<br />Slide 31<br />
  40. 40. Combining Rules and Code lists<br />Real power of code lists and CAM – ability to select code list values based on XPath rule criteria to handle different partner configurations, versioning and cross-table validations <br />e.g. Ford / Mustang | Chevy / Corvette<br />Message version id = 1.6 – use code list XYZ-1-6 <br />Slide 32<br />
  41. 41. Code lists examples<br />Load lookup list XML into CAM editor<br />Assign lookup() rule to XML component<br />Using SQL lookups – need to define connectivity to database and the SQL query to perform – we will do this part in the next section<br />Slide 33<br />
  42. 42. Code Lists Summary<br />Lookups can be to external XML file instances<br />Simple XML format for optimized performance and readability<br />Dynamic runtime control via XPath rules to select lists to be applied<br />Lookup can reference SQL statement for database content checking<br />Slide 34<br />
  43. 43. Part 2<br />Example CAM templates <br />Running CAMV validations<br />Results handling techniques<br />Summary<br />Exchange Development<br />Deploy<br />Requirements<br />CAMV<br />Model<br /> Data<br />Test<br />Build<br /> Exchange<br />Generate<br />Dictionary<br />
  44. 44. CAM templates<br />Here we introduce CAM templates and understanding their component sections<br />Template is abstraction layer over schema structure and rules<br />Template can be automatically built from existing XSD schema<br />Add additional XPath validation rules<br />Compiled templates provide the validation instructions for the CAMV validation engine<br />Using CAMV validations and handling results<br />Slide 36<br />
  45. 45. CAM Templates Overview<br />Consists of 4 functional sections:<br /><ul><li>Header declares properties and parameters for the CAM process to reference
  46. 46. AssemblyStructure captures the business information exchange structures
  47. 47. BusinessUseContextprovides the rules to apply during validation
  48. 48. Extensionpoints to the annotations and external lookup tables</li></ul>Slide 37<br />
  49. 49. Example CAM templates<br />Examples Reviewed<br />Quick walk through of important details<br />Exchange Development<br />Deploy<br />Requirements<br />CAMV<br />Model<br /> Data<br />Test<br />Build<br /> Exchange<br />Generate<br />Dictionary<br />
  50. 50. Available Test Suite Examples<br />Experimental SAR Examples<br />Two test example templates and XML instances:<br />Baseline SAR with just structure and content usage rules, schema parlance “cardinality, facets and enumerations”<br />Baseline SAR advanced – logical business rules added to check consistency of information and structure components<br />Each test set contains examples that pass and those that fail depending on the template validation applied<br />OASIS EML V7 – UOCAVA Testing<br /><ul><li>Set of test examples for Election Management:
  51. 51. Both individual test cases and folder based multiple examples
  52. 52. Each test uses different template and validation scenario</li></ul>* SAR – Suspicious Activity Report NIEM exchange<br />* EML – Election Markup Language Standard<br />Slide 39<br />
  53. 53. Experimental SAR Overview<br />Areas of Interest:<br /><ul><li>Drugs
  54. 54. Fraud
  55. 55. Gangs
  56. 56. Internet
  57. 57. Pornography
  58. 58. Missing Persons
  59. 59. Property
  60. 60. Vehicles
  61. 61. Community
  62. 62. Weapons/Chemicals
  63. 63. Prescriptions
  64. 64. Travel/Immigration
  65. 65. Terrorism</li></ul>* SAR – Suspicious Activity Report<br />Slide 40<br />
  66. 66. Visual Template Rules Wizard Tools<br />Slide 41<br />
  67. 67. Running CAMV Validation <br />Illustrative examples – pass, fail, warnings<br />Default structure handling<br />Data type and Content checking<br />Cross-field validation rules<br />SQL database lookup<br />Exchange Development<br />Deploy<br />Requirements<br />CAMV<br />Model<br /> Data<br />Test<br />Build<br /> Exchange<br />Generate<br />Dictionary<br />
  68. 68. Example Advanced Rules<br />Business Rule: Providing warning if PurgeDate is earlier than PurgeReviewDate<br /><as:constraintcondition="//sbl:PrivacyDetails/sbl:PrivacyPurgeDate < //sbl:PrivacyDetails/sbl:PrivacyPurgeReviewDate"action="printMessage(//sbl:PrivacyDetails/sbl:PrivacyPurgeReviewDate,Warning: Review date not before purge date)"><as:annotation/></as:constraint><br />Business Rule: Location must contain an address or a highway or coordinate set<br /><as:constraintcondition="not(./nc:LocationAddress) and(not(./nc:LocationHighway)) and(not(./nc:LocationTwoDimensionalGeographicCoordinate))"action="printMessage(//j:TargetLocation/sbl:Location,Empty Location information)"><as:annotation><as:documentationtype="documentation">Example of advanced rule</as:documentation></as:annotation></as:constraint><br />Slide 43<br />
  69. 69. Default Structure Handling<br />By default all structure components are required and string content<br />Content Masks<br />Structure control<br />Slide 44<br />
  70. 70. Running CAMV details<br />Batch Command Line Execution Window<br />Viewing Same Template in Visual Editor<br /><ul><li>From within the Test Suite folder on the command line execute > Ant runALL</li></ul>Slide 45<br />
  71. 71. Sample SAR Validation Results HTML<br />Slide 46<br />
  72. 72. Installing and using SQL lookup example<br />Contains test sample and template<br />DB lookup sample install folder contents<br /> Run start and stop database scripts<br />Simply download and unpack the ZIP archive and drop the DatasourceExample package into the samples Test Suite folder<br />Then add the camv-test-DbList.xml to the testsuites folder<br />Slide 47<br />
  73. 73. SQL DB configuration details<br />Modify to match your local directory structure<br />camv-test-DbList.xml contains data source reference and connection configuration<br />Modify inside dbProps.props file to match your local directory structure<br />Slide 48<br />
  74. 74. Sample SQLDB Test Run<br /><ul><li> Start the database instance (slide 47)
  75. 75. From within the Test Suite folder on the command line execute > Ant runALL</li></ul>Slide 49<br />
  76. 76. DB lookup test results rendered as HTML<br />SQL DB lookup result<br />Slide 50<br />
  77. 77. CAM Editor Visual Tools<br />SQL lookup entry wizard<br />Run CAMV validation wizard<br />Visual entry of SQL connection details<br />Visual review of validation results<br />Exchange Development<br />Deploy<br />Requirements<br />CAMV<br />Model<br /> Data<br />Test<br />Build<br /> Exchange<br />Generate<br />Dictionary<br />
  78. 78. CAM template SQL lookup rule definition<br />This is the myLists.cam example template<br />Slide 52<br />
  79. 79. CAM template SQL lookup rule wizard<br />Slide 53<br />
  80. 80. Test from CAM Editor validation Run Wizard <br />Pick test case XML file<br />1<br />Choose JDBC driver<br />Confirm driver name<br />2<br />3<br />Replace default connection with actual JDBC string<br />4<br />NOTE: this is the same information as contained in the dbProp.props file<br />jdbc:derby://localhost:1527/firstdb<br />Slide 54<br />
  81. 81. Sample Visual Test Results<br />SQL lookup result displayed<br />Slide 55<br />
  82. 82. More Results Handling<br />XSLT script post-processing<br />XML Diff considerations<br />Regression Testing with CAMV<br />Middleware Integration<br />Exchange Development<br />Deploy<br />Requirements<br />CAMV<br />Model<br /> Data<br />Test<br />Build<br /> Exchange<br />Generate<br />Dictionary<br />
  83. 83. Default XSLT rendering of results<br />HTML output<br />Finds CAM validation results attributes<br />Formats and outputs error details<br />Slide 57<br />
  84. 84. Post-Processing Tips and Tricks<br />XSLT post-processing not only for HTML reporting<br />Create response error messaging directly from CAMV output<br />Create receipt notification directly from CAMV output<br />Can use simple DIFF to compare generic HTML report output to detect regression test changes<br />Rule based checking is superior to simple result content change testing<br />Java API and Spring supports direct integration of CAMV and returning validation results directly to middleware<br />Slide 58<br />
  85. 85. Summary<br />Review<br />Next Steps<br />Future enhancements<br />Resources and Links<br />Exchange Development<br />Deploy<br />Requirements<br />CAMV<br />Model<br /> Data<br />Test<br />Build<br /> Exchange<br />Generate<br />Dictionary<br />
  86. 86. Review and Value Proposition<br />Testing and verification of your exchange XML examples<br />SQL database lookups and flexible code lists handling<br />Business rule checking<br />Post-processing options and reporting with XSLT scripts<br />Regression testing with batch processing<br />Flexible deployment of XML validation framework<br />Integration via Spring API to middleware<br />Slide 60<br />
  87. 87. What are we working on?<br />Improvements<br />“CAM for web services” – currently exchange-centric<br />Enhancing ANT capabilities and soapUI integration<br />New features<br />Dictionary integration with NIEM Domain Update Tool<br />Evaluation tools for dictionaries and components<br />Enhancing XML example generation with synthetic data<br />Slide 61<br />
  88. 88. CAMV Summary<br />Open source, open public standards based, cross-platform deployment written using Java<br />Uses Java APIs, Spring API, JDOM, etc.<br />Validation features:<br />XPath V2.0 support<br />Looks ups<br />20 built-in functions<br />Reporting<br />Embedded CAMERROR, CAMWARN tags<br />Spring API and results set handler<br />Optional sysout test result log<br />Slide 62<br />
  89. 89. Links and References<br />DOWNLOADS -<br />http://cameditor.org/ #CAMV_Testing<br />NIEM MATERIALS -<br />Oracle NIEM website<br />http://www.oracle.com/goto/niem<br />Oracle XMLOrb blog site<br />http://blogs.oracle.com/xmlorb<br />Slide 63<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.