How to assert an Event with payload using TIBCO BusinessEvents (BE) Java API
book
Article ID: KB0074813
calendar_today
Updated On:
Products
Versions
TIBCO BusinessEvents Enterprise Edition
5.6.1
Description
Create and assert an Event to BE with BE Java API
Environment
All Operatiing Systems
Resolution
Attached (TestProject.zip) a sample project that includes the java code to create and assert the Event (folder /JavaScr class: com.tibco.testJavaAPI.TestAPICreateAndSendEventWithPayload) and the BE project. The java class starts an BE instance (API mode), creates and asserts two Events (with payload) to the working memory. Each asserted Event triggers the Rule "Rules.rTestSupport()". In the Rule a test concept created with input data of the Event. The serialized concept printed to BE log. BE agent stopped in Java class after execution.
To perform a test: 1.) Open project (TestProjectBEandJavaCode) in Studio and build the ear 2.) Update below properties in java class “com.tibco.testJavaAPI.TestAPICreateAndSendEventWithPayload “ with your settings
private static final String TRA_FILE = "<location TRA file>"; private static final String CDD_FILE = "<locationCDDFile>"; private static final String PROC_UNIT = "default"; private static final String REPO_URL = "<locationEarFile>";
3.) Test application - Windows start scripts available in /bin folder - Edit setEnv.bat and modify environment parameters - Start application and execute StartSampleIrun.bat
Sample output: 2020 Aug 27 11:55:21:894 GMT +2 BETestsupportAPI Info [main] - [runtime.session] Starting BE engine in API mode 2020 Aug 27 11:55:21:894 GMT +2 BETestsupportAPI Info [main] - [runtime.session] Loading catalog functions. 2020 Aug 27 11:55:21:895 GMT +2 BETestsupportAPI Info [main] - [runtime.session] Loading the project from: D:/temp/KB/CreateAndAssertEventWithPayLoadInJavaCode/project/bin/testSupportAPI.ear 2020 Aug 27 11:55:22:719 GMT +2 BETestsupportAPI Info [main] - [runtime.session] Loaded the project successfully 2020 Aug 27 11:55:23:391 GMT +2 BETestsupportAPI Info [Catalog-Functions-Loader] - [runtime.session] Loaded catalog functions. 2020 Aug 27 11:55:23:397 GMT +2 BETestsupportAPI Info [main] - [runtime.session] Project XPATH version:2.0 2020 Aug 27 11:55:23:397 GMT +2 BETestsupportAPI Info [main] - [runtime.session] Registering Ontology Classes... 2020 Aug 27 11:55:23:436 GMT +2 BETestsupportAPI Info [main] - [runtime.session] Registered Ontology Classes 2020 Aug 27 11:55:23:493 GMT +2 BETestsupportAPI Info [main] - [runtime.session] Loaded BE Jar catalog functions 2020 Aug 27 11:55:23:493 GMT +2 BETestsupportAPI Info [main] - [runtime.session] EAR generated with: 2020 Aug 27 11:55:23:494 GMT +2 BETestsupportAPI Info [main] - [runtime.session] D:/tibco_BE56test/be/5.6/lib/be-functions.jar : Version 5.6.1.130, 2020-08-21 - ... 2020 Aug 27 11:55:23:790 GMT +2 BETestsupportAPI None [main] - [runtime.session] BE Engine BETestsupportAPI started 2020 Aug 27 11:55:23:797 GMT +2 BETestsupportAPI Info [main] - [user] [inference-class] #### Rules.rTestSupport(): Rule triggered
2020 Aug 27 11:55:24:461 GMT +2 BETestsupportAPI Info [main] - [user] [inference-class] #### Rules.rTestSupport(): TestConcept created with Event property and payload values. Serialized concept: <?xml version="1.0" encoding="UTF-8"?>