Skip to content

Instantly share code, notes, and snippets.

@ndemengel
Last active April 30, 2017 18:42
Show Gist options
  • Save ndemengel/b005c1d9ee0e359114440a98272e5487 to your computer and use it in GitHub Desktop.
Save ndemengel/b005c1d9ee0e359114440a98272e5487 to your computer and use it in GitHub Desktop.
Sample use of JvmSynchronizedEventsService
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {
// only populate the context with the classes that interest us for this test
SomePublisher.class,
JvmSynchronizedEventsService.class,
SomeConsumer.class
})
public class SomeTest {
@Inject
SomeConsumer someConsumer;
@Inject
SomePublisher somePublisher;
@Test
public void should_observe_event_publication_and_consumption() {
// when
somePublisher.doSomethingThatFiresAnEvent();
// then
verifyThatEventHasBeenConsumedInTheExpectedWayBy(someConsumer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment