/virtuoso-opensource-6.1.5/binsrc/bpel/tests/tevent/tevent.sql

# · SQL · 118 lines · 80 code · 16 blank · 22 comment · 0 complexity · c45ca4b74eca37905f2039a68f0d0138 MD5 · raw file

  1. --
  2. -- $Id: tevent.sql,v 1.2.2.1 2012/03/08 12:54:59 source Exp $
  3. --
  4. -- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
  5. -- project.
  6. --
  7. -- Copyright (C) 1998-2012 OpenLink Software
  8. --
  9. -- This project is free software; you can redistribute it and/or modify it
  10. -- under the terms of the GNU General Public License as published by the
  11. -- Free Software Foundation; only version 2 of the License, dated June 1991.
  12. --
  13. -- This program is distributed in the hope that it will be useful, but
  14. -- WITHOUT ANY WARRANTY; without even the implied warranty of
  15. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. -- General Public License for more details.
  17. --
  18. -- You should have received a copy of the GNU General Public License along
  19. -- with this program; if not, write to the Free Software Foundation, Inc.,
  20. -- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. --
  22. --
  23. use db;
  24. drop table event_test_1;
  25. drop table event_test_2;
  26. create table event_test_1 (id int identity primary key, dt varchar);
  27. create table event_test_2 (id int identity primary key, dt varchar);
  28. delete from bpel..script where bs_name in ('Event', 'AsyncBPELService');
  29. create procedure upload_async_process ()
  30. {
  31. declare id any;
  32. bpel..import_script ('file:/tevent/AsyncBPELService/bpel.xml', 'AsyncBPELService', id);
  33. bpel..compile_script (id, '/AsyncBPELService');
  34. };
  35. create procedure upload_event_process ()
  36. {
  37. declare id any;
  38. bpel..import_script ('file:/tevent/bpel.xml', 'Event', id);
  39. bpel..compile_script (id, '/Event');
  40. };
  41. upload_async_process ();
  42. ECHO BOTH $IF $EQU $STATE OK "PASSED:" "***FAILED:";
  43. ECHO BOTH " AsyncBPELService created : STATE=" $STATE " MESSAGE=" $MESSAGE "\n";
  44. upload_event_process ();
  45. ECHO BOTH $IF $EQU $STATE OK "PASSED:" "***FAILED:";
  46. ECHO BOTH " Event process created : STATE=" $STATE " MESSAGE=" $MESSAGE "\n";
  47. select xpath_eval ('//loanApplication/loanAmount/text()', xml_tree_doc (
  48. db.dba.soap_client (url=>sprintf ('http://localhost:%s/Event',
  49. server_http_port()),
  50. soap_action=>'initiate', operation=>'initiate',
  51. parameters => vector ('par0', xtree_doc (
  52. '<loanApplication xmlns="http://www.autoloan.com/ns/autoloan">
  53. <SSN>1234567890</SSN>
  54. <email>a@a.com</email>
  55. <customerName>joe doe</customerName>
  56. <loanAmount>10000</loanAmount>
  57. <carModel>zaz</carModel>
  58. <carYear>1960</carYear>
  59. <creditRating/>
  60. </loanApplication>')),
  61. style=>1,
  62. time_out=>180
  63. )));
  64. ECHO BOTH $IF $EQU $LAST[1] 10000 "PASSED:" "***FAILED:";
  65. ECHO BOTH " Event returns " $LAST[1] "\n";
  66. select count(*) from event_test_1;
  67. ECHO BOTH $IF $EQU $LAST[1] 0 "PASSED:" "***FAILED:";
  68. ECHO BOTH " event_test_1 contains " $LAST[1] "\n";
  69. select count(*) from event_test_2;
  70. ECHO BOTH $IF $EQU $LAST[1] 0 "PASSED:" "***FAILED:";
  71. ECHO BOTH " event_test_2 contains " $LAST[1] "\n";
  72. select xpath_eval ('//loanApplication/loanAmount/text()', xml_tree_doc (
  73. db.dba.soap_client (url=>sprintf ('http://localhost:%s/Event',
  74. server_http_port()),
  75. soap_action=>'initiate', operation=>'initiate',
  76. parameters => vector ('par0', xtree_doc (
  77. '<loanApplication xmlns="http://www.autoloan.com/ns/autoloan">
  78. <SSN>9234567890</SSN>
  79. <email>a@a.bar</email>
  80. <customerName>joe doe</customerName>
  81. <loanAmount>100000</loanAmount>
  82. <carModel>bmw</carModel>
  83. <carYear>2003</carYear>
  84. <creditRating/>
  85. </loanApplication>')),
  86. style=>1,
  87. time_out=>180
  88. )));
  89. ECHO BOTH $IF $EQU $LAST[1] 100000 "PASSED:" "***FAILED:";
  90. ECHO BOTH " Event returns " $LAST[1] "\n";
  91. select count(*) from event_test_1;
  92. ECHO BOTH $IF $EQU $LAST[1] 2 "PASSED:" "***FAILED:";
  93. ECHO BOTH " event_test_1 contains " $LAST[1] "\n";
  94. select dt from event_test_2;
  95. ECHO BOTH $IF $EQU $LAST[1] 'Alarm timeout: no response from AsyncBPELService after 15 seconds' "PASSED:" "***FAILED:";
  96. ECHO BOTH " event_test_2 record " $LAST[1] "\n";
  97. select count(*) from event_test_2;
  98. ECHO BOTH $IF $EQU $LAST[1] 1 "PASSED:" "***FAILED:";
  99. ECHO BOTH " event_test_2 contains " $LAST[1] "\n";
  100. select dt from event_test_1;
  101. ECHO BOTH $IF $EQU $LAST[1] 'we will finish processing your request soon' "PASSED:" "***FAILED:";
  102. ECHO BOTH " event_test_1 2-d record " $LAST[1] "\n";