Wednesday, May 5, 2010

XQuery and Unit Tests

XQuery can turn into a nightmare, not much during development, but during their maintenance.... XQuery code is very convoluted (XPath expressions can be daunting) and after one week you have coded them I dare you understand what you wrote in the first place. You touch it, you break it.

Hence it's paramount to unit test them. I am looking at the best way of doing it either INSIDE OSB or INSIDE ECLIPSE.

One way could be to follow this approach - INSIDE OSB:

http://blogs.oracle.com/knutvatsendvik/2010/03/unit_testing_framework_for_xquery.html

The utility is very well thought, especially impressive if the XMLDiffXQ utility

As for invoking directly XQuery from Java, here are the xquery related jars in OSB:



   ¦  C:\bea103osb\modules\                                                                                       ¦
   ¦   22-04-10 13:52¦        54443¦   A      ¦com.bea.core.xquery.beaxmlbeans-interop_1.2.1.0.jar                ¦
   ¦   22-04-10 13:52¦        55472¦   A      ¦com.bea.core.xquery.xmlbeans-interop_1.2.1.0.jar                   ¦
   ¦   22-04-10 13:52¦      4563307¦   A      ¦com.bea.core.xquery_1.2.1.0.jar                                    ¦
   ¦ ------------------------------------------------------------------------------------------------------------ ¦
   ¦  C:\bea103osb\modules\features\                                                                              ¦
   ¦   22-04-10 13:52¦          517¦   A      ¦weblogic.server.modules.xquery_10.3.0.0.jar                        ¦
   ¦ ------------------------------------------------------------------------------------------------------------ ¦
   ¦  C:\bea103osb\osb_10.3\eclipse\plugins\com.bea.alsb.xquery.xmlbeans-interop_1.0.200\lib\                     ¦
   ¦   22-04-10 14:22¦        54443¦   A      ¦com.bea.core.xquery.beaxmlbeans-interop_1.2.1.0.jar                ¦
   ¦   22-04-10 14:22¦        55472¦   A      ¦com.bea.core.xquery.xmlbeans-interop_1.2.1.0.jar                   ¦
   ¦ ------------------------------------------------------------------------------------------------------------ ¦
   ¦  C:\bea103osb\osb_10.3\eclipse\plugins\com.bea.alsb.xquery_1.0.200\lib\                                      ¦
   ¦   22-04-10 14:22¦      4563307¦   A      ¦com.bea.core.xquery_1.2.1.0.jar                                    ¦
   ¦ ------------------------------------------------------------------------------------------------------------ ¦
   ¦  C:\bea103osb\tools\eclipse_pkgs\2.0\pkgs\eclipse\plugins\com.bea.wli.ide.xquery.core_10.3.0\                ¦
   ¦   22-04-10 14:05¦       150403¦   A      ¦xquery-core.jar                                                    ¦
   ¦ ------------------------------------------------------------------------------------------------------------ ¦
   ¦  C:\bea103osb\tools\eclipse_pkgs\2.0\pkgs\eclipse\plugins\com.bea.wli.ide.xquery.ui_10.3.0\                  ¦
   ¦   22-04-10 14:05¦       148611¦   A      ¦xquery-ui.jar                                                      ¦

Here http://biemond.blogspot.com/2008/11/using-xquery-in-jdeveloper-11g-and.html is an example of how to execute XQuery code from Java... but it requires JDeveloper!

Here http://wordpress.transentia.com.au/wordpress/2010/11/20/unit-testing-xquery-using-osbs-api-2/  is someone who seems to have drunk the bitter cup to its last sip and managed to implement Unit Testing for OSB Xqueries..... Kudos!

No comments: