Skip to content

Instantly share code, notes, and snippets.

@nremond
Created June 22, 2012 12:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nremond/2972382 to your computer and use it in GitHub Desktop.
Save nremond/2972382 to your computer and use it in GitHub Desktop.
Account feeder
class AccountFeeder() extends com.excilys.ebi.gatling.core.feeder.Feeder {
import org.joda.time.DateTime
import scala.util.Random
private val RNG = new Random()
// random number in between [a...b]
def randInt(a:Int, b:Int) = RNG.nextInt(b-a) + a
def daysOfMonth(year:Int, month:Int) = new DateTime(year, month, 1, 0, 0, 0, 000).dayOfMonth().getMaximumValue()
def next: Map[String, String] = {
val email = scala.math.abs(java.util.UUID.randomUUID().getMostSignificantBits()) + "_gatling@ne-pas-envoyer.com"
val year = randInt(1945, 1994)
val month = randInt(1, 12)
val day = randInt(1, daysOfMonth(year, month))
Map("contactEmail" -> email,
"birthdayYear" -> year.toString,
"birthdayMonth" -> month.toString,
"birthdayDay" -> day.toString)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment