Adding Unit Test Suite for the BusinessEvents Project
TIBCO BusinessEvents Studio provides a wizard to create a unit test suite for the project using new wizard dialog.
Procedure
Sample Unit Test Suite File
The following is a sample unit test suite
.java file generated for the CreditCardApplication project to test if a particular event has been asserted.
package; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import java.util.List; import com.tibco.cep.runtime.model.event.SimpleEvent; import com.tibco.cep.runtime.service.tester.beunit.BETestEngine; import com.tibco.cep.runtime.service.tester.beunit.Expecter; import com.tibco.cep.runtime.service.tester.beunit.TestDataHelper; import com.tibco.cep.runtime.session.RuleServiceProvider; /** * @description */ public class BEUnitTestSuite2 { private static BETestEngine engine; private static TestDataHelper helper; private static Expecter expecter; @BeforeClass public static void setUpBeforeClass() throws Exception { engine = new BETestEngine("C:/tibco/BE54v95/be/5.4/examples/standard/WebStudio/CreditCardApplication.ear", "C:/tibco/BE54v95/be/5.4/bin/be-engine.tra", "Deployments/CreditCardApplication.cdd", "default", "inference-class", true); // Start the test engine engine.start(); // Create a helper to work with test data helper = new TestDataHelper(engine); // Create an Expecter object to test rule execution, modifications, assertions, etc. expecter = new Expecter(engine); } @AfterClass public static void tearDownAfterClass() throws Exception { try { engine.shutdown(); } catch (Exception localException) { } } @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } /** * Test whether a particular Event was asserted by the engine during rule execution */ @Test public void testEventAsserted() throws Exception { engine.resetSession(); // (optional) reset the rule session, which will clear working memory, restart timers, and clear the data from any previous tests // TODO : Change test data path here to create events to be asserted from a test data file List<SimpleEvent> events = helper.createEventsFromTestData("/TestData/<test data file name>"); if (events.size() > 0) { engine.assertEvent(events.get(0), false); } engine.executeRules(); expecter.expectEventAsserted("/Events/<event name>"); } }
Copyright © Cloud Software Group, Inc. All rights reserved.