Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jboss.soa.qa.drools.cep;
- import org.jboss.arquillian.container.test.api.Deployment;
- import org.jboss.arquillian.junit.Arquillian;
- import org.jboss.shrinkwrap.api.spec.JavaArchive;
- import org.jboss.soa.qa.BaseSwitchYardTest;
- import org.jboss.soa.qa.audit.auditor.ProviderAuditor;
- import org.jboss.soa.qa.runtime.TestSupport;
- import org.switchyard.bus.camel.audit.Auditor;
- import org.junit.Assert;
- import org.junit.Before;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import java.util.Arrays;
- @RunWith(Arquillian.class)
- public class DroolsCEPServiceTest extends BaseSwitchYardTest {
- private static final int WAIT_TIME = 2000;
- private TestDependencies test;
- @Deployment
- public static JavaArchive createDeployment() {
- return TestCommons.createDeployment();
- }
- @Before
- public void setUp() {
- if (test == null) {
- test = (TestDependencies) new TestSupport().initCDI(TestDependencies.class);
- }
- test.getAudit().clear();
- test.getEventLogger().clear();
- test.getBeatLogger().clear();
- test.getAudit().setAuditors(Arrays.<Class<? extends Auditor>>asList(ProviderAuditor.class));
- }
- @Test
- public void stream() throws InterruptedException {
- callService(test.getStreamService());
- }
- @Test
- public void cloud() throws InterruptedException {
- callService(test.getCloudService());
- }
- private void callService(CEPService service) throws InterruptedException {
- System.out.println("@@@@@@ Calling SwitchYard Service from Groovy test");
- final Tick t1 = new Tick().setEventName("heartBeat OK tick 1");
- final Tick t2 = new Tick().setEventName("heartBeat OK tick 2");
- final Tick t3 = new Tick().setEventName("heartBeat OK tick 3");
- service.heartBeat(t1);
- service.heartBeat(t2);
- Thread.sleep(WAIT_TIME);
- Assert.assertTrue("Waiting for second beat", test.getBeatLogger().isEmpty());
- service.tickerBeat(t3);
- Thread.sleep(WAIT_TIME);
- Assert.assertFalse("Rule firedXXX", test.getBeatLogger().isEmpty());
- // Listeners called
- Assert.assertTrue("Runtime logger called", test.getEventLogger().containsSource("runtime"));
- Assert.assertTrue("Agenda logger called", test.getEventLogger().containsSource("agenda"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement