Search in sources :

Example 21 with InMemoryEventLoggingListener

use of il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener 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());
}
Also used : PrintBProgramRunnerListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener) BProgramRunner(il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) InMemoryEventLoggingListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener) Test(org.junit.Test)

Example 22 with InMemoryEventLoggingListener

use of il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener 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());
}
Also used : PrintBProgramRunnerListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener) BProgramRunner(il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) InMemoryEventLoggingListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener) BEvent(il.ac.bgu.cs.bp.bpjs.model.BEvent) Test(org.junit.Test)

Example 23 with InMemoryEventLoggingListener

use of il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener 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)+$"));
}
Also used : PrintBProgramRunnerListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener) BProgramRunner(il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) BProgram(il.ac.bgu.cs.bp.bpjs.model.BProgram) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) InMemoryEventLoggingListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener) Test(org.junit.Test)

Example 24 with InMemoryEventLoggingListener

use of il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener 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$"));
}
Also used : PrintBProgramRunnerListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener) BProgramRunner(il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) BProgram(il.ac.bgu.cs.bp.bpjs.model.BProgram) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) InMemoryEventLoggingListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener) Test(org.junit.Test)

Example 25 with InMemoryEventLoggingListener

use of il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener 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()));
}
Also used : PrintBProgramRunnerListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener) EventPattern(il.ac.bgu.cs.bp.bpjs.analysis.eventpattern.EventPattern) BProgramRunner(il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner) EventSet(il.ac.bgu.cs.bp.bpjs.model.eventsets.EventSet) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) InMemoryEventLoggingListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener) BEvent(il.ac.bgu.cs.bp.bpjs.model.BEvent) Test(org.junit.Test)

Aggregations

BProgramRunner (il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner)26 InMemoryEventLoggingListener (il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener)26 PrintBProgramRunnerListener (il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener)26 Test (org.junit.Test)26 SingleResourceBProgram (il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram)21 BEvent (il.ac.bgu.cs.bp.bpjs.model.BEvent)13 EventPattern (il.ac.bgu.cs.bp.bpjs.analysis.eventpattern.EventPattern)10 BProgram (il.ac.bgu.cs.bp.bpjs.model.BProgram)3 PrioritizedBSyncEventSelectionStrategy (il.ac.bgu.cs.bp.bpjs.model.eventselection.PrioritizedBSyncEventSelectionStrategy)3 StringBProgram (il.ac.bgu.cs.bp.bpjs.model.StringBProgram)2 BProgramRunnerListenerAdapter (il.ac.bgu.cs.bp.bpjs.execution.listeners.BProgramRunnerListenerAdapter)1 FailedAssertion (il.ac.bgu.cs.bp.bpjs.model.FailedAssertion)1 LoggingEventSelectionStrategyDecorator (il.ac.bgu.cs.bp.bpjs.model.eventselection.LoggingEventSelectionStrategyDecorator)1 SimpleEventSelectionStrategy (il.ac.bgu.cs.bp.bpjs.model.eventselection.SimpleEventSelectionStrategy)1 EventSet (il.ac.bgu.cs.bp.bpjs.model.eventsets.EventSet)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 HashSet (java.util.HashSet)1