use of il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener in project BPjs by bThink-BGU.
the class NamedArgsHotNColdTest method superStepTest.
@Test
public void superStepTest() throws InterruptedException {
BProgramRunner sut = new BProgramRunner(new SingleResourceBProgram("NamedArgsHotNCold.js"));
sut.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = sut.addListener(new InMemoryEventLoggingListener());
sut.run();
eventLogger.getEvents().forEach(e -> System.out.println(e));
final BEvent hotEvent = new BEvent("hotEvent");
final BEvent coldEvent = new BEvent("coldEvent");
final BEvent allDoneEvent = new BEvent("allDone");
EventPattern expected = new EventPattern().append(coldEvent).append(hotEvent).append(coldEvent).append(hotEvent).append(coldEvent).append(hotEvent).append(allDoneEvent);
assertTrue(expected.matches(eventLogger.getEvents()));
}
use of il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener in project BPjs by bThink-BGU.
the class BSyncDataPassingTest method priorityDataTest_noBlocking.
@Test
public void priorityDataTest_noBlocking() {
BProgram bp = new SingleResourceBProgram("BSyncDataPassingTest.js");
bp.putInGlobalScope("block30", false);
bp.setEventSelectionStrategy(new PrioritizedBSyncEventSelectionStrategy());
BProgramRunner rnr = new BProgramRunner(bp);
InMemoryEventLoggingListener eventsLogger = rnr.addListener(new InMemoryEventLoggingListener());
rnr.addListener(new PrintBProgramRunnerListener());
rnr.run();
assertEquals(Arrays.asList("p30", "p20", "p10", "p3", "p2", "p1"), eventsLogger.eventNames());
}
use of il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener in project BPjs by bThink-BGU.
the class BSyncDataPassingTest method priorityDataTest_blocking.
@Test
public void priorityDataTest_blocking() {
BProgram bp = new SingleResourceBProgram("BSyncDataPassingTest.js");
bp.putInGlobalScope("block30", true);
bp.setEventSelectionStrategy(new PrioritizedBSyncEventSelectionStrategy(17));
BProgramRunner rnr = new BProgramRunner(bp);
InMemoryEventLoggingListener eventsLogger = rnr.addListener(new InMemoryEventLoggingListener());
rnr.addListener(new PrintBProgramRunnerListener());
rnr.run();
assertEquals(Arrays.asList("p20", "p10", "p3", "p2", "p1"), eventsLogger.eventNames());
}
use of il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener in project BPjs by bThink-BGU.
the class EventsArraysTest method testEventsWithData.
@Test
public void testEventsWithData() throws Exception {
BProgramRunner bpr = new BProgramRunner(new SingleResourceBProgram("EventArrays.js"));
bpr.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener events = bpr.addListener(new InMemoryEventLoggingListener());
bpr.run();
assertEquals(Arrays.asList("e11", "e21"), events.getEvents().stream().map(BEvent::getName).collect(toList()));
}
use of il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener in project BPjs by bThink-BGU.
the class FailedAssertionTest method testNoAssertion.
@Test
public void testNoAssertion() throws InterruptedException {
final SingleResourceBProgram bprog = new SingleResourceBProgram("FailedAssertionTest.js");
BProgramRunner sut = new BProgramRunner(bprog);
sut.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = sut.addListener(new InMemoryEventLoggingListener());
System.out.println("About to start program");
bprog.putInGlobalScope("shouldFail", false);
sut.run();
assertEquals(Arrays.asList("piff", "puff", "poof!", "peff"), eventLogger.eventNames());
assertFalse(sut.hasFailedAssertion());
}
Aggregations