Skip to content

Instantly share code, notes, and snippets.

View erikvanoosten's full-sized avatar

Erik van Oosten erikvanoosten

View GitHub Profile
@erikvanoosten
erikvanoosten / gist:3604873
Last active October 10, 2015 00:38
Sentries example usage
class DoItAllService extends nl.grons.sentries.support.SentrySupport {
val dbSentry = sentry("mysql:localhost:3366") withMetrics withFailLimit(failLimit = 5, retryDelay = 500 millis)
val twitterApiSentry = sentry("twitter") withMetrics withFailLimit(failLimit = 5, retryDelay = 500 millis) withConcurrencyLimit(3)
def loadTweetFromDb(id: Long): Tweet = dbSentry {
database.load(id)
}
def getFromTwitter(id: Long): Tweet = twitterApiSentry {
@erikvanoosten
erikvanoosten / gist:1059045
Created July 1, 2011 17:40
Example of a specs2 unit test, with mocks and rich context
import org.specs2.mutable._
import org.specs2.mock._
import org.specs2.specification.Scope
class ParentElementStrategyTest extends SpecificationWithJUnit with Mockito {
"The ParentElementStrategy" should {
"extract a user ref" in new SimpleContext {
val testColumn = mock[Column]
registry.get("urn:grons.nl:user:9475877") returns testColumn
userStrategy("user").getShardForEntity(ad, columns) must beTheSameAs(testColumn)