use of il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener in project BPjs by bThink-BGU.
the class InterruptTest method superStepTest.
@Test
public void superStepTest() throws InterruptedException {
BProgramRunner sut = new BProgramRunner(new SingleResourceBProgram("Interrupt.js"));
sut.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = sut.addListener(new InMemoryEventLoggingListener());
sut.run();
eventLogger.getEvents().forEach(e -> System.out.println(e));
final BEvent breakingEvent = new BEvent("breaking");
assertEquals(Arrays.asList(breakingEvent, breakingEvent), eventLogger.getEvents());
}
use of il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener in project BPjs by bThink-BGU.
the class DfsBProgramVerifierTest method testAAABRun.
@Test
public void testAAABRun() throws Exception {
BProgram program = new SingleResourceBProgram("AAABTrace.js");
BProgramRunner rnr = new BProgramRunner(program);
rnr.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = rnr.addListener(new InMemoryEventLoggingListener());
rnr.run();
eventLogger.getEvents().forEach(System.out::println);
assertTrue(eventNamesString(eventLogger.getEvents(), "").matches("^(AAAB)+$"));
}
use of il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener in project BPjs by bThink-BGU.
the class DfsBProgramVerifierTest method deadlockRun.
@Test
public void deadlockRun() throws Exception {
BProgram program = new SingleResourceBProgram("deadlocking.js");
BProgramRunner rnr = new BProgramRunner(program);
rnr.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = rnr.addListener(new InMemoryEventLoggingListener());
rnr.run();
eventLogger.getEvents().forEach(System.out::println);
assertTrue(eventNamesString(eventLogger.getEvents(), "").matches("^A$"));
}
use of il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener in project BPjs by bThink-BGU.
the class AddingBthreadsTest method superStepTest.
@Test
public void superStepTest() throws InterruptedException {
final BEvent parentDone = new BEvent("parentDone");
final BEvent kidADone = new BEvent("kidADone");
final BEvent kidBDone = new BEvent("kidBDone");
BProgramRunner sut = new BProgramRunner(new SingleResourceBProgram("AddingBthreads.js"));
sut.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = sut.addListener(new InMemoryEventLoggingListener());
sut.run();
EventSet kiddies = il.ac.bgu.cs.bp.bpjs.model.eventsets.ComposableEventSet.anyOf(kidADone, kidBDone);
EventPattern expected = new EventPattern().append(kiddies).append(kiddies).append(parentDone).append(kiddies).append(kiddies).append(parentDone);
System.out.println("Actual events:");
eventLogger.getEvents().forEach(System.out::println);
System.out.println("/Actual events");
assertTrue(expected.matches(eventLogger.getEvents()));
}
use of il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener in project BPjs by bThink-BGU.
the class InterruptHandlerTest method echoEventTest.
@Test
public void echoEventTest() throws InterruptedException {
BProgramRunner sut = new BProgramRunner(new SingleResourceBProgram("InterruptHandler.js"));
sut.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = sut.addListener(new InMemoryEventLoggingListener());
sut.run();
eventLogger.getEvents().forEach(e -> System.out.println(e));
EventPattern expected = new EventPattern().append(new BEvent("boom")).append(new BEvent("boom")).append(new BEvent("internalValue"));
assertTrue(expected.matches(eventLogger.getEvents()));
}
Aggregations